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

Commit d4c59f5b authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Add tests for dump methods"

parents cd2d3c35 a8aa3b53
Loading
Loading
Loading
Loading
+6 −0
Original line number Original line Diff line number Diff line
@@ -91,6 +91,7 @@ public class A2dpServiceTest {
        }
        }


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


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

    private void connectDevice(BluetoothDevice device) {
    private void connectDevice(BluetoothDevice device) {
        connectDeviceWithCodecStatus(device, null);
        connectDeviceWithCodecStatus(device, null);
    }
    }
+18 −0
Original line number Original line Diff line number Diff line
@@ -417,4 +417,22 @@ public class A2dpStateMachineTest {
        // Check if low latency audio been update.
        // Check if low latency audio been update.
        verify(mA2dpService, times(6)).updateLowLatencyAudioSupport(mTestDevice);
        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 Original line Diff line number Diff line
@@ -464,4 +464,12 @@ public class A2dpSinkServiceTest {
        assertThat(mService.setConnectionPolicy(mDevice1,
        assertThat(mService.setConnectionPolicy(mDevice1,
                BluetoothProfile.CONNECTION_POLICY_ALLOWED)).isFalse();
                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 Original line Diff line number Diff line
@@ -428,4 +428,10 @@ public class AvrcpControllerServiceTest {
                eq(AvrcpControllerStateMachine.MESSAGE_PROCESS_GET_PLAYER_ITEMS),
                eq(AvrcpControllerStateMachine.MESSAGE_PROCESS_GET_PLAYER_ITEMS),
                eq(new ArrayList<>(Arrays.asList(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 Original line Diff line number Diff line
@@ -211,7 +211,7 @@ public class BatteryServiceTest {
     * Test that an outgoing connection to device
     * Test that an outgoing connection to device
     */
     */
    @Test
    @Test
    public void testConnect() {
    public void testConnectAndDump() {
        // Update the device policy so okToConnect() returns true
        // Update the device policy so okToConnect() returns true
        when(mAdapterService.getDatabase()).thenReturn(mDatabaseManager);
        when(mAdapterService.getDatabase()).thenReturn(mDatabaseManager);
        when(mDatabaseManager
        when(mDatabaseManager
@@ -222,6 +222,9 @@ public class BatteryServiceTest {
                .getRemoteUuids(any(BluetoothDevice.class));
                .getRemoteUuids(any(BluetoothDevice.class));
        // Send a connect request
        // Send a connect request
        Assert.assertTrue("Connect expected to succeed", mService.connect(mDevice));
        Assert.assertTrue("Connect expected to succeed", mService.connect(mDevice));

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


    /**
    /**
Loading