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);
}
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();
}
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);
}
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);
}
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);
}
Aggregations