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

Commit a8aa3b53 authored by Sungsoo Lim's avatar Sungsoo Lim
Browse files

Add tests for dump methods

Bug: 237467631
Test: atest BluetoothInstrumentationTests
Change-Id: I93049503bdbdf5003ef5414cc207f8e2741c02fd
parent 582626c9
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -91,6 +91,7 @@ public class A2dpServiceTest {
        }

        TestUtils.setAdapterService(mAdapterService);
        doReturn(true).when(mAdapterService).isA2dpOffloadEnabled();
        doReturn(MAX_CONNECTED_AUDIO_DEVICES).when(mAdapterService).getMaxConnectedAudioDevices();
        doReturn(true, false).when(mAdapterService).isStartedProfile(anyString());
        doReturn(false).when(mAdapterService).isQuietModeEnabled();
@@ -865,6 +866,11 @@ public class A2dpServiceTest {
                verifySupportTime, verifyNotSupportTime, verifyEnabledTime);
    }

    @Test
    public void testDumpDoesNotCrash() {
        mA2dpService.dump(new StringBuilder());
    }

    private void connectDevice(BluetoothDevice device) {
        connectDeviceWithCodecStatus(device, null);
    }
+18 −0
Original line number Diff line number Diff line
@@ -417,4 +417,22 @@ public class A2dpStateMachineTest {
        // Check if low latency audio been update.
        verify(mA2dpService, times(6)).updateLowLatencyAudioSupport(mTestDevice);
    }

    @Test
    public void dump_doesNotCrash() {
        BluetoothCodecConfig[] codecsSelectableSbc;
        codecsSelectableSbc = new BluetoothCodecConfig[1];
        codecsSelectableSbc[0] = mCodecConfigSbc;

        BluetoothCodecConfig[] codecsSelectableSbcAac;
        codecsSelectableSbcAac = new BluetoothCodecConfig[2];
        codecsSelectableSbcAac[0] = mCodecConfigSbc;
        codecsSelectableSbcAac[1] = mCodecConfigAac;

        BluetoothCodecStatus codecStatusSbcAndSbc = new BluetoothCodecStatus(mCodecConfigSbc,
                Arrays.asList(codecsSelectableSbcAac), Arrays.asList(codecsSelectableSbc));
        mA2dpStateMachine.processCodecConfigEvent(codecStatusSbcAndSbc);

        mA2dpStateMachine.dump(new StringBuilder());
    }
}
+8 −0
Original line number Diff line number Diff line
@@ -464,4 +464,12 @@ public class A2dpSinkServiceTest {
        assertThat(mService.setConnectionPolicy(mDevice1,
                BluetoothProfile.CONNECTION_POLICY_ALLOWED)).isFalse();
    }

    @Test
    public void testDumpDoesNotCrash() {
        mockDevicePriority(mDevice1, BluetoothProfile.CONNECTION_POLICY_ALLOWED);
        setupDeviceConnection(mDevice1);

        mService.dump(new StringBuilder());
    }
}
+6 −0
Original line number Diff line number Diff line
@@ -428,4 +428,10 @@ public class AvrcpControllerServiceTest {
                eq(AvrcpControllerStateMachine.MESSAGE_PROCESS_GET_PLAYER_ITEMS),
                eq(new ArrayList<>(Arrays.asList(items))));
    }

    @Test
    public void dump_doesNotCrash() {
        mService.getRcPsm(REMOTE_DEVICE_ADDRESS_AS_ARRAY, 1);
        mService.dump(new StringBuilder());
    }
}
+4 −1
Original line number Diff line number Diff line
@@ -211,7 +211,7 @@ public class BatteryServiceTest {
     * Test that an outgoing connection to device
     */
    @Test
    public void testConnect() {
    public void testConnectAndDump() {
        // Update the device policy so okToConnect() returns true
        when(mAdapterService.getDatabase()).thenReturn(mDatabaseManager);
        when(mDatabaseManager
@@ -222,6 +222,9 @@ public class BatteryServiceTest {
                .getRemoteUuids(any(BluetoothDevice.class));
        // Send a connect request
        Assert.assertTrue("Connect expected to succeed", mService.connect(mDevice));

        // Test dump() is not crashed.
        mService.dump(new StringBuilder());
    }

    /**
Loading