Fix ExtServices tests
- Switch the tests from Android.mk to Android.bp. The app itself
cannot move over yet because it uses syntax not supported by bp
- Instrument the test package instead of the package udner test
- Also fix an actual error in a test
Test: this
Change-Id: I0af081ab25630e4e911d4d9cbb60a87b2f75be90
Fixes: 123572762
diff --git a/packages/ExtServices/Android.bp b/packages/ExtServices/Android.bp
new file mode 100644
index 0000000..77972fe
--- /dev/null
+++ b/packages/ExtServices/Android.bp
@@ -0,0 +1,11 @@
+android_library {
+ name: "ExtServices-core",
+ srcs: [
+ "src/**/*.java",
+ ],
+ resource_dirs: [
+ "res",
+ ],
+
+ manifest: "AndroidManifest.xml",
+}
\ No newline at end of file
diff --git a/packages/ExtServices/tests/Android.bp b/packages/ExtServices/tests/Android.bp
new file mode 100644
index 0000000..5de4548
--- /dev/null
+++ b/packages/ExtServices/tests/Android.bp
@@ -0,0 +1,26 @@
+android_test {
+ name: "ExtServicesUnitTests",
+
+ // Include all test java files.
+ srcs: ["src/**/*.java"],
+
+ // We only want this apk build for tests.
+ certificate: "platform",
+
+ libs: [
+ "android.test.runner",
+ "android.test.base",
+ ],
+
+ static_libs: [
+ "ExtServices-core",
+ "android-support-test",
+ "mockito-target-minus-junit4",
+ "espresso-core",
+ "truth-prebuilt",
+ "testables",
+ "testng",
+ ],
+
+ platform_apis: true,
+}
\ No newline at end of file
diff --git a/packages/ExtServices/tests/Android.mk b/packages/ExtServices/tests/Android.mk
deleted file mode 100644
index a57fa94..0000000
--- a/packages/ExtServices/tests/Android.mk
+++ /dev/null
@@ -1,26 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-# We only want this apk build for tests.
-LOCAL_MODULE_TAGS := tests
-LOCAL_CERTIFICATE := platform
-
-LOCAL_JAVA_LIBRARIES := android.test.runner android.test.base
-
-LOCAL_STATIC_JAVA_LIBRARIES := \
- android-support-test \
- mockito-target-minus-junit4 \
- espresso-core \
- truth-prebuilt \
- testables \
- testng
-
-# Include all test java files.
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-LOCAL_PACKAGE_NAME := ExtServicesUnitTests
-LOCAL_PRIVATE_PLATFORM_APIS := true
-
-LOCAL_INSTRUMENTATION_FOR := ExtServices
-
-include $(BUILD_PACKAGE)
diff --git a/packages/ExtServices/tests/AndroidManifest.xml b/packages/ExtServices/tests/AndroidManifest.xml
index ddf725b..3cf1527 100644
--- a/packages/ExtServices/tests/AndroidManifest.xml
+++ b/packages/ExtServices/tests/AndroidManifest.xml
@@ -24,7 +24,7 @@
</application>
<instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
- android:targetPackage="android.ext.services"
+ android:targetPackage="android.ext.services.tests.unit"
android:label="ExtServices Test Cases">
</instrumentation>
diff --git a/packages/ExtServices/tests/src/android/ext/services/notification/NotificationCategorizerTest.java b/packages/ExtServices/tests/src/android/ext/services/notification/NotificationCategorizerTest.java
index 12908e6..c59885e 100644
--- a/packages/ExtServices/tests/src/android/ext/services/notification/NotificationCategorizerTest.java
+++ b/packages/ExtServices/tests/src/android/ext/services/notification/NotificationCategorizerTest.java
@@ -180,7 +180,7 @@
assertFalse(nc.shouldSilence(NotificationCategorizer.CATEGORY_SYSTEM));
when(mSbn.getUid()).thenReturn(FIRST_APPLICATION_UID);
- assertEquals(NotificationCategorizer.CATEGORY_EVERYTHING_ELSE, nc.getCategory(mEntry));
+ assertEquals(NotificationCategorizer.CATEGORY_HIGH, nc.getCategory(mEntry));
}
@Test