summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRebecca Silberstein <silberst@google.com>2016-08-05 11:55:39 -0700
committerRebecca Silberstein <silberst@google.com>2016-08-05 12:12:16 -0700
commit173dae04272c1b40488292f6392a922b4c4b2949 (patch)
tree472e2dee88771d1020c8dc19275f1603882ce860 /tests
parent01dafe766c969517561dd9fd733ec475bc8eee5d (diff)
WifiStateMachine: update new mode in initial state
When WifiController calls setOperationalMode a CMD_SET_OPERATIONAL_MODE message is sent to WifiStateMachine. When this message is received in the InitialState, it is not handled where it is then dropped in the default state. Dropping this message causes WifiController and WifiStateMachine to get out of sync on the operating mode. BUG:29938263 Change-Id: I8481af8d6826f3da18f5762833a7b145d81b74dd TEST:runtest frameworks-wifi
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java69
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 e0f94ad17..53d8f46aa 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java
@@ -475,6 +475,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);
}