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));
}
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));
}
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)));
});
});
}
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);
}
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);
}
Aggregations