summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorNate(Qiang) Jiang <qiangjiang@google.com>2020-03-10 18:53:45 -0700
committerNate(Qiang) Jiang <qiangjiang@google.com>2020-03-10 18:53:45 -0700
commit0fc322ae96667ef108a1c24ad77e8368257ff0e1 (patch)
treea861656dc56b993a62e22cfb93987da80fe8ec7c /tests
parentaa29cd45c87e53ddbc20111b104217b86f6c7464 (diff)
Remove suggesiton trigger disconnect
Bug: 151168228 Test: atest com.android.server.wifi Change-Id: I2a10307b70712752493a694b5c3aeab3c73a54ae
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java45
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java
index 12f27b962..63869e805 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java
@@ -965,6 +965,51 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
mInorder.verifyNoMoreInteractions();
}
+ @Test
+ public void testOnNetworkConnectionSuccessWithOneMatchFromCarrierPrivilegedApp() {
+ assertTrue(mWifiNetworkSuggestionsManager
+ .registerSuggestionConnectionStatusListener(mBinder, mListener,
+ NETWORK_CALLBACK_ID, TEST_PACKAGE_1));
+ when(mTelephonyUtil.getCarrierIdForPackageWithCarrierPrivileges(TEST_PACKAGE_1))
+ .thenReturn(TEST_CARRIER_ID);
+ WifiNetworkSuggestion networkSuggestion = new WifiNetworkSuggestion(
+ WifiConfigurationTestUtil.createPskNetwork(), null, true, false, true, true,
+ false);
+ List<WifiNetworkSuggestion> networkSuggestionList =
+ new ArrayList<WifiNetworkSuggestion>() {{
+ add(networkSuggestion);
+ }};
+ assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS,
+ mWifiNetworkSuggestionsManager.add(networkSuggestionList, TEST_UID_1,
+ TEST_PACKAGE_1, TEST_FEATURE));
+ assertFalse(mWifiNetworkSuggestionsManager.hasUserApprovedForApp(TEST_PACKAGE_1));
+
+ // Simulate connecting to the network.
+ WifiConfiguration connectNetwork =
+ new WifiConfiguration(networkSuggestion.wifiConfiguration);
+ connectNetwork.fromWifiNetworkSuggestion = true;
+ connectNetwork.ephemeral = true;
+ connectNetwork.creatorName = TEST_PACKAGE_1;
+ connectNetwork.creatorUid = TEST_UID_1;
+ mWifiNetworkSuggestionsManager.handleConnectionAttemptEnded(
+ WifiMetrics.ConnectionEvent.FAILURE_NONE, connectNetwork, TEST_BSSID);
+
+ verify(mWifiMetrics).incrementNetworkSuggestionApiNumConnectSuccess();
+
+ // Verify that the correct broadcast was sent out.
+ mInorder.verify(mWifiPermissionsUtil).enforceCanAccessScanResults(eq(TEST_PACKAGE_1),
+ eq(TEST_FEATURE), eq(TEST_UID_1), nullable(String.class));
+ validatePostConnectionBroadcastSent(TEST_PACKAGE_1, networkSuggestion);
+
+ assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS,
+ mWifiNetworkSuggestionsManager.remove(networkSuggestionList, TEST_UID_1,
+ TEST_PACKAGE_1));
+ verify(mWifiConfigManager).removeSuggestionConfiguredNetwork(anyString());
+
+ // Verify no more broadcast were sent out.
+ mInorder.verifyNoMoreInteractions();
+ }
+
/**
* Verify if a user saved network connected and it can match suggestions. Only the
* carrier-privileged suggestor app can receive the broadcast if