Search in sources :

Example 6 with StorageVolumeProvider

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");
}
Also used : StorageVolumeProvider(com.android.settingslib.deviceinfo.StorageVolumeProvider) VolumeInfo(android.os.storage.VolumeInfo) File(java.io.File) Test(org.junit.Test)

Example 7 with StorageVolumeProvider

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");
}
Also used : StorageVolumeProvider(com.android.settingslib.deviceinfo.StorageVolumeProvider) VolumeInfo(android.os.storage.VolumeInfo) File(java.io.File) Test(org.junit.Test)

Example 8 with StorageVolumeProvider

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);
}
Also used : PrivateStorageInfo(com.android.settingslib.deviceinfo.PrivateStorageInfo) StorageVolumeProvider(com.android.settingslib.deviceinfo.StorageVolumeProvider) VolumeInfo(android.os.storage.VolumeInfo) Test(org.junit.Test)

Example 9 with StorageVolumeProvider

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));
}
Also used : Formatter(android.text.format.Formatter) StorageVolumeProvider(com.android.settingslib.deviceinfo.StorageVolumeProvider) VolumeInfo(android.os.storage.VolumeInfo) File(java.io.File) Test(org.junit.Test)

Example 10 with StorageVolumeProvider

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);
}
Also used : PrivateStorageInfo(com.android.settingslib.deviceinfo.PrivateStorageInfo) StorageVolumeProvider(com.android.settingslib.deviceinfo.StorageVolumeProvider) VolumeInfo(android.os.storage.VolumeInfo) Test(org.junit.Test)

Aggregations

VolumeInfo (android.os.storage.VolumeInfo)14 StorageVolumeProvider (com.android.settingslib.deviceinfo.StorageVolumeProvider)14 Test (org.junit.Test)14 PrivateStorageInfo (com.android.settingslib.deviceinfo.PrivateStorageInfo)7 File (java.io.File)7 Formatter (android.text.format.Formatter)1