Merge "Fix NPE in NotificationController" into honeycomb-mr1
This commit is contained in:
commit
553037ba4e
@ -240,7 +240,10 @@ public class NotificationController {
|
||||
return null; // no message found???
|
||||
}
|
||||
|
||||
final String senderName = Address.toFriendly(Address.unpack(message.mFrom));
|
||||
String senderName = Address.toFriendly(Address.unpack(message.mFrom));
|
||||
if (senderName == null) {
|
||||
senderName = ""; // Happens when a message has no from.
|
||||
}
|
||||
final String subject = message.mSubject;
|
||||
final Bitmap senderPhoto = getSenderPhoto(message);
|
||||
|
||||
|
@ -224,6 +224,24 @@ public class NotificationControllerTest extends AndroidTestCase {
|
||||
// TODO Add 2 account test, if we find a way to check content
|
||||
}
|
||||
|
||||
public void testCreateNewMessageNotificationWithEmptyFrom() {
|
||||
final Context c = mProviderContext;
|
||||
Notification n;
|
||||
|
||||
// Message with no from fields.
|
||||
Account a1 = ProviderTestUtils.setupAccount("a1", true, c);
|
||||
Mailbox b1 = ProviderTestUtils.setupMailbox("inbox", a1.mId, true, c, Mailbox.TYPE_INBOX);
|
||||
Message m1 = ProviderTestUtils.setupMessage("message", a1.mId, b1.mId, true, false, c);
|
||||
m1.mFrom = null;
|
||||
m1.save(c);
|
||||
|
||||
// This shouldn't crash.
|
||||
n = mTarget.createNewMessageNotification(a1.mId, 1);
|
||||
|
||||
// Minimum test for the result
|
||||
assertEquals(R.drawable.stat_notify_email_generic, n.icon);
|
||||
}
|
||||
|
||||
public void testGetNotificationTitle() {
|
||||
final Context c = mProviderContext;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user