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

Commit 78c247a3 authored by William Escande's avatar William Escande
Browse files

Java unit test: More errorprone enforced as error

This enforce the following at build time:
* CatchAndPrintStackTrace
* EqualsIncompatibleType
* ModifiedButNotUsed
* TruthIncompatibleType

Bug: 344658662
Test: m BluetoothInstrumentationTests
Flag: TEST_ONLY
Change-Id: Ia01ff4909cd502dde330d60c965ab8542bf662df
parent 5d4970e0
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -59,22 +59,26 @@ java_defaults {
        javacflags: [
            "-Xep:AlmostJavadoc:ERROR",
            "-Xep:BadImport:ERROR",
            "-Xep:CatchAndPrintStackTrace:ERROR",
            "-Xep:CatchFail:ERROR",
            "-Xep:ClassCanBeStatic:ERROR",
            "-Xep:EmptyBlockTag:ERROR",
            "-Xep:EmptyCatch:ERROR",
            "-Xep:EqualsIncompatibleType:ERROR",
            "-Xep:FutureReturnValueIgnored:ERROR",
            "-Xep:InlineMeInliner:ERROR",
            "-Xep:InvalidBlockTag:ERROR",
            "-Xep:InvalidInlineTag:ERROR",
            "-Xep:InvalidParam:ERROR",
            "-Xep:MockNotUsedInProduction:ERROR",
            "-Xep:ModifiedButNotUsed:ERROR",
            "-Xep:NonApiType:ERROR",
            "-Xep:NonCanonicalType:ERROR",
            "-Xep:NotJavadoc:ERROR",
            "-Xep:ReturnAtTheEndOfVoidFunction:ERROR",
            "-Xep:StringCaseLocaleUsage:ERROR",
            "-Xep:StringCharset:ERROR",
            "-Xep:TruthIncompatibleType:ERROR",
            "-Xep:UnnecessaryAssignment:ERROR",
            "-Xep:UnnecessaryAsync:ERROR",
            "-Xep:UnusedMethod:ERROR",
+2 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.bluetooth.avrcpcontroller;

import static com.google.common.truth.Truth.assertThat;

import android.annotation.SuppressLint;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;

@@ -162,6 +163,7 @@ public class BrowseNodeTest {
    }

    @Test
    @SuppressLint("TruthIncompatibleType") // That the point of this test
    public void equals_withDifferentClass() {
        AvrcpItem avrcpItem = new AvrcpItem.Builder().setUuid(TEST_UUID).build();

+0 −3
Original line number Diff line number Diff line
@@ -676,9 +676,6 @@ public class ActiveDeviceManagerTest {
        Assume.assumeTrue(
                "Ignore test when HearingAidService is not enabled", HearingAidService.isEnabled());

        List<BluetoothDevice> connectedHearingAidDevices = new ArrayList<>();
        connectedHearingAidDevices.add(mHearingAidDevice);
        connectedHearingAidDevices.add(mSecondaryAudioDevice);
        when(mHearingAidService.getHiSyncId(mSecondaryAudioDevice)).thenReturn(mHearingAidHiSyncId);

        hearingAidConnected(mHearingAidDevice);
+3 −0
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@ package com.android.bluetooth.map;

import static com.google.common.truth.Truth.assertThat;

import android.annotation.SuppressLint;

import androidx.test.runner.AndroidJUnit4;

import com.android.bluetooth.SignedLongLong;
@@ -106,6 +108,7 @@ public class BluetoothMapConvoListingTest {
    }

    @Test
    @SuppressLint("EqualsIncompatibleType") // That the point of this test
    public void equals_withDifferentClass_returnsFalse() {
        assertThat(mListing.equals(mListingElementEarliestWithReadFalse)).isEqualTo(false);
    }
+3 −0
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@ package com.android.bluetooth.map;

import static com.google.common.truth.Truth.assertThat;

import android.annotation.SuppressLint;

import androidx.test.filters.SmallTest;
import androidx.test.runner.AndroidJUnit4;

@@ -67,6 +69,7 @@ public class MsgTest {
    }

    @Test
    @SuppressLint("TruthIncompatibleType") // That the point of this test
    public void equals_withDifferentClass() {
        BluetoothMapContentObserver.Msg msg =
                new BluetoothMapContentObserver.Msg(TEST_ID, TEST_FOLDER_ID, TEST_READ_FLAG);
Loading