Added CTS test for Messaging with People
Test: runtest -x tests/app/src/android/app/cts/NotificationTest.java
Bug: 63708826
Change-Id: I977a046852f0517768958767453b1cc84a2e852c
diff --git a/tests/app/src/android/app/cts/NotificationTest.java b/tests/app/src/android/app/cts/NotificationTest.java
index ab185f1..8104245 100644
--- a/tests/app/src/android/app/cts/NotificationTest.java
+++ b/tests/app/src/android/app/cts/NotificationTest.java
@@ -265,6 +265,34 @@
assertEquals(uri, restoredPerson.getUri());
}
+ public void testNotification_MessagingStyle_people() {
+ String name = "name";
+ String key = "key";
+ String uri = "name:name";
+ Notification.Person user = new Notification.Person()
+ .setName(name)
+ .setIcon(Icon.createWithResource(mContext, 1))
+ .setKey(key)
+ .setUri(uri);
+ Notification.Person participant = new Notification.Person().setName("sender");
+ Notification.MessagingStyle messagingStyle = new Notification.MessagingStyle(user)
+ .addMessage("text", 0, participant)
+ .addMessage(new Message("text 2", 0, participant));
+ mNotification = new Notification.Builder(mContext, CHANNEL.getId())
+ .setSmallIcon(1)
+ .setStyle(messagingStyle)
+ .build();
+
+ Notification.Person restoredPerson = mNotification.extras.getParcelable(
+ Notification.EXTRA_MESSAGING_PERSON);
+ assertNotNull(restoredPerson);
+ assertNotNull(restoredPerson.getIcon());
+ assertEquals(name, restoredPerson.getName());
+ assertEquals(key, restoredPerson.getKey());
+ assertEquals(uri, restoredPerson.getUri());
+ assertNotNull(mNotification.extras.getParcelableArray(Notification.EXTRA_MESSAGES));
+ }
+
public void testMessagingStyle_historicMessages() {
mNotification = new Notification.Builder(mContext, CHANNEL.getId())