diff options
author | Etan Cohen <etancohen@google.com> | 2019-11-26 11:51:33 -0800 |
---|---|---|
committer | Etan Cohen <etancohen@google.com> | 2019-12-09 20:56:23 -0800 |
commit | 395983b1f1e42f7956b77f909340bd510996bc44 (patch) | |
tree | 52866fb25be8a728cc42ff334b171c297a2bd988 /tests | |
parent | e94666568f2a1187a036b8da85828d42f196e1a2 (diff) |
[WIFI][MAINLINE] Transition WificondControl interfaces: scan callbacks
Transition WificondControl public interfaces to that class itself.
Preparation for the class being extracted to an official API.
Classes shifted: scan callbacks
Bug: 140062898
Test: atest android.net.wifi
Test: atest com.android.server.wifi
Change-Id: I9fea54a61120928d61def25e30761d6d64c729eb
Diffstat (limited to 'tests')
3 files changed, 182 insertions, 69 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiNativeInterfaceManagementTest.java b/tests/wifitests/src/com/android/server/wifi/WifiNativeInterfaceManagementTest.java index aa46d5f7e..ad995abe4 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiNativeInterfaceManagementTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiNativeInterfaceManagementTest.java @@ -37,8 +37,6 @@ import static org.mockito.Mockito.when; import android.app.test.MockAnswerUtil; import android.net.InterfaceConfiguration; -import android.net.wifi.IApInterface; -import android.net.wifi.IClientInterface; import android.net.wifi.SoftApConfiguration; import android.net.wifi.WifiScanner; import android.os.Handler; @@ -132,10 +130,8 @@ public class WifiNativeInterfaceManagementTest extends WifiBaseTest { when(mWificondControl.initialize(mWificondDeathHandlerCaptor.capture())) .thenReturn(true); - when(mWificondControl.setupInterfaceForClientMode(any())) - .thenReturn(mock(IClientInterface.class)); - when(mWificondControl.setupInterfaceForSoftApMode(any())) - .thenReturn(mock(IApInterface.class)); + when(mWificondControl.setupInterfaceForClientMode(any(), any(), any())).thenReturn(true); + when(mWificondControl.setupInterfaceForSoftApMode(any())).thenReturn(true); when(mWificondControl.tearDownClientInterface(any())).thenReturn(true); when(mWificondControl.tearDownSoftApInterface(any())).thenReturn(true); when(mWificondControl.tearDownInterfaces()).thenReturn(true); @@ -495,7 +491,8 @@ public class WifiNativeInterfaceManagementTest extends WifiBaseTest { validateOnDestroyedSoftApInterface( true, false, IFACE_NAME_0, mIfaceCallback0, mNetworkObserverCaptor0.getValue()); // Now continue with rest of STA interface setup. - mInOrder.verify(mWificondControl).setupInterfaceForClientMode(IFACE_NAME_0); + mInOrder.verify(mWificondControl).setupInterfaceForClientMode(eq(IFACE_NAME_0), any(), + any()); mInOrder.verify(mSupplicantStaIfaceHal).setupIface(IFACE_NAME_0); mInOrder.verify(mNwManagementService).registerObserver(mNetworkObserverCaptor1.capture()); mInOrder.verify(mWifiMonitor).startMonitoring(IFACE_NAME_0); @@ -880,7 +877,7 @@ public class WifiNativeInterfaceManagementTest extends WifiBaseTest { @Test public void testSetupClientInterfaceFailureInWificondSetupInterfaceForClientMode() throws Exception { - when(mWificondControl.setupInterfaceForClientMode(any())).thenReturn(null); + when(mWificondControl.setupInterfaceForClientMode(any(), any(), any())).thenReturn(false); assertNull(mWifiNative.setupInterfaceForClientInConnectivityMode(mIfaceCallback0)); mInOrder.verify(mWifiVendorHal).isVendorHalSupported(); @@ -893,7 +890,7 @@ public class WifiNativeInterfaceManagementTest extends WifiBaseTest { mInOrder.verify(mWifiVendorHal).isVendorHalSupported(); mInOrder.verify(mWifiVendorHal).createStaIface(eq(false), mIfaceDestroyedListenerCaptor0.capture()); - mInOrder.verify(mWificondControl).setupInterfaceForClientMode(any()); + mInOrder.verify(mWificondControl).setupInterfaceForClientMode(any(), any(), any()); mInOrder.verify(mWifiVendorHal).isVendorHalSupported(); mInOrder.verify(mWifiVendorHal).removeStaIface(any()); mInOrder.verify(mWifiMetrics).incrementNumSetupClientInterfaceFailureDueToWificond(); @@ -927,7 +924,7 @@ public class WifiNativeInterfaceManagementTest extends WifiBaseTest { mInOrder.verify(mWifiVendorHal).isVendorHalSupported(); mInOrder.verify(mWifiVendorHal).createStaIface(eq(false), mIfaceDestroyedListenerCaptor0.capture()); - mInOrder.verify(mWificondControl).setupInterfaceForClientMode(any()); + mInOrder.verify(mWificondControl).setupInterfaceForClientMode(any(), any(), any()); mInOrder.verify(mSupplicantStaIfaceHal).setupIface(any()); mInOrder.verify(mWifiVendorHal).isVendorHalSupported(); mInOrder.verify(mWifiVendorHal).removeStaIface(any()); @@ -962,7 +959,7 @@ public class WifiNativeInterfaceManagementTest extends WifiBaseTest { mInOrder.verify(mWifiVendorHal).isVendorHalSupported(); mInOrder.verify(mWifiVendorHal).createStaIface(eq(false), mIfaceDestroyedListenerCaptor0.capture()); - mInOrder.verify(mWificondControl).setupInterfaceForClientMode(any()); + mInOrder.verify(mWificondControl).setupInterfaceForClientMode(any(), any(), any()); mInOrder.verify(mSupplicantStaIfaceHal).setupIface(any()); mInOrder.verify(mNwManagementService).registerObserver(mNetworkObserverCaptor0.capture()); mInOrder.verify(mWifiVendorHal).isVendorHalSupported(); @@ -1049,7 +1046,7 @@ public class WifiNativeInterfaceManagementTest extends WifiBaseTest { @Test public void testSetupSoftApInterfaceFailureInWificondSetupInterfaceForSoftapMode() throws Exception { - when(mWificondControl.setupInterfaceForSoftApMode(any())).thenReturn(null); + when(mWificondControl.setupInterfaceForSoftApMode(any())).thenReturn(false); assertNull(mWifiNative.setupInterfaceForSoftApMode(mIfaceCallback0)); mInOrder.verify(mWifiVendorHal).isVendorHalSupported(); @@ -1167,7 +1164,8 @@ public class WifiNativeInterfaceManagementTest extends WifiBaseTest { mInOrder.verify(mSupplicantStaIfaceHal).isInitializationComplete(); mInOrder.verify(mSupplicantStaIfaceHal).registerDeathHandler(any()); mInOrder.verify(mWifiVendorHal).isVendorHalSupported(); - mInOrder.verify(mWificondControl).setupInterfaceForClientMode(IFACE_NAME_0); + mInOrder.verify(mWificondControl).setupInterfaceForClientMode(eq(IFACE_NAME_0), any(), + any()); mInOrder.verify(mSupplicantStaIfaceHal).setupIface(IFACE_NAME_0); mInOrder.verify(mNwManagementService).registerObserver(mNetworkObserverCaptor0.capture()); mInOrder.verify(mWifiMonitor).startMonitoring(IFACE_NAME_0); @@ -1253,7 +1251,8 @@ public class WifiNativeInterfaceManagementTest extends WifiBaseTest { mInOrder.verify(mHostapdHal).terminate(); mInOrder.verify(mIfaceCallback0).onDestroyed(IFACE_NAME_0); // Now continue with rest of STA interface setup. - mInOrder.verify(mWificondControl).setupInterfaceForClientMode(IFACE_NAME_0); + mInOrder.verify(mWificondControl).setupInterfaceForClientMode(eq(IFACE_NAME_0), any(), + any()); mInOrder.verify(mSupplicantStaIfaceHal).setupIface(IFACE_NAME_0); mInOrder.verify(mNwManagementService).registerObserver(mNetworkObserverCaptor1.capture()); mInOrder.verify(mWifiMonitor).startMonitoring(IFACE_NAME_0); @@ -1399,7 +1398,7 @@ public class WifiNativeInterfaceManagementTest extends WifiBaseTest { mInOrder.verify(mWifiVendorHal).isVendorHalSupported(); mInOrder.verify(mWifiVendorHal).createStaIface(eq(false), destroyedListenerCaptor.capture()); - mInOrder.verify(mWificondControl).setupInterfaceForClientMode(ifaceName); + mInOrder.verify(mWificondControl).setupInterfaceForClientMode(eq(ifaceName), any(), any()); mInOrder.verify(mSupplicantStaIfaceHal).setupIface(ifaceName); mInOrder.verify(mNwManagementService).registerObserver(networkObserverCaptor.capture()); mInOrder.verify(mWifiMonitor).startMonitoring(ifaceName); @@ -1476,7 +1475,7 @@ public class WifiNativeInterfaceManagementTest extends WifiBaseTest { mInOrder.verify(mWifiVendorHal).isVendorHalSupported(); mInOrder.verify(mWifiVendorHal).createStaIface(eq(false), destroyedListenerCaptor.capture()); - mInOrder.verify(mWificondControl).setupInterfaceForClientMode(ifaceName); + mInOrder.verify(mWificondControl).setupInterfaceForClientMode(eq(ifaceName), any(), any()); mInOrder.verify(mNwManagementService).registerObserver(networkObserverCaptor.capture()); mInOrder.verify(mWifiMonitor).startMonitoring(ifaceName); mInOrder.verify(mNwManagementService).getInterfaceConfig(ifaceName); diff --git a/tests/wifitests/src/com/android/server/wifi/WifiNativeTest.java b/tests/wifitests/src/com/android/server/wifi/WifiNativeTest.java index f46c50f6d..cfa555f22 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiNativeTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiNativeTest.java @@ -49,6 +49,7 @@ import com.android.server.wifi.wificond.RadioChainInfo; import org.junit.Before; import org.junit.Test; import org.mockito.AdditionalMatchers; +import org.mockito.ArgumentCaptor; import org.mockito.Mock; import org.mockito.MockitoAnnotations; @@ -249,14 +250,29 @@ public class WifiNativeTest extends WifiBaseTest { @Mock private Handler mHandler; @Mock private SendMgmtFrameCallback mSendMgmtFrameCallback; @Mock private Random mRandom; + + ArgumentCaptor<WificondControl.ScanEventCallback> mScanCallbackCaptor = + ArgumentCaptor.forClass(WificondControl.ScanEventCallback.class); + private WifiNative mWifiNative; @Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); when(mWifiVendorHal.isVendorHalSupported()).thenReturn(true); + when(mWifiVendorHal.startVendorHal()).thenReturn(true); when(mWifiVendorHal.startVendorHalSta()).thenReturn(true); when(mWifiVendorHal.startVendorHalAp()).thenReturn(true); + when(mWifiVendorHal.createStaIface(anyBoolean(), any())).thenReturn(WIFI_IFACE_NAME); + + when(mWificondControl.setupInterfaceForClientMode(any(), any(), any())).thenReturn(true); + + when(mStaIfaceHal.registerDeathHandler(any())).thenReturn(true); + when(mStaIfaceHal.isInitializationComplete()).thenReturn(true); + when(mStaIfaceHal.initialize()).thenReturn(true); + when(mStaIfaceHal.startDaemon()).thenReturn(true); + when(mStaIfaceHal.setupIface(any())).thenReturn(true); + mWifiNative = new WifiNative( mWifiVendorHal, mStaIfaceHal, mHostapdHal, mWificondControl, mWifiMonitor, mNwService, mPropertyService, mWifiMetrics, mCarrierNetworkConfig, @@ -587,6 +603,113 @@ public class WifiNativeTest extends WifiBaseTest { // TODO(b/28005116): Add test for the success case of getDriverStateDump(). /** + * Verifies client mode + scan success. + */ + @Test + public void testClientModeScanSuccess() { + mWifiNative.setupInterfaceForClientInConnectivityMode(null); + verify(mWificondControl).setupInterfaceForClientMode(eq(WIFI_IFACE_NAME), + mScanCallbackCaptor.capture(), any()); + + mScanCallbackCaptor.getValue().onScanResultReady(); + verify(mWifiMonitor).broadcastScanResultEvent(WIFI_IFACE_NAME); + } + + /** + * Verifies client mode + scan failure. + */ + @Test + public void testClientModeScanFailure() { + mWifiNative.setupInterfaceForClientInConnectivityMode(null); + verify(mWificondControl).setupInterfaceForClientMode(eq(WIFI_IFACE_NAME), + mScanCallbackCaptor.capture(), any()); + + mScanCallbackCaptor.getValue().onScanFailed(); + verify(mWifiMonitor).broadcastScanFailedEvent(WIFI_IFACE_NAME); + } + + /** + * Verifies client mode + PNO scan success. + */ + @Test + public void testClientModePnoScanSuccess() { + mWifiNative.setupInterfaceForClientInConnectivityMode(null); + verify(mWificondControl).setupInterfaceForClientMode(eq(WIFI_IFACE_NAME), + any(), mScanCallbackCaptor.capture()); + + mScanCallbackCaptor.getValue().onScanResultReady(); + verify(mWifiMonitor).broadcastPnoScanResultEvent(WIFI_IFACE_NAME); + verify(mWifiMetrics).incrementPnoFoundNetworkEventCount(); + } + + /** + * Verifies client mode + PNO scan failure. + */ + @Test + public void testClientModePnoScanFailure() { + mWifiNative.setupInterfaceForClientInConnectivityMode(null); + verify(mWificondControl).setupInterfaceForClientMode(eq(WIFI_IFACE_NAME), + any(), mScanCallbackCaptor.capture()); + + mScanCallbackCaptor.getValue().onScanFailed(); + verify(mWifiMetrics).incrementPnoScanFailedCount(); + } + + /** + * Verifies scan mode + scan success. + */ + @Test + public void testScanModeScanSuccess() { + mWifiNative.setupInterfaceForClientInScanMode(null); + verify(mWificondControl).setupInterfaceForClientMode(eq(WIFI_IFACE_NAME), + mScanCallbackCaptor.capture(), any()); + + mScanCallbackCaptor.getValue().onScanResultReady(); + verify(mWifiMonitor).broadcastScanResultEvent(WIFI_IFACE_NAME); + } + + /** + * Verifies scan mode + scan failure. + */ + @Test + public void testScanModeScanFailure() { + mWifiNative.setupInterfaceForClientInScanMode(null); + verify(mWificondControl).setupInterfaceForClientMode(eq(WIFI_IFACE_NAME), + mScanCallbackCaptor.capture(), any()); + + mScanCallbackCaptor.getValue().onScanFailed(); + verify(mWifiMonitor).broadcastScanFailedEvent(WIFI_IFACE_NAME); + } + + /** + * Verifies scan mode + PNO scan success. + */ + @Test + public void testCScanModePnoScanSuccess() { + mWifiNative.setupInterfaceForClientInScanMode(null); + verify(mWificondControl).setupInterfaceForClientMode(eq(WIFI_IFACE_NAME), + any(), mScanCallbackCaptor.capture()); + + mScanCallbackCaptor.getValue().onScanResultReady(); + verify(mWifiMonitor).broadcastPnoScanResultEvent(WIFI_IFACE_NAME); + verify(mWifiMetrics).incrementPnoFoundNetworkEventCount(); + } + + /** + * Verifies scan mode + PNO scan failure. + */ + @Test + public void testScanModePnoScanFailure() { + mWifiNative.setupInterfaceForClientInScanMode(null); + verify(mWificondControl).setupInterfaceForClientMode(eq(WIFI_IFACE_NAME), + any(), mScanCallbackCaptor.capture()); + + mScanCallbackCaptor.getValue().onScanFailed(); + verify(mWifiMetrics).incrementPnoScanFailedCount(); + } + + + /** * Verifies that signalPoll() calls underlying WificondControl. */ @Test @@ -652,7 +775,7 @@ public class WifiNativeTest extends WifiBaseTest { @Test public void testGetScanResults() { // Mock the returned array of NativeScanResult. - NativeScanResult[] mockScanResults = {MOCK_NATIVE_SCAN_RESULT}; + List<NativeScanResult> mockScanResults = Arrays.asList(MOCK_NATIVE_SCAN_RESULT); when(mWificondControl.getScanResults(anyString(), anyInt())).thenReturn(mockScanResults); ArrayList<ScanDetail> returnedScanResults = mWifiNative.getScanResults(WIFI_IFACE_NAME); @@ -660,15 +783,15 @@ public class WifiNativeTest extends WifiBaseTest { // AP. So verify carrier network is not checked, since EAP is currently required for a // carrier network. verify(mCarrierNetworkConfig, never()).isCarrierNetwork(anyString()); - assertEquals(mockScanResults.length, returnedScanResults.size()); + assertEquals(mockScanResults.size(), returnedScanResults.size()); // Since NativeScanResult is organized differently from ScanResult, this only checks // a few fields. - for (int i = 0; i < mockScanResults.length; i++) { - assertArrayEquals(mockScanResults[i].ssid, + for (int i = 0; i < mockScanResults.size(); i++) { + assertArrayEquals(mockScanResults.get(i).ssid, returnedScanResults.get(i).getScanResult().SSID.getBytes()); - assertEquals(mockScanResults[i].frequency, + assertEquals(mockScanResults.get(i).frequency, returnedScanResults.get(i).getScanResult().frequency); - assertEquals(mockScanResults[i].tsf, + assertEquals(mockScanResults.get(i).tsf, returnedScanResults.get(i).getScanResult().timestamp); } } @@ -689,7 +812,7 @@ public class WifiNativeTest extends WifiBaseTest { NativeScanResult nativeScanResult = createMockNativeScanResult(); nativeScanResult.infoElement = out.toByteArray(); when(mWificondControl.getScanResults(anyString(), anyInt())).thenReturn( - new NativeScanResult[]{nativeScanResult}); + Arrays.asList(nativeScanResult)); // AP associated with a carrier network. int eapType = WifiEnterpriseConfig.Eap.SIM; @@ -735,7 +858,7 @@ public class WifiNativeTest extends WifiBaseTest { List<RadioChainInfo> nativeRadioChainInfos = Arrays.asList( MOCK_NATIVE_RADIO_CHAIN_INFO_1, MOCK_NATIVE_RADIO_CHAIN_INFO_2); nativeScanResult.radioChainInfos = nativeRadioChainInfos; - NativeScanResult[] mockScanResults = { nativeScanResult }; + List<NativeScanResult> mockScanResults = Arrays.asList(nativeScanResult); when(mWificondControl.getScanResults(anyString(), anyInt())).thenReturn(mockScanResults); @@ -744,15 +867,15 @@ public class WifiNativeTest extends WifiBaseTest { // AP. So verify carrier network is not checked, since EAP is currently required for a // carrier network. verify(mCarrierNetworkConfig, never()).isCarrierNetwork(anyString()); - assertEquals(mockScanResults.length, returnedScanResults.size()); + assertEquals(mockScanResults.size(), returnedScanResults.size()); // Since NativeScanResult is organized differently from ScanResult, this only checks // a few fields. - for (int i = 0; i < mockScanResults.length; i++) { - assertArrayEquals(mockScanResults[i].ssid, + for (int i = 0; i < mockScanResults.size(); i++) { + assertArrayEquals(mockScanResults.get(i).ssid, returnedScanResults.get(i).getScanResult().SSID.getBytes()); - assertEquals(mockScanResults[i].frequency, + assertEquals(mockScanResults.get(i).frequency, returnedScanResults.get(i).getScanResult().frequency); - assertEquals(mockScanResults[i].tsf, + assertEquals(mockScanResults.get(i).tsf, returnedScanResults.get(i).getScanResult().timestamp); ScanResult.RadioChainInfo[] scanRcis = returnedScanResults.get( i).getScanResult().radioChainInfos; diff --git a/tests/wifitests/src/com/android/server/wifi/WificondControlTest.java b/tests/wifitests/src/com/android/server/wifi/WificondControlTest.java index e7db2cc1c..93afc4eb1 100644 --- a/tests/wifitests/src/com/android/server/wifi/WificondControlTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WificondControlTest.java @@ -105,6 +105,10 @@ public class WificondControlTest extends WifiBaseTest { private Clock mClock; @Mock private SendMgmtFrameCallback mSendMgmtFrameCallback; + @Mock + private WificondControl.ScanEventCallback mNormalScanCallback; + @Mock + private WificondControl.ScanEventCallback mPnoScanCallback; private TestLooper mLooper; private WificondControl mWificondControl; private static final String TEST_INTERFACE_NAME = "test_wlan_if"; @@ -174,10 +178,10 @@ public class WificondControlTest extends WifiBaseTest { when(mClientInterface.getInterfaceName()).thenReturn(TEST_INTERFACE_NAME); when(mWifiInjector.getWifiMetrics()).thenReturn(mWifiMetrics); mLooper = new TestLooper(); - mWificondControl = new WificondControl(mWifiInjector, mWifiMonitor, + mWificondControl = new WificondControl(mWifiInjector, mAlarmManager, new Handler(mLooper.getLooper()), mClock); - assertEquals(mClientInterface, mWificondControl.setupInterfaceForClientMode( - TEST_INTERFACE_NAME)); + assertEquals(true, mWificondControl.setupInterfaceForClientMode(TEST_INTERFACE_NAME, + mNormalScanCallback, mPnoScanCallback)); verify(mWifiInjector).makeWificond(); verify(mWifiCondBinder).linkToDeath(any(IBinder.DeathRecipient.class), anyInt()); } @@ -210,9 +214,8 @@ public class WificondControlTest extends WifiBaseTest { mWificondControl.binderDied(); mLooper.dispatchAll(); when(mWifiInjector.makeWificond()).thenReturn(null); - IClientInterface returnedClientInterface = - mWificondControl.setupInterfaceForClientMode(TEST_INTERFACE_NAME); - assertEquals(null, returnedClientInterface); + assertEquals(false, mWificondControl.setupInterfaceForClientMode(TEST_INTERFACE_NAME, + mNormalScanCallback, mPnoScanCallback)); verify(mWifiInjector, times(2)).makeWificond(); } @@ -226,9 +229,8 @@ public class WificondControlTest extends WifiBaseTest { when(mWifiInjector.makeWificond()).thenReturn(mWificond); when(mWificond.createClientInterface(TEST_INTERFACE_NAME)).thenReturn(null); - IClientInterface returnedClientInterface = - mWificondControl.setupInterfaceForClientMode(TEST_INTERFACE_NAME); - assertEquals(null, returnedClientInterface); + assertEquals(false, mWificondControl.setupInterfaceForClientMode(TEST_INTERFACE_NAME, + mNormalScanCallback, mPnoScanCallback)); } /** @@ -308,9 +310,7 @@ public class WificondControlTest extends WifiBaseTest { when(mWifiInjector.makeWificond()).thenReturn(mWificond); when(mWificond.createApInterface(TEST_INTERFACE_NAME)).thenReturn(mApInterface); - IApInterface returnedApInterface = - mWificondControl.setupInterfaceForSoftApMode(TEST_INTERFACE_NAME); - assertEquals(mApInterface, returnedApInterface); + assertEquals(true, mWificondControl.setupInterfaceForSoftApMode(TEST_INTERFACE_NAME)); verify(mWifiInjector).makeWificond(); verify(mWifiCondBinder).linkToDeath(any(IBinder.DeathRecipient.class), anyInt()); verify(mWificond).createApInterface(TEST_INTERFACE_NAME); @@ -326,10 +326,7 @@ public class WificondControlTest extends WifiBaseTest { mLooper.dispatchAll(); when(mWifiInjector.makeWificond()).thenReturn(null); - IApInterface returnedApInterface = - mWificondControl.setupInterfaceForSoftApMode(TEST_INTERFACE_NAME); - - assertEquals(null, returnedApInterface); + assertEquals(false, mWificondControl.setupInterfaceForSoftApMode(TEST_INTERFACE_NAME)); verify(mWifiInjector, times(2)).makeWificond(); } @@ -343,9 +340,7 @@ public class WificondControlTest extends WifiBaseTest { when(mWifiInjector.makeWificond()).thenReturn(mWificond); when(mWificond.createApInterface(TEST_INTERFACE_NAME)).thenReturn(null); - IApInterface returnedApInterface = - mWificondControl.setupInterfaceForSoftApMode(TEST_INTERFACE_NAME); - assertEquals(null, returnedApInterface); + assertEquals(false, mWificondControl.setupInterfaceForSoftApMode(TEST_INTERFACE_NAME)); } /** @@ -403,9 +398,7 @@ public class WificondControlTest extends WifiBaseTest { public void testSetupMulitpleInterfaces() throws Exception { when(mWificond.createApInterface(TEST_INTERFACE_NAME1)).thenReturn(mApInterface); - IApInterface returnedApInterface = - mWificondControl.setupInterfaceForSoftApMode(TEST_INTERFACE_NAME1); - assertEquals(mApInterface, returnedApInterface); + assertEquals(true, mWificondControl.setupInterfaceForSoftApMode(TEST_INTERFACE_NAME1)); verify(mWifiInjector).makeWificond(); verify(mWifiCondBinder).linkToDeath(any(IBinder.DeathRecipient.class), anyInt()); @@ -467,7 +460,8 @@ public class WificondControlTest extends WifiBaseTest { when(mWifiInjector.makeWificond()).thenReturn(mWificond); when(mWificond.createClientInterface(TEST_INTERFACE_NAME)).thenReturn(mClientInterface); - mWificondControl.setupInterfaceForClientMode(TEST_INTERFACE_NAME); + mWificondControl.setupInterfaceForClientMode(TEST_INTERFACE_NAME, mNormalScanCallback, + mPnoScanCallback); mWificondControl.signalPoll(TEST_INTERFACE_NAME); verify(mClientInterface).signalPoll(); } @@ -481,9 +475,8 @@ public class WificondControlTest extends WifiBaseTest { when(mWificond.createClientInterface(TEST_INTERFACE_NAME)).thenReturn(mClientInterface); // Configure client interface. - IClientInterface returnedClientInterface = - mWificondControl.setupInterfaceForClientMode(TEST_INTERFACE_NAME); - assertEquals(mClientInterface, returnedClientInterface); + assertEquals(true, mWificondControl.setupInterfaceForClientMode(TEST_INTERFACE_NAME, + mNormalScanCallback, mPnoScanCallback)); // Tear down interfaces. assertTrue(mWificondControl.tearDownInterfaces()); @@ -500,7 +493,8 @@ public class WificondControlTest extends WifiBaseTest { when(mWifiInjector.makeWificond()).thenReturn(mWificond); when(mWificond.createClientInterface(TEST_INTERFACE_NAME)).thenReturn(mClientInterface); - mWificondControl.setupInterfaceForClientMode(TEST_INTERFACE_NAME); + mWificondControl.setupInterfaceForClientMode(TEST_INTERFACE_NAME, mNormalScanCallback, + mPnoScanCallback); mWificondControl.getTxPacketCounters(TEST_INTERFACE_NAME); verify(mClientInterface).getPacketCounters(); } @@ -515,9 +509,8 @@ public class WificondControlTest extends WifiBaseTest { when(mWificond.createClientInterface(TEST_INTERFACE_NAME)).thenReturn(mClientInterface); // Configure client interface. - IClientInterface returnedClientInterface = - mWificondControl.setupInterfaceForClientMode(TEST_INTERFACE_NAME); - assertEquals(mClientInterface, returnedClientInterface); + assertEquals(true, mWificondControl.setupInterfaceForClientMode(TEST_INTERFACE_NAME, + mNormalScanCallback, mPnoScanCallback)); // Tear down interfaces. assertTrue(mWificondControl.tearDownInterfaces()); @@ -536,9 +529,8 @@ public class WificondControlTest extends WifiBaseTest { when(mWificond.createClientInterface(TEST_INTERFACE_NAME)).thenReturn(mClientInterface); // Configure client interface. - IClientInterface returnedClientInterface = - mWificondControl.setupInterfaceForClientMode(TEST_INTERFACE_NAME); - assertEquals(mClientInterface, returnedClientInterface); + assertEquals(true, mWificondControl.setupInterfaceForClientMode(TEST_INTERFACE_NAME, + mNormalScanCallback, mPnoScanCallback)); // Tear down interfaces. assertTrue(mWificondControl.tearDownInterfaces()); @@ -546,7 +538,7 @@ public class WificondControlTest extends WifiBaseTest { // getScanResults should fail. assertEquals(0, mWificondControl.getScanResults(TEST_INTERFACE_NAME, - WificondControl.SCAN_TYPE_SINGLE_SCAN).length); + WificondControl.SCAN_TYPE_SINGLE_SCAN).size()); } /** @@ -663,7 +655,7 @@ public class WificondControlTest extends WifiBaseTest { assertNotNull(scanEvent); scanEvent.OnScanResultReady(); - verify(mWifiMonitor).broadcastScanResultEvent(any(String.class)); + verify(mNormalScanCallback).onScanResultReady(); } /** @@ -672,14 +664,13 @@ public class WificondControlTest extends WifiBaseTest { */ @Test public void testScanFailedEvent() throws Exception { - ArgumentCaptor<IScanEvent> messageCaptor = ArgumentCaptor.forClass(IScanEvent.class); verify(mWifiScannerImpl).subscribeScanEvents(messageCaptor.capture()); IScanEvent scanEvent = messageCaptor.getValue(); assertNotNull(scanEvent); scanEvent.OnScanFailed(); - verify(mWifiMonitor).broadcastScanFailedEvent(any(String.class)); + verify(mNormalScanCallback).onScanFailed(); } /** @@ -693,7 +684,7 @@ public class WificondControlTest extends WifiBaseTest { IPnoScanEvent pnoScanEvent = messageCaptor.getValue(); assertNotNull(pnoScanEvent); pnoScanEvent.OnPnoNetworkFound(); - verify(mWifiMonitor).broadcastPnoScanResultEvent(any(String.class)); + verify(mPnoScanCallback).onScanResultReady(); } /** @@ -707,10 +698,10 @@ public class WificondControlTest extends WifiBaseTest { assertNotNull(pnoScanEvent); pnoScanEvent.OnPnoNetworkFound(); - verify(mWifiMetrics).incrementPnoFoundNetworkEventCount(); + verify(mPnoScanCallback).onScanResultReady(); pnoScanEvent.OnPnoScanFailed(); - verify(mWifiMetrics).incrementPnoScanFailedCount(); + verify(mPnoScanCallback).onScanFailed(); } /** |