summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorOscar Shu <xshu@google.com>2020-04-21 00:33:11 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2020-04-21 00:33:11 +0000
commit7935833ba18cc2386d985e2f6677e4a9a44776a3 (patch)
treef0a72e9125b0736da58dab5cea003bd91f1120eb /tests
parent0a0b43885adfb3b286f072338fbc02abac869646 (diff)
parentd91c276f113fc7aabc2ae4d9beff7d041a49a750 (diff)
Merge "Add UserActionEvent for edit mac rand and metered" into rvc-dev
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java7
-rw-r--r--tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointManagerTest.java16
2 files changed, 20 insertions, 3 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java
index 8e199ec00..5f8fe98f7 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java
@@ -51,6 +51,7 @@ import androidx.test.filters.SmallTest;
import com.android.dx.mockito.inline.extended.ExtendedMockito;
import com.android.server.wifi.WifiScoreCard.PerNetwork;
+import com.android.server.wifi.proto.nano.WifiMetricsProto.UserActionEvent;
import com.android.server.wifi.util.LruConnectionTracker;
import com.android.server.wifi.util.WifiPermissionsUtil;
import com.android.server.wifi.util.WifiPermissionsWrapper;
@@ -142,6 +143,7 @@ public class WifiConfigManagerTest extends WifiBaseTest {
@Mock private WifiNetworkSuggestionsManager mWifiNetworkSuggestionsManager;
@Mock private WifiScoreCard mWifiScoreCard;
@Mock private PerNetwork mPerNetwork;
+ @Mock private WifiMetrics mWifiMetrics;
private LruConnectionTracker mLruConnectionTracker;
private MockResources mResources;
@@ -222,6 +224,7 @@ public class WifiConfigManagerTest extends WifiBaseTest {
when(mWifiInjector.getWifiLastResortWatchdog().shouldIgnoreSsidUpdate())
.thenReturn(false);
when(mWifiInjector.getMacAddressUtil()).thenReturn(mMacAddressUtil);
+ when(mWifiInjector.getWifiMetrics()).thenReturn(mWifiMetrics);
when(mMacAddressUtil.calculatePersistentMac(any(), any())).thenReturn(TEST_RANDOMIZED_MAC);
when(mWifiScoreCard.lookupNetwork(any())).thenReturn(mPerNetwork);
@@ -634,6 +637,8 @@ public class WifiConfigManagerTest extends WifiBaseTest {
networks.add(openNetwork);
verifyAddNetworkToWifiConfigManager(openNetwork);
+ // Verify user action event is not logged when the network is added
+ verify(mWifiMetrics, never()).logUserActionEvent(anyInt(), anyBoolean(), anyBoolean());
verify(mWcmListener).onNetworkAdded(wifiConfigCaptor.capture());
assertEquals(openNetwork.networkId, wifiConfigCaptor.getValue().networkId);
reset(mWcmListener);
@@ -642,6 +647,8 @@ public class WifiConfigManagerTest extends WifiBaseTest {
openNetwork.macRandomizationSetting = WifiConfiguration.RANDOMIZATION_NONE;
NetworkUpdateResult networkUpdateResult = updateNetworkToWifiConfigManager(openNetwork);
assertNotEquals(WifiConfiguration.INVALID_NETWORK_ID, networkUpdateResult.getNetworkId());
+ verify(mWifiMetrics).logUserActionEvent(
+ UserActionEvent.EVENT_CONFIGURE_MAC_RANDOMIZATION_OFF, openNetwork.networkId);
List<WifiConfiguration> retrievedNetworks =
mWifiConfigManager.getConfiguredNetworksWithPasswords();
diff --git a/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointManagerTest.java b/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointManagerTest.java
index 861aa94ff..4a4c0e460 100644
--- a/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointManagerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointManagerTest.java
@@ -108,6 +108,7 @@ import com.android.server.wifi.hotspot2.anqp.DomainNameElement;
import com.android.server.wifi.hotspot2.anqp.HSOsuProvidersElement;
import com.android.server.wifi.hotspot2.anqp.I18Name;
import com.android.server.wifi.hotspot2.anqp.OsuProviderInfo;
+import com.android.server.wifi.proto.nano.WifiMetricsProto.UserActionEvent;
import com.android.server.wifi.util.InformationElementUtil;
import com.android.server.wifi.util.InformationElementUtil.RoamingConsortium;
@@ -678,7 +679,7 @@ public class PasspointManagerTest extends WifiBaseTest {
}
verify(provider).uninstallCertsAndKeys();
- verify(mWifiConfigManager, times(2)).removePasspointConfiguredNetwork(
+ verify(mWifiConfigManager, times(3)).removePasspointConfiguredNetwork(
provider.getWifiConfig().getKey());
/**
* 1 from |removeProvider| + 2 from |setAutojoinEnabled| + 2 from
@@ -750,26 +751,35 @@ public class PasspointManagerTest extends WifiBaseTest {
* @param provider a mock provider that is already added into the PasspointManager
*/
private void verifyEnableMacRandomization(PasspointProvider provider) {
+ when(provider.setMacRandomizationEnabled(anyBoolean())).thenReturn(true);
assertTrue(mManager.enableMacRandomization(provider.getConfig().getHomeSp().getFqdn(),
false));
verify(provider).setMacRandomizationEnabled(false);
- when(provider.setMacRandomizationEnabled(true)).thenReturn(true);
+ verify(mWifiMetrics).logUserActionEvent(
+ UserActionEvent.EVENT_CONFIGURE_MAC_RANDOMIZATION_OFF, false, true);
assertTrue(mManager.enableMacRandomization(provider.getConfig().getHomeSp().getFqdn(),
true));
- verify(mWifiConfigManager).removePasspointConfiguredNetwork(
+ verify(mWifiConfigManager, times(2)).removePasspointConfiguredNetwork(
provider.getWifiConfig().getKey());
+ verify(mWifiMetrics).logUserActionEvent(
+ UserActionEvent.EVENT_CONFIGURE_MAC_RANDOMIZATION_ON, false, true);
verify(provider).setMacRandomizationEnabled(true);
assertFalse(mManager.enableMacRandomization(provider.getConfig().getHomeSp().getFqdn()
+ "-XXXX", false));
}
private void verifySetMeteredOverride(PasspointProvider provider) {
+ when(provider.setMeteredOverride(anyInt())).thenReturn(true);
assertTrue(mManager.setMeteredOverride(provider.getConfig().getHomeSp().getFqdn(),
METERED_OVERRIDE_METERED));
verify(provider).setMeteredOverride(METERED_OVERRIDE_METERED);
+ verify(mWifiMetrics).logUserActionEvent(
+ UserActionEvent.EVENT_CONFIGURE_METERED_STATUS_METERED, false, true);
assertTrue(mManager.setMeteredOverride(provider.getConfig().getHomeSp().getFqdn(),
METERED_OVERRIDE_NOT_METERED));
verify(provider).setMeteredOverride(METERED_OVERRIDE_NOT_METERED);
+ verify(mWifiMetrics).logUserActionEvent(
+ UserActionEvent.EVENT_CONFIGURE_METERED_STATUS_UNMETERED, false, true);
assertFalse(mManager.setMeteredOverride(provider.getConfig().getHomeSp().getFqdn()
+ "-XXXX", METERED_OVERRIDE_METERED));
}