use of androidx.preference.Preference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class RecentNotifyingAppsPreferenceControllerTest method display_showRecentsWithInstantApp.
@Test
public void display_showRecentsWithInstantApp() throws Exception {
List<Event> events = new ArrayList<>();
Event app = new Event();
app.mEventType = Event.NOTIFICATION_INTERRUPTION;
app.mPackage = "com.foo.bar";
app.mTimeStamp = System.currentTimeMillis();
events.add(app);
Event app1 = new Event();
app1.mEventType = Event.NOTIFICATION_INTERRUPTION;
app1.mPackage = "com.foo.barinstant";
app1.mTimeStamp = System.currentTimeMillis() + 200;
events.add(app1);
UsageEvents usageEvents = getUsageEvents(new String[] { "com.foo.bar", "com.foo.barinstant" }, events);
when(mIUsageStatsManager.queryEventsForUser(anyLong(), anyLong(), anyInt(), anyString())).thenReturn(usageEvents);
ApplicationsState.AppEntry app1Entry = mock(ApplicationsState.AppEntry.class);
ApplicationsState.AppEntry app2Entry = mock(ApplicationsState.AppEntry.class);
app1Entry.info = mApplicationInfo;
app2Entry.info = mApplicationInfo;
when(mAppState.getEntry(app.getPackageName(), UserHandle.myUserId())).thenReturn(app1Entry);
when(mAppState.getEntry(app1.getPackageName(), UserHandle.myUserId())).thenReturn(app2Entry);
// Only the regular app app1 should have its intent resolve.
when(mPackageManager.resolveActivity(argThat(intentMatcher(app.getPackageName())), anyInt())).thenReturn(new ResolveInfo());
// Make sure app2 is considered an instant app.
ReflectionHelpers.setStaticField(AppUtils.class, "sInstantAppDataProvider", (InstantAppDataProvider) (ApplicationInfo info) -> {
if (info == app2Entry.info) {
return true;
} else {
return false;
}
});
mController.displayPreference(mScreen);
ArgumentCaptor<Preference> prefCaptor = ArgumentCaptor.forClass(Preference.class);
verify(mCategory, times(2)).addPreference(prefCaptor.capture());
List<Preference> prefs = prefCaptor.getAllValues();
assertThat(prefs.get(1).getKey()).isEqualTo(RecentNotifyingAppsPreferenceController.getKey(UserHandle.myUserId(), app.getPackageName()));
assertThat(prefs.get(0).getKey()).isEqualTo(RecentNotifyingAppsPreferenceController.getKey(UserHandle.myUserId(), app1.getPackageName()));
}
use of androidx.preference.Preference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class PulseNotificationPreferenceControllerTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = spy(RuntimeEnvironment.application);
when(mContext.getResources()).thenReturn(mResources);
mController = new PulseNotificationPreferenceController(mContext, "testkey");
mPreference = new Preference(mContext);
mPreference.setKey(mController.getPreferenceKey());
when(mScreen.findPreference(mPreference.getKey())).thenReturn(mPreference);
}
use of androidx.preference.Preference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class RingtonePreferenceControllerBaseTest method updateState_shouldSetSummary.
@Test
public void updateState_shouldSetSummary() {
Preference preference = mock(Preference.class);
Settings.System.putString(mContext.getContentResolver(), Settings.System.RINGTONE, "content://test/ringtone");
mController.updateState(preference);
verify(preference).setSummary(anyString());
}
use of androidx.preference.Preference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class SnoozeNotificationPreferenceControllerTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mController = new SnoozeNotificationPreferenceController(mContext, "key");
mPreference = new Preference(RuntimeEnvironment.application);
mPreference.setKey(mController.getPreferenceKey());
when(mScreen.findPreference(mPreference.getKey())).thenReturn(mPreference);
}
use of androidx.preference.Preference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class VibrateWhenRingPreferenceControllerTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = spy(RuntimeEnvironment.application);
mContentResolver = mContext.getContentResolver();
when(mContext.getSystemService(Context.TELEPHONY_SERVICE)).thenReturn(mTelephonyManager);
mController = new VibrateWhenRingPreferenceController(mContext, KEY_VIBRATE_WHEN_RINGING);
mPreference = new Preference(mContext);
mPreference.setKey(mController.getPreferenceKey());
when(mScreen.findPreference(mPreference.getKey())).thenReturn(mPreference);
}
Aggregations