summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRebecca Silberstein <silberst@google.com>2016-08-05 21:30:13 +0000
committerandroid-build-merger <android-build-merger@google.com>2016-08-05 21:30:13 +0000
commit673719204b0e689be876a4fa8e753609a1eef868 (patch)
treefaa96cf940d8f934ecef9c1188f1235b3ea282ee /tests
parentc279df77a547187bd883383c967c6b9642dbb289 (diff)
parent5870db356197f38fbf5f2e9d344d4312090a0b46 (diff)
WifiStateMachine: update new mode in initial state am: 173dae0427
am: 5870db3561 Change-Id: I8c5003b86d30d4a0297cff2df46f3d2960ba239d
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);
}