diff options
author | Jong Wook Kim <jongwook@google.com> | 2018-05-17 13:55:26 -0700 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2018-05-17 13:55:26 -0700 |
commit | f2134b83a6e901054267667859a7f263aaec9588 (patch) | |
tree | 302ef4a31cd2edb0e94a6dddeaa7bc46d013ff36 /tests | |
parent | 4c5f46a20a524cc8ea6207b9db4059f75b06b1d9 (diff) | |
parent | 896b173bb20b4e3d9841d3f000c466574f2cdc66 (diff) |
Merge "Update WifiInfo MAC address more frequently" into pi-dev am: faa9f916fa
am: 896b173bb2
Change-Id: I816293fe327379582a3f5f7488ecc5251405dc25
Diffstat (limited to 'tests')
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java | 38 |
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 2712a42e3..b067d9dfa 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java @@ -2395,4 +2395,42 @@ public class WifiStateMachineTest { verify(mIpClient).shutdown(); verify(mIpClient).awaitShutdown(); } + + /** + * 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()); + } } |