diff options
author | TreeHugger Robot <treehugger-gerrit@google.com> | 2017-10-04 19:22:32 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2017-10-04 19:22:32 +0000 |
commit | 7ce813a6129ab0c0b812b27e332730a8a2165d43 (patch) | |
tree | b133404383ad29bad8ffc6a917982aabebb1963d /tests | |
parent | 988256f6c383c2c6b24d295c2f2e7ce77ec9955f (diff) | |
parent | e6b6ab66c49702d3358b4894d28e322ea9534a84 (diff) |
Merge "Fail scan request if no channels are available" into oc-mr1-dev
Diffstat (limited to 'tests')
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/scanner/WificondScannerTest.java | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/scanner/WificondScannerTest.java b/tests/wifitests/src/com/android/server/wifi/scanner/WificondScannerTest.java index ed7c58298..d337cf1cf 100644 --- a/tests/wifitests/src/com/android/server/wifi/scanner/WificondScannerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/scanner/WificondScannerTest.java @@ -32,6 +32,7 @@ import com.android.server.wifi.ScanDetail; import com.android.server.wifi.ScanResults; import com.android.server.wifi.WifiMonitor; import com.android.server.wifi.WifiNative; +import com.android.server.wifi.scanner.ChannelHelper.ChannelCollection; import org.junit.Before; import org.junit.Test; @@ -56,6 +57,39 @@ public class WificondScannerTest extends BaseWifiScannerImplTest { mLooper.getLooper(), mClock); } + /** + * Test that WificondScannerImpl will not issue a scan and report scan failure + * when there is no channel to scan for. + */ + @Test + public void singleScanNotIssuedIfNoAvailableChannels() { + // Use mocked ChannelHelper and ChannelCollection to simulate the scenario + // that no channel is available for this request. + ChannelHelper channelHelper = mock(ChannelHelper.class); + ChannelCollection channelCollection = mock(ChannelCollection.class); + when(channelHelper.createChannelCollection()).thenReturn(channelCollection); + when(channelCollection.isEmpty()).thenReturn(true); + + mScanner = new WificondScannerImpl(mContext, mWifiNative, mWifiMonitor, + channelHelper, mLooper.getLooper(), mClock); + + WifiNative.ScanSettings settings = new NativeScanSettingsBuilder() + .withBasePeriod(10000) // ms + .withMaxApPerScan(10) + .addBucketWithBand(10000 /* ms */, WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN, + WifiScanner.WIFI_BAND_5_GHZ) + .build(); + WifiNative.ScanEventHandler eventHandler = mock(WifiNative.ScanEventHandler.class); + mScanner.startSingleScan(settings, eventHandler); + + mLooper.dispatchAll(); + + // No scan is issued to WifiNative. + verify(mWifiNative, never()).scan(any(), any(Set.class)); + // A scan failed event must be reported. + verify(eventHandler).onScanStatus(WifiNative.WIFI_SCAN_FAILED); + } + @Test public void backgroundScanSuccessSingleBucket() { WifiNative.ScanSettings settings = new NativeScanSettingsBuilder() |