summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java22
1 files changed, 18 insertions, 4 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java b/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java
index 20766898d..58f5b1ccc 100644
--- a/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java
@@ -421,6 +421,7 @@ public class ClientModeImplTest extends WifiBaseTest {
@Mock ThroughputPredictor mThroughputPredictor;
@Mock ScanRequestProxy mScanRequestProxy;
@Mock DeviceConfigFacade mDeviceConfigFacade;
+ @Mock Network mNetwork;
final ArgumentCaptor<WifiConfigManager.OnNetworkUpdateListener> mConfigUpdateListenerCaptor =
ArgumentCaptor.forClass(WifiConfigManager.OnNetworkUpdateListener.class);
@@ -533,10 +534,8 @@ public class ClientModeImplTest extends WifiBaseTest {
return null;
}).when(mIpClient).shutdown();
when(mConnectivityManager.registerNetworkAgent(any(), any(), any(), any(), anyInt(), any(),
- anyInt())).thenReturn(mock(Network.class));
- List<SubscriptionInfo> subList = new ArrayList<>() {{
- add(mock(SubscriptionInfo.class));
- }};
+ anyInt())).thenReturn(mNetwork);
+ List<SubscriptionInfo> subList = Arrays.asList(mock(SubscriptionInfo.class));
when(mSubscriptionManager.getActiveSubscriptionInfoList()).thenReturn(subList);
when(mSubscriptionManager.getActiveSubscriptionIdList())
.thenReturn(new int[]{DATA_SUBID});
@@ -5266,4 +5265,19 @@ public class ClientModeImplTest extends WifiBaseTest {
verifyNoMoreInteractions(mNetworkAgentHandler);
}
+
+ @Test
+ public void testSyncGetCurrentNetwork() throws Exception {
+ // syncGetCurrentNetwork() returns null when disconnected
+ mLooper.startAutoDispatch();
+ assertNull(mCmi.syncGetCurrentNetwork(mCmiAsyncChannel));
+ mLooper.stopAutoDispatch();
+
+ connect();
+
+ // syncGetCurrentNetwork() returns non-null Network when connected
+ mLooper.startAutoDispatch();
+ assertEquals(mNetwork, mCmi.syncGetCurrentNetwork(mCmiAsyncChannel));
+ mLooper.stopAutoDispatch();
+ }
}