diff options
Diffstat (limited to 'tests')
6 files changed, 74 insertions, 22 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java b/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java index 53218f790..8195117e7 100644 --- a/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java +++ b/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java @@ -543,7 +543,8 @@ public class ClientModeImplTest extends WifiBaseTest { WifiCarrierInfoManager tu = new WifiCarrierInfoManager(mTelephonyManager, mSubscriptionManager, mWifiInjector, mock(FrameworkFacade.class), - mock(WifiContext.class), mock(WifiConfigStore.class), mock(Handler.class)); + mock(WifiContext.class), mock(WifiConfigStore.class), mock(Handler.class), + mWifiMetrics); mWifiCarrierInfoManager = spy(tu); // static mocking mSession = ExtendedMockito.mockitoSession().strictness(Strictness.LENIENT) diff --git a/tests/wifitests/src/com/android/server/wifi/WifiCarrierInfoManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiCarrierInfoManagerTest.java index 28bffa149..2c1c2ec91 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiCarrierInfoManagerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiCarrierInfoManagerTest.java @@ -128,6 +128,7 @@ public class WifiCarrierInfoManagerTest extends WifiBaseTest { @Mock AlertDialog.Builder mAlertDialogBuilder; @Mock AlertDialog mAlertDialog; @Mock WifiCarrierInfoManager.OnUserApproveCarrierListener mListener; + @Mock WifiMetrics mWifiMetrics; private List<SubscriptionInfo> mSubInfoList; @@ -176,7 +177,7 @@ public class WifiCarrierInfoManagerTest extends WifiBaseTest { when(mWifiInjector.getWifiConfigManager()).thenReturn(mWifiConfigManager); mWifiCarrierInfoManager = new WifiCarrierInfoManager(mTelephonyManager, mSubscriptionManager, mWifiInjector, mFrameworkFacade, mContext, mWifiConfigStore, - new Handler(mLooper.getLooper())); + new Handler(mLooper.getLooper()), mWifiMetrics); ArgumentCaptor<ImsiPrivacyProtectionExemptionStoreData.DataSource> imsiDataSourceArgumentCaptor = ArgumentCaptor.forClass(ImsiPrivacyProtectionExemptionStoreData.DataSource.class); @@ -1535,6 +1536,8 @@ public class WifiCarrierInfoManagerTest extends WifiBaseTest { sendBroadcastForUserActionOnImsi(NOTIFICATION_USER_ALLOWED_CARRIER_INTENT_ACTION, CARRIER_NAME, DATA_CARRIER_ID); verify(mNotificationManger).cancel(SystemMessage.NOTE_NETWORK_SUGGESTION_AVAILABLE); + verify(mWifiMetrics).addUserApprovalCarrierUiReaction( + WifiCarrierInfoManager.ACTION_USER_ALLOWED_CARRIER, false); validateUserApprovalDialog(CARRIER_NAME); // Simulate user clicking on allow in the dialog. @@ -1553,6 +1556,8 @@ public class WifiCarrierInfoManagerTest extends WifiBaseTest { assertTrue(mWifiCarrierInfoManager .hasUserApprovedImsiPrivacyExemptionForCarrier(DATA_CARRIER_ID)); verify(mListener).onUserAllowed(DATA_CARRIER_ID); + verify(mWifiMetrics).addUserApprovalCarrierUiReaction( + WifiCarrierInfoManager.ACTION_USER_ALLOWED_CARRIER, true); } @Test @@ -1581,6 +1586,8 @@ public class WifiCarrierInfoManagerTest extends WifiBaseTest { assertFalse(mWifiCarrierInfoManager .hasUserApprovedImsiPrivacyExemptionForCarrier(DATA_CARRIER_ID)); verify(mListener, never()).onUserAllowed(DATA_CARRIER_ID); + verify(mWifiMetrics).addUserApprovalCarrierUiReaction( + WifiCarrierInfoManager.ACTION_USER_DISALLOWED_CARRIER, false); } @Test @@ -1601,6 +1608,8 @@ public class WifiCarrierInfoManagerTest extends WifiBaseTest { //Simulate user dismissal the notification sendBroadcastForUserActionOnImsi(NOTIFICATION_USER_DISMISSED_INTENT_ACTION, CARRIER_NAME, DATA_SUBID); + verify(mWifiMetrics).addUserApprovalCarrierUiReaction( + WifiCarrierInfoManager.ACTION_USER_DISMISS, false); reset(mNotificationManger); // No Notification is active, should send notification again. mWifiCarrierInfoManager.sendImsiProtectionExemptionNotificationIfRequired(DATA_CARRIER_ID); @@ -1637,6 +1646,8 @@ public class WifiCarrierInfoManagerTest extends WifiBaseTest { sendBroadcastForUserActionOnImsi(NOTIFICATION_USER_ALLOWED_CARRIER_INTENT_ACTION, CARRIER_NAME, DATA_SUBID); verify(mNotificationManger).cancel(SystemMessage.NOTE_NETWORK_SUGGESTION_AVAILABLE); + verify(mWifiMetrics).addUserApprovalCarrierUiReaction( + WifiCarrierInfoManager.ACTION_USER_ALLOWED_CARRIER, false); validateUserApprovalDialog(CARRIER_NAME); // Simulate user clicking on disallow in the dialog. @@ -1655,6 +1666,8 @@ public class WifiCarrierInfoManagerTest extends WifiBaseTest { assertFalse(mWifiCarrierInfoManager .hasUserApprovedImsiPrivacyExemptionForCarrier(DATA_CARRIER_ID)); verify(mListener, never()).onUserAllowed(DATA_CARRIER_ID); + verify(mWifiMetrics).addUserApprovalCarrierUiReaction( + WifiCarrierInfoManager.ACTION_USER_DISALLOWED_CARRIER, true); } @Test @@ -1675,6 +1688,8 @@ public class WifiCarrierInfoManagerTest extends WifiBaseTest { sendBroadcastForUserActionOnImsi(NOTIFICATION_USER_ALLOWED_CARRIER_INTENT_ACTION, CARRIER_NAME, DATA_SUBID); verify(mNotificationManger).cancel(SystemMessage.NOTE_NETWORK_SUGGESTION_AVAILABLE); + verify(mWifiMetrics).addUserApprovalCarrierUiReaction( + WifiCarrierInfoManager.ACTION_USER_ALLOWED_CARRIER, false); validateUserApprovalDialog(CARRIER_NAME); // Simulate user clicking on dismissal in the dialog. @@ -1698,6 +1713,8 @@ public class WifiCarrierInfoManagerTest extends WifiBaseTest { assertFalse(mWifiCarrierInfoManager .hasUserApprovedImsiPrivacyExemptionForCarrier(DATA_CARRIER_ID)); verify(mListener, never()).onUserAllowed(DATA_CARRIER_ID); + verify(mWifiMetrics).addUserApprovalCarrierUiReaction( + WifiCarrierInfoManager.ACTION_USER_DISMISS, true); } @Test diff --git a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java index 9e9ae1cb4..d1e476b6f 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java @@ -230,7 +230,8 @@ public class WifiConfigManagerTest extends WifiBaseTest { mWifiCarrierInfoManager = new WifiCarrierInfoManager(mTelephonyManager, mSubscriptionManager, mWifiInjector, mock(FrameworkFacade.class), - mock(WifiContext.class), mock(WifiConfigStore.class), mock(Handler.class)); + mock(WifiContext.class), mock(WifiConfigStore.class), mock(Handler.class), + mWifiMetrics); mLruConnectionTracker = new LruConnectionTracker(100, mContext); createWifiConfigManager(); mWifiConfigManager.addOnNetworkUpdateListener(mWcmListener); diff --git a/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java b/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java index fc9dfba0a..04730bbe3 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java @@ -4180,9 +4180,6 @@ public class WifiMetricsTest extends WifiBaseTest { add(60); }}); - mWifiMetrics.addNetworkSuggestionUserApprovalAppUiReaction(1, true); - mWifiMetrics.addNetworkSuggestionUserApprovalAppUiReaction(2, false); - mWifiMetrics.incrementNetworkSuggestionUserRevokePermission(); mWifiMetrics.incrementNetworkSuggestionUserRevokePermission(); @@ -4211,24 +4208,60 @@ public class WifiMetricsTest extends WifiBaseTest { assertEquals(WifiMetricsProto.WifiNetworkSuggestionApiLog.TYPE_NON_PRIVILEGED, mDecodedProto.wifiNetworkSuggestionApiLog.appCountPerType[2].appType); assertEquals(3, mDecodedProto.wifiNetworkSuggestionApiLog.appCountPerType[2].count); + } + + /** + * Test the generation of 'UserReactionToApprovalUiEvent' message. + */ + @Test + public void testUserReactionToApprovalUiEvent() throws Exception { + mWifiMetrics.addUserApprovalSuggestionAppUiReaction(1, true); + mWifiMetrics.addUserApprovalSuggestionAppUiReaction(2, false); + + mWifiMetrics.addUserApprovalCarrierUiReaction( + WifiCarrierInfoManager.ACTION_USER_ALLOWED_CARRIER, true); + mWifiMetrics.addUserApprovalCarrierUiReaction( + WifiCarrierInfoManager.ACTION_USER_DISMISS, false); + mWifiMetrics.addUserApprovalCarrierUiReaction( + WifiCarrierInfoManager.ACTION_USER_DISALLOWED_CARRIER, false); + + dumpProtoAndDeserialize(); assertEquals(2, - mDecodedProto.wifiNetworkSuggestionApiLog.userApprovalAppUiReaction.length); - assertEquals(WifiMetricsProto.WifiNetworkSuggestionApiLog.ACTION_ALLOWED, - mDecodedProto.wifiNetworkSuggestionApiLog.userApprovalAppUiReaction[0] + mDecodedProto.userReactionToApprovalUiEvent.userApprovalAppUiReaction.length); + assertEquals(WifiMetricsProto.UserReactionToApprovalUiEvent.ACTION_ALLOWED, + mDecodedProto.userReactionToApprovalUiEvent.userApprovalAppUiReaction[0] .userAction); assertEquals(true, - mDecodedProto.wifiNetworkSuggestionApiLog.userApprovalAppUiReaction[0] + mDecodedProto.userReactionToApprovalUiEvent.userApprovalAppUiReaction[0] .isDialog); - assertEquals(WifiMetricsProto.WifiNetworkSuggestionApiLog.ACTION_DISALLOWED, - mDecodedProto.wifiNetworkSuggestionApiLog.userApprovalAppUiReaction[1] + assertEquals(WifiMetricsProto.UserReactionToApprovalUiEvent.ACTION_DISALLOWED, + mDecodedProto.userReactionToApprovalUiEvent.userApprovalAppUiReaction[1] .userAction); assertEquals(false, - mDecodedProto.wifiNetworkSuggestionApiLog.userApprovalAppUiReaction[1] + mDecodedProto.userReactionToApprovalUiEvent.userApprovalAppUiReaction[1] .isDialog); - assertEquals(2, mDecodedProto.wifiNetworkSuggestionApiLog - .userRevokeAppSuggestionPermission); + assertEquals(3, + mDecodedProto.userReactionToApprovalUiEvent.userApprovalCarrierUiReaction.length); + assertEquals(WifiMetricsProto.UserReactionToApprovalUiEvent.ACTION_ALLOWED, + mDecodedProto.userReactionToApprovalUiEvent.userApprovalCarrierUiReaction[0] + .userAction); + assertEquals(true, + mDecodedProto.userReactionToApprovalUiEvent.userApprovalCarrierUiReaction[0] + .isDialog); + assertEquals(WifiMetricsProto.UserReactionToApprovalUiEvent.ACTION_DISMISS, + mDecodedProto.userReactionToApprovalUiEvent.userApprovalCarrierUiReaction[1] + .userAction); + assertEquals(false, + mDecodedProto.userReactionToApprovalUiEvent.userApprovalCarrierUiReaction[1] + .isDialog); + assertEquals(WifiMetricsProto.UserReactionToApprovalUiEvent.ACTION_DISALLOWED, + mDecodedProto.userReactionToApprovalUiEvent.userApprovalCarrierUiReaction[2] + .userAction); + assertEquals(false, + mDecodedProto.userReactionToApprovalUiEvent.userApprovalCarrierUiReaction[2] + .isDialog); } private NetworkSelectionExperimentDecisions findUniqueNetworkSelectionExperimentDecisions( diff --git a/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java index dcf7453ed..897dca341 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java @@ -2270,7 +2270,7 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest { sendBroadcastForUserActionOnApp( NOTIFICATION_USER_DISMISSED_INTENT_ACTION, TEST_PACKAGE_1, TEST_UID_1); reset(mNotificationManger); - verify(mWifiMetrics).addNetworkSuggestionUserApprovalAppUiReaction( + verify(mWifiMetrics).addUserApprovalSuggestionAppUiReaction( WifiNetworkSuggestionsManager.ACTION_USER_DISMISS, false); // Simulate finding the network in scan results. mWifiNetworkSuggestionsManager.getNetworkSuggestionsForScanDetail( @@ -2328,7 +2328,7 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest { // Verify config store interactions. verify(mWifiConfigManager, times(2)).saveToStore(true); assertTrue(mDataSource.hasNewDataToSerialize()); - verify(mWifiMetrics).addNetworkSuggestionUserApprovalAppUiReaction( + verify(mWifiMetrics).addUserApprovalSuggestionAppUiReaction( WifiNetworkSuggestionsManager.ACTION_USER_ALLOWED_APP, false); reset(mNotificationManger); @@ -2380,7 +2380,7 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest { // Verify config store interactions. verify(mWifiConfigManager, times(2)).saveToStore(true); assertTrue(mDataSource.hasNewDataToSerialize()); - verify(mWifiMetrics).addNetworkSuggestionUserApprovalAppUiReaction( + verify(mWifiMetrics).addUserApprovalSuggestionAppUiReaction( WifiNetworkSuggestionsManager.ACTION_USER_DISALLOWED_APP, false); reset(mNotificationManger); @@ -2550,7 +2550,7 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest { // Verify config store interactions. verify(mWifiConfigManager, times(2)).saveToStore(true); assertTrue(mDataSource.hasNewDataToSerialize()); - verify(mWifiMetrics).addNetworkSuggestionUserApprovalAppUiReaction( + verify(mWifiMetrics).addUserApprovalSuggestionAppUiReaction( WifiNetworkSuggestionsManager.ACTION_USER_ALLOWED_APP, true); // We should not resend the notification next time the network is found in scan results. @@ -2596,7 +2596,7 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest { // Verify config store interactions. verify(mWifiConfigManager, times(2)).saveToStore(true); assertTrue(mDataSource.hasNewDataToSerialize()); - verify(mWifiMetrics).addNetworkSuggestionUserApprovalAppUiReaction( + verify(mWifiMetrics).addUserApprovalSuggestionAppUiReaction( WifiNetworkSuggestionsManager.ACTION_USER_DISALLOWED_APP, true); // Now trigger the app-ops callback to ensure we remove all of their suggestions. @@ -2650,7 +2650,7 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest { // Verify no new config store or app-op interactions. verify(mWifiConfigManager).saveToStore(true); // 1 already done for add verify(mAppOpsManager, never()).setMode(any(), anyInt(), any(), anyInt()); - verify(mWifiMetrics).addNetworkSuggestionUserApprovalAppUiReaction( + verify(mWifiMetrics).addUserApprovalSuggestionAppUiReaction( WifiNetworkSuggestionsManager.ACTION_USER_DISMISS, true); // We should resend the notification next time the network is found in scan results. 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 e75cefcef..885cf87a3 100644 --- a/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointManagerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointManagerTest.java @@ -230,7 +230,7 @@ public class PasspointManagerTest extends WifiBaseTest { .thenReturn(mWifiNetworkSuggestionsManager); mWifiCarrierInfoManager = new WifiCarrierInfoManager(mTelephonyManager, mSubscriptionManager, mWifiInjector, mock(FrameworkFacade.class), - mock(WifiContext.class), mWifiConfigStore, mock(Handler.class)); + mock(WifiContext.class), mWifiConfigStore, mock(Handler.class), mWifiMetrics); mLooper = new TestLooper(); mHandler = new Handler(mLooper.getLooper()); mManager = new PasspointManager(mContext, mWifiInjector, mHandler, mWifiNative, |