Register SimpleBroadcastReceiver permission.
Update SimpleBroadcastReceiver API to pass in broadcast permission and register Growth Broadcast Receiver with permission to prevent other apps from triggering Growth Nudge on their behalf. Flag: EXEMPT add separately Test: Manual Bug: 397739323 Change-Id: I3a9d5e131ced752af0a1b35d400eed6d170fc81e
This commit is contained in:
@@ -126,6 +126,29 @@ class SimpleBroadcastReceiverTest {
|
||||
assertThat(intentFilter.getAction(1)).isEqualTo("test_action_2")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun sync_register_withCompletionRunnable_and_permission_and_flag() {
|
||||
underTest =
|
||||
SimpleBroadcastReceiver(context, Handler(Looper.getMainLooper()), intentConsumer)
|
||||
|
||||
underTest.register(completionRunnable, "permission", 1, "test_action_1", "test_action_2")
|
||||
getInstrumentation().waitForIdleSync()
|
||||
|
||||
verify(context)
|
||||
.registerReceiver(
|
||||
same(underTest),
|
||||
intentFilterCaptor.capture(),
|
||||
eq("permission"),
|
||||
eq(null),
|
||||
eq(1),
|
||||
)
|
||||
verify(completionRunnable).run()
|
||||
val intentFilter = intentFilterCaptor.value
|
||||
assertThat(intentFilter.countActions()).isEqualTo(2)
|
||||
assertThat(intentFilter.getAction(0)).isEqualTo("test_action_1")
|
||||
assertThat(intentFilter.getAction(1)).isEqualTo("test_action_2")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun async_unregister() {
|
||||
underTest.unregisterReceiverSafely()
|
||||
|
||||
Reference in New Issue
Block a user