Search in sources :

Example 11 with PrivateStorageInfo

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

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 12 with PrivateStorageInfo

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

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(android.support.v7.widget.RecyclerView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) Test(org.junit.Test)

Example 13 with PrivateStorageInfo

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

the class StorageDashboardFragmentTest method test_cacheProviderDoesntProvideValuesIfAppsMissing.

@Test
public void test_cacheProviderDoesntProvideValuesIfAppsMissing() {
    CachedStorageValuesHelper helper = mock(CachedStorageValuesHelper.class);
    PrivateStorageInfo info = new PrivateStorageInfo(0, 0);
    when(helper.getCachedPrivateStorageInfo()).thenReturn(info);
    mFragment.setCachedStorageValuesHelper(helper);
    mFragment.initializeCachedValues();
    assertThat(mFragment.getPrivateStorageInfo()).isNull();
    assertThat(mFragment.getAppsStorageResult()).isNull();
}
Also used : CachedStorageValuesHelper(com.android.settings.deviceinfo.storage.CachedStorageValuesHelper) PrivateStorageInfo(com.android.settingslib.deviceinfo.PrivateStorageInfo) Test(org.junit.Test)

Example 14 with PrivateStorageInfo

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

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;
}
Also used : PrivateStorageInfo(com.android.settingslib.deviceinfo.PrivateStorageInfo) VisibleForTesting(android.support.annotation.VisibleForTesting)

Example 15 with PrivateStorageInfo

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

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(android.support.v7.widget.RecyclerView) View(android.view.View) RecyclerView(android.support.v7.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