Merge changes from topic "am-cc17cb7d48ea4bd7adc9183dc0c381e3-sc-dev" into sc-dev
* changes: Apply jarjar rules on coverage tests Re-skip connectivity unit tests before S Move ConnectivityCoverageTests to general-tests Fix ConnectivityManagerTest initialization on Q Move test_mainline_modules to AndroidTest.xml Add ConnectivityCoverageTests to postsubmit Add connectivity coverage tests Make tests compatible with mockito-extended Fix KeepalivePacketDataUtilTest crash on eng build Update connectivity TEST_MAPPING
This commit is contained in:
commit
0f956db686
71 changed files with 577 additions and 210 deletions
24
TEST_MAPPING
24
TEST_MAPPING
|
|
@ -11,6 +11,17 @@
|
|||
"exclude-annotation": "com.android.testutils.SkipPresubmit"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "TetheringTests"
|
||||
},
|
||||
{
|
||||
"name": "TetheringIntegrationTests"
|
||||
}
|
||||
],
|
||||
"postsubmit": [
|
||||
{
|
||||
"name": "ConnectivityCoverageTests"
|
||||
}
|
||||
],
|
||||
"mainline-presubmit": [
|
||||
|
|
@ -24,11 +35,22 @@
|
|||
]
|
||||
}
|
||||
],
|
||||
// Tests on physical devices with SIM cards: postsubmit only for capacity constraints
|
||||
"mainline-postsubmit": [
|
||||
// Tests on physical devices with SIM cards: postsubmit only for capacity constraints
|
||||
{
|
||||
"name": "CtsNetTestCasesLatestSdk[CaptivePortalLoginGoogle.apk+NetworkStackGoogle.apk+com.google.android.resolv.apex+com.google.android.tethering.apex]",
|
||||
"keywords": ["sim"]
|
||||
},
|
||||
{
|
||||
"name": "TetheringCoverageTests[CaptivePortalLoginGoogle.apk+NetworkStackGoogle.apk+com.google.android.resolv.apex+com.google.android.tethering.apex]"
|
||||
},
|
||||
{
|
||||
"name": "ConnectivityCoverageTests[CaptivePortalLoginGoogle.apk+NetworkStackGoogle.apk+com.google.android.resolv.apex+com.google.android.tethering.apex]"
|
||||
}
|
||||
],
|
||||
"imports": [
|
||||
{
|
||||
"path": "packages/modules/NetworkStack"
|
||||
}
|
||||
],
|
||||
"imports": [
|
||||
|
|
|
|||
|
|
@ -1,12 +0,0 @@
|
|||
{
|
||||
"presubmit": [
|
||||
{
|
||||
"name": "TetheringTests"
|
||||
}
|
||||
],
|
||||
"postsubmit": [
|
||||
{
|
||||
"name": "TetheringIntegrationTests"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -22,6 +22,7 @@ java_sdk_library {
|
|||
defaults: ["framework-module-defaults"],
|
||||
impl_library_visibility: [
|
||||
"//packages/modules/Connectivity/Tethering:__subpackages__",
|
||||
"//packages/modules/Connectivity/tests:__subpackages__",
|
||||
],
|
||||
|
||||
srcs: [":framework-tethering-srcs"],
|
||||
|
|
|
|||
|
|
@ -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__",
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,7 +51,8 @@ android_library {
|
|||
defaults: ["TetheringIntegrationTestsDefaults"],
|
||||
visibility: [
|
||||
"//packages/modules/Connectivity/tests/cts/tethering",
|
||||
"//packages/modules/Connectivity/Tethering/tests/mts",
|
||||
"//packages/modules/Connectivity/tests:__subpackages__",
|
||||
"//packages/modules/Connectivity/Tethering/tests:__subpackages__",
|
||||
]
|
||||
}
|
||||
|
||||
|
|
@ -77,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,
|
||||
|
|
@ -90,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
|
||||
|
|
@ -104,7 +119,6 @@ android_test {
|
|||
"libnetworkstackutilsjni",
|
||||
"libtetherutilsjni",
|
||||
],
|
||||
jarjar_rules: ":TetheringTestsJarJarRules",
|
||||
compile_multilib: "both",
|
||||
manifest: "AndroidManifest_coverage.xml",
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ import static android.Manifest.permission.READ_DEVICE_CONFIG;
|
|||
import static android.Manifest.permission.TETHER_PRIVILEGED;
|
||||
import static android.Manifest.permission.WRITE_SETTINGS;
|
||||
import static android.net.TetheringManager.TETHERING_WIFI;
|
||||
import static android.net.cts.util.CtsTetheringUtils.isWifiTetheringSupported;
|
||||
import static android.provider.DeviceConfig.NAMESPACE_CONNECTIVITY;
|
||||
|
||||
import static com.android.testutils.TestNetworkTrackerKt.initTestNetwork;
|
||||
|
|
@ -102,8 +101,7 @@ public class TetheringModuleTest {
|
|||
|
||||
TestNetworkTracker tnt = null;
|
||||
try {
|
||||
tetherEventCallback.assumeTetheringSupported();
|
||||
assumeTrue(isWifiTetheringSupported(mContext, tetherEventCallback));
|
||||
tetherEventCallback.assumeWifiTetheringSupported(mContext);
|
||||
tetherEventCallback.expectNoTetheringActive();
|
||||
|
||||
final TetheringInterface tetheredIface =
|
||||
|
|
|
|||
|
|
@ -87,7 +87,8 @@ android_library {
|
|||
defaults: ["TetheringTestsDefaults"],
|
||||
target_sdk_version: "30",
|
||||
visibility: [
|
||||
"//packages/modules/Connectivity/Tethering/tests/integration",
|
||||
"//packages/modules/Connectivity/tests:__subpackages__",
|
||||
"//packages/modules/Connectivity/Tethering/tests:__subpackages__",
|
||||
]
|
||||
}
|
||||
|
||||
|
|
@ -98,7 +99,7 @@ android_test {
|
|||
"device-tests",
|
||||
"mts",
|
||||
],
|
||||
jarjar_rules: ":TetheringTestsJarJarRules",
|
||||
defaults: ["TetheringTestsDefaults"],
|
||||
compile_multilib: "both",
|
||||
jarjar_rules: ":TetheringTestsJarJarRules",
|
||||
}
|
||||
|
|
|
|||
|
|
@ -109,3 +109,9 @@ java_library {
|
|||
"com.android.tethering",
|
||||
],
|
||||
}
|
||||
|
||||
filegroup {
|
||||
name: "connectivity-jarjar-rules",
|
||||
srcs: ["jarjar-rules.txt"],
|
||||
visibility: ["//packages/modules/Connectivity:__subpackages__"],
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,6 +43,66 @@ 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
|
||||
min_sdk_version: "30",
|
||||
// TODO: change to 31 as soon as it is available
|
||||
target_sdk_version: "30",
|
||||
test_suites: ["general-tests", "mts"],
|
||||
defaults: [
|
||||
"framework-connectivity-test-defaults",
|
||||
"FrameworksNetTests-jni-defaults",
|
||||
"libnetworkstackutilsjni_deps",
|
||||
],
|
||||
manifest: "AndroidManifest_coverage.xml",
|
||||
test_config: "AndroidTest_Coverage.xml",
|
||||
static_libs: [
|
||||
// Added first so all tests use extended mockito, instead of all tests using regular mockito
|
||||
// (some tests would fail).
|
||||
// TODO: consider removing extended mockito usage in tests that use it, for performance
|
||||
"mockito-target-extended-minus-junit4",
|
||||
"modules-utils-native-coverage-listener",
|
||||
"ConnectivityCoverageTestsLib",
|
||||
"TetheringCoverageTestsLib",
|
||||
],
|
||||
jni_libs: [
|
||||
// For mockito extended
|
||||
"libdexmakerjvmtiagent",
|
||||
"libstaticjvmtiagent",
|
||||
// For NetworkStackUtils included in NetworkStackBase
|
||||
"libnetworkstackutilsjni",
|
||||
"libtetherutilsjni",
|
||||
// For framework tests
|
||||
"libservice-connectivity",
|
||||
],
|
||||
libs: [
|
||||
// Although not required to compile the static libs together, the "libs" used to build each
|
||||
// of the common static test libs are necessary for R8 to avoid "Missing class" warnings and
|
||||
// incorrect optimizations
|
||||
"framework-tethering.impl",
|
||||
"framework-wifi.stubs.module_lib",
|
||||
],
|
||||
compile_multilib: "both",
|
||||
}
|
||||
|
||||
// defaults for tests that need to build against framework-connectivity's @hide APIs
|
||||
// Only usable from targets that have visibility on framework-connectivity.impl.
|
||||
// Instead of using this, consider avoiding to depend on hidden connectivity APIs in
|
||||
|
|
|
|||
29
tests/common/AndroidManifest_coverage.xml
Normal file
29
tests/common/AndroidManifest_coverage.xml
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2021 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
package="com.android.connectivity.tests.coverage">
|
||||
|
||||
<application tools:replace="android:label"
|
||||
android:debuggable="true"
|
||||
android:label="Connectivity coverage tests">
|
||||
<uses-library android:name="android.test.runner" />
|
||||
</application>
|
||||
<instrumentation android:name="androidx.test.runner.AndroidJUnitRunner"
|
||||
android:targetPackage="com.android.connectivity.tests.coverage"
|
||||
android:label="Connectivity coverage tests">
|
||||
</instrumentation>
|
||||
</manifest>
|
||||
28
tests/common/AndroidTest_Coverage.xml
Normal file
28
tests/common/AndroidTest_Coverage.xml
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
<!-- Copyright (C) 2021 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<configuration description="Runs coverage tests for Connectivity">
|
||||
<target_preparer class="com.android.tradefed.targetprep.TestAppInstallSetup">
|
||||
<option name="test-file-name" value="ConnectivityCoverageTests.apk" />
|
||||
</target_preparer>
|
||||
|
||||
<option name="test-tag" value="ConnectivityCoverageTests" />
|
||||
<option name="config-descriptor:metadata" key="mainline-param" value="CaptivePortalLoginGoogle.apk+NetworkStackGoogle.apk+com.google.android.resolv.apex+com.google.android.tethering.apex" />
|
||||
<test class="com.android.tradefed.testtype.AndroidJUnitTest" >
|
||||
<option name="package" value="com.android.connectivity.tests.coverage" />
|
||||
<option name="runner" value="androidx.test.runner.AndroidJUnitRunner" />
|
||||
<option name="hidden-api-checks" value="false"/>
|
||||
<option name="device-listeners" value="com.android.modules.utils.testing.NativeCoverageHackInstrumentationListener" />
|
||||
</test>
|
||||
</configuration>
|
||||
|
|
@ -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 =
|
||||
|
|
|
|||
|
|
@ -55,16 +55,12 @@ import static android.net.NetworkCapabilities.NET_CAPABILITY_PARTIAL_CONNECTIVIT
|
|||
import static android.net.NetworkCapabilities.NET_CAPABILITY_VALIDATED;
|
||||
import static android.net.NetworkCapabilities.TRANSPORT_TEST;
|
||||
import static android.net.NetworkCapabilities.TRANSPORT_WIFI;
|
||||
import static android.net.TetheringManager.TETHERING_WIFI;
|
||||
import static android.net.TetheringManager.TetheringRequest;
|
||||
import static android.net.cts.util.CtsNetUtils.ConnectivityActionReceiver;
|
||||
import static android.net.cts.util.CtsNetUtils.HTTP_PORT;
|
||||
import static android.net.cts.util.CtsNetUtils.NETWORK_CALLBACK_ACTION;
|
||||
import static android.net.cts.util.CtsNetUtils.TEST_HOST;
|
||||
import static android.net.cts.util.CtsNetUtils.TestNetworkCallback;
|
||||
import static android.net.cts.util.CtsTetheringUtils.StartTetheringCallback;
|
||||
import static android.net.cts.util.CtsTetheringUtils.TestTetheringEventCallback;
|
||||
import static android.net.cts.util.CtsTetheringUtils.isWifiTetheringSupported;
|
||||
import static android.net.util.NetworkStackUtils.TEST_CAPTIVE_PORTAL_HTTPS_URL;
|
||||
import static android.net.util.NetworkStackUtils.TEST_CAPTIVE_PORTAL_HTTP_URL;
|
||||
import static android.os.MessageQueue.OnFileDescriptorEventListener.EVENT_INPUT;
|
||||
|
|
@ -133,9 +129,9 @@ import android.net.SocketKeepalive;
|
|||
import android.net.TelephonyNetworkSpecifier;
|
||||
import android.net.TestNetworkInterface;
|
||||
import android.net.TestNetworkManager;
|
||||
import android.net.TetheringManager;
|
||||
import android.net.Uri;
|
||||
import android.net.cts.util.CtsNetUtils;
|
||||
import android.net.cts.util.CtsTetheringUtils;
|
||||
import android.net.util.KeepaliveUtils;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.os.Binder;
|
||||
|
|
@ -286,7 +282,6 @@ public class ConnectivityManagerTest {
|
|||
private final ArraySet<Integer> mNetworkTypes = new ArraySet<>();
|
||||
private UiAutomation mUiAutomation;
|
||||
private CtsNetUtils mCtsNetUtils;
|
||||
private TetheringManager mTm;
|
||||
|
||||
// Used for cleanup purposes.
|
||||
private final List<Range<Integer>> mVpnRequiredUidRanges = new ArrayList<>();
|
||||
|
|
@ -302,7 +297,6 @@ public class ConnectivityManagerTest {
|
|||
mWifiManager = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE);
|
||||
mPackageManager = mContext.getPackageManager();
|
||||
mCtsNetUtils = new CtsNetUtils(mContext);
|
||||
mTm = mContext.getSystemService(TetheringManager.class);
|
||||
|
||||
if (DevSdkIgnoreRuleKt.isDevSdkInRange(null /* minExclusive */,
|
||||
Build.VERSION_CODES.R /* maxInclusive */)) {
|
||||
|
|
@ -2239,14 +2233,15 @@ public class ConnectivityManagerTest {
|
|||
ConnectivitySettingsManager.getNetworkAvoidBadWifi(mContext);
|
||||
final int curPrivateDnsMode = ConnectivitySettingsManager.getPrivateDnsMode(mContext);
|
||||
|
||||
final TestTetheringEventCallback tetherEventCallback = new TestTetheringEventCallback();
|
||||
TestTetheringEventCallback tetherEventCallback = null;
|
||||
final CtsTetheringUtils tetherUtils = new CtsTetheringUtils(mContext);
|
||||
try {
|
||||
mTm.registerTetheringEventCallback(c -> c.run() /* executor */, tetherEventCallback);
|
||||
tetherEventCallback = tetherUtils.registerTetheringEventCallback();
|
||||
// Adopt for NETWORK_SETTINGS permission.
|
||||
mUiAutomation.adoptShellPermissionIdentity();
|
||||
// start tethering
|
||||
tetherEventCallback.assumeWifiTetheringSupported(mContext);
|
||||
startWifiTethering(tetherEventCallback);
|
||||
tetherUtils.startWifiTethering(tetherEventCallback);
|
||||
// Update setting to verify the behavior.
|
||||
mCm.setAirplaneMode(true);
|
||||
ConnectivitySettingsManager.setPrivateDnsMode(mContext,
|
||||
|
|
@ -2267,8 +2262,10 @@ public class ConnectivityManagerTest {
|
|||
mCm.setAirplaneMode(false);
|
||||
ConnectivitySettingsManager.setNetworkAvoidBadWifi(mContext, curAvoidBadWifi);
|
||||
ConnectivitySettingsManager.setPrivateDnsMode(mContext, curPrivateDnsMode);
|
||||
mTm.unregisterTetheringEventCallback(tetherEventCallback);
|
||||
mTm.stopAllTethering();
|
||||
if (tetherEventCallback != null) {
|
||||
tetherUtils.unregisterTetheringEventCallback(tetherEventCallback);
|
||||
}
|
||||
tetherUtils.stopAllTethering();
|
||||
mUiAutomation.dropShellPermissionIdentity();
|
||||
}
|
||||
}
|
||||
|
|
@ -2315,19 +2312,6 @@ public class ConnectivityManagerTest {
|
|||
ConnectivitySettingsManager.getNetworkAvoidBadWifi(mContext));
|
||||
}
|
||||
|
||||
private void startWifiTethering(final TestTetheringEventCallback callback) throws Exception {
|
||||
if (!isWifiTetheringSupported(mContext, callback)) return;
|
||||
|
||||
final List<String> wifiRegexs =
|
||||
callback.getTetheringInterfaceRegexps().getTetherableWifiRegexs();
|
||||
final StartTetheringCallback startTetheringCallback = new StartTetheringCallback();
|
||||
final TetheringRequest request = new TetheringRequest.Builder(TETHERING_WIFI)
|
||||
.setShouldShowEntitlementUi(false).build();
|
||||
mTm.startTethering(request, c -> c.run() /* executor */, startTetheringCallback);
|
||||
startTetheringCallback.verifyTetheringStarted();
|
||||
callback.expectTetheredInterfacesChanged(wifiRegexs, TETHERING_WIFI);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify that per-app OEM network preference functions as expected for network preference TEST.
|
||||
* For specified apps, validate networks are prioritized in order: unmetered, TEST transport,
|
||||
|
|
|
|||
|
|
@ -440,12 +440,6 @@ public final class CtsTetheringUtils {
|
|||
return callback.getTetheringInterfaceRegexps().getTetherableWifiRegexs();
|
||||
}
|
||||
|
||||
public static boolean isWifiTetheringSupported(final Context ctx,
|
||||
final TestTetheringEventCallback callback) throws Exception {
|
||||
return !getWifiTetherableInterfaceRegexps(callback).isEmpty()
|
||||
&& isPortableHotspotSupported(ctx);
|
||||
}
|
||||
|
||||
/* Returns if wifi supports hotspot. */
|
||||
private static boolean isPortableHotspotSupported(final Context ctx) throws Exception {
|
||||
final PackageManager pm = ctx.getPackageManager();
|
||||
|
|
@ -522,4 +516,8 @@ public final class CtsTetheringUtils {
|
|||
callback.expectNoTetheringActive();
|
||||
callback.expectOneOfOffloadStatusChanged(TETHER_HARDWARE_OFFLOAD_STOPPED);
|
||||
}
|
||||
|
||||
public void stopAllTethering() {
|
||||
mTm.stopAllTethering();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,17 +49,16 @@ java_defaults {
|
|||
],
|
||||
}
|
||||
|
||||
android_test {
|
||||
name: "FrameworksNetTests",
|
||||
android_library {
|
||||
name: "FrameworksNetTestsLib",
|
||||
min_sdk_version: "30",
|
||||
defaults: [
|
||||
"framework-connectivity-test-defaults",
|
||||
"FrameworksNetTests-jni-defaults",
|
||||
],
|
||||
srcs: [
|
||||
"java/**/*.java",
|
||||
"java/**/*.kt",
|
||||
],
|
||||
test_suites: ["device-tests"],
|
||||
jarjar_rules: "jarjar-rules.txt",
|
||||
static_libs: [
|
||||
"androidx.test.rules",
|
||||
|
|
@ -83,7 +82,21 @@ android_test {
|
|||
"android.test.mock",
|
||||
"ServiceConnectivityResources",
|
||||
],
|
||||
visibility: ["//packages/modules/Connectivity/tests:__subpackages__"],
|
||||
}
|
||||
|
||||
android_test {
|
||||
name: "FrameworksNetTests",
|
||||
min_sdk_version: "30",
|
||||
defaults: [
|
||||
"framework-connectivity-test-defaults",
|
||||
"FrameworksNetTests-jni-defaults",
|
||||
],
|
||||
test_suites: ["device-tests"],
|
||||
static_libs: [
|
||||
"FrameworksNetTestsLib",
|
||||
],
|
||||
jni_libs: [
|
||||
"libservice-connectivity",
|
||||
],
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,11 +36,14 @@ import android.net.INetworkStatsSession;
|
|||
import android.net.NetworkStats.Entry;
|
||||
import android.net.NetworkStatsHistory;
|
||||
import android.net.NetworkTemplate;
|
||||
import android.os.Build;
|
||||
import android.os.RemoteException;
|
||||
|
||||
import androidx.test.InstrumentationRegistry;
|
||||
import androidx.test.filters.SmallTest;
|
||||
import androidx.test.runner.AndroidJUnit4;
|
||||
|
||||
import com.android.testutils.DevSdkIgnoreRule;
|
||||
import com.android.testutils.DevSdkIgnoreRunner;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
|
@ -49,8 +52,9 @@ import org.mockito.Mock;
|
|||
import org.mockito.MockitoAnnotations;
|
||||
import org.mockito.invocation.InvocationOnMock;
|
||||
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
@RunWith(DevSdkIgnoreRunner.class)
|
||||
@SmallTest
|
||||
@DevSdkIgnoreRule.IgnoreUpTo(Build.VERSION_CODES.R)
|
||||
public class NetworkStatsManagerTest {
|
||||
private static final String TEST_SUBSCRIBER_ID = "subid";
|
||||
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ import static org.junit.Assert.fail;
|
|||
import static org.mockito.ArgumentMatchers.anyBoolean;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.ArgumentMatchers.nullable;
|
||||
import static org.mockito.Mockito.CALLS_REAL_METHODS;
|
||||
import static org.mockito.Mockito.any;
|
||||
import static org.mockito.Mockito.anyInt;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
|
@ -67,7 +68,9 @@ import android.os.Messenger;
|
|||
import android.os.Process;
|
||||
|
||||
import androidx.test.filters.SmallTest;
|
||||
import androidx.test.runner.AndroidJUnit4;
|
||||
|
||||
import com.android.testutils.DevSdkIgnoreRule;
|
||||
import com.android.testutils.DevSdkIgnoreRunner;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
|
@ -76,8 +79,9 @@ import org.mockito.ArgumentCaptor;
|
|||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
@RunWith(DevSdkIgnoreRunner.class)
|
||||
@SmallTest
|
||||
@DevSdkIgnoreRule.IgnoreUpTo(VERSION_CODES.R)
|
||||
public class ConnectivityManagerTest {
|
||||
|
||||
@Mock Context mCtx;
|
||||
|
|
@ -215,7 +219,8 @@ public class ConnectivityManagerTest {
|
|||
public void testCallbackRelease() throws Exception {
|
||||
ConnectivityManager manager = new ConnectivityManager(mCtx, mService);
|
||||
NetworkRequest request = makeRequest(1);
|
||||
NetworkCallback callback = mock(ConnectivityManager.NetworkCallback.class);
|
||||
NetworkCallback callback = mock(ConnectivityManager.NetworkCallback.class,
|
||||
CALLS_REAL_METHODS);
|
||||
Handler handler = new Handler(Looper.getMainLooper());
|
||||
ArgumentCaptor<Messenger> captor = ArgumentCaptor.forClass(Messenger.class);
|
||||
|
||||
|
|
@ -243,7 +248,8 @@ public class ConnectivityManagerTest {
|
|||
ConnectivityManager manager = new ConnectivityManager(mCtx, mService);
|
||||
NetworkRequest req1 = makeRequest(1);
|
||||
NetworkRequest req2 = makeRequest(2);
|
||||
NetworkCallback callback = mock(ConnectivityManager.NetworkCallback.class);
|
||||
NetworkCallback callback = mock(ConnectivityManager.NetworkCallback.class,
|
||||
CALLS_REAL_METHODS);
|
||||
Handler handler = new Handler(Looper.getMainLooper());
|
||||
ArgumentCaptor<Messenger> captor = ArgumentCaptor.forClass(Messenger.class);
|
||||
|
||||
|
|
|
|||
|
|
@ -23,14 +23,16 @@ import static org.junit.Assert.assertNull;
|
|||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import android.os.Build;
|
||||
import android.test.mock.MockContext;
|
||||
|
||||
import androidx.test.filters.SmallTest;
|
||||
import androidx.test.runner.AndroidJUnit4;
|
||||
|
||||
import com.android.internal.net.VpnProfile;
|
||||
import com.android.internal.org.bouncycastle.x509.X509V1CertificateGenerator;
|
||||
import com.android.net.module.util.ProxyUtils;
|
||||
import com.android.testutils.DevSdkIgnoreRule;
|
||||
import com.android.testutils.DevSdkIgnoreRunner;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
|
@ -51,7 +53,8 @@ import javax.security.auth.x500.X500Principal;
|
|||
|
||||
/** Unit tests for {@link Ikev2VpnProfile.Builder}. */
|
||||
@SmallTest
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
@RunWith(DevSdkIgnoreRunner.class)
|
||||
@DevSdkIgnoreRule.IgnoreUpTo(Build.VERSION_CODES.R)
|
||||
public class Ikev2VpnProfileTest {
|
||||
private static final String SERVER_ADDR_STRING = "1.2.3.4";
|
||||
private static final String IDENTITY_STRING = "Identity";
|
||||
|
|
|
|||
|
|
@ -36,10 +36,13 @@ import android.net.ipmemorystore.NetworkAttributes;
|
|||
import android.net.ipmemorystore.NetworkAttributesParcelable;
|
||||
import android.net.ipmemorystore.Status;
|
||||
import android.net.networkstack.ModuleNetworkStackClient;
|
||||
import android.os.Build;
|
||||
import android.os.RemoteException;
|
||||
|
||||
import androidx.test.filters.SmallTest;
|
||||
import androidx.test.runner.AndroidJUnit4;
|
||||
|
||||
import com.android.testutils.DevSdkIgnoreRule;
|
||||
import com.android.testutils.DevSdkIgnoreRunner;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
|
@ -53,8 +56,9 @@ import org.mockito.MockitoAnnotations;
|
|||
import java.net.UnknownHostException;
|
||||
import java.util.Arrays;
|
||||
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
@RunWith(DevSdkIgnoreRunner.class)
|
||||
@SmallTest
|
||||
@DevSdkIgnoreRule.IgnoreUpTo(Build.VERSION_CODES.R)
|
||||
public class IpMemoryStoreTest {
|
||||
private static final String TAG = IpMemoryStoreTest.class.getSimpleName();
|
||||
private static final String TEST_CLIENT_ID = "testClientId";
|
||||
|
|
|
|||
|
|
@ -29,9 +29,10 @@ import android.os.Build;
|
|||
import android.os.Parcel;
|
||||
|
||||
import androidx.test.filters.SmallTest;
|
||||
import androidx.test.runner.AndroidJUnit4;
|
||||
|
||||
import com.android.internal.util.CollectionUtils;
|
||||
import com.android.testutils.DevSdkIgnoreRule;
|
||||
import com.android.testutils.DevSdkIgnoreRunner;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
|
@ -45,7 +46,8 @@ import java.util.Set;
|
|||
|
||||
/** Unit tests for {@link IpSecAlgorithm}. */
|
||||
@SmallTest
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
@RunWith(DevSdkIgnoreRunner.class)
|
||||
@DevSdkIgnoreRule.IgnoreUpTo(Build.VERSION_CODES.R)
|
||||
public class IpSecAlgorithmTest {
|
||||
private static final byte[] KEY_MATERIAL;
|
||||
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue