From 060438fd2b162bf91a296013ce8ca91006728219 Mon Sep 17 00:00:00 2001 From: Nate Jiang Date: Thu, 26 Mar 2020 17:00:10 -0700 Subject: Add or Remove WifiNetworkSuggestion with null should fail. Bug: 152554222 Test: atest com.android.server.wifi Change-Id: I5764f63b8054d56bfc6423c26a78631a1546c077 --- .../wifi/WifiNetworkSuggestionsManagerTest.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'tests') diff --git a/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java index f26ceb664..ea2953a20 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java @@ -648,6 +648,24 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest { assertSuggestionsEquals(expectedMatchingNetworkSuggestions, matchingExtNetworkSuggestions); } + /** + * Verify add or remove suggestion list with null object will result error code. + */ + @Test + public void testAddRemoveNetworkSuggestionWithNullObject() { + assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_ERROR_ADD_INVALID, + mWifiNetworkSuggestionsManager.add(Collections.singletonList(null), + TEST_UID_1, TEST_PACKAGE_1, TEST_FEATURE)); + WifiNetworkSuggestion networkSuggestion = new WifiNetworkSuggestion( + WifiConfigurationTestUtil.createOpenNetwork(), null, false, false, true, true); + assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS, + mWifiNetworkSuggestionsManager.add(Collections.singletonList(networkSuggestion), + TEST_UID_1, TEST_PACKAGE_1, TEST_FEATURE)); + assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_ERROR_REMOVE_INVALID, + mWifiNetworkSuggestionsManager.remove(Collections.singletonList(null), + TEST_UID_1, TEST_PACKAGE_1)); + } + /** * Verify a successful lookup of a single network suggestion matching the provided scan detail. */ @@ -3292,6 +3310,7 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest { List allSrList = new ArrayList<>() {{ add(passpointScanResult); add(nonPasspointScanResult); + add(null); }}; when(mPasspointManager.getMatchingScanResults(eq(mockPasspoint), eq(allSrList))) .thenReturn(ppSrList); -- cgit v1.2.3