summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java38
1 files changed, 38 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 86692c8ce..44fdd4874 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java
@@ -2338,4 +2338,42 @@ public class WifiStateMachineTest {
mLooper.dispatchAll();
verify(mIpClient).shutdown();
}
+
+ /**
+ * Verify that WifiInfo's MAC address is updated when the state machine receives
+ * NETWORK_CONNECTION_EVENT while in ConnectedState.
+ */
+ @Test
+ public void verifyWifiInfoMacUpdatedWithNetworkConnectionWhileConnected() throws Exception {
+ when(mWifiNative.getMacAddress(WIFI_IFACE_NAME))
+ .thenReturn(TEST_LOCAL_MAC_ADDRESS.toString());
+ connect();
+ assertEquals("ConnectedState", getCurrentState().getName());
+ assertEquals(TEST_LOCAL_MAC_ADDRESS.toString(), mWsm.getWifiInfo().getMacAddress());
+
+ when(mWifiNative.getMacAddress(WIFI_IFACE_NAME))
+ .thenReturn(TEST_GLOBAL_MAC_ADDRESS.toString());
+ mWsm.sendMessage(WifiMonitor.NETWORK_CONNECTION_EVENT, 0, 0, sBSSID);
+ mLooper.dispatchAll();
+ assertEquals(TEST_GLOBAL_MAC_ADDRESS.toString(), mWsm.getWifiInfo().getMacAddress());
+ }
+
+ /**
+ * Verify that WifiInfo's MAC address is updated when the state machine receives
+ * NETWORK_CONNECTION_EVENT while in DisconnectedState.
+ */
+ @Test
+ public void verifyWifiInfoMacUpdatedWithNetworkConnectionWhileDisconnected() throws Exception {
+ when(mWifiNative.getMacAddress(WIFI_IFACE_NAME))
+ .thenReturn(TEST_LOCAL_MAC_ADDRESS.toString());
+ disconnect();
+ assertEquals("DisconnectedState", getCurrentState().getName());
+ assertEquals(TEST_LOCAL_MAC_ADDRESS.toString(), mWsm.getWifiInfo().getMacAddress());
+
+ when(mWifiNative.getMacAddress(WIFI_IFACE_NAME))
+ .thenReturn(TEST_GLOBAL_MAC_ADDRESS.toString());
+ mWsm.sendMessage(WifiMonitor.NETWORK_CONNECTION_EVENT, 0, 0, sBSSID);
+ mLooper.dispatchAll();
+ assertEquals(TEST_GLOBAL_MAC_ADDRESS.toString(), mWsm.getWifiInfo().getMacAddress());
+ }
}