summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorpkanwar <pkanwar@google.com>2016-01-23 18:04:22 -0800
committerPankaj Kanwar <pkanwar@google.com>2016-02-01 17:24:07 +0000
commitc94a64a292925a00c33413c81a46941093495b3e (patch)
treee1c8d81d124b021f869e3045db22d7ade21085f2 /tests
parentcb8c60a24d9e89f3b1aa601e76e38e05f8db6fae (diff)
Add DhcpFailure and BadNetworkEvent tests to WifiStateMachine
This CL adds 2 tests for WifiStateMachine: - TestDhcpFailure tests failure in dhcp client. - TestBadNetworkEvent tests sending the NETWORK_DISCONNECTION_EVENT during connection to make sure that the state machine does not break. BUG=26901681 Change-Id: I9e79d8a07d18f397a38816e0a508d13482143937
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java45
1 files changed, 45 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 c092f0d79..a32b1e893 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java
@@ -552,6 +552,51 @@ public class WifiStateMachineTest {
}
@Test
+ public void testDhcpFailure() throws Exception {
+ addNetwork();
+
+ mWsm.setOperationalMode(WifiStateMachine.CONNECT_MODE);
+ mWsm.syncEnableNetwork(mWsmAsyncChannel, 0, true);
+ wait(200);
+
+ verify(mWifiNative).enableNetwork(0, true);
+
+ mWsm.sendMessage(WifiMonitor.NETWORK_CONNECTION_EVENT, 0, 0, sBSSID);
+
+ mWsm.sendMessage(WifiMonitor.SUPPLICANT_STATE_CHANGE_EVENT, 0, 0,
+ new StateChangeResult(0, sWifiSsid, sBSSID, SupplicantState.COMPLETED));
+ wait(200);
+
+ assertEquals("ObtainingIpState", getCurrentState().getName());
+
+ mWsm.sendMessage(DhcpStateMachine.CMD_POST_DHCP_ACTION, DhcpStateMachine.DHCP_FAILURE, 0,
+ null);
+ wait(200);
+
+ assertEquals("DisconnectingState", getCurrentState().getName());
+ }
+
+ @Test
+ public void testBadNetworkEvent() throws Exception {
+ addNetwork();
+
+ mWsm.setOperationalMode(WifiStateMachine.CONNECT_MODE);
+ mWsm.syncEnableNetwork(mWsmAsyncChannel, 0, true);
+ wait(200);
+
+ verify(mWifiNative).enableNetwork(0, true);
+
+ mWsm.sendMessage(WifiMonitor.NETWORK_DISCONNECTION_EVENT, 0, 0, sBSSID);
+
+ mWsm.sendMessage(WifiMonitor.SUPPLICANT_STATE_CHANGE_EVENT, 0, 0,
+ new StateChangeResult(0, sWifiSsid, sBSSID, SupplicantState.COMPLETED));
+ wait(200);
+
+ assertEquals("DisconnectedState", getCurrentState().getName());
+ }
+
+
+ @Test
public void disconnect() throws Exception {
connect();