aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelipe Leme <felipeal@google.com>2024-05-04 04:57:03 +0000
committerFelipe Leme <felipeal@google.com>2024-05-06 16:43:04 +0000
commit5e0b24a0eab14ea6d4628cd641153ea0e34b17ef (patch)
tree28e46b650f9ba36cfee8e93e362023505f43358b
parent7639d6fae8052d6328c64ac508b8f6438391e5a7 (diff)
downloadmodules-utils-5e0b24a0eab14ea6d4628cd641153ea0e34b17ef.tar.gz
Added new build target for extended-mockito-rule targets.
Bug: 338434399 Test: atest ModulesUtilsTestingTests AdServicesTestUtilityTests StatsdTestUtilsTest Flag: TEST_ONLY Change-Id: Id023e2d4d94df71c8a49f5a6ee452bc24e93a237
-rw-r--r--java/com/android/modules/utils/testing/Android.bp60
1 files changed, 48 insertions, 12 deletions
diff --git a/java/com/android/modules/utils/testing/Android.bp b/java/com/android/modules/utils/testing/Android.bp
index 4b285f1..f866d8d 100644
--- a/java/com/android/modules/utils/testing/Android.bp
+++ b/java/com/android/modules/utils/testing/Android.bp
@@ -28,45 +28,81 @@ java_library {
visibility: ["//visibility:public"],
}
-// TODO(b/281577492): split in 2 (one for just ExtendedMockito stuff)
+// Utility for mocking DeviceConfig and other device state.
+//
// NOTE: clients should depend on modules-utils-testable-device-config-defaults
// instead of using this library directly (so it sets the proper JNI dependencies)
java_library {
name: "modules-utils-testable-device-config",
srcs: [
+ "TestableDeviceConfig.java",
+ ],
+ static_libs: [
+ "modules-utils-build",
+ "modules-utils-extended-mockito-rule",
+ ],
+ libs: [
+ "framework-configinfrastructure",
+ ],
+ visibility: ["//visibility:public"],
+}
+
+// Utility for mocking DeviceConfig and other device state.
+//
+// NOTE: if you're only using ExtendedMockitoRule (without TestableDevicConfig), you should use
+// modules-utils-extended-mockito-rule-defaults instead
+//
+// In order to use these utils successfully, both Java code and native libraries will be required.
+// If your code is in a library, you will have to depend on these defaults both in the library as
+// well as in the android_test that it gets linked into.
+// You will also need to specify android:debuggable="true" in the test's manifest.
+java_defaults {
+ name: "modules-utils-testable-device-config-defaults",
+ static_libs: ["modules-utils-testable-device-config"],
+ defaults: ["modules-utils-extended-mockito-rule-defaults"],
+ defaults_visibility: ["//visibility:public"],
+}
+
+// Utility for using ExtendedMockitoRule.
+//
+// NOTE: most clients should depend on modules-utils-extended-mockito-rule-defaults
+// instead of using this library directly (so it sets the proper JNI dependencies)
+java_library {
+ name: "modules-utils-extended-mockito-rule",
+ srcs: [
"AbstractExtendedMockitoRule.java",
"StaticMockFixture.java",
"ExtendedMockitoRule.java",
- "TestableDeviceConfig.java",
],
static_libs: [
- "androidx.test.rules",
+ "junit",
"mockito-target-extended-minus-junit4",
- "modules-utils-build",
- "modules-utils-preconditions",
],
libs: [
- "framework-configinfrastructure",
- "framework-annotations-lib",
+ "framework-annotations-lib", // @VisibleForTesting
],
sdk_version: "module_current",
min_sdk_version: "29",
+ // compile_multilib: "both",
+ // TODO(b/338434399): figure out why adding compile_multib causes a failure:
+ // In file included from build/make/core/soong_java_prebuilt.mk:38:
+ // build/make/core/base_rules.mk:300: error: frameworks/libs/modules-utils/java/com/android/modules/utils/testing:
+ // MODULE.TARGET.JAVA_LIBRARIES.modules-utils-extended-mockito-rule already defined by frameworks/libs/modules-utils/java/com/android/modules/utils/testing.
visibility: ["//visibility:public"],
lint: {
baseline_filename: "lint-baseline.xml",
},
}
-// TODO(b/281577492): split in 2 (one for just ExtendedMockito stuff)
-// Utility for mocking DeviceConfig and other device state.
+// Utility for using ExtendedMockitoRule.
+//
// In order to use these utils successfully, both Java code and native libraries will be required.
// If your code is in a library, you will have to depend on these defaults both in the library as
// well as in the android_test that it gets linked into.
// You will also need to specify android:debuggable="true" in the test's manifest.
java_defaults {
- name: "modules-utils-testable-device-config-defaults",
- static_libs: ["modules-utils-testable-device-config"],
- compile_multilib: "both",
+ name: "modules-utils-extended-mockito-rule-defaults",
+ static_libs: ["modules-utils-extended-mockito-rule"],
jni_libs: [
"libdexmakerjvmtiagent",
"libstaticjvmtiagent",