summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2020-05-06 04:53:17 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2020-05-06 04:53:17 +0000
commit297dc4e32df726542e895abb3869a8c47b62c143 (patch)
treea681f9a6895b063daa3ff5d18ca134dcf629ca01 /libs
parent104a76ff70684221cdf05b6a1f0cedd91b468af8 (diff)
parenta86c9944ed5ee4a4c3637cf7aab229d6230aac77 (diff)
Merge "[WifiTrackerLib] Fix WifiPickerTrackerTest to mock correct config API" into rvc-dev am: a86c9944ed
Change-Id: I3f97da5925ca9b3d68374b3ff1576608d6e4922d
Diffstat (limited to 'libs')
-rw-r--r--libs/WifiTrackerLib/tests/src/com/android/wifitrackerlib/WifiPickerTrackerTest.java26
1 files changed, 21 insertions, 5 deletions
diff --git a/libs/WifiTrackerLib/tests/src/com/android/wifitrackerlib/WifiPickerTrackerTest.java b/libs/WifiTrackerLib/tests/src/com/android/wifitrackerlib/WifiPickerTrackerTest.java
index bb69003c7..f59e34499 100644
--- a/libs/WifiTrackerLib/tests/src/com/android/wifitrackerlib/WifiPickerTrackerTest.java
+++ b/libs/WifiTrackerLib/tests/src/com/android/wifitrackerlib/WifiPickerTrackerTest.java
@@ -49,11 +49,13 @@ import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
+import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import java.time.Clock;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.BitSet;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
@@ -392,7 +394,7 @@ public class WifiPickerTrackerTest {
final WifiPickerTracker wifiPickerTracker = createTestWifiPickerTracker();
final WifiConfiguration config = new WifiConfiguration();
config.SSID = "\"ssid\"";
- when(mMockWifiManager.getConfiguredNetworks())
+ when(mMockWifiManager.getPrivilegedConfiguredNetworks())
.thenReturn(Collections.singletonList(config));
wifiPickerTracker.onStart();
verify(mMockContext).registerReceiver(mBroadcastReceiverCaptor.capture(),
@@ -426,7 +428,7 @@ public class WifiPickerTrackerTest {
final WifiConfiguration config = new WifiConfiguration();
config.SSID = "\"ssid\"";
config.networkId = 1;
- when(mMockWifiManager.getConfiguredNetworks())
+ when(mMockWifiManager.getPrivilegedConfiguredNetworks())
.thenReturn(Collections.singletonList(config));
when(mMockWifiInfo.getNetworkId()).thenReturn(1);
when(mMockWifiInfo.getRssi()).thenReturn(-50);
@@ -448,7 +450,7 @@ public class WifiPickerTrackerTest {
final WifiConfiguration config = new WifiConfiguration();
config.SSID = "\"ssid\"";
config.networkId = 1;
- when(mMockWifiManager.getConfiguredNetworks())
+ when(mMockWifiManager.getPrivilegedConfiguredNetworks())
.thenReturn(Collections.singletonList(config));
when(mMockWifiManager.getScanResults()).thenReturn(Arrays.asList(
buildScanResult("ssid", "bssid", START_MILLIS)));
@@ -479,7 +481,7 @@ public class WifiPickerTrackerTest {
final WifiConfiguration config = new WifiConfiguration();
config.SSID = "\"ssid\"";
config.networkId = 1;
- when(mMockWifiManager.getConfiguredNetworks())
+ when(mMockWifiManager.getPrivilegedConfiguredNetworks())
.thenReturn(Collections.singletonList(config));
when(mMockWifiManager.getScanResults()).thenReturn(Arrays.asList(
buildScanResult("ssid", "bssid", START_MILLIS)));
@@ -578,7 +580,8 @@ public class WifiPickerTrackerTest {
public void testGetConnectedEntry_alreadyConnectedToPasspoint_returnsPasspointEntry() {
final String fqdn = "fqdn";
final String friendlyName = "friendlyName";
- final WifiPickerTracker wifiPickerTracker = createTestWifiPickerTracker();
+ final int networkId = 1;
+ // Create a passpoint configuration to match with the current network
final PasspointConfiguration passpointConfig = new PasspointConfiguration();
final HomeSp homeSp = new HomeSp();
homeSp.setFqdn(fqdn);
@@ -587,10 +590,23 @@ public class WifiPickerTrackerTest {
passpointConfig.setCredential(new Credential());
when(mMockWifiManager.getPasspointConfigurations())
.thenReturn(Collections.singletonList(passpointConfig));
+ // Create a wifi config to match the WifiInfo netId and unique id of the passpoint config
+ final WifiConfiguration config = Mockito.mock(WifiConfiguration.class);
+ config.SSID = "\"ssid\"";
+ config.networkId = networkId;
+ config.allowedKeyManagement = new BitSet();
+ config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.SUITE_B_192);
+
+ when(config.isPasspoint()).thenReturn(true);
+ when(config.getKey()).thenReturn(passpointConfig.getUniqueId());
+ when(mMockWifiManager.getPrivilegedConfiguredNetworks())
+ .thenReturn(Collections.singletonList(config));
when(mMockWifiInfo.isPasspointAp()).thenReturn(true);
+ when(mMockWifiInfo.getNetworkId()).thenReturn(networkId);
when(mMockWifiInfo.getPasspointFqdn()).thenReturn(fqdn);
when(mMockWifiInfo.getRssi()).thenReturn(-50);
when(mMockNetworkInfo.getDetailedState()).thenReturn(NetworkInfo.DetailedState.CONNECTED);
+ final WifiPickerTracker wifiPickerTracker = createTestWifiPickerTracker();
wifiPickerTracker.onStart();
verify(mMockContext).registerReceiver(mBroadcastReceiverCaptor.capture(),