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

Commit b2dad24a authored by Jordan Liu's avatar Jordan Liu
Browse files

Fix testBroadcastUndeliveredUserLocked

The old code which verifies that one receiver is registered does not
count the receiver that GsmInboundSmsHandler creates when the device is
in TEST_MODE (defaults to on, on userdebug). So we replace the times(1)
call with an atLeastOnce().

Bug: 145232009
Test: atest GsmInboundSmsHandlerTest#testBroadcastUndeliveredUserLocked
Change-Id: Id8ed77afba10fee2d8bca6ddffeb8bd3ab26c0e8
Merged-In: Id8ed77afba10fee2d8bca6ddffeb8bd3ab26c0e8
parent 5c2a8680
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import static org.mockito.Matchers.anyBoolean;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyLong;
import static org.mockito.Matchers.nullable;
import static org.mockito.Mockito.atLeastOnce;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.never;
@@ -806,8 +807,9 @@ public class GsmInboundSmsHandlerTest extends TelephonyTest {
        SmsBroadcastUndelivered.initialize(mContext, mGsmInboundSmsHandler, mCdmaInboundSmsHandler);

        // verify that a broadcast receiver is registered for current user (user == null) based on
        // implementation in ContextFixture
        verify(mContext, times(1)).registerReceiverAsUser(any(BroadcastReceiver.class),
        // implementation in ContextFixture. registerReceiver may be called more than once (for
        // example by GsmInboundSmsHandler if TEST_MODE is true)
        verify(mContext, atLeastOnce()).registerReceiverAsUser(any(BroadcastReceiver.class),
                eq((UserHandle)null), any(IntentFilter.class), eq((String)null), eq((Handler)null));

        // wait for ScanRawTableThread