use of com.android.settingslib.deviceinfo.StorageVolumeProvider in project platform_packages_apps_Settings by BlissRoms.
the class StorageSummaryDonutPreferenceControllerTest method testPopulateWithVolume.
@Test
public void testPopulateWithVolume() throws Exception {
VolumeInfo volume = Mockito.mock(VolumeInfo.class);
File file = Mockito.mock(File.class);
StorageVolumeProvider svp = Mockito.mock(StorageVolumeProvider.class);
when(volume.getPath()).thenReturn(file);
when(file.getTotalSpace()).thenReturn(KILOBYTE * 10);
when(file.getFreeSpace()).thenReturn(KILOBYTE);
when(svp.getPrimaryStorageSize()).thenReturn(KILOBYTE * 10);
mController.updateSizes(svp, volume);
mController.updateState(mPreference);
assertThat(mPreference.getTitle().toString()).isEqualTo("9.00KB");
assertThat(mPreference.getSummary().toString()).isEqualTo("Used of 10KB");
}
use of com.android.settingslib.deviceinfo.StorageVolumeProvider in project android_packages_apps_Settings by omnirom.
the class StorageSummaryDonutPreferenceControllerTest method testPopulateWithVolume.
@Test
public void testPopulateWithVolume() throws Exception {
VolumeInfo volume = Mockito.mock(VolumeInfo.class);
File file = Mockito.mock(File.class);
StorageVolumeProvider svp = Mockito.mock(StorageVolumeProvider.class);
when(volume.getPath()).thenReturn(file);
when(file.getTotalSpace()).thenReturn(KILOBYTE * 10);
when(file.getFreeSpace()).thenReturn(KILOBYTE);
when(svp.getPrimaryStorageSize()).thenReturn(KILOBYTE * 10);
mController.updateSizes(svp, volume);
mController.updateState(mPreference);
assertThat(mPreference.getTitle().toString()).isEqualTo("9.00KB");
assertThat(mPreference.getSummary().toString()).isEqualTo("Used of 10KB");
}
use of com.android.settingslib.deviceinfo.StorageVolumeProvider in project android_packages_apps_Settings by omnirom.
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);
}
use of com.android.settingslib.deviceinfo.StorageVolumeProvider in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class StorageSummaryDonutPreferenceControllerTest method testPopulateWithVolume.
@Test
public void testPopulateWithVolume() {
final long totalSpace = KILOBYTE * 10;
final long freeSpace = KILOBYTE;
final long usedSpace = totalSpace - freeSpace;
final VolumeInfo volume = Mockito.mock(VolumeInfo.class);
final File file = Mockito.mock(File.class);
final StorageVolumeProvider svp = Mockito.mock(StorageVolumeProvider.class);
when(volume.getPath()).thenReturn(file);
when(file.getTotalSpace()).thenReturn(totalSpace);
when(file.getFreeSpace()).thenReturn(freeSpace);
when(svp.getPrimaryStorageSize()).thenReturn(totalSpace);
mController.updateSizes(svp, volume);
mController.updateState(mPreference);
final Formatter.BytesResult usedSpaceResults = Formatter.formatBytes(mContext.getResources(), usedSpace, 0);
assertThat(mPreference.getTitle().toString()).isEqualTo(usedSpaceResults.value + " " + usedSpaceResults.units);
assertThat(mPreference.getSummary().toString()).isEqualTo("Used of " + Formatter.formatShortFileSize(mContext, totalSpace));
}
use of com.android.settingslib.deviceinfo.StorageVolumeProvider in project Resurrection_packages_apps_Settings by ResurrectionRemix.
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);
}
Aggregations