Skip to content

Commit 229867f

Browse files
authored
Merge pull request #420 from Iterable/feature/MOB-3897-add-regression-test-for-immutable
[MOB-3897] Add regression test for PendingIntent.FLAG_IMMUTABLE
2 parents ad9b830 + cdf99c4 commit 229867f

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

iterableapi/src/test/java/com/iterable/iterableapi/IterableNotificationTest.java

+16
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import android.app.Notification;
44
import android.app.NotificationManager;
5+
import android.app.PendingIntent;
56
import android.content.Context;
67
import android.content.Intent;
78
import android.os.Bundle;
@@ -91,4 +92,19 @@ public void testNoAction() throws Exception {
9192
assertEquals("button1", savedIntent.getStringExtra(IterableConstants.ACTION_IDENTIFIER));
9293
}
9394

95+
@Test
96+
public void testPendingIntentImmutable() throws Exception {
97+
Bundle notif = new Bundle();
98+
notif.putString(IterableConstants.ITERABLE_DATA_KEY, getResourceString("push_payload_action_buttons.json"));
99+
100+
IterableNotificationBuilder iterableNotification = postNotification(notif);
101+
StatusBarNotification statusBarNotification = mNotificationManager.getActiveNotifications()[0];
102+
Notification notification = statusBarNotification.getNotification();
103+
104+
assertTrue((shadowOf(notification.contentIntent).getFlags() & PendingIntent.FLAG_IMMUTABLE) != 0);
105+
assertTrue((shadowOf(notification.actions[0].actionIntent).getFlags() & PendingIntent.FLAG_IMMUTABLE) != 0);
106+
assertTrue((shadowOf(notification.actions[1].actionIntent).getFlags() & PendingIntent.FLAG_IMMUTABLE) != 0);
107+
assertTrue((shadowOf(notification.actions[2].actionIntent).getFlags() & PendingIntent.FLAG_IMMUTABLE) != 0);
108+
}
109+
94110
}

0 commit comments

Comments
 (0)