Search in sources :

Example 6 with ResolveInfoBuilder

use of com.android.settings.testutils.ResolveInfoBuilder in project android_packages_apps_Settings by omnirom.

the class SmartAutoRotateCameraStateControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    final Context context = Mockito.spy(RuntimeEnvironment.application);
    final ContentResolver contentResolver = RuntimeEnvironment.application.getContentResolver();
    when(context.getContentResolver()).thenReturn(contentResolver);
    final PackageManager packageManager = Mockito.mock(PackageManager.class);
    when(context.getPackageManager()).thenReturn(packageManager);
    doReturn(PACKAGE_NAME).when(packageManager).getRotationResolverPackageName();
    mController = new SmartAutoRotateCameraStateController(context, "smart_auto_rotate");
    when(mController.isCameraLocked()).thenReturn(false);
    final ResolveInfo resolveInfo = new ResolveInfoBuilder(PACKAGE_NAME).build();
    resolveInfo.serviceInfo = new ServiceInfo();
    when(packageManager.resolveService(any(), anyInt())).thenReturn(resolveInfo);
}
Also used : Context(android.content.Context) ResolveInfo(android.content.pm.ResolveInfo) ServiceInfo(android.content.pm.ServiceInfo) PackageManager(android.content.pm.PackageManager) ResolveInfoBuilder(com.android.settings.testutils.ResolveInfoBuilder) ContentResolver(android.content.ContentResolver) Before(org.junit.Before)

Example 7 with ResolveInfoBuilder

use of com.android.settings.testutils.ResolveInfoBuilder in project android_packages_apps_Settings by omnirom.

the class SmartAutoRotateBatterySaverControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    final Context context = Mockito.spy(RuntimeEnvironment.application);
    final ContentResolver contentResolver = RuntimeEnvironment.application.getContentResolver();
    when(context.getContentResolver()).thenReturn(contentResolver);
    final PackageManager packageManager = Mockito.mock(PackageManager.class);
    when(context.getPackageManager()).thenReturn(packageManager);
    doReturn(PACKAGE_NAME).when(packageManager).getRotationResolverPackageName();
    mController = Mockito.spy(new SmartAutoRotateBatterySaverController(context, "smart_auto_rotate"));
    when(mController.isPowerSaveMode()).thenReturn(false);
    final ResolveInfo resolveInfo = new ResolveInfoBuilder(PACKAGE_NAME).build();
    resolveInfo.serviceInfo = new ServiceInfo();
    when(packageManager.resolveService(any(), anyInt())).thenReturn(resolveInfo);
}
Also used : Context(android.content.Context) ResolveInfo(android.content.pm.ResolveInfo) ServiceInfo(android.content.pm.ServiceInfo) PackageManager(android.content.pm.PackageManager) ResolveInfoBuilder(com.android.settings.testutils.ResolveInfoBuilder) ContentResolver(android.content.ContentResolver) Before(org.junit.Before)

Example 8 with ResolveInfoBuilder

use of com.android.settings.testutils.ResolveInfoBuilder in project android_packages_apps_Settings by omnirom.

the class RTTSettingPreferenceControllerTest method setupTestIntent.

private void setupTestIntent() {
    final ResolveInfo info = new ResolveInfoBuilder("pkg").setActivity("pkg", "class").build();
    final Intent intent = new Intent("com.android.test.action.example");
    mShadowPackageManager.addResolveInfoForIntent(intent, info);
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) Intent(android.content.Intent) ResolveInfoBuilder(com.android.settings.testutils.ResolveInfoBuilder)

Aggregations

ResolveInfo (android.content.pm.ResolveInfo)8 ResolveInfoBuilder (com.android.settings.testutils.ResolveInfoBuilder)8 ServiceInfo (android.content.pm.ServiceInfo)5 Before (org.junit.Before)5 Context (android.content.Context)4 ContentResolver (android.content.ContentResolver)3 Intent (android.content.Intent)3 PackageManager (android.content.pm.PackageManager)2 Test (org.junit.Test)2 SettingsMainSwitchBar (com.android.settings.widget.SettingsMainSwitchBar)1