From e4bbd1043145248dcf582d94391614b1765adb8e Mon Sep 17 00:00:00 2001 From: Huihong Luo Date: Mon, 1 May 2017 14:59:28 -0700 Subject: [PATCH] cts: skip wifi related tests if wifi is unsupported Such as in the case of Android emulator. BUG: 37633976 Test: ANDROID_BUILD_TOP= ./android-cts/tools/cts-tradefed run cts -m CtsNetTestCases Change-Id: Id4ee7b216ea12ad9599953b439c91db96d38b374 --- .../android/net/cts/ConnectivityManagerTest.java | 16 ++++++++++++++++ .../android/net/wifi/cts/WifiManagerTest.java | 12 ++++++++++++ 2 files changed, 28 insertions(+) diff --git a/tests/cts/net/src/android/net/cts/ConnectivityManagerTest.java b/tests/cts/net/src/android/net/cts/ConnectivityManagerTest.java index b951378139..cd6dbb2441 100644 --- a/tests/cts/net/src/android/net/cts/ConnectivityManagerTest.java +++ b/tests/cts/net/src/android/net/cts/ConnectivityManagerTest.java @@ -789,24 +789,40 @@ public class ConnectivityManagerTest extends AndroidTestCase { /** Verify that accept_ra_rt_info_min_plen exists and is set to the expected value */ public void testAcceptRaRtInfoMinPlen() throws Exception { + if (!mPackageManager.hasSystemFeature(PackageManager.FEATURE_WIFI)) { + Log.i(TAG, "testConnectivityChanged_manifestRequestOnlyPreN_shouldReceiveIntent cannot execute unless device supports WiFi"); + return; + } Scanner s = makeWifiSysctlScanner("accept_ra_rt_info_min_plen"); assertEquals(IPV6_WIFI_ACCEPT_RA_RT_INFO_MIN_PLEN, s.nextInt()); } /** Verify that accept_ra_rt_info_max_plen exists and is set to the expected value */ public void testAcceptRaRtInfoMaxPlen() throws Exception { + if (!mPackageManager.hasSystemFeature(PackageManager.FEATURE_WIFI)) { + Log.i(TAG, "testConnectivityChanged_manifestRequestOnlyPreN_shouldReceiveIntent cannot execute unless device supports WiFi"); + return; + } Scanner s = makeWifiSysctlScanner("accept_ra_rt_info_max_plen"); assertEquals(IPV6_WIFI_ACCEPT_RA_RT_INFO_MAX_PLEN, s.nextInt()); } /** Verify that router_solicitations exists and is set to the expected value */ public void testRouterSolicitations() throws Exception { + if (!mPackageManager.hasSystemFeature(PackageManager.FEATURE_WIFI)) { + Log.i(TAG, "testConnectivityChanged_manifestRequestOnlyPreN_shouldReceiveIntent cannot execute unless device supports WiFi"); + return; + } Scanner s = makeWifiSysctlScanner("router_solicitations"); assertEquals(IPV6_WIFI_ROUTER_SOLICITATIONS, s.nextInt()); } /** Verify that router_solicitation_max_interval exists and is in an acceptable interval */ public void testRouterSolicitationMaxInterval() throws Exception { + if (!mPackageManager.hasSystemFeature(PackageManager.FEATURE_WIFI)) { + Log.i(TAG, "testConnectivityChanged_manifestRequestOnlyPreN_shouldReceiveIntent cannot execute unless device supports WiFi"); + return; + } Scanner s = makeWifiSysctlScanner("router_solicitation_max_interval"); int interval = s.nextInt(); // Verify we're in the interval [15 minutes, 60 minutes]. Lower values may adversely diff --git a/tests/cts/net/src/android/net/wifi/cts/WifiManagerTest.java b/tests/cts/net/src/android/net/wifi/cts/WifiManagerTest.java index 33c184a317..e065378fab 100644 --- a/tests/cts/net/src/android/net/wifi/cts/WifiManagerTest.java +++ b/tests/cts/net/src/android/net/wifi/cts/WifiManagerTest.java @@ -563,6 +563,10 @@ public class WifiManagerTest extends AndroidTestCase { * @throws Exception */ public void testAddPasspointConfigWithUserCredential() throws Exception { + if (!WifiFeature.isWifiSupported(getContext())) { + // skip the test if WiFi is not supported + return; + } testAddPasspointConfig(generatePasspointConfig(generateUserCredential())); } @@ -573,6 +577,10 @@ public class WifiManagerTest extends AndroidTestCase { * @throws Exception */ public void testAddPasspointConfigWithCertCredential() throws Exception { + if (!WifiFeature.isWifiSupported(getContext())) { + // skip the test if WiFi is not supported + return; + } testAddPasspointConfig(generatePasspointConfig(generateCertCredential())); } @@ -583,6 +591,10 @@ public class WifiManagerTest extends AndroidTestCase { * @throws Exception */ public void testAddPasspointConfigWithSimCredential() throws Exception { + if (!WifiFeature.isWifiSupported(getContext())) { + // skip the test if WiFi is not supported + return; + } testAddPasspointConfig(generatePasspointConfig(generateSimCredential())); }