use of org.robolectric.shadows.ShadowPackageManager in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class SimStatusDialogControllerTest method setup.
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
mContext = RuntimeEnvironment.application;
when(mDialog.getContext()).thenReturn(mContext);
mLifecycleOwner = () -> mLifecycle;
mLifecycle = new Lifecycle(mLifecycleOwner);
mController = spy(new SimStatusDialogController(mDialog, mLifecycle, 0));
doReturn(mServiceState).when(mController).getCurrentServiceState();
doReturn(0).when(mSignalStrength).getDbm();
doReturn(0).when(mSignalStrength).getAsuLevel();
doReturn(mPhoneStateListener).when(mController).getPhoneStateListener();
doReturn("").when(mController).getPhoneNumber();
doReturn(mSignalStrength).when(mController).getSignalStrength();
doReturn(mSubscriptionInfo).when(mSubscriptionManager).getActiveSubscriptionInfo(anyInt());
when(mEuiccManager.isEnabled()).thenReturn(true);
when(mEuiccManager.getEid()).thenReturn("");
ReflectionHelpers.setField(mController, "mTelephonyManager", mTelephonyManager);
ReflectionHelpers.setField(mController, "mCarrierConfigManager", mCarrierConfigManager);
ReflectionHelpers.setField(mController, "mSubscriptionInfo", mSubscriptionInfo);
ReflectionHelpers.setField(mController, "mEuiccManager", mEuiccManager);
ReflectionHelpers.setField(mController, "mSubscriptionManager", mSubscriptionManager);
when(mCarrierConfigManager.getConfigForSubId(anyInt())).thenReturn(mPersistableBundle);
when(mPersistableBundle.getBoolean(CarrierConfigManager.KEY_SHOW_SIGNAL_STRENGTH_IN_SIM_STATUS_BOOL)).thenReturn(true);
final ShadowPackageManager shadowPackageManager = Shadows.shadowOf(RuntimeEnvironment.application.getPackageManager());
final PackageInfo sysUIPackageInfo = new PackageInfo();
sysUIPackageInfo.packageName = "com.android.systemui";
shadowPackageManager.addPackage(sysUIPackageInfo);
}
use of org.robolectric.shadows.ShadowPackageManager in project materialistic by hidroh.
the class TestApplication method addResolver.
public static void addResolver(Intent intent) {
ShadowPackageManager packageManager = shadowOf(RuntimeEnvironment.application.getPackageManager());
packageManager.addResolveInfoForIntent(intent, ShadowResolveInfo.newResolveInfo("label", "com.android.chrome", "DefaultActivity"));
}
use of org.robolectric.shadows.ShadowPackageManager in project android_packages_apps_Settings by omnirom.
the class GestureNavigationSettingsAssistControllerTest method setUp.
@Before
public void setUp() {
mContext = ApplicationProvider.getApplicationContext();
// This sets up SystemNavigationPreferenceController.isGestureAvailable() so it returns true
SettingsShadowResources.overrideResource(R.bool.config_swipe_up_gesture_setting_available, true);
final String recentsComponentPackageName = "recents.component";
SettingsShadowResources.overrideResource(R.string.config_recentsComponentName, recentsComponentPackageName + "/.ComponentName");
final Intent quickStepIntent = new Intent(ACTION_QUICKSTEP).setPackage(recentsComponentPackageName);
final ResolveInfo info = new ResolveInfo();
info.serviceInfo = new ServiceInfo();
info.resolvePackageName = recentsComponentPackageName;
info.serviceInfo.packageName = info.resolvePackageName;
info.serviceInfo.name = recentsComponentPackageName;
info.serviceInfo.applicationInfo = new ApplicationInfo();
info.serviceInfo.applicationInfo.flags = ApplicationInfo.FLAG_SYSTEM;
ShadowPackageManager shadowPackageManager = Shadows.shadowOf(mContext.getPackageManager());
shadowPackageManager.addResolveInfoForIntent(quickStepIntent, info);
mController = new GestureNavigationSettingsAssistController(mContext, KEY_SWIPE_FOR_ASSIST);
}
use of org.robolectric.shadows.ShadowPackageManager in project android_packages_apps_Settings by omnirom.
the class DataUsageUtilsTest method hasEthernet_shouldQueryEthernetSummaryForUser.
@Test
public void hasEthernet_shouldQueryEthernetSummaryForUser() throws Exception {
ShadowPackageManager pm = shadowOf(RuntimeEnvironment.application.getPackageManager());
pm.setSystemFeature(PackageManager.FEATURE_ETHERNET, true);
final String subscriber = "TestSub";
when(mTelephonyManager.getSubscriberId()).thenReturn(subscriber);
DataUsageUtils.hasEthernet(mContext);
verify(mNetworkStatsManager).querySummaryForUser(eq(ConnectivityManager.TYPE_ETHERNET), eq(subscriber), anyLong(), /* startTime */
anyLong());
}
use of org.robolectric.shadows.ShadowPackageManager in project android_packages_apps_Settings by omnirom.
the class AvatarViewMixinTest method queryProviderAuthority_useNewShadowPackagteManager_returnAuthority.
@Test
public void queryProviderAuthority_useNewShadowPackagteManager_returnAuthority() {
final AvatarViewMixin avatarViewMixin = new AvatarViewMixin(mActivity, mImageView);
ShadowPackageManager shadowPackageManager = Shadow.extract(mContext.getPackageManager());
final PackageInfo accountProvider = new PackageInfo();
accountProvider.packageName = "test.pkg";
accountProvider.applicationInfo = new ApplicationInfo();
accountProvider.applicationInfo.flags = ApplicationInfo.FLAG_SYSTEM;
accountProvider.applicationInfo.packageName = accountProvider.packageName;
accountProvider.providers = new ProviderInfo[1];
accountProvider.providers[0] = new ProviderInfo();
accountProvider.providers[0].authority = FAKE_AUTHORITY;
accountProvider.providers[0].packageName = accountProvider.packageName;
accountProvider.providers[0].name = "test.class";
accountProvider.providers[0].applicationInfo = accountProvider.applicationInfo;
final ResolveInfo resolveInfo = new ResolveInfo();
resolveInfo.providerInfo = accountProvider.providers[0];
shadowPackageManager.addResolveInfoForIntent(AvatarViewMixin.INTENT_GET_ACCOUNT_DATA, resolveInfo);
assertThat(avatarViewMixin.queryProviderAuthority()).isEqualTo(FAKE_AUTHORITY);
}
Aggregations