From 1f4620ac7aa7b1536b3445729558d0cf6b40bf4f Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Wed, 18 Dec 2019 17:16:36 -0800 Subject: [PATCH] Fix Error Prone errors Soong wasn't including android_app or android_test sources in the javac-check target used for the Error Prone build, which allowed some Error Prone errors to get in. Fix them so Error Prone can be re-enabled for these targets. Fixes: frameworks/base/core/tests/coretests/src/android/view/textclassifier/ActionsSuggestionsHelperTest.java:241: error: [JUnit4TestNotRun] This looks like a test method but is not run; please add @Test and @Ignore, or, if this is a helper method, reduce its visibility. frameworks/base/core/tests/systemproperties/src/android/os/SystemPropertiesTest.java:97: error: [JUnit3TestNotRun] Test method will not be run; please correct method signature (Should be public, non-static, and method name should begin with "test"). frameworks/base/services/tests/servicestests/src/com/android/server/backup/utils/FileUtilsTest.java:64: error: [CheckReturnValue] Ignored return value of method that is annotated with @CheckReturnValue frameworks/base/services/tests/servicestests/src/com/android/server/backup/utils/FileUtilsTest.java:68: error: [CheckReturnValue] Ignored return value of method that is annotated with @CheckReturnValue frameworks/base/services/tests/servicestests/src/com/android/server/backup/utils/FileUtilsTest.java:78: error: [CheckReturnValue] Ignored return value of method that is annotated with @CheckReturnValue frameworks/base/services/tests/servicestests/src/com/android/server/hdmi/HdmiCecLocalDeviceAudioSystemTest.java:533: error: [JUnit4TestNotRun] This looks like a test method but is not run; please add @Test and @Ignore, or, if this is a helper method, reduce its visibility. frameworks/base/services/tests/servicestests/src/com/android/server/locksettings/LockSettingsStorageTests.java:480: error: [JUnit4TestNotRun] This looks like a test method but is not run; please add @Test and @Ignore, or, if this is a helper method, reduce its visibility. frameworks/base/services/tests/servicestests/src/com/android/server/locksettings/LockSettingsStorageTests.java:491: error: [JUnit4TestNotRun] This looks like a test method but is not run; please add @Test and @Ignore, or, if this is a helper method, reduce its visibility. frameworks/base/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java:4196: error: [JUnit4TestNotRun] This looks like a test method but is not run; please add @Test and @Ignore, or, if this is a helper method, reduce its visibility. Bug: 146455923 Test: m RUN_ERROR_PRONE=true javac-check Change-Id: I829373d41c97962fe2122ea74cef12ba342ac33c Merged-In: I829373d41c97962fe2122ea74cef12ba342ac33c --- .../ActionsSuggestionsHelperTest.java | 1 + .../src/android/os/SystemPropertiesTest.java | 2 +- .../server/backup/utils/FileUtilsTest.java | 16 +++++++--------- .../hdmi/HdmiCecLocalDeviceAudioSystemTest.java | 1 + .../locksettings/LockSettingsStorageTests.java | 2 ++ .../NotificationManagerServiceTest.java | 1 + 6 files changed, 13 insertions(+), 10 deletions(-) diff --git a/core/tests/coretests/src/android/view/textclassifier/ActionsSuggestionsHelperTest.java b/core/tests/coretests/src/android/view/textclassifier/ActionsSuggestionsHelperTest.java index 80bce264c11b4..ec7e83f1f2439 100644 --- a/core/tests/coretests/src/android/view/textclassifier/ActionsSuggestionsHelperTest.java +++ b/core/tests/coretests/src/android/view/textclassifier/ActionsSuggestionsHelperTest.java @@ -238,6 +238,7 @@ public class ActionsSuggestionsHelperTest { assertThat(conversationActions).isEmpty(); } + @Test public void createLabeledIntentResult_null() { ActionsSuggestionsModel.ActionSuggestion nativeSuggestion = new ActionsSuggestionsModel.ActionSuggestion( diff --git a/core/tests/systemproperties/src/android/os/SystemPropertiesTest.java b/core/tests/systemproperties/src/android/os/SystemPropertiesTest.java index 9f70538191c20..67783bff92994 100644 --- a/core/tests/systemproperties/src/android/os/SystemPropertiesTest.java +++ b/core/tests/systemproperties/src/android/os/SystemPropertiesTest.java @@ -94,7 +94,7 @@ public class SystemPropertiesTest extends TestCase { } @SmallTest - private static void testHandle() throws Exception { + public void testHandle() throws Exception { String value; SystemProperties.Handle handle = SystemProperties.find("doesnotexist_2341431"); assertNull(handle); diff --git a/services/tests/servicestests/src/com/android/server/backup/utils/FileUtilsTest.java b/services/tests/servicestests/src/com/android/server/backup/utils/FileUtilsTest.java index eaa9c45209795..d54aa3b1c2f65 100644 --- a/services/tests/servicestests/src/com/android/server/backup/utils/FileUtilsTest.java +++ b/services/tests/servicestests/src/com/android/server/backup/utils/FileUtilsTest.java @@ -27,7 +27,6 @@ import com.google.common.io.Files; import org.junit.AfterClass; import org.junit.Before; -import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; @@ -41,11 +40,6 @@ public class FileUtilsTest { private static File sTemporaryDir; private File mTemporaryFile; - @BeforeClass - public static void setUpClass() { - sTemporaryDir = Files.createTempDir(); - } - @AfterClass public static void tearDownClass() { if (sTemporaryDir != null) { @@ -55,17 +49,21 @@ public class FileUtilsTest { @Before public void setUp() throws Exception { + if (sTemporaryDir != null) { + sTemporaryDir.delete(); + } + sTemporaryDir = Files.createTempDir(); mTemporaryFile = new File(sTemporaryDir, "fileutilstest.txt"); } /** Test that if file does not exist, {@link FileUtils#createNewFile()} creates the file. */ @Test public void testEnsureFileExists_fileDoesNotAlreadyExist_getsCreated() { - assertThat(!mTemporaryFile.exists()); + assertThat(mTemporaryFile.exists()).isFalse(); FileUtils.createNewFile(mTemporaryFile); - assertThat(mTemporaryFile.exists()); + assertThat(mTemporaryFile.exists()).isTrue(); } /** Test that if file does exist, {@link FileUtils#createNewFile()} does not error out. */ @@ -75,6 +73,6 @@ public class FileUtilsTest { FileUtils.createNewFile(mTemporaryFile); - assertThat(mTemporaryFile.exists()); + assertThat(mTemporaryFile.exists()).isTrue(); } } diff --git a/services/tests/servicestests/src/com/android/server/hdmi/HdmiCecLocalDeviceAudioSystemTest.java b/services/tests/servicestests/src/com/android/server/hdmi/HdmiCecLocalDeviceAudioSystemTest.java index a89198ae37083..163832983b5b7 100644 --- a/services/tests/servicestests/src/com/android/server/hdmi/HdmiCecLocalDeviceAudioSystemTest.java +++ b/services/tests/servicestests/src/com/android/server/hdmi/HdmiCecLocalDeviceAudioSystemTest.java @@ -530,6 +530,7 @@ public class HdmiCecLocalDeviceAudioSystemTest { assertThat(mNativeWrapper.getOnlyResultMessage()).isEqualTo(expectedMessage); } + @Test public void handleSystemAudioModeRequest_fromNonTV_tVNotSupport() { HdmiCecMessage message = HdmiCecMessageBuilder.buildSystemAudioModeRequest( diff --git a/services/tests/servicestests/src/com/android/server/locksettings/LockSettingsStorageTests.java b/services/tests/servicestests/src/com/android/server/locksettings/LockSettingsStorageTests.java index a1f423e77865a..ab9b39c280e9d 100644 --- a/services/tests/servicestests/src/com/android/server/locksettings/LockSettingsStorageTests.java +++ b/services/tests/servicestests/src/com/android/server/locksettings/LockSettingsStorageTests.java @@ -477,6 +477,7 @@ public class LockSettingsStorageTests { assertEquals(2, PersistentData.TYPE_SP_WEAVER); } + @Test public void testCredentialHash_serializeUnserialize() { byte[] serialized = CredentialHash.create( PAYLOAD, LockPatternUtils.CREDENTIAL_TYPE_PASSWORD).toBytes(); @@ -488,6 +489,7 @@ public class LockSettingsStorageTests { assertFalse(deserialized.isBaseZeroPattern); } + @Test public void testCredentialHash_unserialize_versionGatekeeper() { // This test ensures that we can read serialized VERSION_GATEKEEPER CredentialHashes // even if we change the wire format in the future. diff --git a/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java b/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java index b5542afed46d4..0fce618012f95 100755 --- a/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java +++ b/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java @@ -4193,6 +4193,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { assertEquals(0, mService.countLogSmartSuggestionsVisible); } + @Test public void testReportSeen_delegated() { Notification.Builder nb = new Notification.Builder(mContext, mTestNotificationChannel.getId())