diff options
author | Jimmy Chen <jimmycmchen@google.com> | 2020-03-20 16:40:44 +0800 |
---|---|---|
committer | Jimmy Chen <jimmycmchen@google.com> | 2020-03-23 16:04:10 +0800 |
commit | 21b91439e158c9a5de1db23de56c2cb6d89b3021 (patch) | |
tree | 316f0558a4f84e830cf91443c0c2fdb1bc9076ef /tests | |
parent | 5de1f8121f567ac7421cd68c24874e9665cc1178 (diff) |
Wifi: fix inconsistent state in handleSupplicantStateChange
Bug: 142814689
Test: atest FrameworksWifiTests
Change-Id: I1c91c618bdac249bf5093cc677993f1b063f27f1
Diffstat (limited to 'tests')
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java b/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java index 2eae8ca54..aeb49707e 100644 --- a/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java +++ b/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java @@ -4761,4 +4761,38 @@ public class ClientModeImplTest extends WifiBaseTest { assertTrue(WifiSsid.createFromAsciiEncoded(sFilsSsid).equals(wifiInfo.getWifiSsid())); assertEquals("ConnectedState", getCurrentState().getName()); } + + /** + * Tests the wifi info is updated correctly for connecting network. + */ + @Test + public void testWifiInfoOnConnectingNextNetwork() throws Exception { + + mConnectedNetwork.ephemeral = true; + mConnectedNetwork.trusted = true; + mConnectedNetwork.osu = true; + + triggerConnect(); + when(mWifiConfigManager.getScanDetailCacheForNetwork(FRAMEWORK_NETWORK_ID)) + .thenReturn(mScanDetailCache); + + when(mScanDetailCache.getScanDetail(sBSSID)).thenReturn( + getGoogleGuestScanDetail(TEST_RSSI, sBSSID, sFreq)); + when(mScanDetailCache.getScanResult(sBSSID)).thenReturn( + getGoogleGuestScanDetail(TEST_RSSI, sBSSID, sFreq).getScanResult()); + + // before the fist success connection, there is no valid wifi info. + assertEquals(WifiConfiguration.INVALID_NETWORK_ID, mCmi.getWifiInfo().getNetworkId()); + + mCmi.sendMessage(WifiMonitor.SUPPLICANT_STATE_CHANGE_EVENT, 0, 0, + new StateChangeResult(FRAMEWORK_NETWORK_ID, + sWifiSsid, sBSSID, SupplicantState.ASSOCIATED)); + mLooper.dispatchAll(); + + // retrieve correct wifi info on receiving the supplicant state change event. + assertEquals(FRAMEWORK_NETWORK_ID, mCmi.getWifiInfo().getNetworkId()); + assertEquals(mConnectedNetwork.ephemeral, mCmi.getWifiInfo().isEphemeral()); + assertEquals(mConnectedNetwork.trusted, mCmi.getWifiInfo().isTrusted()); + assertEquals(mConnectedNetwork.osu, mCmi.getWifiInfo().isOsuAp()); + } } |