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

Commit 91ec84a4 authored by William Escande's avatar William Escande Committed by Gerrit Code Review
Browse files

Merge changes I6842932f,I67158ab5,Ia01ff490 into main

* changes:
  TestErrorProne: NarrowCalculation & UndefinedEquals
  ErrorProne: TruthConstantAsserts
  Java unit test: More errorprone enforced as error
parents 642afe85 ee597f5f
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -59,22 +59,29 @@ 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:NarrowCalculation:ERROR",
            "-Xep:NonApiType:ERROR",
            "-Xep:NonCanonicalType:ERROR",
            "-Xep:NotJavadoc:ERROR",
            "-Xep:ReturnAtTheEndOfVoidFunction:ERROR",
            "-Xep:StringCaseLocaleUsage:ERROR",
            "-Xep:StringCharset:ERROR",
            "-Xep:TruthConstantAsserts:ERROR",
            "-Xep:TruthIncompatibleType:ERROR",
            "-Xep:UndefinedEquals:ERROR",
            "-Xep:UnnecessaryAssignment:ERROR",
            "-Xep:UnnecessaryAsync:ERROR",
            "-Xep:UnusedMethod:ERROR",
+2 −4
Original line number Diff line number Diff line
@@ -26,12 +26,10 @@ import android.bluetooth.BluetoothCodecConfig;
import android.bluetooth.BluetoothCodecStatus;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothProfile;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.HandlerThread;

import androidx.test.InstrumentationRegistry;
import androidx.test.filters.MediumTest;
import androidx.test.runner.AndroidJUnit4;

@@ -252,7 +250,7 @@ public class A2dpStateMachineTest {

        // Verify that one connection state broadcast is executed
        ArgumentCaptor<Intent> intentArgument2 = ArgumentCaptor.forClass(Intent.class);
        verify(mA2dpService, timeout(A2dpStateMachine.sConnectTimeoutMs * 2).times(2))
        verify(mA2dpService, timeout(A2dpStateMachine.sConnectTimeoutMs * 2L).times(2))
                .sendBroadcast(intentArgument2.capture(), anyString(), any(Bundle.class));
        assertThat(intentArgument2.getValue().getIntExtra(BluetoothProfile.EXTRA_STATE, -1))
                .isEqualTo(BluetoothProfile.STATE_DISCONNECTED);
@@ -289,7 +287,7 @@ public class A2dpStateMachineTest {

        // Verify that one connection state broadcast is executed
        ArgumentCaptor<Intent> intentArgument2 = ArgumentCaptor.forClass(Intent.class);
        verify(mA2dpService, timeout(A2dpStateMachine.sConnectTimeoutMs * 2).times(2))
        verify(mA2dpService, timeout(A2dpStateMachine.sConnectTimeoutMs * 2L).times(2))
                .sendBroadcast(intentArgument2.capture(), anyString(), any(Bundle.class));
        assertThat(intentArgument2.getValue().getIntExtra(BluetoothProfile.EXTRA_STATE, -1))
                .isEqualTo(BluetoothProfile.STATE_DISCONNECTED);
+6 −4
Original line number Diff line number Diff line
@@ -396,14 +396,16 @@ public class BrowserPlayerWrapperTest {
                Assert.assertNotNull(folder);
                Assert.assertFalse(folder.isPlayable);
                Assert.assertEquals(expected.getDescription().getMediaId(), folder.mediaId);
                Assert.assertEquals(expected.getDescription().getTitle(), folder.title);
                Assert.assertEquals(expected.getDescription().getTitle().toString(), folder.title);
            } else {
                Metadata song = item.song;
                Assert.assertNotNull(song);
                Assert.assertEquals(expected.getDescription().getMediaId(), song.mediaId);
                Assert.assertEquals(expected.getDescription().getTitle(), song.title);
                Assert.assertEquals(expected.getDescription().getSubtitle(), song.artist);
                Assert.assertEquals(expected.getDescription().getDescription(), song.album);
                Assert.assertEquals(expected.getDescription().getTitle().toString(), song.title);
                Assert.assertEquals(
                        expected.getDescription().getSubtitle().toString(), song.artist);
                Assert.assertEquals(
                        expected.getDescription().getDescription().toString(), song.album);
                if (expected.getDescription().getIconBitmap() != null) {
                    Assert.assertNotNull(song.image);
                    Bitmap expectedBitmap = expected.getDescription().getIconBitmap();
+3 −5
Original line number Diff line number Diff line
@@ -18,13 +18,11 @@ package com.android.bluetooth.avrcpcontroller;

import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.content.Context;
import android.net.Uri;
import android.support.v4.media.MediaBrowserCompat.MediaItem;
import android.support.v4.media.MediaDescriptionCompat;
import android.support.v4.media.MediaMetadataCompat;

import androidx.test.InstrumentationRegistry;
import androidx.test.runner.AndroidJUnit4;

import org.junit.After;
@@ -554,7 +552,7 @@ public final class AvrcpItemTest {
        Assert.assertEquals(UUID, desc.getMediaId());
        Assert.assertEquals(null, desc.getMediaUri());
        Assert.assertEquals(title, desc.getTitle().toString());
        Assert.assertEquals(desc.getSubtitle(), null);
        Assert.assertNull(desc.getSubtitle());
        Assert.assertEquals(uri, desc.getIconUri());
        Assert.assertEquals(null, desc.getIconBitmap());
    }
@@ -583,7 +581,7 @@ public final class AvrcpItemTest {
        Assert.assertEquals(UUID, desc.getMediaId());
        Assert.assertEquals(null, desc.getMediaUri());
        Assert.assertEquals(displayName, desc.getTitle().toString());
        Assert.assertEquals(desc.getSubtitle(), null);
        Assert.assertNull(desc.getSubtitle());
        Assert.assertEquals(uri, desc.getIconUri());
        Assert.assertEquals(null, desc.getIconBitmap());
    }
@@ -610,7 +608,7 @@ public final class AvrcpItemTest {
        Assert.assertEquals(UUID, desc.getMediaId());
        Assert.assertEquals(null, desc.getMediaUri());
        Assert.assertEquals(title, desc.getTitle().toString());
        Assert.assertEquals(desc.getSubtitle(), null);
        Assert.assertNull(desc.getSubtitle());
        Assert.assertEquals(uri, desc.getIconUri());
        Assert.assertEquals(null, desc.getIconBitmap());
    }
+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();

Loading