summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMitchell Wills <mwills@google.com>2016-02-11 11:48:54 -0800
committerMitchell Wills <mwills@google.com>2016-02-11 20:52:50 -0800
commit54e2c84547e22622ba4a08bddd1c632d1d937be3 (patch)
tree72b78daaacbc21b6474af655312dc61a2e4835b9 /tests
parent63539f1283899fbbf83ab90757961b4be51d5034 (diff)
Migrate channel/band toString to ChannelHelper
Change-Id: Ia4ea1d29b74cd08593f13b9e74cb6f6257adf78b
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/MultiClientSchedulerTest.java44
-rw-r--r--tests/wifitests/src/com/android/server/wifi/scanner/ChannelHelperTest.java48
2 files changed, 72 insertions, 20 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/MultiClientSchedulerTest.java b/tests/wifitests/src/com/android/server/wifi/MultiClientSchedulerTest.java
index 97da4a473..45dc3899e 100644
--- a/tests/wifitests/src/com/android/server/wifi/MultiClientSchedulerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/MultiClientSchedulerTest.java
@@ -34,6 +34,7 @@ import android.net.wifi.WifiScanner.ScanSettings;
import android.test.suitebuilder.annotation.SmallTest;
import com.android.server.wifi.WifiNative.BucketSettings;
+import com.android.server.wifi.scanner.ChannelHelper;
import org.junit.After;
import org.junit.Before;
@@ -546,36 +547,39 @@ public class MultiClientSchedulerTest {
if ((settings.reportEvents & WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN) != 0) {
if ((bucket.report_events & WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN) == 0) {
ignoreString
- .append(" ")
- .append(WifiChannelHelper.toString(getAllChannels(bucket)))
- .append("=after_each_scan:")
- .append(bucket.report_events & WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN)
- .append("!=")
- .append(settings.reportEvents & WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN);
+ .append(" ")
+ .append(ChannelHelper.toString(bucket))
+ .append("=after_each_scan:")
+ .append(bucket.report_events & WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN)
+ .append("!=")
+ .append(settings.reportEvents
+ & WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN);
continue;
}
}
if ((settings.reportEvents & WifiScanner.REPORT_EVENT_FULL_SCAN_RESULT) != 0) {
if ((bucket.report_events & WifiScanner.REPORT_EVENT_FULL_SCAN_RESULT) == 0) {
ignoreString
- .append(" ")
- .append(WifiChannelHelper.toString(getAllChannels(bucket)))
- .append("=full_result:")
- .append(bucket.report_events & WifiScanner.REPORT_EVENT_FULL_SCAN_RESULT)
- .append("!=")
- .append(settings.reportEvents & WifiScanner.REPORT_EVENT_FULL_SCAN_RESULT);
+ .append(" ")
+ .append(ChannelHelper.toString(bucket))
+ .append("=full_result:")
+ .append(bucket.report_events
+ & WifiScanner.REPORT_EVENT_FULL_SCAN_RESULT)
+ .append("!=")
+ .append(settings.reportEvents
+ & WifiScanner.REPORT_EVENT_FULL_SCAN_RESULT);
continue;
}
}
if ((settings.reportEvents & WifiScanner.REPORT_EVENT_NO_BATCH) == 0) {
if ((bucket.report_events & WifiScanner.REPORT_EVENT_NO_BATCH) != 0) {
ignoreString
- .append(" ")
- .append(WifiChannelHelper.toString(getAllChannels(bucket)))
- .append("=no_batch:")
- .append(bucket.report_events & WifiScanner.REPORT_EVENT_NO_BATCH)
- .append("!=")
- .append(settings.reportEvents & WifiScanner.REPORT_EVENT_NO_BATCH);
+ .append(" ")
+ .append(ChannelHelper.toString(bucket))
+ .append("=no_batch:")
+ .append(bucket.report_events & WifiScanner.REPORT_EVENT_NO_BATCH)
+ .append("!=")
+ .append(settings.reportEvents & WifiScanner.REPORT_EVENT_NO_BATCH);
continue;
}
}
@@ -596,7 +600,7 @@ public class MultiClientSchedulerTest {
if (bucket.period_ms != expectedPeriod) {
ignoreString
.append(" ")
- .append(WifiChannelHelper.toString(getAllChannels(bucket)))
+ .append(ChannelHelper.toString(bucket))
.append("=period:")
.append(bucket.period_ms)
.append("!=")
@@ -607,7 +611,7 @@ public class MultiClientSchedulerTest {
if (bucket.period_ms > expectedPeriod) {
ignoreString
.append(" ")
- .append(WifiChannelHelper.toString(getAllChannels(bucket)))
+ .append(ChannelHelper.toString(bucket))
.append("=period:")
.append(bucket.period_ms)
.append(">")
diff --git a/tests/wifitests/src/com/android/server/wifi/scanner/ChannelHelperTest.java b/tests/wifitests/src/com/android/server/wifi/scanner/ChannelHelperTest.java
index 196376c41..c54e3997b 100644
--- a/tests/wifitests/src/com/android/server/wifi/scanner/ChannelHelperTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/scanner/ChannelHelperTest.java
@@ -20,6 +20,7 @@ import static com.android.server.wifi.ScanTestUtil.channelsToNativeSettings;
import static com.android.server.wifi.ScanTestUtil.channelsToSpec;
import static com.android.server.wifi.ScanTestUtil.createRequest;
+import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.doCallRealMethod;
import static org.mockito.Mockito.mock;
@@ -44,6 +45,53 @@ public class ChannelHelperTest {
/**
* Unit tests for
+ * {@link com.android.server.wifi.scanner.ChannelHelper#toString}.
+ */
+ public static class ToStringTest {
+ /**
+ * Compute a string representing the channels in a ScanSettings with a band set.
+ */
+ @Test
+ public void scanSettings_band() {
+ WifiScanner.ScanSettings scanSettings = createRequest(WifiScanner.WIFI_BAND_BOTH,
+ 10000, 0, 20, WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN);
+ assertEquals("24Ghz & 5Ghz (no DFS)", ChannelHelper.toString(scanSettings));
+ }
+
+ /**
+ * Compute a string representing the channels in a ScanSettings with a list of channels set.
+ */
+ @Test
+ public void scanSettings_channels() {
+ WifiScanner.ScanSettings scanSettings = createRequest(channelsToSpec(5150, 2400),
+ 10000, 0, 20, WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN);
+ assertEquals("[5150,2400]", ChannelHelper.toString(scanSettings));
+ }
+
+ /**
+ * Compute a string representing the channels in a BucketSettings with a band set.
+ */
+ @Test
+ public void bucketSettings_band() {
+ WifiScanner.ScanSettings scanSettings = createRequest(WifiScanner.WIFI_BAND_5_GHZ,
+ 10000, 0, 20, WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN);
+ assertEquals("5Ghz (no DFS)", ChannelHelper.toString(scanSettings));
+ }
+
+ /**
+ * Compute a string representing the channels in a BucketSettings with a list of channels
+ * set.
+ */
+ @Test
+ public void bucketSettings_channels() {
+ WifiScanner.ScanSettings scanSettings = createRequest(channelsToSpec(2400, 5100),
+ 10000, 0, 20, WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN);
+ assertEquals("[2400,5100]", ChannelHelper.toString(scanSettings));
+ }
+ }
+
+ /**
+ * Unit tests for
* {@link com.android.server.wifi.scanner.ChannelHelper.ChannelCollection}.
*/
public static class ChannelCollectionTest {