Apply jarjar rules on coverage tests
Apply their respective jarjar rules on tethering and general connectivity tests, then merge both into the coverage tests suite. This is necessary to ensure that classes covered by tests have names matching classes used in code. Also fix IpConnectivityLogTest to use the module utility instead of the hidden BitUtils, as the test would fail after internal utils are jarjared. Bug: 187935317 Test: atest ConnectivityCoverageTests TetheringCoverageTests Original-Change: https://android-review.googlesource.com/1749680 Merged-In: Ib95b58dab93f7adebc445b662a6d15db1ce0e7c2 Change-Id: Ib95b58dab93f7adebc445b662a6d15db1ce0e7c2
This commit is contained in:
@@ -22,7 +22,7 @@ filegroup {
|
||||
name: "TetheringTestsJarJarRules",
|
||||
srcs: ["jarjar-rules.txt"],
|
||||
visibility: [
|
||||
"//frameworks/base/packages/Tethering/tests:__subpackages__",
|
||||
"//packages/modules/Connectivity/tests:__subpackages__",
|
||||
"//packages/modules/Connectivity/Tethering/tests:__subpackages__",
|
||||
]
|
||||
}
|
||||
|
||||
@@ -78,9 +78,27 @@ android_test {
|
||||
compile_multilib: "both",
|
||||
}
|
||||
|
||||
android_library {
|
||||
name: "TetheringCoverageTestsLib",
|
||||
min_sdk_version: "30",
|
||||
static_libs: [
|
||||
"NetdStaticLibTestsLib",
|
||||
"NetworkStaticLibTestsLib",
|
||||
"NetworkStackTestsLib",
|
||||
"TetheringTestsLatestSdkLib",
|
||||
"TetheringIntegrationTestsLatestSdkLib",
|
||||
],
|
||||
jarjar_rules: ":TetheringTestsJarJarRules",
|
||||
manifest: "AndroidManifest_coverage.xml",
|
||||
visibility: [
|
||||
"//packages/modules/Connectivity/tests:__subpackages__"
|
||||
],
|
||||
}
|
||||
|
||||
// Special version of the tethering tests that includes all tests necessary for code coverage
|
||||
// purposes. This is currently the union of TetheringTests, TetheringIntegrationTests and
|
||||
// NetworkStackTests.
|
||||
// TODO: remove in favor of ConnectivityCoverageTests, which includes below tests and more
|
||||
android_test {
|
||||
name: "TetheringCoverageTests",
|
||||
platform_apis: true,
|
||||
@@ -91,11 +109,7 @@ android_test {
|
||||
defaults: ["libnetworkstackutilsjni_deps"],
|
||||
static_libs: [
|
||||
"modules-utils-native-coverage-listener",
|
||||
"NetdStaticLibTestsLib",
|
||||
"NetworkStaticLibTestsLib",
|
||||
"NetworkStackTestsLib",
|
||||
"TetheringTestsLatestSdkLib",
|
||||
"TetheringIntegrationTestsLatestSdkLib",
|
||||
"TetheringCoverageTestsLib",
|
||||
],
|
||||
jni_libs: [
|
||||
// For mockito extended
|
||||
|
||||
@@ -77,7 +77,6 @@ java_defaults {
|
||||
"libstaticjvmtiagent",
|
||||
"libtetherutilsjni",
|
||||
],
|
||||
jarjar_rules: ":TetheringTestsJarJarRules",
|
||||
}
|
||||
|
||||
// Library containing the unit tests. This is used by the coverage test target to pull in the
|
||||
@@ -102,4 +101,5 @@ android_test {
|
||||
],
|
||||
defaults: ["TetheringTestsDefaults"],
|
||||
compile_multilib: "both",
|
||||
jarjar_rules: ":TetheringTestsJarJarRules",
|
||||
}
|
||||
|
||||
@@ -112,3 +112,9 @@ java_library {
|
||||
"com.android.tethering",
|
||||
],
|
||||
}
|
||||
|
||||
filegroup {
|
||||
name: "connectivity-jarjar-rules",
|
||||
srcs: ["jarjar-rules.txt"],
|
||||
visibility: ["//packages/modules/Connectivity:__subpackages__"],
|
||||
}
|
||||
|
||||
@@ -43,6 +43,23 @@ java_library {
|
||||
],
|
||||
}
|
||||
|
||||
// Connectivity coverage tests combines Tethering and Connectivity tests, each with their
|
||||
// respective jarjar rules applied.
|
||||
// Some tests may be duplicated (in particular static lib tests), as they need to be run under both
|
||||
// jarjared packages to cover both usages.
|
||||
android_library {
|
||||
name: "ConnectivityCoverageTestsLib",
|
||||
min_sdk_version: "30",
|
||||
static_libs: [
|
||||
"FrameworksNetTestsLib",
|
||||
"NetdStaticLibTestsLib",
|
||||
"NetworkStaticLibTestsLib",
|
||||
],
|
||||
jarjar_rules: ":connectivity-jarjar-rules",
|
||||
manifest: "AndroidManifest_coverage.xml",
|
||||
visibility: ["//visibility:private"],
|
||||
}
|
||||
|
||||
android_test {
|
||||
name: "ConnectivityCoverageTests",
|
||||
// Tethering started on SDK 30
|
||||
@@ -62,13 +79,9 @@ android_test {
|
||||
// (some tests would fail).
|
||||
// TODO: consider removing extended mockito usage in tests that use it, for performance
|
||||
"mockito-target-extended-minus-junit4",
|
||||
"FrameworksNetTestsLib",
|
||||
"modules-utils-native-coverage-listener",
|
||||
"NetdStaticLibTestsLib",
|
||||
"NetworkStaticLibTestsLib",
|
||||
"NetworkStackTestsLib",
|
||||
"TetheringTestsLatestSdkLib",
|
||||
"TetheringIntegrationTestsLatestSdkLib",
|
||||
"ConnectivityCoverageTestsLib",
|
||||
"TetheringCoverageTestsLib",
|
||||
],
|
||||
jni_libs: [
|
||||
// For mockito extended
|
||||
|
||||
@@ -19,6 +19,8 @@ package android.net.metrics;
|
||||
import static android.net.NetworkCapabilities.TRANSPORT_CELLULAR;
|
||||
import static android.net.NetworkCapabilities.TRANSPORT_WIFI;
|
||||
|
||||
import static com.android.net.module.util.NetworkCapabilitiesUtils.unpackBits;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.timeout;
|
||||
@@ -31,8 +33,6 @@ import android.net.Network;
|
||||
import androidx.test.filters.SmallTest;
|
||||
import androidx.test.runner.AndroidJUnit4;
|
||||
|
||||
import com.android.internal.util.BitUtils;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -49,7 +49,7 @@ import java.util.List;
|
||||
@SmallTest
|
||||
public class IpConnectivityLogTest {
|
||||
private static final int FAKE_NET_ID = 100;
|
||||
private static final int[] FAKE_TRANSPORT_TYPES = BitUtils.unpackBits(TRANSPORT_WIFI);
|
||||
private static final int[] FAKE_TRANSPORT_TYPES = unpackBits(TRANSPORT_WIFI);
|
||||
private static final long FAKE_TIME_STAMP = System.currentTimeMillis();
|
||||
private static final String FAKE_INTERFACE_NAME = "test";
|
||||
private static final IpReachabilityEvent FAKE_EV =
|
||||
|
||||
Reference in New Issue
Block a user