Search in sources :

Example 1 with StorageVolumeProvider

use of com.android.settingslib.deviceinfo.StorageVolumeProvider in project android_packages_apps_Settings by LineageOS.

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 2 with StorageVolumeProvider

use of com.android.settingslib.deviceinfo.StorageVolumeProvider in project android_packages_apps_Settings by LineageOS.

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 3 with StorageVolumeProvider

use of com.android.settingslib.deviceinfo.StorageVolumeProvider 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 4 with StorageVolumeProvider

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

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 5 with StorageVolumeProvider

use of com.android.settingslib.deviceinfo.StorageVolumeProvider in project android_packages_apps_Settings by DirtyUnicorns.

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