Search in sources :

Example 1 with ShadowPackageManager

use of org.robolectric.shadows.ShadowPackageManager in project Parse-SDK-Android by ParsePlatform.

the class ParseClientConfigurationTest method setupMockMetaData.

private Bundle setupMockMetaData() throws Exception {
    Bundle metaData = mock(Bundle.class);
    ShadowPackageManager packageManager = shadowOf(RuntimeEnvironment.application.getPackageManager());
    ApplicationInfo info = packageManager.getApplicationInfo(RuntimeEnvironment.application.getPackageName(), PackageManager.GET_META_DATA);
    info.metaData = metaData;
    return metaData;
}
Also used : ShadowPackageManager(org.robolectric.shadows.ShadowPackageManager) Bundle(android.os.Bundle) ApplicationInfo(android.content.pm.ApplicationInfo)

Example 2 with ShadowPackageManager

use of org.robolectric.shadows.ShadowPackageManager in project sms-backup-plus by jberkel.

the class BackupJobsTest method before.

@Before
public void before() {
    initMocks(this);
    ShadowPackageManager pm = shadowOf(RuntimeEnvironment.application.getPackageManager());
    Intent executeIntent = new Intent("com.firebase.jobdispatcher.ACTION_EXECUTE");
    executeIntent.setClassName(RuntimeEnvironment.application, "com.zegoggles.smssync.service.SmsJobService");
    ResolveInfo ri = new ResolveInfo();
    ServiceInfo si = new ServiceInfo();
    si.packageName = "com.zegoggles.smssync.service.SmsJobService";
    ri.serviceInfo = si;
    ri.isDefault = true;
    pm.addResolveInfoForIntent(executeIntent, ri);
    subject = new BackupJobs(RuntimeEnvironment.application, preferences);
    when(preferences.getDataTypePreferences()).thenReturn(dataTypePreferences);
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) ServiceInfo(android.content.pm.ServiceInfo) ShadowPackageManager(org.robolectric.shadows.ShadowPackageManager) Intent(android.content.Intent) Before(org.junit.Before)

Example 3 with ShadowPackageManager

use of org.robolectric.shadows.ShadowPackageManager in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class SetupChooseLockPatternTest method chooseLockSaved_shouldEnableRedactionInterstitial.

@Test
public void chooseLockSaved_shouldEnableRedactionInterstitial() {
    findFragment(mActivity).onChosenLockSaveFinished(false, null);
    ShadowPackageManager spm = Shadows.shadowOf(application.getPackageManager());
    ComponentName cname = new ComponentName(application, SetupRedactionInterstitial.class);
    final int componentEnabled = spm.getComponentEnabledSettingFlags(cname) & PackageManager.COMPONENT_ENABLED_STATE_ENABLED;
    assertThat(componentEnabled).isEqualTo(PackageManager.COMPONENT_ENABLED_STATE_ENABLED);
}
Also used : ShadowPackageManager(org.robolectric.shadows.ShadowPackageManager) ComponentName(android.content.ComponentName) Test(org.junit.Test)

Example 4 with ShadowPackageManager

use of org.robolectric.shadows.ShadowPackageManager in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class LiveCaptionPreferenceControllerTest method getAvailabilityStatus_canResolveIntent_shouldReturnAvailable.

@Test
public void getAvailabilityStatus_canResolveIntent_shouldReturnAvailable() {
    final ShadowPackageManager pm = Shadows.shadowOf(RuntimeEnvironment.application.getPackageManager());
    pm.addResolveInfoForIntent(LiveCaptionPreferenceController.LIVE_CAPTION_INTENT, new ResolveInfo());
    assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) ShadowPackageManager(org.robolectric.shadows.ShadowPackageManager) Test(org.junit.Test)

Example 5 with ShadowPackageManager

use of org.robolectric.shadows.ShadowPackageManager in project android_packages_apps_Settings by omnirom.

the class TtsEnginePreferenceFragmentTest method setUp.

@Before
public void setUp() {
    mContext = RuntimeEnvironment.application;
    final ResolveInfo info = new ResolveInfo();
    final ServiceInfo serviceInfo = spy(new ServiceInfo());
    serviceInfo.packageName = mContext.getPackageName();
    serviceInfo.name = mContext.getClass().getName();
    info.serviceInfo = serviceInfo;
    doReturn("title").when(serviceInfo).loadLabel(any(PackageManager.class));
    doReturn(1).when(serviceInfo).getIconResource();
    final ShadowPackageManager spm = Shadow.extract(mContext.getPackageManager());
    spm.addResolveInfoForIntent(new Intent(TextToSpeech.Engine.INTENT_ACTION_TTS_SERVICE), info);
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) ServiceInfo(android.content.pm.ServiceInfo) PackageManager(android.content.pm.PackageManager) ShadowPackageManager(org.robolectric.shadows.ShadowPackageManager) ShadowPackageManager(org.robolectric.shadows.ShadowPackageManager) Intent(android.content.Intent) Before(org.junit.Before)

Aggregations

ShadowPackageManager (org.robolectric.shadows.ShadowPackageManager)17 Test (org.junit.Test)9 ResolveInfo (android.content.pm.ResolveInfo)7 ApplicationInfo (android.content.pm.ApplicationInfo)5 ComponentName (android.content.ComponentName)4 Before (org.junit.Before)4 Intent (android.content.Intent)3 PackageInfo (android.content.pm.PackageInfo)3 PackageManager (android.content.pm.PackageManager)3 ServiceInfo (android.content.pm.ServiceInfo)3 Context (android.content.Context)2 ProviderInfo (android.content.pm.ProviderInfo)2 BatteryFixSliceTest (com.android.settings.homepage.contextualcards.slices.BatteryFixSliceTest)2 ActivityThread (android.app.ActivityThread)1 Application (android.app.Application)1 LoadedApk (android.app.LoadedApk)1 Package (android.content.pm.PackageParser.Package)1 Resources (android.content.res.Resources)1 Bundle (android.os.Bundle)1 Lifecycle (com.android.settingslib.core.lifecycle.Lifecycle)1