diff options
author | xshu <xshu@google.com> | 2020-04-15 17:14:05 -0700 |
---|---|---|
committer | xshu <xshu@google.com> | 2020-04-16 19:19:42 -0700 |
commit | d91c276f113fc7aabc2ae4d9beff7d041a49a750 (patch) | |
tree | bb5ecbc329098b5efe7718afda0c9d54c037274c /tests | |
parent | 8b8fafe34020b5fe5b43fa99685fb38dcb506c4a (diff) |
Add UserActionEvent for edit mac rand and metered
Log these events for passpoint and non-passpoint networks.
Bug: 153925826
Test: atest com.android.server.wifi
Change-Id: Ifcfc689ad0f02ace5caec119dec22b92c39ecce3
Diffstat (limited to 'tests')
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java | 7 | ||||
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointManagerTest.java | 16 |
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)); } |