diff options
author | Amin Shaikh <ashaikh@google.com> | 2016-11-21 17:28:26 -0800 |
---|---|---|
committer | Amin Shaikh <ashaikh@google.com> | 2016-11-30 10:01:53 -0800 |
commit | cb46b737eaf8f59f07270e57b37bfddcfc121fdb (patch) | |
tree | 0c39924c717f4bc352832cce773471bc72ad3888 /tests | |
parent | 585cd77a9c472af47ecd67ccd47e119b6a26bc38 (diff) |
Refactor NetworkScoreAppManager for testing.
Bug: 32913019
Test: runtest frameworks-wifi
Change-Id: If4bef94b6a275215ce47c8e77edb1af8cf4df3c0
Diffstat (limited to 'tests')
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/util/WifiPermissionsUtilTest.java | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/util/WifiPermissionsUtilTest.java b/tests/wifitests/src/com/android/server/wifi/util/WifiPermissionsUtilTest.java index 61820d780..c0d3e2bf1 100644 --- a/tests/wifitests/src/com/android/server/wifi/util/WifiPermissionsUtilTest.java +++ b/tests/wifitests/src/com/android/server/wifi/util/WifiPermissionsUtilTest.java @@ -28,6 +28,7 @@ import android.content.Context; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.content.pm.UserInfo; +import android.net.NetworkScorerAppManager; import android.os.Build; import android.os.UserHandle; import android.os.UserManager; @@ -66,6 +67,7 @@ public class WifiPermissionsUtilTest { @Mock private UserManager mMockUserManager; @Mock private WifiSettingsStore mMockWifiSettingsStore; @Mock private ContentResolver mMockContentResolver; + @Mock private NetworkScorerAppManager mNetworkScorerAppManager; private static final String TEST_PACKAGE_NAME = "com.google.somePackage"; private static final String INVALID_PACKAGE = "BAD_PACKAGE"; @@ -125,7 +127,7 @@ public class WifiPermissionsUtilTest { mCurrentUser = UserHandle.USER_CURRENT_OR_SELF; setupTestCase(); WifiPermissionsUtil codeUnderTest = new WifiPermissionsUtil(mMockPermissionsWrapper, - mMockContext, mMockWifiSettingsStore, mMockUserManager); + mMockContext, mMockWifiSettingsStore, mMockUserManager, mNetworkScorerAppManager); try { output = codeUnderTest.canAccessScanResults(TEST_PACKAGE_NAME, mUid, mTargetVersion); } catch (SecurityException e) { @@ -152,7 +154,7 @@ public class WifiPermissionsUtilTest { mMockUserInfo.id = mCallingUser; setupTestCase(); WifiPermissionsUtil codeUnderTest = new WifiPermissionsUtil(mMockPermissionsWrapper, - mMockContext, mMockWifiSettingsStore, mMockUserManager); + mMockContext, mMockWifiSettingsStore, mMockUserManager, mNetworkScorerAppManager); try { output = codeUnderTest.canAccessScanResults(TEST_PACKAGE_NAME, mUid, mTargetVersion); } catch (SecurityException e) { @@ -174,7 +176,7 @@ public class WifiPermissionsUtilTest { mPermissionsList.put(mMacAddressPermission, mUid); setupTestCase(); WifiPermissionsUtil codeUnderTest = new WifiPermissionsUtil(mMockPermissionsWrapper, - mMockContext, mMockWifiSettingsStore, mMockUserManager); + mMockContext, mMockWifiSettingsStore, mMockUserManager, mNetworkScorerAppManager); try { output = codeUnderTest.canAccessScanResults(TEST_PACKAGE_NAME, mUid, mTargetVersion); } catch (SecurityException e) { @@ -202,7 +204,7 @@ public class WifiPermissionsUtilTest { mPermissionsList.put(mInteractAcrossUsersFullPermission, mUid); setupTestCase(); WifiPermissionsUtil codeUnderTest = new WifiPermissionsUtil(mMockPermissionsWrapper, - mMockContext, mMockWifiSettingsStore, mMockUserManager); + mMockContext, mMockWifiSettingsStore, mMockUserManager, mNetworkScorerAppManager); try { output = codeUnderTest.canAccessScanResults(TEST_PACKAGE_NAME, mUid, mTargetVersion); } catch (SecurityException e) { @@ -228,7 +230,7 @@ public class WifiPermissionsUtilTest { mWifiScanAllowApps = AppOpsManager.MODE_ALLOWED; setupTestCase(); WifiPermissionsUtil codeUnderTest = new WifiPermissionsUtil(mMockPermissionsWrapper, - mMockContext, mMockWifiSettingsStore, mMockUserManager); + mMockContext, mMockWifiSettingsStore, mMockUserManager, mNetworkScorerAppManager); try { output = codeUnderTest.canAccessScanResults(TEST_PACKAGE_NAME, mUid, mTargetVersion); } catch (SecurityException e) { @@ -253,7 +255,7 @@ public class WifiPermissionsUtilTest { mCurrentUser = UserHandle.USER_CURRENT_OR_SELF; setupTestCase(); WifiPermissionsUtil codeUnderTest = new WifiPermissionsUtil(mMockPermissionsWrapper, - mMockContext, mMockWifiSettingsStore, mMockUserManager); + mMockContext, mMockWifiSettingsStore, mMockUserManager, mNetworkScorerAppManager); try { output = codeUnderTest.canAccessScanResults(TEST_PACKAGE_NAME, mUid, mTargetVersion); } catch (SecurityException e) { @@ -281,7 +283,7 @@ public class WifiPermissionsUtilTest { mCurrentUser = UserHandle.USER_CURRENT_OR_SELF; setupTestCase(); WifiPermissionsUtil codeUnderTest = new WifiPermissionsUtil(mMockPermissionsWrapper, - mMockContext, mMockWifiSettingsStore, mMockUserManager); + mMockContext, mMockWifiSettingsStore, mMockUserManager, mNetworkScorerAppManager); try { output = codeUnderTest.canAccessScanResults(TEST_PACKAGE_NAME, mUid, mTargetVersion); } catch (SecurityException e) { @@ -312,7 +314,7 @@ public class WifiPermissionsUtilTest { mMockUserInfo.id = mCallingUser; setupTestCase(); WifiPermissionsUtil codeUnderTest = new WifiPermissionsUtil(mMockPermissionsWrapper, - mMockContext, mMockWifiSettingsStore, mMockUserManager); + mMockContext, mMockWifiSettingsStore, mMockUserManager, mNetworkScorerAppManager); try { output = codeUnderTest.canAccessScanResults(TEST_PACKAGE_NAME, mUid, mTargetVersion); } catch (SecurityException e) { @@ -338,7 +340,7 @@ public class WifiPermissionsUtilTest { mLocationModeSetting = Settings.Secure.LOCATION_MODE_HIGH_ACCURACY; setupTestCase(); WifiPermissionsUtil codeUnderTest = new WifiPermissionsUtil(mMockPermissionsWrapper, - mMockContext, mMockWifiSettingsStore, mMockUserManager); + mMockContext, mMockWifiSettingsStore, mMockUserManager, mNetworkScorerAppManager); try { output = codeUnderTest.canAccessScanResults(TEST_PACKAGE_NAME, mUid, mTargetVersion); } catch (SecurityException e) { @@ -356,7 +358,7 @@ public class WifiPermissionsUtilTest { boolean output = false; setupTestCase(); WifiPermissionsUtil codeUnderTest = new WifiPermissionsUtil(mMockPermissionsWrapper, - mMockContext, mMockWifiSettingsStore, mMockUserManager); + mMockContext, mMockWifiSettingsStore, mMockUserManager, mNetworkScorerAppManager); try { output = codeUnderTest.canAccessScanResults(TEST_PACKAGE_NAME, mUid, mTargetVersion); } catch (SecurityException e) { @@ -429,8 +431,7 @@ public class WifiPermissionsUtilTest { anyString(), anyInt()); when(mMockPermissionsWrapper.getCallingUserId(mUid)).thenReturn(mCallingUser); when(mMockPermissionsWrapper.getCurrentUser()).thenReturn(mCurrentUser); - when(mMockPermissionsWrapper.isCallerActiveNwScorer(mUid)) - .thenReturn(mActiveNwScorer); + when(mNetworkScorerAppManager.isCallerActiveScorer(mUid)).thenReturn(mActiveNwScorer); when(mMockPermissionsWrapper.getUidPermission(mManifestStringCoarse, mUid)) .thenReturn(mCoarseLocationPermission); when(mMockWifiSettingsStore.getLocationModeSetting(mMockContext)) |