Search in sources :

Example 1 with ResolveInfoBuilder

use of com.android.settings.testutils.ResolveInfoBuilder in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class RTTSettingPreferenceControllerTest method getAvailabilityStatus_defaultDialerIsExpected_intentCanBeHandled_returnAVAILABLE.

@Test
public void getAvailabilityStatus_defaultDialerIsExpected_intentCanBeHandled_returnAVAILABLE() {
    // Default dialer is expected.
    doReturn(true).when(mController).isDialerSupportRTTSetting();
    // Intent can be handled.
    final ResolveInfo info = new ResolveInfoBuilder("pkg").setActivity("pkg", "class").build();
    final Intent intent = new Intent("com.android.test.action.example");
    mShadowPackageManager.addResolveInfoForIntent(intent, info);
    assertThat(mController.getAvailabilityStatus()).isEqualTo(BasePreferenceController.AVAILABLE);
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) Intent(android.content.Intent) ResolveInfoBuilder(com.android.settings.testutils.ResolveInfoBuilder) Test(org.junit.Test)

Example 2 with ResolveInfoBuilder

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

the class SmartAutoRotateControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    final Context context = Mockito.spy(RuntimeEnvironment.application);
    mContentResolver = RuntimeEnvironment.application.getContentResolver();
    when(context.getPackageManager()).thenReturn(mPackageManager);
    when(context.getContentResolver()).thenReturn(mContentResolver);
    doReturn(PACKAGE_NAME).when(mPackageManager).getRotationResolverPackageName();
    doReturn(PackageManager.PERMISSION_GRANTED).when(mPackageManager).checkPermission(Manifest.permission.CAMERA, PACKAGE_NAME);
    mController = Mockito.spy(new SmartAutoRotateController(context, "test_key"));
    when(mController.isCameraLocked()).thenReturn(false);
    when(mController.isPowerSaveMode()).thenReturn(false);
    doReturn(mController.getPreferenceKey()).when(mPreference).getKey();
    final ResolveInfo resolveInfo = new ResolveInfoBuilder(PACKAGE_NAME).build();
    resolveInfo.serviceInfo = new ServiceInfo();
    when(mPackageManager.resolveService(any(), anyInt())).thenReturn(resolveInfo);
    enableAutoRotation();
}
Also used : Context(android.content.Context) ResolveInfo(android.content.pm.ResolveInfo) ServiceInfo(android.content.pm.ServiceInfo) ResolveInfoBuilder(com.android.settings.testutils.ResolveInfoBuilder) Before(org.junit.Before)

Example 3 with ResolveInfoBuilder

use of com.android.settings.testutils.ResolveInfoBuilder in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class RTTSettingPreferenceControllerTest method getAvailabilityStatus_defaultDialerIsNotExpected_returnUNSUPPORTED_ON_DEVICE.

@Test
public void getAvailabilityStatus_defaultDialerIsNotExpected_returnUNSUPPORTED_ON_DEVICE() {
    // Default dialer is not expected.
    doReturn(false).when(mController).isDialerSupportRTTSetting();
    // Intent can be handled.
    final ResolveInfo info = new ResolveInfoBuilder("pkg").setActivity("pkg", "class").build();
    final Intent intent = new Intent("com.android.test.action.example");
    mShadowPackageManager.addResolveInfoForIntent(intent, info);
    assertThat(mController.getAvailabilityStatus()).isEqualTo(BasePreferenceController.UNSUPPORTED_ON_DEVICE);
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) Intent(android.content.Intent) ResolveInfoBuilder(com.android.settings.testutils.ResolveInfoBuilder) Test(org.junit.Test)

Example 4 with ResolveInfoBuilder

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

the class SmartAutoRotatePreferenceControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mContext = Mockito.spy(RuntimeEnvironment.application);
    FakeFeatureFactory.setupForTest();
    mContentResolver = RuntimeEnvironment.application.getContentResolver();
    when(mContext.getPackageManager()).thenReturn(mPackageManager);
    when(mContext.getResources()).thenReturn(mResources);
    when(mContext.getContentResolver()).thenReturn(mContentResolver);
    doReturn(PACKAGE_NAME).when(mPackageManager).getRotationResolverPackageName();
    doReturn(PackageManager.PERMISSION_GRANTED).when(mPackageManager).checkPermission(Manifest.permission.CAMERA, PACKAGE_NAME);
    when(mContext.getString(R.string.auto_rotate_option_off)).thenReturn("Off");
    when(mContext.getString(R.string.auto_rotate_option_on)).thenReturn("On");
    when(mContext.getString(R.string.auto_rotate_option_face_based)).thenReturn("On - Face-based");
    disableCameraBasedRotation();
    final ResolveInfo resolveInfo = new ResolveInfoBuilder(PACKAGE_NAME).build();
    resolveInfo.serviceInfo = new ServiceInfo();
    when(mPackageManager.resolveService(any(), anyInt())).thenReturn(resolveInfo);
    mController = Mockito.spy(new SmartAutoRotatePreferenceController(mContext, "smart_auto_rotate"));
    when(mController.isCameraLocked()).thenReturn(false);
    when(mController.isPowerSaveMode()).thenReturn(false);
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) ServiceInfo(android.content.pm.ServiceInfo) ResolveInfoBuilder(com.android.settings.testutils.ResolveInfoBuilder) Before(org.junit.Before)

Example 5 with ResolveInfoBuilder

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

the class SmartAutoRotatePreferenceFragmentTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    final Context context = spy(RuntimeEnvironment.application);
    ContentResolver mContentResolver = RuntimeEnvironment.application.getContentResolver();
    when(context.getPackageManager()).thenReturn(mPackageManager);
    when(context.getContentResolver()).thenReturn(mContentResolver);
    doReturn(PACKAGE_NAME).when(mPackageManager).getRotationResolverPackageName();
    doReturn(PackageManager.PERMISSION_GRANTED).when(mPackageManager).checkPermission(Manifest.permission.CAMERA, PACKAGE_NAME);
    final ResolveInfo resolveInfo = new ResolveInfoBuilder(PACKAGE_NAME).build();
    resolveInfo.serviceInfo = new ServiceInfo();
    when(mPackageManager.resolveService(any(), anyInt())).thenReturn(resolveInfo);
    mFragment = spy(new SmartAutoRotatePreferenceFragment());
    when(mActivity.getPackageManager()).thenReturn(mPackageManager);
    when(mFragment.getActivity()).thenReturn(mActivity);
    when(mFragment.getContext()).thenReturn(context);
    doReturn(mView).when(mFragment).getView();
    when(mFragment.findPreference(AUTO_ROTATE_SWITCH_PREFERENCE_ID)).thenReturn(mRotateSwitchPreference);
    mSwitchBar = spy(new SettingsMainSwitchBar(context));
    when(mActivity.getSwitchBar()).thenReturn(mSwitchBar);
    doReturn(mSwitchBar).when(mView).findViewById(R.id.switch_bar);
}
Also used : Context(android.content.Context) ResolveInfo(android.content.pm.ResolveInfo) ServiceInfo(android.content.pm.ServiceInfo) SettingsMainSwitchBar(com.android.settings.widget.SettingsMainSwitchBar) ResolveInfoBuilder(com.android.settings.testutils.ResolveInfoBuilder) ContentResolver(android.content.ContentResolver) Before(org.junit.Before)

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