diff options
author | TreeHugger Robot <treehugger-gerrit@google.com> | 2017-05-19 01:26:46 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2017-05-19 01:26:49 +0000 |
commit | f4232f9036f66fd505786dff0a3d6e84f78c8168 (patch) | |
tree | d0bf2a660c16e263d7a10744491f7e67f6d028e5 /tests | |
parent | 56a5f2f6e07086346829c5681ba37395c1521d2e (diff) | |
parent | 8131b04dc799cb0c75240c7b9eb0517ba1f00be8 (diff) |
Merge "WifiNative: Add VINTF check for vendor HAL" into oc-dev
Diffstat (limited to 'tests')
3 files changed, 92 insertions, 10 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/HalDeviceManagerTest.java b/tests/wifitests/src/com/android/server/wifi/HalDeviceManagerTest.java index 570100bbf..3e203a666 100644 --- a/tests/wifitests/src/com/android/server/wifi/HalDeviceManagerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/HalDeviceManagerTest.java @@ -21,6 +21,8 @@ import static com.android.server.wifi.HalDeviceManager.START_HAL_RETRY_TIMES; import static junit.framework.Assert.assertEquals; import static org.hamcrest.core.IsEqual.equalTo; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyInt; import static org.mockito.Matchers.anyLong; @@ -1050,6 +1052,34 @@ public class HalDeviceManagerTest { executeAndValidateStartupSequence(1, false); } + /** + * Validate that isSupported() returns true when IServiceManager finds the vendor HAL daemon in + * the VINTF. + */ + @Test + public void testIsSupportedTrue() throws Exception { + when(mServiceManagerMock.getTransport( + eq(IWifi.kInterfaceName), eq(HalDeviceManager.HAL_INSTANCE_NAME))) + .thenReturn(IServiceManager.Transport.HWBINDER); + mInOrder = inOrder(mServiceManagerMock, mWifiMock); + executeAndValidateInitializationSequence(); + assertTrue(mDut.isSupported()); + } + + /** + * Validate that isSupported() returns true when IServiceManager finds the vendor HAL daemon in + * the VINTF. + */ + @Test + public void testIsSupportedFalse() throws Exception { + when(mServiceManagerMock.getTransport( + eq(IWifi.kInterfaceName), eq(HalDeviceManager.HAL_INSTANCE_NAME))) + .thenReturn(IServiceManager.Transport.EMPTY); + mInOrder = inOrder(mServiceManagerMock, mWifiMock); + executeAndValidateInitializationSequence(); + assertFalse(mDut.isSupported()); + } + // utilities private void dumpDut(String prefix) { StringWriter sw = new StringWriter(); diff --git a/tests/wifitests/src/com/android/server/wifi/WifiNativeTest.java b/tests/wifitests/src/com/android/server/wifi/WifiNativeTest.java index 281c47a07..b1285042d 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiNativeTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiNativeTest.java @@ -23,6 +23,7 @@ import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.anyBoolean; import static org.mockito.Mockito.eq; import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -151,6 +152,7 @@ public class WifiNativeTest { @Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); + when(mWifiVendorHal.isVendorHalSupported()).thenReturn(true); when(mWifiVendorHal.startVendorHal(anyBoolean())).thenReturn(true); mWifiNative = new WifiNative("test0", mWifiVendorHal, mStaIfaceHal, mWificondControl); } @@ -491,11 +493,27 @@ public class WifiNativeTest { } /** + * Verifies that setupDriverForClientMode() does not call start vendor HAL when it is not + * supported and calls underlying WificondControl setup. + */ + @Test + public void testSetupDriverForClientModeWithNoVendorHal() { + when(mWifiVendorHal.isVendorHalSupported()).thenReturn(false); + IClientInterface clientInterface = mock(IClientInterface.class); + when(mWificondControl.setupDriverForClientMode()).thenReturn(clientInterface); + + IClientInterface returnedClientInterface = mWifiNative.setupForClientMode(); + assertEquals(clientInterface, returnedClientInterface); + verify(mWifiVendorHal, never()).startVendorHal(anyBoolean()); + verify(mWificondControl).setupDriverForClientMode(); + } + + /** * Verifies that setupDriverForClientMode() returns null when underlying WificondControl * call fails. */ @Test - public void testSetupDriverForClientModeError() { + public void testSetupDriverForClientModeWificondError() { when(mWificondControl.setupDriverForClientMode()).thenReturn(null); IClientInterface returnedClientInterface = mWifiNative.setupForClientMode(); @@ -505,6 +523,19 @@ public class WifiNativeTest { } /** + * Verifies that setupDriverForClientMode() returns null when underlying Hal call fails. + */ + @Test + public void testSetupDriverForClientModeHalError() { + when(mWifiVendorHal.startVendorHal(anyBoolean())).thenReturn(false); + + IClientInterface returnedClientInterface = mWifiNative.setupForClientMode(); + assertEquals(null, returnedClientInterface); + verify(mWifiVendorHal).startVendorHal(eq(true)); + verify(mWificondControl, never()).setupDriverForClientMode(); + } + + /** * Verifies that setupDriverForSoftApMode() calls underlying WificondControl. */ @Test @@ -519,11 +550,27 @@ public class WifiNativeTest { } /** + * Verifies that setupDriverForClientMode() does not call start vendor HAL when it is not + * supported and calls underlying WificondControl setup. + */ + @Test + public void testSetupDriverForSoftApModeWithNoVendorHal() { + when(mWifiVendorHal.isVendorHalSupported()).thenReturn(false); + IApInterface apInterface = mock(IApInterface.class); + when(mWificondControl.setupDriverForSoftApMode()).thenReturn(apInterface); + + IApInterface returnedApInterface = mWifiNative.setupForSoftApMode(); + assertEquals(apInterface, returnedApInterface); + verify(mWifiVendorHal, never()).startVendorHal(anyBoolean()); + verify(mWificondControl).setupDriverForSoftApMode(); + } + + /** * Verifies that setupDriverForSoftApMode() returns null when underlying WificondControl * call fails. */ @Test - public void testSetupDriverForSoftApModeError() { + public void testSetupDriverForSoftApModeWificondError() { when(mWificondControl.setupDriverForSoftApMode()).thenReturn(null); IApInterface returnedApInterface = mWifiNative.setupForSoftApMode(); @@ -533,6 +580,19 @@ public class WifiNativeTest { } /** + * Verifies that setupDriverForSoftApMode() returns null when underlying Hal call fails. + */ + @Test + public void testSetupDriverForSoftApModeHalError() { + when(mWifiVendorHal.startVendorHal(anyBoolean())).thenReturn(false); + + IApInterface returnedApInterface = mWifiNative.setupForSoftApMode(); + assertEquals(null, returnedApInterface); + verify(mWifiVendorHal).startVendorHal(eq(false)); + verify(mWificondControl, never()).setupDriverForSoftApMode(); + } + + /** * Verifies that enableSupplicant() calls underlying WificondControl. */ @Test diff --git a/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java b/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java index fc55266ad..dc34e3538 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java @@ -521,14 +521,12 @@ public class WifiStateMachineTest { @Test public void loadComponentsFailure() throws Exception { - when(mWifiNative.startHal(anyBoolean())).thenReturn(false); when(mWifiNative.enableSupplicant()).thenReturn(false); mWsm.setSupplicantRunning(true); mLooper.dispatchAll(); assertEquals("InitialState", getCurrentState().getName()); - when(mWifiNative.startHal(anyBoolean())).thenReturn(true); mWsm.setSupplicantRunning(true); mLooper.dispatchAll(); assertEquals("InitialState", getCurrentState().getName()); @@ -548,8 +546,6 @@ public class WifiStateMachineTest { @Test public void shouldStartSupplicantWhenConnectModeRequested() throws Exception { - when(mWifiNative.startHal(anyBoolean())).thenReturn(true); - // The first time we start out in InitialState, we sit around here. mLooper.dispatchAll(); assertEquals("InitialState", getCurrentState().getName()); @@ -566,8 +562,6 @@ public class WifiStateMachineTest { */ @Test public void checkIsWifiEnabledForModeChanges() throws Exception { - when(mWifiNative.startHal(anyBoolean())).thenReturn(true); - // Check initial state mLooper.dispatchAll(); assertEquals("InitialState", getCurrentState().getName()); @@ -638,8 +632,6 @@ public class WifiStateMachineTest { */ @Test public void checkStartInCorrectStateAfterChangingInitialState() throws Exception { - when(mWifiNative.startHal(anyBoolean())).thenReturn(true); - // Check initial state mLooper.dispatchAll(); assertEquals("InitialState", getCurrentState().getName()); |