use of com.android.settings.deviceinfo.StorageItemPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class StorageItemPreferenceControllerTest method testMeasurementCompletedUpdatesPreferences.
@Test
public void testMeasurementCompletedUpdatesPreferences() {
final StorageItemPreference audio = new StorageItemPreference(mContext);
final StorageItemPreference image = new StorageItemPreference(mContext);
final StorageItemPreference games = new StorageItemPreference(mContext);
final StorageItemPreference movies = new StorageItemPreference(mContext);
final StorageItemPreference apps = new StorageItemPreference(mContext);
final StorageItemPreference system = new StorageItemPreference(mContext);
final StorageItemPreference files = new StorageItemPreference(mContext);
final PreferenceScreen screen = mock(PreferenceScreen.class);
when(screen.findPreference(eq(StorageItemPreferenceController.GAME_KEY))).thenReturn(games);
when(screen.findPreference(eq(StorageItemPreferenceController.AUDIO_KEY))).thenReturn(audio);
when(screen.findPreference(eq(StorageItemPreferenceController.PHOTO_KEY))).thenReturn(image);
when(screen.findPreference(eq(StorageItemPreferenceController.FILES_KEY))).thenReturn(files);
when(screen.findPreference(eq(StorageItemPreferenceController.MOVIES_KEY))).thenReturn(movies);
when(screen.findPreference(eq(StorageItemPreferenceController.SYSTEM_KEY))).thenReturn(system);
when(screen.findPreference(eq(StorageItemPreferenceController.OTHER_APPS_KEY))).thenReturn(apps);
mController.displayPreference(screen);
// There should 870MB attributed.
mController.setUsedSize(MEGABYTE_IN_BYTES * 970);
final StorageAsyncLoader.AppsStorageResult result = new StorageAsyncLoader.AppsStorageResult();
result.gamesSize = MEGABYTE_IN_BYTES * 80;
result.videoAppsSize = MEGABYTE_IN_BYTES * 160;
result.musicAppsSize = MEGABYTE_IN_BYTES * 40;
result.otherAppsSize = MEGABYTE_IN_BYTES * 90;
result.externalStats = new StorageStatsSource.ExternalStorageStats(// total
MEGABYTE_IN_BYTES * 500, // audio
MEGABYTE_IN_BYTES * 100, // video
MEGABYTE_IN_BYTES * 150, MEGABYTE_IN_BYTES * 200, // image
0);
final SparseArray<StorageAsyncLoader.AppsStorageResult> results = new SparseArray<>();
results.put(0, result);
mController.onLoadFinished(results, 0);
assertThat(audio.getSummary().toString()).isEqualTo("0.14 GB");
assertThat(image.getSummary().toString()).isEqualTo("0.35 GB");
assertThat(games.getSummary().toString()).isEqualTo("0.08 GB");
assertThat(movies.getSummary().toString()).isEqualTo("0.16 GB");
assertThat(apps.getSummary().toString()).isEqualTo("0.09 GB");
assertThat(files.getSummary().toString()).isEqualTo("0.05 GB");
}
use of com.android.settings.deviceinfo.StorageItemPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class StorageItemPreferenceControllerTest method settingUserIdAppliesNewIcons.
@Test
public void settingUserIdAppliesNewIcons() {
final StorageItemPreference audio = spy(new StorageItemPreference(mContext));
audio.setIcon(R.drawable.ic_media_stream);
final StorageItemPreference video = spy(new StorageItemPreference(mContext));
video.setIcon(R.drawable.ic_local_movies);
final StorageItemPreference image = spy(new StorageItemPreference(mContext));
image.setIcon(R.drawable.ic_photo_library);
final StorageItemPreference games = spy(new StorageItemPreference(mContext));
games.setIcon(R.drawable.ic_videogame_vd_theme_24);
final StorageItemPreference apps = spy(new StorageItemPreference(mContext));
apps.setIcon(R.drawable.ic_storage_apps);
final StorageItemPreference system = spy(new StorageItemPreference(mContext));
system.setIcon(R.drawable.ic_system_update);
final StorageItemPreference files = spy(new StorageItemPreference(mContext));
files.setIcon(R.drawable.ic_folder_vd_theme_24);
final PreferenceScreen screen = mock(PreferenceScreen.class);
when(screen.findPreference(eq(StorageItemPreferenceController.GAME_KEY))).thenReturn(games);
when(screen.findPreference(eq(StorageItemPreferenceController.AUDIO_KEY))).thenReturn(audio);
when(screen.findPreference(eq(StorageItemPreferenceController.PHOTO_KEY))).thenReturn(image);
when(screen.findPreference(eq(StorageItemPreferenceController.FILES_KEY))).thenReturn(files);
when(screen.findPreference(eq(StorageItemPreferenceController.MOVIES_KEY))).thenReturn(video);
when(screen.findPreference(eq(StorageItemPreferenceController.SYSTEM_KEY))).thenReturn(system);
when(screen.findPreference(eq(StorageItemPreferenceController.OTHER_APPS_KEY))).thenReturn(apps);
mController.displayPreference(screen);
mController.setUserId(new UserHandle(10));
verify(audio, times(2)).setIcon(nullable(Drawable.class));
verify(video, times(2)).setIcon(nullable(Drawable.class));
verify(image, times(2)).setIcon(nullable(Drawable.class));
verify(games, times(2)).setIcon(nullable(Drawable.class));
verify(apps, times(2)).setIcon(nullable(Drawable.class));
verify(system, times(2)).setIcon(nullable(Drawable.class));
verify(files, times(2)).setIcon(nullable(Drawable.class));
}
use of com.android.settings.deviceinfo.StorageItemPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class SecondaryUserController method displayPreference.
@Override
public void displayPreference(PreferenceScreen screen) {
if (mStoragePreference == null) {
mStoragePreference = new StorageItemPreference(screen.getContext());
PreferenceGroup group = screen.findPreference(TARGET_PREFERENCE_GROUP_KEY);
mStoragePreference.setTitle(mUser.name);
mStoragePreference.setKey(PREFERENCE_KEY_BASE + mUser.id);
if (mSize != SIZE_NOT_SET) {
mStoragePreference.setStorageSize(mSize, mTotalSizeBytes);
}
group.setVisible(true);
group.addPreference(mStoragePreference);
maybeSetIcon();
}
}
use of com.android.settings.deviceinfo.StorageItemPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class UserProfileController method displayPreference.
@Override
public void displayPreference(PreferenceScreen screen) {
mStoragePreference = new StorageItemPreference(screen.getContext());
mStoragePreference.setOrder(mPreferenceOrder);
mStoragePreference.setKey(PREFERENCE_KEY_BASE + mUser.id);
mStoragePreference.setTitle(mUser.name);
screen.addPreference(mStoragePreference);
}
use of com.android.settings.deviceinfo.StorageItemPreference in project android_packages_apps_Settings by omnirom.
the class StorageItemPreferenceControllerTest method getPreferenceScreen.
private PreferenceScreen getPreferenceScreen() {
final StorageItemPreference publicStorage = spy(new StorageItemPreference(mContext));
publicStorage.setIcon(R.drawable.ic_folder_vd_theme_24);
final StorageItemPreference images = spy(new StorageItemPreference(mContext));
images.setIcon(R.drawable.ic_photo_library);
final StorageItemPreference videos = spy(new StorageItemPreference(mContext));
videos.setIcon(R.drawable.ic_local_movies);
final StorageItemPreference audio = spy(new StorageItemPreference(mContext));
audio.setIcon(R.drawable.ic_media_stream);
final StorageItemPreference apps = spy(new StorageItemPreference(mContext));
apps.setIcon(R.drawable.ic_storage_apps);
final StorageItemPreference games = spy(new StorageItemPreference(mContext));
games.setIcon(R.drawable.ic_videogame_vd_theme_24);
final StorageItemPreference documentsAndOther = spy(new StorageItemPreference(mContext));
documentsAndOther.setIcon(R.drawable.ic_folder_vd_theme_24);
final StorageItemPreference system = spy(new StorageItemPreference(mContext));
system.setIcon(R.drawable.ic_system_update);
final StorageItemPreference trash = spy(new StorageItemPreference(mContext));
trash.setIcon(R.drawable.ic_trash_can);
final PreferenceScreen screen = mock(PreferenceScreen.class);
when(screen.findPreference(eq(StorageItemPreferenceController.PUBLIC_STORAGE_KEY))).thenReturn(publicStorage);
when(screen.findPreference(eq(StorageItemPreferenceController.IMAGES_KEY))).thenReturn(images);
when(screen.findPreference(eq(StorageItemPreferenceController.VIDEOS_KEY))).thenReturn(videos);
when(screen.findPreference(eq(StorageItemPreferenceController.AUDIO_KEY))).thenReturn(audio);
when(screen.findPreference(eq(StorageItemPreferenceController.APPS_KEY))).thenReturn(apps);
when(screen.findPreference(eq(StorageItemPreferenceController.GAMES_KEY))).thenReturn(games);
when(screen.findPreference(eq(StorageItemPreferenceController.DOCUMENTS_AND_OTHER_KEY))).thenReturn(documentsAndOther);
when(screen.findPreference(eq(StorageItemPreferenceController.SYSTEM_KEY))).thenReturn(system);
when(screen.findPreference(eq(StorageItemPreferenceController.TRASH_KEY))).thenReturn(trash);
return screen;
}
Aggregations