From bd7f2904d9ca25a22915eb7394bce502bdc3dbf2 Mon Sep 17 00:00:00 2001 From: Bjoern Johansson Date: Thu, 17 Aug 2017 17:04:13 -0700 Subject: [PATCH] Skip WifiManager tests if WiFi is not supported Some of the WifiManager tests assumed that WiFi is always supported. This is not true for all devices, for example the Android emulator, and is not a requirement in the CDD. BUG: 37633976 Test: Successfully ran 'run cts -m CtsNetTestCases' Change-Id: Ia6d62e8d2b6e0b0c2ef2fafd50529e722e4419e4 --- .../android/net/wifi/cts/WifiManagerTest.java | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) 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 ea63f787cf..754336af98 100644 --- a/tests/cts/net/src/android/net/wifi/cts/WifiManagerTest.java +++ b/tests/cts/net/src/android/net/wifi/cts/WifiManagerTest.java @@ -801,7 +801,11 @@ public class WifiManagerTest extends AndroidTestCase { * Note: Location mode must be enabled for this test. */ public void testStartLocalOnlyHotspotSuccess() { - // first check that softap mode is supported by the device + if (!WifiFeature.isWifiSupported(getContext())) { + // skip the test if WiFi is not supported + return; + } + // check that softap mode is supported by the device if (!mWifiManager.isPortableHotspotSupported()) { return; } @@ -826,7 +830,11 @@ public class WifiManagerTest extends AndroidTestCase { * Note: Location mode must be enabled for this test. */ public void testSetWifiEnabledByAppDoesNotStopHotspot() { - // first check that softap mode is supported by the device + if (!WifiFeature.isWifiSupported(getContext())) { + // skip the test if WiFi is not supported + return; + } + // check that softap mode is supported by the device if (!mWifiManager.isPortableHotspotSupported()) { return; } @@ -850,7 +858,11 @@ public class WifiManagerTest extends AndroidTestCase { * Note: Location mode must be enabled for this test. */ public void testStartLocalOnlyHotspotSingleRequestByApps() { - // first check that softap mode is supported by the device + if (!WifiFeature.isWifiSupported(getContext())) { + // skip the test if WiFi is not supported + return; + } + // check that softap mode is supported by the device if (!mWifiManager.isPortableHotspotSupported()) { return; }