diff options
author | Rebecca Silberstein <silberst@google.com> | 2016-08-05 21:32:40 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2016-08-05 21:32:40 +0000 |
commit | e92ef5d5cbdfed45cb3a818499a7eafb63d34b01 (patch) | |
tree | 8f1db305c0c0e86bbc7c6107eec3882722cd7628 /tests | |
parent | e1cb273e87d73341e54d3b333ad8ff5d478c0c4e (diff) | |
parent | 673719204b0e689be876a4fa8e753609a1eef868 (diff) |
WifiStateMachine: update new mode in initial state am: 173dae0427 am: 5870db3561
am: 673719204b
Change-Id: I7bdebc4a09cdeb8050696c715ee0892bf9f5bfac
Diffstat (limited to 'tests')
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java b/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java index 5531eeadf..66a46e334 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java @@ -519,6 +519,75 @@ public class WifiStateMachineTest { assertEquals("InitialState", getCurrentState().getName()); } + /** + * Test to check that mode changes from WifiController will be properly handled in the + * InitialState by WifiStateMachine. + */ + @Test + public void checkOperationalModeInInitialState() throws Exception { + when(mWifiNative.loadDriver()).thenReturn(true); + when(mWifiNative.startHal()).thenReturn(true); + when(mWifiNative.startSupplicant(anyBoolean())).thenReturn(true); + + mLooper.dispatchAll(); + assertEquals("InitialState", getCurrentState().getName()); + assertEquals(WifiStateMachine.CONNECT_MODE, mWsm.getOperationalModeForTest()); + + mWsm.setOperationalMode(WifiStateMachine.SCAN_ONLY_WITH_WIFI_OFF_MODE); + mLooper.dispatchAll(); + assertEquals(WifiStateMachine.SCAN_ONLY_WITH_WIFI_OFF_MODE, + mWsm.getOperationalModeForTest()); + + mWsm.setOperationalMode(WifiStateMachine.SCAN_ONLY_MODE); + mLooper.dispatchAll(); + assertEquals(WifiStateMachine.SCAN_ONLY_MODE, mWsm.getOperationalModeForTest()); + + mWsm.setOperationalMode(WifiStateMachine.CONNECT_MODE); + mLooper.dispatchAll(); + assertEquals(WifiStateMachine.CONNECT_MODE, mWsm.getOperationalModeForTest()); + } + + /** + * Test that mode changes for WifiStateMachine in the InitialState are realized when supplicant + * is started. + */ + @Test + public void checkStartInCorrectStateAfterChangingInitialState() throws Exception { + when(mWifiNative.loadDriver()).thenReturn(true); + when(mWifiNative.startHal()).thenReturn(true); + when(mWifiNative.startSupplicant(anyBoolean())).thenReturn(true); + + // Check initial state + mLooper.dispatchAll(); + assertEquals("InitialState", getCurrentState().getName()); + assertEquals(WifiStateMachine.CONNECT_MODE, mWsm.getOperationalModeForTest()); + + // Update the mode + mWsm.setOperationalMode(WifiStateMachine.SCAN_ONLY_MODE); + mLooper.dispatchAll(); + assertEquals(WifiStateMachine.SCAN_ONLY_MODE, mWsm.getOperationalModeForTest()); + + // Start supplicant so we move to the next state + mWsm.setSupplicantRunning(true); + mLooper.dispatchAll(); + assertEquals("SupplicantStartingState", getCurrentState().getName()); + when(mWifiNative.setBand(anyInt())).thenReturn(true); + when(mWifiNative.setDeviceName(anyString())).thenReturn(true); + when(mWifiNative.setManufacturer(anyString())).thenReturn(true); + when(mWifiNative.setModelName(anyString())).thenReturn(true); + when(mWifiNative.setModelNumber(anyString())).thenReturn(true); + when(mWifiNative.setSerialNumber(anyString())).thenReturn(true); + when(mWifiNative.setConfigMethods(anyString())).thenReturn(true); + when(mWifiNative.setDeviceType(anyString())).thenReturn(true); + when(mWifiNative.setSerialNumber(anyString())).thenReturn(true); + when(mWifiNative.setScanningMacOui(any(byte[].class))).thenReturn(true); + + mWsm.sendMessage(WifiMonitor.SUP_CONNECTION_EVENT); + mLooper.dispatchAll(); + + assertEquals("ScanModeState", getCurrentState().getName()); + } + private void addNetworkAndVerifySuccess() throws Exception { addNetworkAndVerifySuccess(false); } |