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

Commit c47a0f76 authored by Meng Wang's avatar Meng Wang Committed by Android (Google) Code Review
Browse files

Merge "Remove ApdnSender constructor related unit tests" into main

parents 53e21d2b dd6bf0a7
Loading
Loading
Loading
Loading
+0 −30
Original line number Diff line number Diff line
@@ -392,31 +392,6 @@ public class ApduSenderTest {
        verify(mMockCi, times(1)).iccOpenLogicalChannel(eq(ApduSender.ISD_R_AID), anyInt(), any());
    }

    @Test
    public void testConstructor_doNotCloseOpenChannelInSharedPreference()
                  throws InterruptedException {
        // Open a channel and not close it, by making CI.iccTransmitApduLogicalChannel throw.
        int channel = LogicalChannelMocker.mockOpenLogicalChannelResponse(mMockCi, "9000");
        doThrow(new RuntimeException()).when(mMockCi).iccTransmitApduLogicalChannel(
                eq(channel), anyInt(), anyInt(), anyInt(), anyInt(), anyInt(), any(),
                anyBoolean(), any());
        mSender.send((selectResponse, requestBuilder) -> requestBuilder.addApdu(
                10, 1, 2, 3, 0, "a"), mResponseCaptor, mHandler);
        mLooper.processAllMessages();
        // Stub close channel
        reset(mMockCi);
        LogicalChannelMocker.mockCloseLogicalChannel(mMockCi, channel, /* error= */ null);

        // Call constructor
        mSender = new ApduSender(InstrumentationRegistry.getContext(), PHONE_ID,
                            mMockCi, ApduSender.ISD_R_AID, false /* supportExtendedApdu */);
        mLooper.processAllMessages();

        // The constructor should have closed channel
        verify(mMockCi, times(0)).iccCloseLogicalChannel(eq(channel), eq(true /*isEs10*/), any());
        assertEquals(1, getChannelIdFromSharedPreferences());
    }

    @Test
    public void testSend_OpenChannelFailedNoSuchElement_useChannelInSharedPreference() {
        // Open a channel but not close, by making CI.iccTransmitApduLogicalChannel throw.
@@ -427,13 +402,8 @@ public class ApduSenderTest {
        mSender.send((selectResponse, requestBuilder) -> requestBuilder.addApdu(
                10, 1, 2, 3, 0, "a"), mResponseCaptor, mHandler);
        mLooper.processAllMessages();
        reset(mMockCi);
        // Constructor fails to close channel
        LogicalChannelMocker.mockCloseLogicalChannel(
                mMockCi, channel, new CommandException(RADIO_NOT_AVAILABLE));
        mSender = new ApduSender(InstrumentationRegistry.getContext(), PHONE_ID,
                            mMockCi, ApduSender.ISD_R_AID, false /* supportExtendedApdu */);
        mLooper.processAllMessages();
        reset(mMockCi);
        // Stub open channel failure NO_SUCH_ELEMENT
        LogicalChannelMocker.mockOpenLogicalChannelResponse(mMockCi,