summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDavid Su <dysu@google.com>2019-11-29 03:27:22 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2019-11-29 03:27:22 +0000
commite82b8608ecb4aef36457c3312de181a94e82256f (patch)
treedd65b2f28438bc182ac6d340bdc54af4db62f3bb /tests
parentc3aa2712ce17a826335ba38577b37206e699f0cf (diff)
parenta2949725ba019f99b0b18f7c75ec49ae83af44ba (diff)
Merge "Rename WifiScanner scan types, clean up hidden network"
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/ScanRequestProxyTest.java39
-rw-r--r--tests/wifitests/src/com/android/server/wifi/ScanTestUtil.java10
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WakeupControllerTest.java2
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiNetworkFactoryTest.java9
-rw-r--r--tests/wifitests/src/com/android/server/wifi/scanner/BackgroundScanSchedulerTest.java8
-rw-r--r--tests/wifitests/src/com/android/server/wifi/scanner/WifiScanningServiceTest.java31
6 files changed, 50 insertions, 49 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/ScanRequestProxyTest.java b/tests/wifitests/src/com/android/server/wifi/ScanRequestProxyTest.java
index 0e5cbd592..465fe2046 100644
--- a/tests/wifitests/src/com/android/server/wifi/ScanRequestProxyTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/ScanRequestProxyTest.java
@@ -33,6 +33,7 @@ import android.net.wifi.IScanResultsCallback;
import android.net.wifi.ScanResult;
import android.net.wifi.WifiManager;
import android.net.wifi.WifiScanner;
+import android.net.wifi.WifiScanner.ScanSettings.HiddenNetwork;
import android.os.Handler;
import android.os.IBinder;
import android.os.UserHandle;
@@ -53,6 +54,7 @@ import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
/**
@@ -63,16 +65,16 @@ public class ScanRequestProxyTest extends WifiBaseTest {
private static final int TEST_UID = 5;
private static final String TEST_PACKAGE_NAME_1 = "com.test.1";
private static final String TEST_PACKAGE_NAME_2 = "com.test.2";
- private static final List<WifiScanner.ScanSettings.HiddenNetwork> TEST_HIDDEN_NETWORKS_LIST =
- new ArrayList<WifiScanner.ScanSettings.HiddenNetwork>() {{
- add(new WifiScanner.ScanSettings.HiddenNetwork("test_ssid_1"));
- add(new WifiScanner.ScanSettings.HiddenNetwork("test_ssid_2"));
+ private static final List<HiddenNetwork> TEST_HIDDEN_NETWORKS_LIST =
+ new ArrayList<HiddenNetwork>() {{
+ add(new HiddenNetwork("test_ssid_1"));
+ add(new HiddenNetwork("test_ssid_2"));
}};
- private static final List<WifiScanner.ScanSettings.HiddenNetwork> TEST_HIDDEN_NETWORKS_LIST_NS =
- new ArrayList<WifiScanner.ScanSettings.HiddenNetwork>() {{
- add(new WifiScanner.ScanSettings.HiddenNetwork("test_ssid_3"));
- add(new WifiScanner.ScanSettings.HiddenNetwork("test_ssid_4"));
+ private static final List<HiddenNetwork> TEST_HIDDEN_NETWORKS_LIST_NS =
+ new ArrayList<HiddenNetwork>() {{
+ add(new HiddenNetwork("test_ssid_3"));
+ add(new HiddenNetwork("test_ssid_4"));
}};
@Mock private Context mContext;
@@ -876,31 +878,30 @@ public class ScanRequestProxyTest extends WifiBaseTest {
assertNotNull(scanSettings);
assertEquals(WifiScanner.WIFI_BAND_BOTH_WITH_DFS, scanSettings.band);
if (expectHighAccuracyType) {
- assertEquals(WifiScanner.TYPE_HIGH_ACCURACY, scanSettings.type);
+ assertEquals(WifiScanner.SCAN_TYPE_HIGH_ACCURACY, scanSettings.type);
} else {
- assertEquals(WifiScanner.TYPE_LOW_LATENCY, scanSettings.type);
+ assertEquals(WifiScanner.SCAN_TYPE_LOW_LATENCY, scanSettings.type);
}
assertEquals(WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN
| WifiScanner.REPORT_EVENT_FULL_SCAN_RESULT, scanSettings.reportEvents);
- List<WifiScanner.ScanSettings.HiddenNetwork> hiddenNetworkList =
+ List<HiddenNetwork> hiddenNetworkList =
new ArrayList<>();
hiddenNetworkList.addAll(TEST_HIDDEN_NETWORKS_LIST);
hiddenNetworkList.addAll(TEST_HIDDEN_NETWORKS_LIST_NS);
if (expectHiddenNetworks) {
- assertNotNull(scanSettings.hiddenNetworks);
- assertEquals(hiddenNetworkList.size(), scanSettings.hiddenNetworks.length);
- for (int i = 0; i < scanSettings.hiddenNetworks.length; i++) {
- validateHiddenNetworkInList(scanSettings.hiddenNetworks[i], hiddenNetworkList);
+ assertEquals(hiddenNetworkList.size(), scanSettings.hiddenNetworks.size());
+ for (HiddenNetwork hiddenNetwork : scanSettings.hiddenNetworks) {
+ validateHiddenNetworkInList(hiddenNetwork, hiddenNetworkList);
}
} else {
- assertNull(scanSettings.hiddenNetworks);
+ assertEquals(Collections.emptyList(), scanSettings.hiddenNetworks);
}
}
private void validateHiddenNetworkInList(
- WifiScanner.ScanSettings.HiddenNetwork expectedHiddenNetwork,
- List<WifiScanner.ScanSettings.HiddenNetwork> hiddenNetworkList) {
- for (WifiScanner.ScanSettings.HiddenNetwork hiddenNetwork : hiddenNetworkList) {
+ HiddenNetwork expectedHiddenNetwork,
+ List<HiddenNetwork> hiddenNetworkList) {
+ for (HiddenNetwork hiddenNetwork : hiddenNetworkList) {
if (hiddenNetwork.ssid.equals(expectedHiddenNetwork.ssid)) {
return;
}
diff --git a/tests/wifitests/src/com/android/server/wifi/ScanTestUtil.java b/tests/wifitests/src/com/android/server/wifi/ScanTestUtil.java
index 19ebd2ddc..212937fc3 100644
--- a/tests/wifitests/src/com/android/server/wifi/ScanTestUtil.java
+++ b/tests/wifitests/src/com/android/server/wifi/ScanTestUtil.java
@@ -62,13 +62,13 @@ public class ScanTestUtil {
public static WifiScanner.ScanSettings createRequest(int type, int band, int period, int batch,
int bssidsPerScan, int reportEvents) {
- return createRequest(WifiScanner.TYPE_HIGH_ACCURACY, band, period, 0, 0,
+ return createRequest(WifiScanner.SCAN_TYPE_HIGH_ACCURACY, band, period, 0, 0,
batch, bssidsPerScan, reportEvents);
}
public static WifiScanner.ScanSettings createRequest(int band, int period, int batch,
int bssidsPerScan, int reportEvents) {
- return createRequest(WifiScanner.TYPE_HIGH_ACCURACY, band, period, 0, 0, batch,
+ return createRequest(WifiScanner.SCAN_TYPE_HIGH_ACCURACY, band, period, 0, 0, batch,
bssidsPerScan, reportEvents);
}
@@ -183,11 +183,11 @@ public class ScanTestUtil {
private static int getNativeScanType(int type) {
switch(type) {
- case WifiScanner.TYPE_LOW_LATENCY:
+ case WifiScanner.SCAN_TYPE_LOW_LATENCY:
return WifiNative.SCAN_TYPE_LOW_LATENCY;
- case WifiScanner.TYPE_LOW_POWER:
+ case WifiScanner.SCAN_TYPE_LOW_POWER:
return WifiNative.SCAN_TYPE_LOW_POWER;
- case WifiScanner.TYPE_HIGH_ACCURACY:
+ case WifiScanner.SCAN_TYPE_HIGH_ACCURACY:
return WifiNative.SCAN_TYPE_HIGH_ACCURACY;
default:
fail();
diff --git a/tests/wifitests/src/com/android/server/wifi/WakeupControllerTest.java b/tests/wifitests/src/com/android/server/wifi/WakeupControllerTest.java
index c9cf0aca2..b7c793afc 100644
--- a/tests/wifitests/src/com/android/server/wifi/WakeupControllerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WakeupControllerTest.java
@@ -292,7 +292,7 @@ public class WakeupControllerTest extends WifiBaseTest {
initializeWakeupController(true /* enabled */);
mWakeupController.start();
mWakeupController.stop();
- verify(mWifiScanner).deregisterScanListener(any());
+ verify(mWifiScanner).unregisterScanListener(any());
}
/**
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiNetworkFactoryTest.java b/tests/wifitests/src/com/android/server/wifi/WifiNetworkFactoryTest.java
index 06737762b..461476fce 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiNetworkFactoryTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiNetworkFactoryTest.java
@@ -2906,14 +2906,13 @@ public class WifiNetworkFactoryTest extends WifiBaseTest {
ScanSettings scanSettings = mScanSettingsArgumentCaptor.getValue();
assertNotNull(scanSettings);
assertEquals(WifiScanner.WIFI_BAND_BOTH_WITH_DFS, scanSettings.band);
- assertEquals(WifiScanner.TYPE_HIGH_ACCURACY, scanSettings.type);
+ assertEquals(WifiScanner.SCAN_TYPE_HIGH_ACCURACY, scanSettings.type);
assertEquals(WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN, scanSettings.reportEvents);
if (hiddenSsid == null) {
- assertNull(scanSettings.hiddenNetworks);
+ assertEquals(Collections.emptyList(), scanSettings.hiddenNetworks);
} else {
- assertNotNull(scanSettings.hiddenNetworks);
- assertNotNull(scanSettings.hiddenNetworks[0]);
- assertEquals(scanSettings.hiddenNetworks[0].ssid, addEnclosingQuotes(hiddenSsid));
+ assertNotNull(scanSettings.hiddenNetworks.get(0));
+ assertEquals(scanSettings.hiddenNetworks.get(0).ssid, addEnclosingQuotes(hiddenSsid));
}
WorkSource workSource = mWorkSourceArgumentCaptor.getValue();
assertNotNull(workSource);
diff --git a/tests/wifitests/src/com/android/server/wifi/scanner/BackgroundScanSchedulerTest.java b/tests/wifitests/src/com/android/server/wifi/scanner/BackgroundScanSchedulerTest.java
index 39ecb6f6e..938ce9022 100644
--- a/tests/wifitests/src/com/android/server/wifi/scanner/BackgroundScanSchedulerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/scanner/BackgroundScanSchedulerTest.java
@@ -418,8 +418,8 @@ public class BackgroundScanSchedulerTest extends WifiBaseTest {
@Test
public void singleExponentialBackOffRequest() {
Collection<ScanSettings> requests = Collections.singleton(createRequest(
- WifiScanner.TYPE_LOW_LATENCY, WifiScanner.WIFI_BAND_BOTH, 30000, 160000, 2, 0, 20,
- WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN
+ WifiScanner.SCAN_TYPE_LOW_LATENCY, WifiScanner.WIFI_BAND_BOTH,
+ 30000, 160000, 2, 0, 20, WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN
));
mScheduler.updateSchedule(requests);
@@ -435,8 +435,8 @@ public class BackgroundScanSchedulerTest extends WifiBaseTest {
@Test
public void exponentialBackOffAndRegularRequests() {
Collection<ScanSettings> requests = new ArrayList<>();
- requests.add(createRequest(WifiScanner.TYPE_LOW_LATENCY, WifiScanner.WIFI_BAND_BOTH, 30000,
- 200000, 1, 0, 20, WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN));
+ requests.add(createRequest(WifiScanner.SCAN_TYPE_LOW_LATENCY, WifiScanner.WIFI_BAND_BOTH,
+ 30000, 200000, 1, 0, 20, WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN));
requests.add(createRequest(channelsToSpec(5175), 30000, 0, 20,
WifiScanner.REPORT_EVENT_AFTER_BUFFER_FULL));
diff --git a/tests/wifitests/src/com/android/server/wifi/scanner/WifiScanningServiceTest.java b/tests/wifitests/src/com/android/server/wifi/scanner/WifiScanningServiceTest.java
index d1cb3ba86..ce5a066d7 100644
--- a/tests/wifitests/src/com/android/server/wifi/scanner/WifiScanningServiceTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/scanner/WifiScanningServiceTest.java
@@ -756,7 +756,7 @@ public class WifiScanningServiceTest extends WifiBaseTest {
WifiScanner.ScanSettings requestSettings = createRequest(WifiScanner.WIFI_BAND_BOTH, 0,
0, 20, WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN);
int requestId = 33;
- requestSettings.type = WifiScanner.TYPE_HIGH_ACCURACY;
+ requestSettings.type = WifiScanner.SCAN_TYPE_HIGH_ACCURACY;
WorkSource workSource = new WorkSource(Binder.getCallingUid()); // don't explicitly set
when(mContext.checkPermission(
@@ -805,10 +805,11 @@ public class WifiScanningServiceTest extends WifiBaseTest {
WifiScanner.ScanSettings requestSettings = createRequest(WifiScanner.WIFI_BAND_BOTH, 0,
0, 20, WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN);
int requestId = 33;
- requestSettings.hiddenNetworks = new WifiScanner.ScanSettings.HiddenNetwork[] {
- new WifiScanner.ScanSettings.HiddenNetwork("Test1"),
- new WifiScanner.ScanSettings.HiddenNetwork("Test2")
- };
+ requestSettings.hiddenNetworks.clear();
+ requestSettings.hiddenNetworks.add(
+ new WifiScanner.ScanSettings.HiddenNetwork("Test1"));
+ requestSettings.hiddenNetworks.add(
+ new WifiScanner.ScanSettings.HiddenNetwork("Test2"));
WorkSource workSource = new WorkSource(Binder.getCallingUid()); // don't explicitly set
when(mContext.checkPermission(
@@ -1327,13 +1328,13 @@ public class WifiScanningServiceTest extends WifiBaseTest {
// Create identitical scan requests other than the types being different.
WifiScanner.ScanSettings requestSettings1 = createRequest(channelsToSpec(2400), 0,
0, 20, WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN);
- requestSettings1.type = WifiScanner.TYPE_LOW_LATENCY;
+ requestSettings1.type = WifiScanner.SCAN_TYPE_LOW_LATENCY;
int requestId1 = 12;
ScanResults results1 = ScanResults.create(0, WifiScanner.WIFI_BAND_UNSPECIFIED, 2400);
WifiScanner.ScanSettings requestSettings2 = createRequest(channelsToSpec(2400), 0,
0, 20, WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN);
- requestSettings2.type = WifiScanner.TYPE_HIGH_ACCURACY;
+ requestSettings2.type = WifiScanner.SCAN_TYPE_HIGH_ACCURACY;
int requestId2 = 13;
ScanResults results2 = ScanResults.create(0, WifiScanner.WIFI_BAND_UNSPECIFIED, 2400);
@@ -1396,14 +1397,14 @@ public class WifiScanningServiceTest extends WifiBaseTest {
public void sendMultipleSingleScanRequestWhilePreviousScanRunning() throws RemoteException {
WifiScanner.ScanSettings requestSettings1 = createRequest(channelsToSpec(2400), 0,
0, 20, WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN);
- requestSettings1.type = WifiScanner.TYPE_LOW_LATENCY;
+ requestSettings1.type = WifiScanner.SCAN_TYPE_LOW_LATENCY;
int requestId1 = 12;
WorkSource workSource1 = new WorkSource(1121);
ScanResults results1 = ScanResults.create(0, WifiScanner.WIFI_BAND_UNSPECIFIED, 2400);
WifiScanner.ScanSettings requestSettings2 = createRequest(channelsToSpec(2450, 5175), 0,
0, 20, WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN);
- requestSettings2.type = WifiScanner.TYPE_HIGH_ACCURACY;
+ requestSettings2.type = WifiScanner.SCAN_TYPE_HIGH_ACCURACY;
int requestId2 = 13;
WorkSource workSource2 = new WorkSource(Binder.getCallingUid()); // don't explicitly set
ScanResults results2 =
@@ -1411,7 +1412,7 @@ public class WifiScanningServiceTest extends WifiBaseTest {
WifiScanner.ScanSettings requestSettings3 = createRequest(channelsToSpec(5150), 0,
0, 20, WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN);
- requestSettings3.type = WifiScanner.TYPE_LOW_POWER;
+ requestSettings3.type = WifiScanner.SCAN_TYPE_LOW_POWER;
int requestId3 = 15;
// Let one of the WorkSources be a chained workSource.
WorkSource workSource3 = new WorkSource();
@@ -1519,13 +1520,13 @@ public class WifiScanningServiceTest extends WifiBaseTest {
ScanResults.merge(WifiScanner.WIFI_BAND_BOTH, results24GHz, results5GHz);
WifiScanner.ScanSettings requestSettings1 = createRequest(
- WifiScanner.TYPE_HIGH_ACCURACY, WifiScanner.WIFI_BAND_BOTH, 0,
+ WifiScanner.SCAN_TYPE_HIGH_ACCURACY, WifiScanner.WIFI_BAND_BOTH, 0,
0, 20, WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN);
int requestId1 = 12;
ScanResults results1 = resultsBoth;
WifiScanner.ScanSettings requestSettings2 = createRequest(
- WifiScanner.TYPE_LOW_LATENCY, WifiScanner.WIFI_BAND_24_GHZ, 0,
+ WifiScanner.SCAN_TYPE_LOW_LATENCY, WifiScanner.WIFI_BAND_24_GHZ, 0,
0, 20, WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN);
int requestId2 = 13;
ScanResults results2 = results24GHz;
@@ -1587,21 +1588,21 @@ public class WifiScanningServiceTest extends WifiBaseTest {
WifiScanner.ScanSettings requestSettings1 = createRequest(channelsToSpec(2400, 2450), 0,
0, 20, WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN);
- requestSettings1.type = WifiScanner.TYPE_LOW_LATENCY;
+ requestSettings1.type = WifiScanner.SCAN_TYPE_LOW_LATENCY;
int requestId1 = 12;
WorkSource workSource1 = new WorkSource(1121);
ScanResults results1 = results1and3;
WifiScanner.ScanSettings requestSettings2 = createRequest(channelsToSpec(2450, 5175), 0,
0, 20, WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN);
- requestSettings2.type = WifiScanner.TYPE_HIGH_ACCURACY;
+ requestSettings2.type = WifiScanner.SCAN_TYPE_HIGH_ACCURACY;
int requestId2 = 13;
WorkSource workSource2 = new WorkSource(Binder.getCallingUid()); // don't explicitly set
ScanResults results2 = ScanResults.create(0, 2450, 5175, 2450);
WifiScanner.ScanSettings requestSettings3 = createRequest(channelsToSpec(2400), 0,
0, 20, WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN);
- requestSettings3.type = WifiScanner.TYPE_LOW_POWER;
+ requestSettings3.type = WifiScanner.SCAN_TYPE_LOW_POWER;
int requestId3 = 15;
WorkSource workSource3 = new WorkSource(2292);
ScanResults results3 = results2400;