Merge commit '47eec246a9293616cb74d2c354be85201ec4e19e' into mergeit
Change-Id: I988ae328e0e9bb99b086490cf2ef48ca19779d13
This commit is contained in:
@@ -83,7 +83,7 @@ public class MusicViewHolderControllerTest {
|
||||
@Test
|
||||
public void storageShouldRepresentStorageStatsQuery() throws Exception {
|
||||
when(mSource.getExternalStorageStats(nullable(String.class), nullable(UserHandle.class))).thenReturn(
|
||||
new StorageStatsSource.ExternalStorageStats(1, 1, 0, 0));
|
||||
new StorageStatsSource.ExternalStorageStats(1, 1, 0, 0, 0));
|
||||
|
||||
mController.queryStats();
|
||||
mController.setupView(mHolder);
|
||||
|
@@ -17,6 +17,7 @@ package com.android.settings.deviceinfo;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.Matchers.anyInt;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
@@ -31,11 +32,16 @@ import com.android.settingslib.applications.StorageStatsSource;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Captor;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.annotation.Config;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
||||
public class StorageProfileFragmentTest {
|
||||
@Captor
|
||||
private ArgumentCaptor<SparseArray<StorageAsyncLoader.AppsStorageResult>> mCaptor;
|
||||
|
||||
@Test
|
||||
public void verifyAppSizesAreZeroedOut() {
|
||||
StorageItemPreferenceController controller = mock(StorageItemPreferenceController.class);
|
||||
@@ -45,18 +51,17 @@ public class StorageProfileFragmentTest {
|
||||
result.otherAppsSize = 200;
|
||||
result.gamesSize = 300;
|
||||
result.videoAppsSize = 400;
|
||||
result.externalStats = new StorageStatsSource.ExternalStorageStats(6, 1, 2, 3);
|
||||
result.externalStats = new StorageStatsSource.ExternalStorageStats(6, 1, 2, 3, 0);
|
||||
SparseArray<StorageAsyncLoader.AppsStorageResult> resultsArray = new SparseArray<>();
|
||||
resultsArray.put(0, result);
|
||||
fragment.setPreferenceController(controller);
|
||||
|
||||
fragment.onLoadFinished(null, resultsArray);
|
||||
|
||||
ArgumentCaptor<StorageAsyncLoader.AppsStorageResult> resultCaptor = ArgumentCaptor.forClass(
|
||||
StorageAsyncLoader.AppsStorageResult.class);
|
||||
verify(controller).onLoadFinished(resultCaptor.capture());
|
||||
MockitoAnnotations.initMocks(this);
|
||||
verify(controller).onLoadFinished(mCaptor.capture(), anyInt());
|
||||
|
||||
StorageAsyncLoader.AppsStorageResult extractedResult = resultCaptor.getValue();
|
||||
StorageAsyncLoader.AppsStorageResult extractedResult = mCaptor.getValue().get(0);
|
||||
assertThat(extractedResult.musicAppsSize).isEqualTo(0);
|
||||
assertThat(extractedResult.videoAppsSize).isEqualTo(0);
|
||||
assertThat(extractedResult.otherAppsSize).isEqualTo(0);
|
||||
|
@@ -168,7 +168,7 @@ public class SecondaryUserControllerTest {
|
||||
MEGABYTE_IN_BYTES * 30,
|
||||
MEGABYTE_IN_BYTES * 10,
|
||||
MEGABYTE_IN_BYTES * 10,
|
||||
MEGABYTE_IN_BYTES * 10);
|
||||
MEGABYTE_IN_BYTES * 10, 0);
|
||||
result.put(10, userResult);
|
||||
|
||||
mController.handleResult(result);
|
||||
|
@@ -36,6 +36,7 @@ import android.graphics.drawable.Drawable;
|
||||
import android.os.UserHandle;
|
||||
import android.os.storage.VolumeInfo;
|
||||
import android.support.v7.preference.PreferenceScreen;
|
||||
import android.util.SparseArray;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.LinearLayout;
|
||||
@@ -275,22 +276,22 @@ public class StorageItemPreferenceControllerTest {
|
||||
result.videoAppsSize = MEGABYTE_IN_BYTES * 160;
|
||||
result.musicAppsSize = MEGABYTE_IN_BYTES * 40;
|
||||
result.otherAppsSize = MEGABYTE_IN_BYTES * 90;
|
||||
result.systemSize = MEGABYTE_IN_BYTES * 100; // This value is ignored and overridden now.
|
||||
result.externalStats =
|
||||
new StorageStatsSource.ExternalStorageStats(
|
||||
MEGABYTE_IN_BYTES * 500, // total
|
||||
MEGABYTE_IN_BYTES * 100, // audio
|
||||
MEGABYTE_IN_BYTES * 150, // video
|
||||
MEGABYTE_IN_BYTES * 200); // image
|
||||
MEGABYTE_IN_BYTES * 200, 0); // image
|
||||
|
||||
mController.onLoadFinished(result);
|
||||
SparseArray<StorageAsyncLoader.AppsStorageResult> results = new SparseArray<>();
|
||||
results.put(0, result);
|
||||
mController.onLoadFinished(results, 0);
|
||||
|
||||
assertThat(audio.getSummary().toString()).isEqualTo("0.14GB");
|
||||
assertThat(image.getSummary().toString()).isEqualTo("0.35GB");
|
||||
assertThat(games.getSummary().toString()).isEqualTo("0.08GB");
|
||||
assertThat(movies.getSummary().toString()).isEqualTo("0.16GB");
|
||||
assertThat(apps.getSummary().toString()).isEqualTo("0.09GB");
|
||||
assertThat(system.getSummary().toString()).isEqualTo("0.10GB");
|
||||
assertThat(files.getSummary().toString()).isEqualTo("0.05GB");
|
||||
}
|
||||
|
||||
@@ -488,4 +489,4 @@ public class StorageItemPreferenceControllerTest {
|
||||
|
||||
verify(screen).addPreference(files);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -114,7 +114,7 @@ public class UserProfileControllerTest {
|
||||
99 * MEGABYTE_IN_BYTES,
|
||||
33 * MEGABYTE_IN_BYTES,
|
||||
33 * MEGABYTE_IN_BYTES,
|
||||
33 * MEGABYTE_IN_BYTES);
|
||||
33 * MEGABYTE_IN_BYTES, 0);
|
||||
result.put(10, userResult);
|
||||
|
||||
mController.handleResult(result);
|
||||
@@ -141,4 +141,4 @@ public class UserProfileControllerTest {
|
||||
Preference preference = argumentCaptor.getValue();
|
||||
assertThat(preference.getIcon()).isEqualTo(drawable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -133,9 +133,9 @@ public class StorageAsyncLoaderTest {
|
||||
info.id = SECONDARY_USER_ID;
|
||||
mUsers.add(info);
|
||||
when(mSource.getExternalStorageStats(anyString(), eq(UserHandle.SYSTEM)))
|
||||
.thenReturn(new StorageStatsSource.ExternalStorageStats(9, 2, 3, 4));
|
||||
.thenReturn(new StorageStatsSource.ExternalStorageStats(9, 2, 3, 4, 0));
|
||||
when(mSource.getExternalStorageStats(anyString(), eq(new UserHandle(SECONDARY_USER_ID))))
|
||||
.thenReturn(new StorageStatsSource.ExternalStorageStats(10, 3, 3, 4));
|
||||
.thenReturn(new StorageStatsSource.ExternalStorageStats(10, 3, 3, 4, 0));
|
||||
|
||||
SparseArray<StorageAsyncLoader.AppsStorageResult> result = mLoader.loadInBackground();
|
||||
|
||||
@@ -144,19 +144,6 @@ public class StorageAsyncLoaderTest {
|
||||
assertThat(result.get(SECONDARY_USER_ID).externalStats.totalBytes).isEqualTo(10L);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSystemAppsBaseSizeIsAddedToSystem() throws Exception {
|
||||
ApplicationInfo systemApp =
|
||||
addPackage(PACKAGE_NAME_1, 100, 1, 10, ApplicationInfo.CATEGORY_UNDEFINED);
|
||||
systemApp.flags = ApplicationInfo.FLAG_SYSTEM;
|
||||
|
||||
SparseArray<StorageAsyncLoader.AppsStorageResult> result = mLoader.loadInBackground();
|
||||
|
||||
assertThat(result.size()).isEqualTo(1);
|
||||
assertThat(result.get(PRIMARY_USER_ID).otherAppsSize).isEqualTo(10L);
|
||||
assertThat(result.get(PRIMARY_USER_ID).systemSize).isEqualTo(1L);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdatedSystemAppCodeSizeIsCounted() throws Exception {
|
||||
ApplicationInfo systemApp =
|
||||
|
Reference in New Issue
Block a user