diff options
author | TreeHugger Robot <treehugger-gerrit@google.com> | 2018-03-13 18:30:01 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2018-03-13 18:30:01 +0000 |
commit | 2e6ff3b94f8c780d589619111c87e39931cacfb6 (patch) | |
tree | 7607b89e976129acd09e5e010f6100d90c850195 /tests | |
parent | 6e40128e26b6aa86fbd4a046c09e8a62ca93aa6c (diff) | |
parent | f4e144565d1dba55e25ab7b454a7eb7d4a6f8290 (diff) |
Merge changes I90340ea2,Ib1f49af3,I86b0efdb,I7e7f3768 into pi-dev
* changes:
WifiNative: Ensure we have a consistent death handling mechanism
WificondControl: Always check for existing ifaces
SupplicantP2pIfaceHal: Always check for existing ifaces
SupplicantStaIfaceHal: Always check for existing ifaces
Diffstat (limited to 'tests')
3 files changed, 70 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 e0e296fa5..d3f044f83 100644 --- a/tests/wifitests/src/com/android/server/wifi/SupplicantStaIfaceHalTest.java +++ b/tests/wifitests/src/com/android/server/wifi/SupplicantStaIfaceHalTest.java @@ -272,6 +272,19 @@ public class SupplicantStaIfaceHalTest { } /** + * Ensures that reject addition of an existing iface. + */ + @Test + public void testDuplicateSetupIfaceV1_1_Fails() throws Exception { + mISupplicantMockV1_1 = mock(android.hardware.wifi.supplicant.V1_1.ISupplicant.class); + executeAndValidateInitializationSequenceV1_1(false, false); + + // Trying setting up the wlan0 interface again & ensure it fails. + assertFalse(mDut.setupIface(WLAN0_IFACE_NAME)); + verifyNoMoreInteractions(mISupplicantMockV1_1); + } + + /** * Sunny day scenario for SupplicantStaIfaceHal interface teardown. */ @Test @@ -301,6 +314,15 @@ public class SupplicantStaIfaceHalTest { } /** + * Ensures that we reject removal of an invalid iface. + */ + @Test + public void testInvalidTeardownInterfaceV1_1_Fails() throws Exception { + assertFalse(mDut.teardownIface(WLAN0_IFACE_NAME)); + verifyNoMoreInteractions(mISupplicantMock); + } + + /** * Sunny day scenario for SupplicantStaIfaceHal initialization * Asserts successful initialization of second interface */ diff --git a/tests/wifitests/src/com/android/server/wifi/WificondControlTest.java b/tests/wifitests/src/com/android/server/wifi/WificondControlTest.java index bcb03b39a..8336c03eb 100644 --- a/tests/wifitests/src/com/android/server/wifi/WificondControlTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WificondControlTest.java @@ -251,6 +251,19 @@ public class WificondControlTest { * Verifies that tearDownClientInterface(TEST_INTERFACE_NAME) calls Wificond. */ @Test + public void testTeardownClientInterfaceOnInvalidIface() throws Exception { + when(mWificond.tearDownClientInterface(TEST_INTERFACE_NAME1)).thenReturn(true); + + assertFalse(mWificondControl.tearDownClientInterface(TEST_INTERFACE_NAME1)); + verify(mWifiScannerImpl, never()).unsubscribeScanEvents(); + verify(mWifiScannerImpl, never()).unsubscribePnoScanEvents(); + verify(mWificond, never()).tearDownClientInterface(any()); + } + + /** + * Verifies that tearDownClientInterface(TEST_INTERFACE_NAME) calls Wificond. + */ + @Test public void testTeardownClientInterfaceFailDueToExceptionScannerUnsubscribe() throws Exception { when(mWificond.tearDownClientInterface(TEST_INTERFACE_NAME)).thenReturn(true); doThrow(new RemoteException()).when(mWifiScannerImpl).unsubscribeScanEvents(); @@ -349,6 +362,18 @@ public class WificondControlTest { } /** + * Verifies that tearDownSoftapInterface(TEST_INTERFACE_NAME) calls Wificond. + */ + @Test + public void testTeardownSoftApInterfaceOnInvalidIface() throws Exception { + testSetupInterfaceForSoftApMode(); + when(mWificond.tearDownApInterface(TEST_INTERFACE_NAME1)).thenReturn(true); + + assertFalse(mWificondControl.tearDownSoftApInterface(TEST_INTERFACE_NAME1)); + verify(mWificond, never()).tearDownApInterface(any()); + } + + /** * Verifies that tearDownClientInterface(TEST_INTERFACE_NAME) calls Wificond. */ @Test diff --git a/tests/wifitests/src/com/android/server/wifi/p2p/SupplicantP2pIfaceHalTest.java b/tests/wifitests/src/com/android/server/wifi/p2p/SupplicantP2pIfaceHalTest.java index 33dd4a659..cda1aae83 100644 --- a/tests/wifitests/src/com/android/server/wifi/p2p/SupplicantP2pIfaceHalTest.java +++ b/tests/wifitests/src/com/android/server/wifi/p2p/SupplicantP2pIfaceHalTest.java @@ -23,6 +23,7 @@ import static org.mockito.Mockito.inOrder; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyNoMoreInteractions; import static org.mockito.Mockito.when; import android.app.test.MockAnswerUtil.AnswerWithArguments; @@ -263,6 +264,19 @@ public class SupplicantP2pIfaceHalTest { } /** + * Ensures that reject addition of an existing iface. + */ + @Test + public void testDuplicateSetupIfaceV1_1_Fails() throws Exception { + mISupplicantMockV1_1 = mock(android.hardware.wifi.supplicant.V1_1.ISupplicant.class); + executeAndValidateInitializationSequenceV1_1(false, false); + + // Trying setting up the p2p0 interface again & ensure it fails. + assertFalse(mDut.setupIface(mIfaceName)); + verifyNoMoreInteractions(mISupplicantMockV1_1); + } + + /** * Sunny day scenario for SupplicantStaIfaceHal teardown. * Asserts successful teardown. * Note: Only applicable for 1.1 supplicant HAL. @@ -279,6 +293,15 @@ public class SupplicantP2pIfaceHalTest { } /** + * Ensures that we reject removal of an invalid iface. + */ + @Test + public void testInvalidTeardownInterfaceV1_1_Fails() throws Exception { + assertFalse(mDut.teardownIface(mIfaceName)); + verifyNoMoreInteractions(mISupplicantMock); + } + + /** * Sunny day scenario for getName() */ @Test |