use of com.android.settings.testutils.FakeFeatureFactory in project android_packages_apps_Settings by omnirom.
the class DatabaseResultLoaderTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = RuntimeEnvironment.application;
FakeFeatureFactory.setupForTest(mMockContext);
FakeFeatureFactory factory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mMockContext);
when(factory.searchFeatureProvider.getSiteMapManager()).thenReturn(mSiteMapManager);
mDb = IndexDatabaseHelper.getInstance(mContext).getWritableDatabase();
setUpDb();
}
use of com.android.settings.testutils.FakeFeatureFactory in project android_packages_apps_Settings by omnirom.
the class InstalledAppResultLoaderTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
final FakeFeatureFactory factory = FakeFeatureFactory.setupForTest(mContext);
when(factory.searchFeatureProvider.getSiteMapManager()).thenReturn(mSiteMapManager);
final List<UserInfo> infos = new ArrayList<>();
infos.add(new UserInfo(1, "user 1", 0));
when(mUserManager.getProfiles(anyInt())).thenReturn(infos);
when(mContext.getSystemService(Context.USER_SERVICE)).thenReturn(mUserManager);
when(mContext.getString(R.string.applications_settings)).thenReturn("app");
when(mPackageManagerWrapper.getInstalledApplicationsAsUser(anyInt(), anyInt())).thenReturn(Arrays.asList(ApplicationTestUtils.buildInfo(0, /* uid */
"app1", FLAG_SYSTEM, 0), ApplicationTestUtils.buildInfo(0, /* uid */
"app2", FLAG_SYSTEM, 0), ApplicationTestUtils.buildInfo(0, /* uid */
"app3", FLAG_SYSTEM, 0), ApplicationTestUtils.buildInfo(0, /* uid */
"app4", 0, /* flags */
0), ApplicationTestUtils.buildInfo(0, /* uid */
"app", 0, /* flags */
0), ApplicationTestUtils.buildInfo(0, /* uid */
"appBuffer", 0, /* flags */
0)));
}
use of com.android.settings.testutils.FakeFeatureFactory in project android_packages_apps_Settings by DirtyUnicorns.
the class AutomaticStorageManagementSwitchPreferenceControllerTest method togglingShouldCauseMetricsEvent.
@Test
public void togglingShouldCauseMetricsEvent() {
// FakeFeatureFactory uses mock contexts, so this test scaffolds itself rather than using
// the instance variables.
FakeFeatureFactory.setupForTest(mMockContext);
FakeFeatureFactory factory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mMockContext);
AutomaticStorageManagementSwitchPreferenceController controller = new AutomaticStorageManagementSwitchPreferenceController(mMockContext, factory.metricsFeatureProvider, mFragmentManager);
controller.onSwitchToggled(true);
verify(factory.metricsFeatureProvider, times(1)).action(any(Context.class), eq(MetricsEvent.ACTION_TOGGLE_STORAGE_MANAGER), eq(true));
}
use of com.android.settings.testutils.FakeFeatureFactory in project android_packages_apps_Settings by DirtyUnicorns.
the class GesturesSettingsPreferenceControllerTest method updateState_assistSupported_shouldSetToAssistGestureStatus.
@Test
@Config(shadows = { ShadowSecureSettings.class })
public void updateState_assistSupported_shouldSetToAssistGestureStatus() {
final FakeFeatureFactory featureFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mActivity);
when(featureFactory.assistGestureFeatureProvider.isSupported(any(Context.class))).thenReturn(true);
when(featureFactory.assistGestureFeatureProvider.isSensorAvailable(any(Context.class))).thenReturn(true);
final ContentResolver cr = mActivity.getContentResolver();
Settings.Secure.putInt(cr, Settings.Secure.ASSIST_GESTURE_ENABLED, 0);
Settings.Secure.putInt(cr, Settings.Secure.ASSIST_GESTURE_SILENCE_ALERTS_ENABLED, 0);
mController.updateState(mPreference);
verify(mActivity).getString(R.string.language_input_gesture_summary_off);
Settings.Secure.putInt(cr, Settings.Secure.ASSIST_GESTURE_ENABLED, 1);
Settings.Secure.putInt(cr, Settings.Secure.ASSIST_GESTURE_SILENCE_ALERTS_ENABLED, 0);
mController.updateState(mPreference);
verify(mActivity).getString(R.string.language_input_gesture_summary_on_with_assist);
Settings.Secure.putInt(cr, Settings.Secure.ASSIST_GESTURE_ENABLED, 0);
Settings.Secure.putInt(cr, Settings.Secure.ASSIST_GESTURE_SILENCE_ALERTS_ENABLED, 1);
mController.updateState(mPreference);
verify(mActivity).getString(R.string.language_input_gesture_summary_on_non_assist);
}
use of com.android.settings.testutils.FakeFeatureFactory in project android_packages_apps_Settings by DirtyUnicorns.
the class GesturesSettingsPreferenceControllerTest method updateState_sensorNotAvailable_shouldSetToEmptyStatus.
@Test
@Config(shadows = { ShadowSecureSettings.class })
public void updateState_sensorNotAvailable_shouldSetToEmptyStatus() {
final FakeFeatureFactory featureFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mActivity);
when(featureFactory.assistGestureFeatureProvider.isSensorAvailable(any(Context.class))).thenReturn(false);
mController.updateState(mPreference);
verify(mPreference).setSummary("");
}
Aggregations