summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRebecca Silberstein <silberst@google.com>2018-04-19 13:24:12 -0700
committerRebecca Silberstein <silberst@google.com>2018-04-19 13:24:12 -0700
commit91c1a804938164cb5c4309a160a576a24648ed6c (patch)
treeb9a943ff7008ce491f1a60d0bbac2bd23d390590 /tests
parent080c2f856866353e300ec431acc106eb076bfeb6 (diff)
WifiStateMachine: switch modes immediately
When switching modes, do it immediately instead of sending a message. To trigger the transition, moved SET_OPERATIONAL_MODE to be a simple trigger for the transition. The states themselves manage the state. Bug: 78268615 Test: frameworks/opt/net/wifi/tests/wifitests/runtests.sh Test: manually toggled airplane mode repeatedly (and quickly) Test: manually toggled wifi repeatedly (and quickly) Change-Id: I024174c140e610c7d84fc4d42b1dee3487d23b97
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java27
1 files changed, 27 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 c70a77102..4729dd841 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java
@@ -785,6 +785,7 @@ public class WifiStateMachineTest {
*/
private void startSupplicantAndDispatchMessages() throws Exception {
mWsm.setOperationalMode(WifiStateMachine.CONNECT_MODE, WIFI_IFACE_NAME);
+
mLooper.dispatchAll();
verify(mWifiLastResortWatchdog, atLeastOnce()).clearAllFailureCounts();
@@ -2385,4 +2386,30 @@ public class WifiStateMachineTest {
verify(config).getOrCreateRandomizedMacAddress();
verify(mWifiNative, never()).setMacAddress(eq(WIFI_IFACE_NAME), any(MacAddress.class));
}
+
+ /**
+ * Verify that we do not crash on quick toggling wifi on/off
+ */
+ @Test
+ public void quickTogglesDoNotCrash() throws Exception {
+ mWsm.setOperationalMode(WifiStateMachine.CONNECT_MODE, WIFI_IFACE_NAME);
+ mWsm.setOperationalMode(WifiStateMachine.DISABLED_MODE, null);
+ mLooper.dispatchAll();
+
+ mWsm.setOperationalMode(WifiStateMachine.DISABLED_MODE, null);
+ mWsm.setOperationalMode(WifiStateMachine.CONNECT_MODE, WIFI_IFACE_NAME);
+ mLooper.dispatchAll();
+
+ mWsm.setOperationalMode(WifiStateMachine.DISABLED_MODE, null);
+ mWsm.setOperationalMode(WifiStateMachine.CONNECT_MODE, WIFI_IFACE_NAME);
+ mWsm.setOperationalMode(WifiStateMachine.DISABLED_MODE, null);
+ mWsm.setOperationalMode(WifiStateMachine.CONNECT_MODE, WIFI_IFACE_NAME);
+ mLooper.dispatchAll();
+
+ mWsm.setOperationalMode(WifiStateMachine.CONNECT_MODE, WIFI_IFACE_NAME);
+ mWsm.setOperationalMode(WifiStateMachine.DISABLED_MODE, null);
+ mWsm.setOperationalMode(WifiStateMachine.CONNECT_MODE, WIFI_IFACE_NAME);
+ mWsm.setOperationalMode(WifiStateMachine.DISABLED_MODE, null);
+ mLooper.dispatchAll();
+ }
}