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

Commit 609ca318 authored by William Escande's avatar William Escande
Browse files

Java unit test : Fix & enforce some errorprone

* JavaUtilDate -> Mostly a silent because I do not want to rewrite all
  tests for now, just prevent expending a wrong usage
* DirectInvocationOnMock

Bug: 344658662
Test: m framework-bluetooth
Flag: Exempt following errorprone recommendation
Change-Id: I338d7a5faf1335919e2d75f5637b8bef7dcd77b3
parent f34b3653
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -173,7 +173,7 @@ public class VolumeControlStackEvent {
    private static String eventTypeString1ToString(int type, String value) {
        switch (type) {
            case EVENT_TYPE_EXT_AUDIO_OUT_DESCRIPTION_CHANGED:
                return "{descrition:" + value + "}";
                return "{description:" + value + "}";
            default:
                break;
        }
+2 −0
Original line number Diff line number Diff line
@@ -62,6 +62,7 @@ java_defaults {
            "-Xep:CatchAndPrintStackTrace:ERROR",
            "-Xep:CatchFail:ERROR",
            "-Xep:ClassCanBeStatic:ERROR",
            "-Xep:DirectInvocationOnMock:ERROR",
            "-Xep:EmptyBlockTag:ERROR",
            "-Xep:EmptyCatch:ERROR",
            "-Xep:EqualsIncompatibleType:ERROR",
@@ -70,6 +71,7 @@ java_defaults {
            "-Xep:InvalidBlockTag:ERROR",
            "-Xep:InvalidInlineTag:ERROR",
            "-Xep:InvalidParam:ERROR",
            "-Xep:JavaUtilDate:ERROR",
            "-Xep:MockNotUsedInProduction:ERROR",
            "-Xep:ModifiedButNotUsed:ERROR",
            "-Xep:NarrowCalculation:ERROR",
+0 −1
Original line number Diff line number Diff line
@@ -378,7 +378,6 @@ public class AvrcpControllerStateMachineTest {
    @Test
    public void testDisconnectWithNullBrowseTree() {
        int numBroadcastsSent = setUpConnectedState(true, true);
        mAvrcpControllerService.stop();

        testDisconnectInternal(numBroadcastsSent);
    }
+8 −10
Original line number Diff line number Diff line
@@ -120,7 +120,7 @@ public class HapClientServiceTest {
        doReturn(mBinder).when(mFrameworkCallback).asBinder();

        /* Prepare CAS groups */
        doReturn(Arrays.asList(0x02, 0x03)).when(mCsipService).getAllGroupIds(BluetoothUuid.CAP);
        doReturn(List.of(0x02, 0x03)).when(mCsipService).getAllGroupIds(BluetoothUuid.CAP);

        int groupId2 = 0x02;
        Map groups2 =
@@ -130,16 +130,14 @@ public class HapClientServiceTest {
        Map groups3 =
                Map.of(groupId3, ParcelUuid.fromString("00001853-0000-1000-8000-00805F9B34FB"));

        doReturn(Arrays.asList(mDevice, mDevice2))
                .when(mCsipService)
                .getGroupDevicesOrdered(groupId2);
        doReturn(List.of(mDevice, mDevice2)).when(mCsipService).getGroupDevicesOrdered(groupId2);
        doReturn(groups2).when(mCsipService).getGroupUuidMapByDevice(mDevice);
        doReturn(groups2).when(mCsipService).getGroupUuidMapByDevice(mDevice2);

        doReturn(Arrays.asList(mDevice3)).when(mCsipService).getGroupDevicesOrdered(0x03);
        doReturn(List.of(mDevice3)).when(mCsipService).getGroupDevicesOrdered(groupId3);
        doReturn(groups3).when(mCsipService).getGroupUuidMapByDevice(mDevice3);

        doReturn(Arrays.asList(mDevice)).when(mCsipService).getGroupDevicesOrdered(0x01);
        doReturn(List.of(mDevice)).when(mCsipService).getGroupDevicesOrdered(0x01);

        doReturn(BluetoothDevice.BOND_BONDED)
                .when(mAdapterService)
@@ -593,9 +591,9 @@ public class HapClientServiceTest {
                .when(mAdapterService)
                .getRemoteUuids(any(BluetoothDevice.class));
        int test_group = 0x02;
        for (BluetoothDevice device : mCsipService.getGroupDevicesOrdered(test_group)) {
            testConnectingDevice(order, device);
        }

        testConnectingDevice(order, mDevice);
        testConnectingDevice(order, mDevice2);

        int flags = 0x21;
        mNativeCallback.onFeaturesUpdate(getByteAddress(mDevice), flags);
@@ -901,7 +899,7 @@ public class HapClientServiceTest {

        // Inject some initial presets
        List<BluetoothHapPresetInfo> presets =
                new ArrayList<BluetoothHapPresetInfo>(
                new ArrayList<>(
                        Arrays.asList(
                                new BluetoothHapPresetInfo.Builder(0x01, "One")
                                        .setAvailable(true)
+2 −11
Original line number Diff line number Diff line
@@ -2112,19 +2112,10 @@ public class ScanManagerTest {
        for (int i = 0; i < scanModeMap.size(); i++) {
            int phy = PHY_LE_ALL_SUPPORTED;
            int ScanMode = scanModeMap.keyAt(i);
            boolean adapterServiceSupportsCoded = mAdapterService.isLeCodedPhySupported();
            int expectedScanMode = scanModeMap.get(ScanMode);
            int expectedPhy;
            int expectedPhy = PHY_LE_1M_MASK;

            if (adapterServiceSupportsCoded) expectedPhy = PHY_LE_1M_MASK | PHY_LE_CODED_MASK;
            else expectedPhy = PHY_LE_1M_MASK;

            Log.d(
                    TAG,
                    "ScanMode: "
                            + String.valueOf(ScanMode)
                            + " expectedScanMode: "
                            + String.valueOf(expectedScanMode));
            Log.d(TAG, "ScanMode: " + ScanMode + " expectedScanMode: " + expectedScanMode);

            // Turn on screen
            sendMessageWaitForProcessed(createScreenOnOffMessage(true));
Loading