Search in sources :

Example 86 with PrivateStorageInfo

use of com.android.settingslib.deviceinfo.PrivateStorageInfo in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class LowStorageSliceTest method getSlice_storageFree_shouldHaveStorageSettingsTitle.

@Test
@Config(shadows = ShadowPrivateStorageInfo.class)
public void getSlice_storageFree_shouldHaveStorageSettingsTitle() {
    ShadowPrivateStorageInfo.setPrivateStorageInfo(new PrivateStorageInfo(100L, 100L));
    final Slice slice = mLowStorageSlice.getSlice();
    final SliceMetadata metadata = SliceMetadata.from(mContext, slice);
    assertThat(metadata.getTitle()).isEqualTo(mContext.getString(R.string.storage_settings));
}
Also used : PrivateStorageInfo(com.android.settingslib.deviceinfo.PrivateStorageInfo) Slice(androidx.slice.Slice) SliceMetadata(androidx.slice.SliceMetadata) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 87 with PrivateStorageInfo

use of com.android.settingslib.deviceinfo.PrivateStorageInfo in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class StorageSliceTest method getSlice_shouldBeCorrectSliceContent.

@Test
public void getSlice_shouldBeCorrectSliceContent() {
    final PrivateStorageInfo info = new PrivateStorageInfo(100L, 600L);
    doReturn(info).when(mStorageSlice).getPrivateStorageInfo();
    doReturn(USED_BYTES_TEXT).when(mStorageSlice).getStorageUsedText(any());
    doReturn(SUMMARY_TEXT).when(mStorageSlice).getStorageSummaryText(any());
    final Slice slice = mStorageSlice.getSlice();
    final SliceMetadata metadata = SliceMetadata.from(mContext, slice);
    assertThat(metadata.getTitle()).isEqualTo(mContext.getString(R.string.storage_label));
    final SliceAction primaryAction = metadata.getPrimaryAction();
    final IconCompat expectedIcon = IconCompat.createWithResource(mContext, R.drawable.ic_homepage_storage);
    assertThat(primaryAction.getIcon().toString()).isEqualTo(expectedIcon.toString());
}
Also used : PrivateStorageInfo(com.android.settingslib.deviceinfo.PrivateStorageInfo) Slice(androidx.slice.Slice) IconCompat(androidx.core.graphics.drawable.IconCompat) SliceMetadata(androidx.slice.SliceMetadata) SliceAction(androidx.slice.core.SliceAction) Test(org.junit.Test)

Example 88 with PrivateStorageInfo

use of com.android.settingslib.deviceinfo.PrivateStorageInfo in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class CachedStorageValuesHelperTest method getCachedPrivateStorageInfo_nullIfDataIsStale.

@Test
public void getCachedPrivateStorageInfo_nullIfDataIsStale() {
    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();
    final PrivateStorageInfo info = mCachedValuesHelper.getCachedPrivateStorageInfo();
    assertThat(info).isNull();
}
Also used : PrivateStorageInfo(com.android.settingslib.deviceinfo.PrivateStorageInfo) Test(org.junit.Test)

Example 89 with PrivateStorageInfo

use of com.android.settingslib.deviceinfo.PrivateStorageInfo in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class CachedStorageValuesHelperTest method getCachedPrivateStorageInfo_nullIfEmpty.

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

Example 90 with PrivateStorageInfo

use of com.android.settingslib.deviceinfo.PrivateStorageInfo in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class CachedStorageValuesHelperTest method getCachedPrivateStorageInfo_cachedValuesAreLoaded.

@Test
public void getCachedPrivateStorageInfo_cachedValuesAreLoaded() {
    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, 6000L).putInt(USER_ID_KEY, 0).putLong(TIMESTAMP_KEY, 10000L).apply();
    final PrivateStorageInfo info = mCachedValuesHelper.getCachedPrivateStorageInfo();
    assertThat(info.freeBytes).isEqualTo(1000L);
    assertThat(info.totalBytes).isEqualTo(6000L);
}
Also used : 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