summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRoshan Pius <rpius@google.com>2017-02-14 10:17:15 -0800
committerRoshan Pius <rpius@google.com>2017-02-16 09:12:20 -0800
commit0a3dcd72290481cb1fcbaaec268cccf343e4ff48 (patch)
tree635246008592050584ad0dc8ee34e790cbaccd89 /tests
parent3aa9b7e616f685ded8fade523317e96cedcdcc2d (diff)
SupplicantStaIfaceHal: Expose current network methods
Expose methods to set bssid of the currently configured network and retrieve the NFC token of the network. While there, Add unit test for the removal of all networks from wpa_supplicant. Bug: 33383725 Test: Unit tests. Change-Id: Ibfff7a3349967c851a3cde62e082aa5d6ec2ee91
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/SupplicantStaIfaceHalTest.java59
-rw-r--r--tests/wifitests/src/com/android/server/wifi/SupplicantStaNetworkHalTest.java21
2 files changed, 80 insertions, 0 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/SupplicantStaIfaceHalTest.java b/tests/wifitests/src/com/android/server/wifi/SupplicantStaIfaceHalTest.java
index a0caad09d..2dc2eaa13 100644
--- a/tests/wifitests/src/com/android/server/wifi/SupplicantStaIfaceHalTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/SupplicantStaIfaceHalTest.java
@@ -472,6 +472,29 @@ public class SupplicantStaIfaceHalTest {
}
/**
+ * Tests removal of all configured networks from wpa_supplicant.
+ */
+ @Test
+ public void testRemoveAllNetworks() throws Exception {
+ executeAndValidateInitializationSequence(false, false, false);
+ doAnswer(new MockAnswerUtil.AnswerWithArguments() {
+ public void answer(ISupplicantStaIface.listNetworksCallback cb) {
+ cb.onValues(mStatusSuccess, new ArrayList<>(NETWORK_ID_TO_SSID.keySet()));
+ }
+ }).when(mISupplicantStaIfaceMock)
+ .listNetworks(any(ISupplicantStaIface.listNetworksCallback.class));
+ doAnswer(new MockAnswerUtil.AnswerWithArguments() {
+ public SupplicantStatus answer(int id) {
+ assertTrue(NETWORK_ID_TO_SSID.containsKey(id));
+ return mStatusSuccess;
+ }
+ }).when(mISupplicantStaIfaceMock).removeNetwork(anyInt());
+
+ assertTrue(mDut.removeAllNetworks());
+ verify(mISupplicantStaIfaceMock, times(NETWORK_ID_TO_SSID.size())).removeNetwork(anyInt());
+ }
+
+ /**
* Tests roaming failure because of unable to reassociate.
*/
@Test
@@ -494,6 +517,42 @@ public class SupplicantStaIfaceHalTest {
}
/**
+ * Tests the retrieval of WPS NFC token.
+ */
+ @Test
+ public void testGetCurrentNetworkWpsNfcConfigurationToken() throws Exception {
+ String token = "45adbc1";
+ when(mSupplicantStaNetworkMock.getWpsNfcConfigurationToken()).thenReturn(token);
+
+ executeAndValidateInitializationSequence(false, false, false);
+
+ // Return null when not connected to the network.
+ assertTrue(mDut.getCurrentNetworkWpsNfcConfigurationToken() == null);
+
+ executeAndValidateConnectSequence(4, false, false);
+
+ assertEquals(token, mDut.getCurrentNetworkWpsNfcConfigurationToken());
+ }
+
+ /**
+ * Tests the retrieval of WPS NFC token.
+ */
+ @Test
+ public void testSetCurrentNetworkBssid() throws Exception {
+ String bssidStr = "34:34:12:12:12:90";
+ when(mSupplicantStaNetworkMock.setBssid(eq(bssidStr))).thenReturn(true);
+
+ executeAndValidateInitializationSequence(false, false, false);
+
+ // Fail when not connected to a network.
+ assertFalse(mDut.setCurrentNetworkBssid(bssidStr));
+
+ executeAndValidateConnectSequence(4, false, false);
+
+ assertTrue(mDut.setCurrentNetworkBssid(bssidStr));
+ }
+
+ /**
* Calls.initialize(), mocking various call back answers and verifying flow, asserting for the
* expected result. Verifies if ISupplicantStaIface manager is initialized or reset.
* Each of the arguments will cause a different failure mode when set true.
diff --git a/tests/wifitests/src/com/android/server/wifi/SupplicantStaNetworkHalTest.java b/tests/wifitests/src/com/android/server/wifi/SupplicantStaNetworkHalTest.java
index 6021b1c7d..780b39cd7 100644
--- a/tests/wifitests/src/com/android/server/wifi/SupplicantStaNetworkHalTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/SupplicantStaNetworkHalTest.java
@@ -617,6 +617,27 @@ public class SupplicantStaNetworkHalTest {
}
/**
+ * Tests the retrieval of WPS NFC token.
+ */
+ @Test
+ public void testGetWpsNfcConfigurationToken() throws Exception {
+ final ArrayList<Byte> token = new ArrayList<>();
+ token.add(Byte.valueOf((byte) 0x45));
+ token.add(Byte.valueOf((byte) 0x34));
+
+ doAnswer(new AnswerWithArguments() {
+ public void answer(ISupplicantStaNetwork.getWpsNfcConfigurationTokenCallback cb)
+ throws RemoteException {
+ cb.onValues(mStatusSuccess, token);
+ }
+ }).when(mISupplicantStaNetworkMock)
+ .getWpsNfcConfigurationToken(
+ any(ISupplicantStaNetwork.getWpsNfcConfigurationTokenCallback.class));
+
+ assertEquals("4534", mSupplicantNetwork.getWpsNfcConfigurationToken());
+ }
+
+ /**
* Sets up the HIDL interface mock with all the setters/getter values.
* Note: This only sets up the mock to return success on all methods.
*/