Run NetworkStaticLibTests on the actual source files.
Currently, NetworkStaticLibTests tests the class files that are
on the bootclasspath of the device. This makes running these
tests slow and/or confusing, because the framework must be
rebuilt and the device flashed before running the tests, and if
this is not done, the old code will be tested instead.
Instead, jarjar the tests so the test can be run without updating
the device.
Bug: 142892223
Test: atest NetworkStaticLibTests passes on device that does not have the library
Change-Id: I6a0dbebddbd0b64e2722078345ffe6b0c0a1801e
diff --git a/staticlibs/Android.bp b/staticlibs/Android.bp
index 713a0d6..3f867fc 100644
--- a/staticlibs/Android.bp
+++ b/staticlibs/Android.bp
@@ -40,6 +40,7 @@
"//frameworks/opt/telephony",
"//packages/modules/NetworkStack",
"//packages/modules/CaptivePortalLogin",
+ "//frameworks/libs/net/common/tests:__subpackages__",
]
}
@@ -53,6 +54,7 @@
"//frameworks/opt/net/ike",
"//packages/modules/NetworkStack",
"//packages/modules/CaptivePortalLogin",
+ "//frameworks/libs/net/common/tests:__subpackages__",
],
}
diff --git a/staticlibs/tests/unit/Android.bp b/staticlibs/tests/unit/Android.bp
index 4a51a8c..fe363f5 100644
--- a/staticlibs/tests/unit/Android.bp
+++ b/staticlibs/tests/unit/Android.bp
@@ -6,9 +6,12 @@
name: "NetworkStaticLibTests",
certificate: "platform",
srcs: ["src/**/*.java","src/**/*.kt"],
+ jarjar_rules: "jarjar-rules.txt",
test_suites: ["device-tests"],
static_libs: [
"androidx.test.rules",
+ "net-utils-framework-common",
+ "net-utils-services-common",
],
libs: [
"android.test.runner",
diff --git a/staticlibs/tests/unit/jarjar-rules.txt b/staticlibs/tests/unit/jarjar-rules.txt
new file mode 100644
index 0000000..dbb3974
--- /dev/null
+++ b/staticlibs/tests/unit/jarjar-rules.txt
@@ -0,0 +1,4 @@
+# Ensure that the tests can directly use the version of classes from the library. Otherwise, they
+# will use whatever version is currently in the bootclasspath on the device running the test.
+# These rules must match the jarjar rules used to build the library.
+rule android.net.util.** com.android.net.module.util.@1