Merge "Use new test utilities from frameworks/libs/net"
diff --git a/tests/cts/hostside/Android.bp b/tests/cts/hostside/Android.bp
index 741c961..47b114b 100644
--- a/tests/cts/hostside/Android.bp
+++ b/tests/cts/hostside/Android.bp
@@ -24,7 +24,6 @@
// Tag this module as a cts test artifact
test_suites: [
"cts",
- "vts10",
"general-tests",
],
}
diff --git a/tests/cts/hostside/app/Android.bp b/tests/cts/hostside/app/Android.bp
index e129be7..9903756 100644
--- a/tests/cts/hostside/app/Android.bp
+++ b/tests/cts/hostside/app/Android.bp
@@ -35,7 +35,6 @@
// Tag this module as a cts test artifact
test_suites: [
"cts",
- "vts10",
"general-tests",
],
}
diff --git a/tests/cts/hostside/app2/Android.bp b/tests/cts/hostside/app2/Android.bp
index a6e9b11..8e27931 100644
--- a/tests/cts/hostside/app2/Android.bp
+++ b/tests/cts/hostside/app2/Android.bp
@@ -23,7 +23,6 @@
// Tag this module as a cts test artifact
test_suites: [
"cts",
- "vts10",
"general-tests",
],
certificate: ":cts-net-app",
diff --git a/tests/cts/net/Android.bp b/tests/cts/net/Android.bp
index 4c00428..913380a 100644
--- a/tests/cts/net/Android.bp
+++ b/tests/cts/net/Android.bp
@@ -66,7 +66,6 @@
defaults: ["CtsNetTestCasesDefaults"],
test_suites: [
"cts",
- "vts10",
"general-tests",
],
test_config_template: "AndroidTestTemplate.xml",
diff --git a/tests/cts/net/TEST_MAPPING b/tests/cts/net/TEST_MAPPING
index 3162e22..9167c98 100644
--- a/tests/cts/net/TEST_MAPPING
+++ b/tests/cts/net/TEST_MAPPING
@@ -1,6 +1,6 @@
{
// TODO: move to mainline-presubmit once supported
- "postsubmit": [
+ "presubmit": [
{
"name": "CtsNetTestCasesLatestSdk",
"options": [
diff --git a/tests/cts/net/api23Test/Android.bp b/tests/cts/net/api23Test/Android.bp
index 0ce9826..e43a5e8 100644
--- a/tests/cts/net/api23Test/Android.bp
+++ b/tests/cts/net/api23Test/Android.bp
@@ -45,7 +45,6 @@
// Tag this module as a cts test artifact
test_suites: [
"cts",
- "vts10",
"general-tests",
],
diff --git a/tests/cts/net/appForApi23/Android.bp b/tests/cts/net/appForApi23/Android.bp
index 399c199..cec6d7f 100644
--- a/tests/cts/net/appForApi23/Android.bp
+++ b/tests/cts/net/appForApi23/Android.bp
@@ -26,7 +26,6 @@
// Tag this module as a cts test artifact
test_suites: [
"cts",
- "vts10",
"general-tests",
],
diff --git a/tests/cts/net/native/qtaguid/Android.bp b/tests/cts/net/native/qtaguid/Android.bp
index 23a0cf7..7c6e19f 100644
--- a/tests/cts/net/native/qtaguid/Android.bp
+++ b/tests/cts/net/native/qtaguid/Android.bp
@@ -42,7 +42,6 @@
// Tag this module as a cts test artifact
test_suites: [
"cts",
- "vts10",
],
cflags: [
diff --git a/tests/cts/net/src/android/net/cts/ConnectivityManagerTest.java b/tests/cts/net/src/android/net/cts/ConnectivityManagerTest.java
index 70b1bbe..db4e3e7 100644
--- a/tests/cts/net/src/android/net/cts/ConnectivityManagerTest.java
+++ b/tests/cts/net/src/android/net/cts/ConnectivityManagerTest.java
@@ -17,6 +17,7 @@
package android.net.cts;
import static android.Manifest.permission.CONNECTIVITY_USE_RESTRICTED_NETWORKS;
+import static android.Manifest.permission.NETWORK_SETTINGS;
import static android.content.pm.PackageManager.FEATURE_ETHERNET;
import static android.content.pm.PackageManager.FEATURE_TELEPHONY;
import static android.content.pm.PackageManager.FEATURE_USB_HOST;
@@ -41,6 +42,7 @@
import static com.android.compatibility.common.util.SystemUtil.runShellCommand;
import static com.android.compatibility.common.util.SystemUtil.runWithShellPermissionIdentity;
+import static com.android.testutils.TestPermissionUtil.runAsShell;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -103,6 +105,8 @@
import libcore.io.Streams;
+import junit.framework.AssertionFailedError;
+
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -118,6 +122,7 @@
import java.net.Inet6Address;
import java.net.InetAddress;
import java.net.InetSocketAddress;
+import java.net.MalformedURLException;
import java.net.Socket;
import java.net.URL;
import java.net.UnknownHostException;
@@ -219,6 +224,16 @@
if (mCtsNetUtils.cellConnectAttempted()) {
mCtsNetUtils.disconnectFromCell();
}
+
+ // All tests in this class require a working Internet connection as they start. Make
+ // sure there is still one as they end that's ready to use for the next test to use.
+ final TestNetworkCallback callback = new TestNetworkCallback();
+ mCm.registerDefaultNetworkCallback(callback);
+ try {
+ assertNotNull("Couldn't restore Internet connectivity", callback.waitForAvailable());
+ } finally {
+ mCm.unregisterNetworkCallback(callback);
+ }
}
/**
@@ -1499,4 +1514,17 @@
return runShellCommand("cmd connectivity airplane-mode")
.trim().equals("enabled");
}
+
+ @Test
+ public void testGetCaptivePortalServerUrl() {
+ final String url = runAsShell(NETWORK_SETTINGS, mCm::getCaptivePortalServerUrl);
+ assertNotNull("getCaptivePortalServerUrl must not be null", url);
+ try {
+ final URL parsedUrl = new URL(url);
+ // As per the javadoc, the URL must be HTTP
+ assertEquals("Invalid captive portal URL protocol", "http", parsedUrl.getProtocol());
+ } catch (MalformedURLException e) {
+ throw new AssertionFailedError("Captive portal server URL is invalid: " + e);
+ }
+ }
}
diff --git a/tests/cts/tethering/src/android/tethering/cts/TetheringManagerTest.java b/tests/cts/tethering/src/android/tethering/cts/TetheringManagerTest.java
index 65a8c7c..92dca39 100644
--- a/tests/cts/tethering/src/android/tethering/cts/TetheringManagerTest.java
+++ b/tests/cts/tethering/src/android/tethering/cts/TetheringManagerTest.java
@@ -757,7 +757,7 @@
if (!isWifiTetheringSupported(tetherEventCallback)) return;
if (previousWifiEnabledState) {
- mCtsNetUtils.disconnectFromWifi(null);
+ mCtsNetUtils.ensureWifiDisconnected(null);
}
final TestNetworkCallback networkCallback = new TestNetworkCallback();