diff options
author | Oscar Shu <xshu@google.com> | 2018-07-24 23:00:58 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2018-07-24 23:00:58 +0000 |
commit | 4e3715ed3e142e265b310686832db21004038ba8 (patch) | |
tree | b2877c2bc2fbc66ea5192a9ed1563165b8e5e273 /tests | |
parent | 6876be34176bc13aa7862c1a620b35d66982fee7 (diff) | |
parent | db017e2376136fb3828d696bbb882ecf5f2d174e (diff) |
Merge "Metrics: count num scan requests with DFS channels"
Diffstat (limited to 'tests')
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java | 6 | ||||
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/scanner/WifiScanningServiceTest.java | 71 |
2 files changed, 74 insertions, 3 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java b/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java index 579dca606..1077eafc6 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java @@ -311,6 +311,7 @@ public class WifiMetricsTest { private static final int DATA_STALL_MIN_TX_BAD_SETTING = 5; private static final int DATA_STALL_MIN_TX_SUCCESS_WITHOUT_RX_SETTING = 75; private static final int NUM_SAR_SENSOR_LISTENER_REGISTRATION_FAILURES = 5; + private static final int NUM_ONESHOT_SCAN_REQUESTS_WITH_DFS_CHANNELS = 4; /** Number of notifications per "Connect to Network" notification type. */ private static final int[] NUM_CONNECT_TO_NETWORK_NOTIFICATIONS = {0, 10, 20, 30, 40}; @@ -706,6 +707,9 @@ public class WifiMetricsTest { for (int i = 0; i < NUM_SAR_SENSOR_LISTENER_REGISTRATION_FAILURES; i++) { mWifiMetrics.incrementNumSarSensorRegistrationFailures(); } + for (int i = 0; i < NUM_ONESHOT_SCAN_REQUESTS_WITH_DFS_CHANNELS; i++) { + mWifiMetrics.incrementOneshotScanWithDfsCount(); + } mWifiMetrics.setWatchdogSuccessTimeDurationMs(NUM_WATCHDOG_SUCCESS_DURATION_MS); mWifiMetrics.setIsMacRandomizationOn(IS_MAC_RANDOMIZATION_ON); @@ -1015,6 +1019,8 @@ public class WifiMetricsTest { assertEquals(NUM_SAR_SENSOR_LISTENER_REGISTRATION_FAILURES, mDecodedProto.numSarSensorRegistrationFailures); + assertEquals(NUM_ONESHOT_SCAN_REQUESTS_WITH_DFS_CHANNELS, + mDecodedProto.numOneshotHasDfsChannelScans); } /** 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 b70834501..be6f11f32 100644 --- a/tests/wifitests/src/com/android/server/wifi/scanner/WifiScanningServiceTest.java +++ b/tests/wifitests/src/com/android/server/wifi/scanner/WifiScanningServiceTest.java @@ -710,7 +710,7 @@ public class WifiScanningServiceTest { assertDumpContainsCallbackLog("singleScanInvalidRequest", requestId, "bad request"); - assertEquals(mWifiMetrics.getOneshotScanCount(), 1); + assertEquals(0, mWifiMetrics.getOneshotScanCount()); assertEquals(mWifiMetrics.getScanReturnEntry( WifiMetricsProto.WifiLog.SCAN_FAILURE_INVALID_CONFIGURATION), 1); @@ -762,7 +762,7 @@ public class WifiScanningServiceTest { assertDumpContainsCallbackLog("singleScanInvalidRequest", requestId, "bad request"); - assertEquals(mWifiMetrics.getOneshotScanCount(), 1); + assertEquals(0, mWifiMetrics.getOneshotScanCount()); assertEquals(mWifiMetrics.getScanReturnEntry( WifiMetricsProto.WifiLog.SCAN_FAILURE_INVALID_CONFIGURATION), 1); @@ -807,7 +807,7 @@ public class WifiScanningServiceTest { assertDumpContainsCallbackLog("singleScanInvalidRequest", requestId, "bad request"); - assertEquals(mWifiMetrics.getOneshotScanCount(), 1); + assertEquals(0, mWifiMetrics.getOneshotScanCount()); assertEquals(mWifiMetrics.getScanReturnEntry( WifiMetricsProto.WifiLog.SCAN_FAILURE_INVALID_CONFIGURATION), 1); @@ -913,6 +913,71 @@ public class WifiScanningServiceTest { } /** + * Do a single scan that includes DFS channels and verify that both oneshot scan count and + * oneshot scan count with dfs are incremented. + */ + @Test + public void testMetricsForOneshotScanWithDFSIsIncremented() throws Exception { + WifiScanner.ScanSettings requestSettings = createRequest( + WifiScanner.WIFI_BAND_BOTH_WITH_DFS, 0, 0, 20, + WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN); + int requestId = 33; + WorkSource workSource = new WorkSource(Binder.getCallingUid()); // don't explicitly set + + startServiceAndLoadDriver(); + mWifiScanningServiceImpl.setWifiHandlerLogForTest(mLog); + + Handler handler = mock(Handler.class); + BidirectionalAsyncChannel controlChannel = connectChannel(handler); + InOrder order = inOrder(handler, mWifiScannerImpl); + + // successful start + when(mWifiScannerImpl.startSingleScan(any(WifiNative.ScanSettings.class), + any(WifiNative.ScanEventHandler.class))).thenReturn(true); + + sendSingleScanRequest(controlChannel, requestId, requestSettings, null); + + assertEquals(0, mWifiMetrics.getOneshotScanCount()); + assertEquals(0, mWifiMetrics.getOneshotScanWithDfsCount()); + // Scan is successfully queue + mLooper.dispatchAll(); + assertEquals(1, mWifiMetrics.getOneshotScanCount()); + assertEquals(1, mWifiMetrics.getOneshotScanWithDfsCount()); + } + + /** + * Do a single scan that excludes DFS channels and verify that only oneshot scan count is + * incremented. + */ + @Test + public void testMetricsForOneshotScanWithDFSIsNotIncremented() throws Exception { + WifiScanner.ScanSettings requestSettings = createRequest( + WifiScanner.WIFI_BAND_5_GHZ, 0, 0, 20, + WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN); + int requestId = 33; + WorkSource workSource = new WorkSource(Binder.getCallingUid()); // don't explicitly set + + startServiceAndLoadDriver(); + mWifiScanningServiceImpl.setWifiHandlerLogForTest(mLog); + + Handler handler = mock(Handler.class); + BidirectionalAsyncChannel controlChannel = connectChannel(handler); + InOrder order = inOrder(handler, mWifiScannerImpl); + + // successful start + when(mWifiScannerImpl.startSingleScan(any(WifiNative.ScanSettings.class), + any(WifiNative.ScanEventHandler.class))).thenReturn(true); + + sendSingleScanRequest(controlChannel, requestId, requestSettings, null); + + assertEquals(0, mWifiMetrics.getOneshotScanCount()); + // Scan is successfully queue + mLooper.dispatchAll(); + assertEquals(1, mWifiMetrics.getOneshotScanCount()); + assertEquals(0, mWifiMetrics.getOneshotScanWithDfsCount()); + } + + /** * Send a single scan request and then disable Wi-Fi before it completes */ @Test |