CtsNetTestCases: Add wifi feature check in new tests
Bug: 150236894
Test: atest android.net.wifi.cts
Change-Id: Ifb0980576379a8d59637a8411c61ab4b7db60af7
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 98f3d44..c836af5 100644
--- a/tests/cts/net/src/android/net/wifi/cts/WifiManagerTest.java
+++ b/tests/cts/net/src/android/net/wifi/cts/WifiManagerTest.java
@@ -1160,6 +1160,10 @@
* network.
*/
public void testConnectWithNetworkId() throws Exception {
+ if (!WifiFeature.isWifiSupported(getContext())) {
+ // skip the test if WiFi is not supported
+ return;
+ }
testConnect(true);
}
@@ -1168,6 +1172,10 @@
* existing saved network.
*/
public void testConnectWithWifiConfiguration() throws Exception {
+ if (!WifiFeature.isWifiSupported(getContext())) {
+ // skip the test if WiFi is not supported
+ return;
+ }
testConnect(false);
}
@@ -1217,6 +1225,10 @@
* an existing saved network metered.
*/
public void testSave() throws Exception {
+ if (!WifiFeature.isWifiSupported(getContext())) {
+ // skip the test if WiFi is not supported
+ return;
+ }
TestActionListener actionListener = new TestActionListener(mLock);
UiAutomation uiAutomation = InstrumentationRegistry.getInstrumentation().getUiAutomation();
List<WifiConfiguration> savedNetworks = null;
@@ -1270,6 +1282,10 @@
* network.
*/
public void testForget() throws Exception {
+ if (!WifiFeature.isWifiSupported(getContext())) {
+ // skip the test if WiFi is not supported
+ return;
+ }
TestActionListener actionListener = new TestActionListener(mLock);
UiAutomation uiAutomation = InstrumentationRegistry.getInstrumentation().getUiAutomation();
int newNetworkId = INVALID_NETWORK_ID;
@@ -1351,6 +1367,10 @@
* WifiManager.TrafficStateCallback)} by sending some traffic.
*/
public void testTrafficStateCallback() throws Exception {
+ if (!WifiFeature.isWifiSupported(getContext())) {
+ // skip the test if WiFi is not supported
+ return;
+ }
TestTrafficStateCallback trafficStateCallback = new TestTrafficStateCallback(mLock);
UiAutomation uiAutomation = InstrumentationRegistry.getInstrumentation().getUiAutomation();
try {
@@ -1387,6 +1407,10 @@
* {@link WifiManager#isScanAlwaysAvailable()}.
*/
public void testScanAlwaysAvailable() throws Exception {
+ if (!WifiFeature.isWifiSupported(getContext())) {
+ // skip the test if WiFi is not supported
+ return;
+ }
UiAutomation uiAutomation = InstrumentationRegistry.getInstrumentation().getUiAutomation();
Boolean currState = null;
try {
@@ -1410,6 +1434,10 @@
* {@link WifiManager#isScanThrottleEnabled()}.
*/
public void testScanThrottleEnabled() throws Exception {
+ if (!WifiFeature.isWifiSupported(getContext())) {
+ // skip the test if WiFi is not supported
+ return;
+ }
UiAutomation uiAutomation = InstrumentationRegistry.getInstrumentation().getUiAutomation();
Boolean currState = null;
try {
@@ -1433,6 +1461,10 @@
* {@link WifiManager#isAutoWakeupEnabled()}.
*/
public void testAutoWakeUpEnabled() throws Exception {
+ if (!WifiFeature.isWifiSupported(getContext())) {
+ // skip the test if WiFi is not supported
+ return;
+ }
UiAutomation uiAutomation = InstrumentationRegistry.getInstrumentation().getUiAutomation();
Boolean currState = null;
try {
@@ -1456,6 +1488,10 @@
* {@link WifiManager#isVerboseLoggingEnabled()}.
*/
public void testVerboseLoggingEnabled() throws Exception {
+ if (!WifiFeature.isWifiSupported(getContext())) {
+ // skip the test if WiFi is not supported
+ return;
+ }
UiAutomation uiAutomation = InstrumentationRegistry.getInstrumentation().getUiAutomation();
Boolean currState = null;
try {
@@ -1482,6 +1518,10 @@
* configuration, suggestions, etc which will also have been lost on factory reset.
*/
public void testFactoryReset() throws Exception {
+ if (!WifiFeature.isWifiSupported(getContext())) {
+ // skip the test if WiFi is not supported
+ return;
+ }
UiAutomation uiAutomation = InstrumentationRegistry.getInstrumentation().getUiAutomation();
List<WifiConfiguration> savedNetworks = null;
try {
diff --git a/tests/cts/net/src/android/net/wifi/cts/WifiMigrationTest.java b/tests/cts/net/src/android/net/wifi/cts/WifiMigrationTest.java
index eb0fc96..6e19a21 100644
--- a/tests/cts/net/src/android/net/wifi/cts/WifiMigrationTest.java
+++ b/tests/cts/net/src/android/net/wifi/cts/WifiMigrationTest.java
@@ -52,6 +52,10 @@
* Tests {@link android.net.wifi.WifiMigration.ConfigStoreMigrationData} class.
*/
public void testWifiMigrationConfigStoreDataBuilder() throws Exception {
+ if (!WifiFeature.isWifiSupported(getContext())) {
+ // skip the test if WiFi is not supported
+ return;
+ }
WifiConfiguration savedNetwork1 = new WifiConfiguration();
savedNetwork1.SSID = "\"test1\"";
WifiConfiguration savedNetwork2 = new WifiConfiguration();
@@ -83,6 +87,10 @@
* Tests {@link android.net.wifi.WifiMigration.ConfigStoreMigrationData} class.
*/
public void testWifiMigrationSettingsDataBuilder() throws Exception {
+ if (!WifiFeature.isWifiSupported(getContext())) {
+ // skip the test if WiFi is not supported
+ return;
+ }
WifiMigration.SettingsMigrationData migrationData =
new WifiMigration.SettingsMigrationData.Builder()
.setScanAlwaysAvailable(true)