summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRoshan Pius <rpius@google.com>2020-05-31 16:19:45 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2020-05-31 16:19:45 +0000
commit552cfec4db5eb8bb4979436f8eba7373d9e2834c (patch)
tree403ee4dc18df875784f60d6670114c6880fd1316 /tests
parent3bd823f2ca68e508a8d406a85cdc46e2d905a7e1 (diff)
parenta442338fbb51bc797ab03eca48d3b0bc0c454e2e (diff)
Merge changes I514b5b3a,Id67082c5 into rvc-dev
* changes: ClientModeImpl: Ignore connect when connecting to network WifiDiagnostics: Add a timeout for logcat calls
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java54
1 files changed, 54 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 bb9db6d51..bc29d34b7 100644
--- a/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java
@@ -1538,6 +1538,60 @@ public class ClientModeImplTest extends WifiBaseTest {
}
/**
+ * If caller tries to connect to a network that is already connecting, the connection request
+ * should succeed.
+ *
+ * Test: Create and trigger connect to a network, then try to reconnect to the same network.
+ * Verify that connection request returns with CONNECT_NETWORK_SUCCEEDED and did not trigger a
+ * new connection.
+ */
+ @Test
+ public void reconnectToConnectingNetwork() throws Exception {
+ triggerConnect();
+
+ // try to reconnect to the same network (before connection is established).
+ IActionListener connectActionListener = mock(IActionListener.class);
+ mCmi.connect(null, FRAMEWORK_NETWORK_ID, mock(Binder.class), connectActionListener, 0,
+ Binder.getCallingUid());
+ mLooper.dispatchAll();
+ verify(connectActionListener).onSuccess();
+
+ // Verify that we didn't trigger a second connection.
+ verify(mWifiNative, times(1)).connectToNetwork(eq(WIFI_IFACE_NAME), any());
+ }
+
+ /**
+ * If caller tries to connect to a network that is already connecting, the connection request
+ * should succeed.
+ *
+ * Test: Create and trigger connect to a network, then try to reconnect to the same network.
+ * Verify that connection request returns with CONNECT_NETWORK_SUCCEEDED and did trigger a new
+ * connection.
+ */
+ @Test
+ public void reconnectToConnectingNetworkWithCredentialChange() throws Exception {
+ triggerConnect();
+
+ // try to reconnect to the same network with a credential changed (before connection is
+ // established).
+ WifiConfiguration config = new WifiConfiguration();
+ config.networkId = FRAMEWORK_NETWORK_ID;
+ NetworkUpdateResult networkUpdateResult =
+ new NetworkUpdateResult(false /* ip */, false /* proxy */, true /* credential */);
+ networkUpdateResult.setNetworkId(FRAMEWORK_NETWORK_ID);
+ when(mWifiConfigManager.addOrUpdateNetwork(eq(config), anyInt()))
+ .thenReturn(networkUpdateResult);
+ IActionListener connectActionListener = mock(IActionListener.class);
+ mCmi.connect(config, WifiConfiguration.INVALID_NETWORK_ID, mock(Binder.class),
+ connectActionListener, 0, Binder.getCallingUid());
+ mLooper.dispatchAll();
+ verify(connectActionListener).onSuccess();
+
+ // Verify that we triggered a second connection.
+ verify(mWifiNative, times(2)).connectToNetwork(eq(WIFI_IFACE_NAME), any());
+ }
+
+ /**
* If caller tries to connect to a new network while still provisioning the current one,
* the connection attempt should succeed.
*/