Search in sources :

Example 46 with PrivateStorageInfo

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

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) ShadowPrivateStorageInfo(com.android.settings.testutils.shadow.ShadowPrivateStorageInfo) Slice(androidx.slice.Slice) SliceMetadata(androidx.slice.SliceMetadata) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 47 with PrivateStorageInfo

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

the class LowStorageSliceTest method getSlice_lowStorage_shouldHaveStorageFreeTitle.

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

Example 48 with PrivateStorageInfo

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

the class TopLevelStoragePreferenceController method refreshSummaryThread.

@VisibleForTesting
protected Future refreshSummaryThread(Preference preference) {
    return ThreadUtils.postOnBackgroundThread(() -> {
        final NumberFormat percentageFormat = NumberFormat.getPercentInstance();
        final PrivateStorageInfo info = PrivateStorageInfo.getPrivateStorageInfo(getStorageManagerVolumeProvider());
        final double privateUsedBytes = info.totalBytes - info.freeBytes;
        ThreadUtils.postOnMainThread(() -> {
            preference.setSummary(mContext.getString(R.string.storage_summary, percentageFormat.format(privateUsedBytes / info.totalBytes), Formatter.formatFileSize(mContext, info.freeBytes)));
        });
    });
}
Also used : PrivateStorageInfo(com.android.settingslib.deviceinfo.PrivateStorageInfo) NumberFormat(java.text.NumberFormat) VisibleForTesting(androidx.annotation.VisibleForTesting)

Example 49 with PrivateStorageInfo

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

the class StorageDashboardFragmentTest method test_loadWhenQuotaOnAndVolumeInfoLoadedButAppsMissing.

@Test
public void test_loadWhenQuotaOnAndVolumeInfoLoadedButAppsMissing() {
    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);
    PrivateStorageInfo info = new PrivateStorageInfo(0, 0);
    mFragment.setPrivateStorageInfo(info);
    mFragment.maybeSetLoading(true);
    verify(mFragment).setLoading(true, false);
}
Also used : PrivateStorageInfo(com.android.settingslib.deviceinfo.PrivateStorageInfo) RecyclerView(androidx.recyclerview.widget.RecyclerView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) Test(org.junit.Test)

Example 50 with PrivateStorageInfo

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

the class StorageDashboardFragmentTest method test_dontLoadWhenQuotaOffIfVolumeInfoNotLoaded.

@Test
public void test_dontLoadWhenQuotaOffIfVolumeInfoNotLoaded() {
    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);
    PrivateStorageInfo info = new PrivateStorageInfo(0, 0);
    mFragment.setPrivateStorageInfo(info);
    mFragment.maybeSetLoading(false);
    verify(mFragment, never()).setLoading(true, false);
}
Also used : PrivateStorageInfo(com.android.settingslib.deviceinfo.PrivateStorageInfo) RecyclerView(androidx.recyclerview.widget.RecyclerView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) 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