summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJimmy Chen <jimmycmchen@google.com>2020-03-24 04:44:23 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2020-03-24 04:44:23 +0000
commit70f3e3846b6544788a56dcb62eee807e4e6dd77b (patch)
tree7c49a59984b12bf3bc39ea94c552402dbaacf2be /tests
parent44f8e09fa0da59aa5d9519715635b9ec9af69e48 (diff)
parent21b91439e158c9a5de1db23de56c2cb6d89b3021 (diff)
Merge "Wifi: fix inconsistent state in handleSupplicantStateChange" into rvc-dev
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java34
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 42bcd0013..865d4ac25 100644
--- a/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java
@@ -4771,4 +4771,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());
+ }
}