use of com.android.settingslib.deviceinfo.PrivateStorageInfo in project android_packages_apps_Settings by omnirom.
the class StorageDashboardFragmentTest method test_cacheProviderProvidesValuesIfBothCached.
@Test
public void test_cacheProviderProvidesValuesIfBothCached() {
CachedStorageValuesHelper helper = mock(CachedStorageValuesHelper.class);
PrivateStorageInfo info = new PrivateStorageInfo(0, 0);
when(helper.getCachedPrivateStorageInfo()).thenReturn(info);
SparseArray<StorageAsyncLoader.AppsStorageResult> result = new SparseArray<>();
when(helper.getCachedAppsStorageResult()).thenReturn(result);
mFragment.setCachedStorageValuesHelper(helper);
mFragment.initializeCachedValues();
assertThat(mFragment.getPrivateStorageInfo()).isEqualTo(info);
assertThat(mFragment.getAppsStorageResult()).isEqualTo(result);
}
use of com.android.settingslib.deviceinfo.PrivateStorageInfo in project android_packages_apps_Settings by omnirom.
the class CachedStorageValuesHelperTest method cacheResult_succeeds.
@Test
public void cacheResult_succeeds() throws Exception {
when(mMockClock.getCurrentTime()).thenReturn(10000L);
final StorageStatsSource.ExternalStorageStats externalStats = new StorageStatsSource.ExternalStorageStats(22222l, 2l, 20L, 200L, 2000L);
final StorageAsyncLoader.AppsStorageResult result = new StorageAsyncLoader.AppsStorageResult();
result.gamesSize = 1L;
result.musicAppsSize = 10l;
result.videoAppsSize = 100L;
result.photosAppsSize = 1000L;
result.otherAppsSize = 10000L;
result.cacheSize = 100000l;
result.externalStats = externalStats;
final PrivateStorageInfo info = new PrivateStorageInfo(1000L, 6000L);
mCachedValuesHelper.cacheResult(info, result);
assertThat(mSharedPreferences.getLong(GAME_APPS_SIZE_KEY, -1)).isEqualTo(1L);
assertThat(mSharedPreferences.getLong(MUSIC_APPS_SIZE_KEY, -1)).isEqualTo(10L);
assertThat(mSharedPreferences.getLong(VIDEO_APPS_SIZE_KEY, -1)).isEqualTo(100L);
assertThat(mSharedPreferences.getLong(PHOTO_APPS_SIZE_KEY, -1)).isEqualTo(1000L);
assertThat(mSharedPreferences.getLong(OTHER_APPS_SIZE_KEY, -1)).isEqualTo(10000L);
assertThat(mSharedPreferences.getLong(CACHE_APPS_SIZE_KEY, -1)).isEqualTo(100000L);
assertThat(mSharedPreferences.getLong(EXTERNAL_TOTAL_BYTES, -1)).isEqualTo(22222L);
assertThat(mSharedPreferences.getLong(EXTERNAL_AUDIO_BYTES, -1)).isEqualTo(2L);
assertThat(mSharedPreferences.getLong(EXTERNAL_VIDEO_BYTES, -1)).isEqualTo(20L);
assertThat(mSharedPreferences.getLong(EXTERNAL_IMAGE_BYTES, -1)).isEqualTo(200L);
assertThat(mSharedPreferences.getLong(EXTERNAL_APP_BYTES, -1)).isEqualTo(2000L);
assertThat(mSharedPreferences.getLong(FREE_BYTES_KEY, -1)).isEqualTo(1000L);
assertThat(mSharedPreferences.getLong(TOTAL_BYTES_KEY, -1)).isEqualTo(6000L);
assertThat(mSharedPreferences.getInt(USER_ID_KEY, -1)).isEqualTo(0);
assertThat(mSharedPreferences.getLong(TIMESTAMP_KEY, -1)).isEqualTo(10000L);
}
use of com.android.settingslib.deviceinfo.PrivateStorageInfo in project android_packages_apps_Settings by omnirom.
the class CachedStorageValuesHelperTest method getCachedPrivateStorageInfo_nullIfDataIsStale.
@Test
public void getCachedPrivateStorageInfo_nullIfDataIsStale() throws Exception {
when(mMockClock.getCurrentTime()).thenReturn(10000000L);
mSharedPreferences.edit().putLong(GAME_APPS_SIZE_KEY, 0).putLong(MUSIC_APPS_SIZE_KEY, 10).putLong(VIDEO_APPS_SIZE_KEY, 100).putLong(PHOTO_APPS_SIZE_KEY, 1000).putLong(OTHER_APPS_SIZE_KEY, 10000).putLong(CACHE_APPS_SIZE_KEY, 100000).putLong(EXTERNAL_TOTAL_BYTES, 2).putLong(EXTERNAL_AUDIO_BYTES, 22).putLong(EXTERNAL_VIDEO_BYTES, 222).putLong(EXTERNAL_IMAGE_BYTES, 2222).putLong(EXTERNAL_APP_BYTES, 22222).putLong(FREE_BYTES_KEY, 1000L).putLong(TOTAL_BYTES_KEY, 5000L).putInt(USER_ID_KEY, 0).putLong(TIMESTAMP_KEY, 10000L).apply();
PrivateStorageInfo info = mCachedValuesHelper.getCachedPrivateStorageInfo();
assertThat(info).isNull();
}
use of com.android.settingslib.deviceinfo.PrivateStorageInfo in project android_packages_apps_Settings by omnirom.
the class StorageDashboardFragment method initializeCachedValues.
@VisibleForTesting
public void initializeCachedValues() {
PrivateStorageInfo info = mCachedStorageValuesHelper.getCachedPrivateStorageInfo();
SparseArray<StorageAsyncLoader.AppsStorageResult> loaderResult = mCachedStorageValuesHelper.getCachedAppsStorageResult();
if (info == null || loaderResult == null) {
return;
}
mStorageInfo = info;
mAppsResult = loaderResult;
}
use of com.android.settingslib.deviceinfo.PrivateStorageInfo in project android_packages_apps_Settings by DirtyUnicorns.
the class CachedStorageValuesHelperTest method getCachedPrivateStorageInfo_nullIfWrongUser.
@Test
public void getCachedPrivateStorageInfo_nullIfWrongUser() throws Exception {
when(mMockClock.getCurrentTime()).thenReturn(10001L);
mSharedPreferences.edit().putLong(GAME_APPS_SIZE_KEY, 0).putLong(MUSIC_APPS_SIZE_KEY, 10).putLong(VIDEO_APPS_SIZE_KEY, 100).putLong(PHOTO_APPS_SIZE_KEY, 1000).putLong(OTHER_APPS_SIZE_KEY, 10000).putLong(CACHE_APPS_SIZE_KEY, 100000).putLong(EXTERNAL_TOTAL_BYTES, 2).putLong(EXTERNAL_AUDIO_BYTES, 22).putLong(EXTERNAL_VIDEO_BYTES, 222).putLong(EXTERNAL_IMAGE_BYTES, 2222).putLong(EXTERNAL_APP_BYTES, 22222).putLong(FREE_BYTES_KEY, 1000L).putLong(TOTAL_BYTES_KEY, 5000L).putInt(USER_ID_KEY, 1).putLong(TIMESTAMP_KEY, 10000L).apply();
PrivateStorageInfo info = mCachedValuesHelper.getCachedPrivateStorageInfo();
assertThat(info).isNull();
}
Aggregations