Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 16b93305 authored by Matías Hernández's avatar Matías Hernández
Browse files

Fix testVisitUris_styleExtrasWithoutStyle

Turns out that Style.addExtras() also populates EXTRA_TEMPLATE, so this unit test wasn't verifying that visitUris processed the CallStyle fields when CallStyle is not set. Luckily, it was verifying the MessagingStyle part of the extras correctly, so it was only half broken. ¯\_(ツ)_/¯

Fixes: 297027668
Test: atest NotificationManagerServiceTest
Change-Id: If852bb910d57702082ac006b8dccdc232a03b7e9
parent 8e3761ce
Loading
Loading
Loading
Loading
+24 −22
Original line number Diff line number Diff line
@@ -6045,31 +6045,33 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
    @Test
    public void testVisitUris_styleExtrasWithoutStyle() {
        Notification notification = new Notification.Builder(mContext, "a")
                .setSmallIcon(android.R.drawable.sym_def_app_icon)
                .build();
        Notification.Builder notification = new Notification.Builder(mContext, "a")
                .setSmallIcon(android.R.drawable.sym_def_app_icon);
        Notification.MessagingStyle messagingStyle = new Notification.MessagingStyle(
                personWithIcon("content://user"))
                .addHistoricMessage(new Notification.MessagingStyle.Message("Heyhey!",
                                System.currentTimeMillis(),
                                personWithIcon("content://historicalMessenger")))
                .addMessage(new Notification.MessagingStyle.Message("Are you there",
        Bundle messagingExtras = new Bundle();
        messagingExtras.putParcelable(Notification.EXTRA_MESSAGING_PERSON,
                personWithIcon("content://user"));
        messagingExtras.putParcelableArray(Notification.EXTRA_HISTORIC_MESSAGES,
                new Bundle[] { new Notification.MessagingStyle.Message("Heyhey!",
                        System.currentTimeMillis() - 100,
                        personWithIcon("content://historicalMessenger")).toBundle()});
        messagingExtras.putParcelableArray(Notification.EXTRA_MESSAGES,
                new Bundle[] { new Notification.MessagingStyle.Message("Are you there?",
                        System.currentTimeMillis(),
                                personWithIcon("content://messenger")))
                        .setShortcutIcon(
                        personWithIcon("content://messenger")).toBundle()});
        messagingExtras.putParcelable(Notification.EXTRA_CONVERSATION_ICON,
                Icon.createWithContentUri("content://conversationShortcut"));
        messagingStyle.addExtras(notification.extras); // Instead of Builder.setStyle(style).
        notification.addExtras(messagingExtras);
        Notification.CallStyle callStyle = Notification.CallStyle.forOngoingCall(
                        personWithIcon("content://caller"),
                        PendingIntent.getActivity(mContext, 0, new Intent(),
                                PendingIntent.FLAG_IMMUTABLE))
                .setVerificationIcon(Icon.createWithContentUri("content://callVerification"));
        callStyle.addExtras(notification.extras); // Same.
        Bundle callExtras = new Bundle();
        callExtras.putParcelable(Notification.EXTRA_CALL_PERSON,
                personWithIcon("content://caller"));
        callExtras.putParcelable(Notification.EXTRA_VERIFICATION_ICON,
                Icon.createWithContentUri("content://callVerification"));
        notification.addExtras(callExtras);
        Consumer<Uri> visitor = (Consumer<Uri>) spy(Consumer.class);
        notification.visitUris(visitor);
        notification.build().visitUris(visitor);
        verify(visitor).accept(eq(Uri.parse("content://user")));
        verify(visitor).accept(eq(Uri.parse("content://historicalMessenger")));