am e54f4889: am bb1ababe: am 0c292bb1: Data call establish time is related to network condition which can’t be controlled by the device. Extend the time limitation to 30 seconds to cover most of the cases.
* commit 'e54f4889f65df9955e22a8adbbb8c1527220103e':
Data call establish time is related to network condition which can’t be controlled by the device. Extend the time limitation to 30 seconds to cover most of the cases.
diff --git a/tests/cts/net/src/android/net/cts/ConnectivityManagerTest.java b/tests/cts/net/src/android/net/cts/ConnectivityManagerTest.java
index 5877812..cd80be2 100644
--- a/tests/cts/net/src/android/net/cts/ConnectivityManagerTest.java
+++ b/tests/cts/net/src/android/net/cts/ConnectivityManagerTest.java
@@ -35,6 +35,8 @@
import android.test.AndroidTestCase;
import android.util.Log;
+import java.util.HashSet;
+import java.util.Set;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
@@ -170,12 +172,20 @@
args = {int.class, int.class}
)
public void testRequestRouteToHost() {
+ Set<Integer> exceptionFreeTypes = new HashSet<Integer>();
+ exceptionFreeTypes.add(ConnectivityManager.TYPE_BLUETOOTH);
+ exceptionFreeTypes.add(ConnectivityManager.TYPE_ETHERNET);
+ exceptionFreeTypes.add(ConnectivityManager.TYPE_MOBILE);
+ exceptionFreeTypes.add(ConnectivityManager.TYPE_MOBILE_DUN);
+ exceptionFreeTypes.add(ConnectivityManager.TYPE_MOBILE_HIPRI);
+ exceptionFreeTypes.add(ConnectivityManager.TYPE_MOBILE_MMS);
+ exceptionFreeTypes.add(ConnectivityManager.TYPE_MOBILE_SUPL);
NetworkInfo[] ni = mCm.getAllNetworkInfo();
for (NetworkInfo n : ni) {
- // make sure network is up (except WIFI due to always fail)
- if (n.isConnected() && (n.getType() != TYPE_WIFI)) {
- assertTrue(mCm.requestRouteToHost(n.getType(), HOST_ADDRESS));
+ if (n.isConnected() && exceptionFreeTypes.contains(n.getType())) {
+ assertTrue("Network type: " + n.getType(), mCm.requestRouteToHost(n.getType(),
+ HOST_ADDRESS));
}
}
diff --git a/tests/cts/net/src/android/net/cts/NetworkInfo_DetailedStateTest.java b/tests/cts/net/src/android/net/cts/NetworkInfo_DetailedStateTest.java
index 196e102..6b9b985 100644
--- a/tests/cts/net/src/android/net/cts/NetworkInfo_DetailedStateTest.java
+++ b/tests/cts/net/src/android/net/cts/NetworkInfo_DetailedStateTest.java
@@ -16,12 +16,13 @@
package android.net.cts;
-import android.net.NetworkInfo.DetailedState;
-import android.test.AndroidTestCase;
import dalvik.annotation.TestLevel;
import dalvik.annotation.TestTargetClass;
import dalvik.annotation.TestTargetNew;
+import android.net.NetworkInfo.DetailedState;
+import android.test.AndroidTestCase;
+
@TestTargetClass(DetailedState.class)
public class NetworkInfo_DetailedStateTest extends AndroidTestCase {
@@ -52,7 +53,7 @@
)
public void testValues() {
DetailedState[] expected = DetailedState.values();
- assertEquals(10, expected.length);
+ assertEquals(11, expected.length);
assertEquals(DetailedState.IDLE, expected[0]);
assertEquals(DetailedState.SCANNING, expected[1]);
assertEquals(DetailedState.CONNECTING, expected[2]);
@@ -63,6 +64,7 @@
assertEquals(DetailedState.DISCONNECTING, expected[7]);
assertEquals(DetailedState.DISCONNECTED, expected[8]);
assertEquals(DetailedState.FAILED, expected[9]);
+ assertEquals(DetailedState.BLOCKED, expected[10]);
}
}
diff --git a/tests/cts/net/src/android/net/http/cts/SslErrorTest.java b/tests/cts/net/src/android/net/http/cts/SslErrorTest.java
new file mode 100755
index 0000000..d186f0e
--- /dev/null
+++ b/tests/cts/net/src/android/net/http/cts/SslErrorTest.java
@@ -0,0 +1,124 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+package android.net.http.cts;
+
+import android.net.http.SslCertificate;
+import android.net.http.SslError;
+
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTargetNew;
+import dalvik.annotation.TestTargetClass;
+
+import java.util.Date;
+
+import junit.framework.TestCase;
+
+@TestTargetClass(SslError.class)
+public class SslErrorTest extends TestCase {
+ private SslCertificate mCertificate;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ mCertificate = new SslCertificate("foo", "bar", new Date(42), new Date(43));
+ }
+
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ method = "hasError",
+ args = {int.class}
+ )
+ public void testHasError() {
+ SslError error = new SslError(SslError.SSL_EXPIRED, mCertificate);
+ assertTrue(error.hasError(SslError.SSL_EXPIRED));
+ assertFalse(error.hasError(SslError.SSL_UNTRUSTED));
+ }
+
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ method = "addError",
+ args = {int.class}
+ )
+ public void testAddError() {
+ SslError error = new SslError(SslError.SSL_EXPIRED, mCertificate);
+ assertFalse(error.hasError(SslError.SSL_UNTRUSTED));
+ error.addError(SslError.SSL_UNTRUSTED);
+ assertTrue(error.hasError(SslError.SSL_UNTRUSTED));
+ }
+
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ method = "addError",
+ args = {int.class}
+ )
+ public void testAddErrorIgnoresInvalidValues() {
+ SslError error = new SslError(SslError.SSL_EXPIRED, mCertificate);
+ error.addError(42);
+ assertFalse(error.hasError(42));
+ }
+
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ method = "SslError",
+ args = {int.class, SslCertificate.class}
+ )
+ public void testConstructorIgnoresInvalidValues() {
+ SslError error = new SslError(42, mCertificate);
+ assertFalse(error.hasError(42));
+ }
+
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ method = "getPrimaryError",
+ args = {}
+ )
+ public void testGetPrimaryError() {
+ SslError error = new SslError(SslError.SSL_EXPIRED, mCertificate);
+ error.addError(SslError.SSL_UNTRUSTED);
+ assertEquals(error.getPrimaryError(), SslError.SSL_UNTRUSTED);
+ }
+
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ method = "getPrimaryError",
+ args = {}
+ )
+ public void testGetPrimaryErrorWithEmptySet() {
+ SslError error = new SslError(42, mCertificate);
+ assertEquals(error.getPrimaryError(), -1);
+ }
+
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ method = "getUrl",
+ args = {}
+ )
+ public void testGetUrl() {
+ SslError error = new SslError(SslError.SSL_EXPIRED, mCertificate, "foo");
+ assertEquals(error.getUrl(), "foo");
+ }
+
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ method = "getUrl",
+ args = {}
+ )
+ public void testGetUrlWithDeprecatedConstructor() {
+ SslError error = new SslError(SslError.SSL_EXPIRED, mCertificate);
+ assertEquals(error.getUrl(), "");
+ }
+}