Search in sources :

Example 21 with PrivateStorageInfo

use of com.android.settingslib.deviceinfo.PrivateStorageInfo in project android_packages_apps_Settings by DirtyUnicorns.

the class CachedStorageValuesHelperTest method getCachedPrivateStorageInfo_nullIfEmpty.

@Test
public void getCachedPrivateStorageInfo_nullIfEmpty() throws Exception {
    PrivateStorageInfo info = mCachedValuesHelper.getCachedPrivateStorageInfo();
    assertThat(info).isNull();
}
Also used : PrivateStorageInfo(com.android.settingslib.deviceinfo.PrivateStorageInfo) Test(org.junit.Test)

Example 22 with PrivateStorageInfo

use of com.android.settingslib.deviceinfo.PrivateStorageInfo in project android_packages_apps_Settings by DirtyUnicorns.

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);
}
Also used : PrivateStorageInfo(com.android.settingslib.deviceinfo.PrivateStorageInfo) StorageStatsSource(com.android.settingslib.applications.StorageStatsSource) Test(org.junit.Test)

Example 23 with PrivateStorageInfo

use of com.android.settingslib.deviceinfo.PrivateStorageInfo in project android_packages_apps_Settings by DirtyUnicorns.

the class VolumeSizesLoaderTest method getVolumeSize_getsValidSizes.

@Test
public void getVolumeSize_getsValidSizes() throws Exception {
    VolumeInfo info = mock(VolumeInfo.class);
    StorageVolumeProvider storageVolumeProvider = mock(StorageVolumeProvider.class);
    when(storageVolumeProvider.getTotalBytes(any(), any())).thenReturn(10000L);
    when(storageVolumeProvider.getFreeBytes(any(), any())).thenReturn(1000L);
    PrivateStorageInfo storageInfo = VolumeSizesLoader.getVolumeSize(storageVolumeProvider, null, info);
    assertThat(storageInfo.freeBytes).isEqualTo(1000L);
    assertThat(storageInfo.totalBytes).isEqualTo(10000L);
}
Also used : PrivateStorageInfo(com.android.settingslib.deviceinfo.PrivateStorageInfo) StorageVolumeProvider(com.android.settingslib.deviceinfo.StorageVolumeProvider) VolumeInfo(android.os.storage.VolumeInfo) Test(org.junit.Test)

Example 24 with PrivateStorageInfo

use of com.android.settingslib.deviceinfo.PrivateStorageInfo in project android_packages_apps_Settings by DirtyUnicorns.

the class StorageDashboardFragmentTest method test_dontLoadWhenQuotaOnAndAllLoaded.

@Test
public void test_dontLoadWhenQuotaOnAndAllLoaded() {
    View fakeView = mock(View.class, RETURNS_DEEP_STUBS);
    RecyclerView fakeRecyclerView = mock(RecyclerView.class, RETURNS_DEEP_STUBS);
    when(fakeView.findViewById(anyInt())).thenReturn(fakeView);
    mFragment = spy(mFragment);
    when(mFragment.getView()).thenReturn(fakeView);
    when(mFragment.getListView()).thenReturn(fakeRecyclerView);
    mFragment.setAppsStorageResult(new SparseArray<>());
    PrivateStorageInfo storageInfo = new PrivateStorageInfo(0, 0);
    mFragment.setPrivateStorageInfo(storageInfo);
    mFragment.maybeSetLoading(true);
    verify(mFragment, never()).setLoading(true, false);
}
Also used : PrivateStorageInfo(com.android.settingslib.deviceinfo.PrivateStorageInfo) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) Test(org.junit.Test)

Example 25 with PrivateStorageInfo

use of com.android.settingslib.deviceinfo.PrivateStorageInfo in project android_packages_apps_Settings by DirtyUnicorns.

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);
}
Also used : SparseArray(android.util.SparseArray) CachedStorageValuesHelper(com.android.settings.deviceinfo.storage.CachedStorageValuesHelper) PrivateStorageInfo(com.android.settingslib.deviceinfo.PrivateStorageInfo) Test(org.junit.Test)

Aggregations

PrivateStorageInfo (com.android.settingslib.deviceinfo.PrivateStorageInfo)99 Test (org.junit.Test)86 View (android.view.View)21 RecyclerView (android.support.v7.widget.RecyclerView)15 CachedStorageValuesHelper (com.android.settings.deviceinfo.storage.CachedStorageValuesHelper)14 Slice (androidx.slice.Slice)9 VolumeInfo (android.os.storage.VolumeInfo)8 Config (org.robolectric.annotation.Config)8 SparseArray (android.util.SparseArray)7 StorageStatsSource (com.android.settingslib.applications.StorageStatsSource)7 StorageVolumeProvider (com.android.settingslib.deviceinfo.StorageVolumeProvider)7 VisibleForTesting (android.support.annotation.VisibleForTesting)6 RecyclerView (androidx.recyclerview.widget.RecyclerView)6 SliceMetadata (androidx.slice.SliceMetadata)5 IconCompat (androidx.core.graphics.drawable.IconCompat)4 ShadowPrivateStorageInfo (com.android.settings.testutils.shadow.ShadowPrivateStorageInfo)4 ListBuilder (androidx.slice.builders.ListBuilder)3 StorageManagerVolumeProvider (com.android.settingslib.deviceinfo.StorageManagerVolumeProvider)3 VisibleForTesting (androidx.annotation.VisibleForTesting)2 NumberFormat (java.text.NumberFormat)2