Re-add the progress bar for storage preferences.

This re-adds the progress bar and unifies the
StorageItemPreference and its alternate.

Change-Id: Iefc12b4b554306c706c83be232175dd2b84227b7
Fixes: 36223433
Test: Settings robotest
This commit is contained in:
Daniel Nishi
2017-03-15 14:00:13 -07:00
parent 9392681afa
commit cf0e659a6c
14 changed files with 183 additions and 203 deletions

View File

@@ -1,56 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2016 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:minHeight="?android:attr/listPreferredItemHeightSmall"
android:gravity="center_vertical"
android:paddingStart="@dimen/preference_no_icon_padding_start"
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
android:paddingTop="16dip"
android:paddingBottom="16dip"
android:background="?android:attr/selectableItemBackground">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@android:id/title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:singleLine="true"
android:textAppearance="@android:style/TextAppearance.Material.Subhead"
android:textAlignment="viewStart"
android:ellipsize="marquee"
android:fadingEdge="horizontal" />
<TextView
android:id="@android:id/summary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAlignment="viewStart"
android:textAppearance="@android:style/TextAppearance.Material.Body1"
android:textColor="?android:attr/textColorSecondaryNoDisable"
android:maxLines="10" />
</LinearLayout>
</LinearLayout>

View File

@@ -30,28 +30,28 @@
android:order="1"
settings:allowDividerAbove="true"
settings:allowDividerBelow="true"/>
<com.android.settings.deviceinfo.storage.StorageItemPreferenceAlternate
<com.android.settings.deviceinfo.StorageItemPreference
android:key="pref_photos_videos"
android:title="@string/storage_photos_videos"
android:order="2"
settings:allowDividerAbove="true" />
<com.android.settings.deviceinfo.storage.StorageItemPreferenceAlternate
settings:allowDividerAbove="true"
android:order="2" />
<com.android.settings.deviceinfo.StorageItemPreference
android:key="pref_music_audio"
android:title="@string/storage_music_audio"
android:order="3" />
<com.android.settings.deviceinfo.storage.StorageItemPreferenceAlternate
<com.android.settings.deviceinfo.StorageItemPreference
android:key="pref_games"
android:title="@string/storage_games"
android:order="4" />
<com.android.settings.deviceinfo.storage.StorageItemPreferenceAlternate
<com.android.settings.deviceinfo.StorageItemPreference
android:key="pref_other_apps"
android:title="@string/storage_other_apps"
android:order="5" />
<com.android.settings.deviceinfo.storage.StorageItemPreferenceAlternate
<com.android.settings.deviceinfo.StorageItemPreference
android:key="pref_files"
android:title="@string/storage_files"
android:order="6" />
<com.android.settings.deviceinfo.storage.StorageItemPreferenceAlternate
<com.android.settings.deviceinfo.StorageItemPreference
android:key="pref_system"
android:title="@string/storage_detail_system"
android:order="100" />

View File

@@ -18,24 +18,24 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
android:title="@string/storage_settings">
<com.android.settings.deviceinfo.storage.StorageItemPreferenceAlternate
<com.android.settings.deviceinfo.StorageItemPreference
android:key="pref_photos_videos"
android:title="@string/storage_photos_videos">
</com.android.settings.deviceinfo.storage.StorageItemPreferenceAlternate>
<com.android.settings.deviceinfo.storage.StorageItemPreferenceAlternate
</com.android.settings.deviceinfo.StorageItemPreference>
<com.android.settings.deviceinfo.StorageItemPreference
android:key="pref_music_audio"
android:title="@string/storage_music_audio">
</com.android.settings.deviceinfo.storage.StorageItemPreferenceAlternate>
<com.android.settings.deviceinfo.storage.StorageItemPreferenceAlternate
</com.android.settings.deviceinfo.StorageItemPreference>
<com.android.settings.deviceinfo.StorageItemPreference
android:key="pref_games"
android:title="@string/storage_games">
</com.android.settings.deviceinfo.storage.StorageItemPreferenceAlternate>
<com.android.settings.deviceinfo.storage.StorageItemPreferenceAlternate
</com.android.settings.deviceinfo.StorageItemPreference>
<com.android.settings.deviceinfo.StorageItemPreference
android:key="pref_other_apps"
android:title="@string/storage_other_apps">
</com.android.settings.deviceinfo.storage.StorageItemPreferenceAlternate>
<com.android.settings.deviceinfo.storage.StorageItemPreferenceAlternate
</com.android.settings.deviceinfo.StorageItemPreference>
<com.android.settings.deviceinfo.StorageItemPreference
android:key="pref_files"
android:title="@string/storage_files">
</com.android.settings.deviceinfo.storage.StorageItemPreferenceAlternate>
</com.android.settings.deviceinfo.StorageItemPreference>
</PreferenceScreen>

View File

@@ -114,6 +114,16 @@ public class StorageDashboardFragment extends DashboardFragment
mSummaryController.updateBytes(usedBytes, totalSize);
mPreferenceController.setVolume(mVolume);
mPreferenceController.setSystemSize(systemSize);
mPreferenceController.setTotalSize(totalSize);
for (int i = 0, size = mSecondaryUsers.size(); i < size; i++) {
PreferenceController controller = mSecondaryUsers.get(i);
if (controller instanceof SecondaryUserController) {
SecondaryUserController userController = (SecondaryUserController) controller;
userController.setTotalSize(totalSize);
}
}
}
@Override

View File

@@ -20,6 +20,7 @@ import android.content.Context;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceViewHolder;
import android.text.format.Formatter;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ProgressBar;
@@ -28,13 +29,18 @@ import com.android.settings.R;
public class StorageItemPreference extends Preference {
public int userHandle;
private ProgressBar progressBar;
private ProgressBar mProgressBar;
private static final int PROGRESS_MAX = 100;
private int progress = -1;
private int mProgressPercent = -1;
public StorageItemPreference(Context context) {
super(context);
this(context, null);
}
public StorageItemPreference(Context context, AttributeSet attrs) {
super(context, attrs);
setLayoutResource(R.layout.storage_item);
setSummary(R.string.memory_calculating_size);
}
public void setStorageSize(long size, long total) {
@@ -42,30 +48,30 @@ public class StorageItemPreference extends Preference {
? String.valueOf(0)
: Formatter.formatFileSize(getContext(), size));
if (total == 0) {
progress = 0;
mProgressPercent = 0;
} else {
progress = (int)(size * PROGRESS_MAX / total);
mProgressPercent = (int)(size * PROGRESS_MAX / total);
}
updateProgressBar();
}
protected void updateProgressBar() {
if (progressBar == null)
if (mProgressBar == null)
return;
if (progress == -1) {
progressBar.setVisibility(View.GONE);
if (mProgressPercent == -1) {
mProgressBar.setVisibility(View.GONE);
return;
}
progressBar.setVisibility(View.VISIBLE);
progressBar.setMax(PROGRESS_MAX);
progressBar.setProgress(progress);
mProgressBar.setVisibility(View.VISIBLE);
mProgressBar.setMax(PROGRESS_MAX);
mProgressBar.setProgress(mProgressPercent);
}
@Override
public void onBindViewHolder(PreferenceViewHolder view) {
progressBar = (ProgressBar) view.findViewById(android.R.id.progress);
mProgressBar = (ProgressBar) view.findViewById(android.R.id.progress);
updateProgressBar();
super.onBindViewHolder(view);
}

View File

@@ -28,6 +28,7 @@ import android.util.SparseArray;
import com.android.settings.Utils;
import com.android.settings.applications.UserManagerWrapper;
import com.android.settings.core.PreferenceController;
import com.android.settings.deviceinfo.StorageItemPreference;
import java.util.ArrayList;
import java.util.List;
@@ -46,8 +47,9 @@ public class SecondaryUserController extends PreferenceController implements
private static final int SIZE_NOT_SET = -1;
private @NonNull UserInfo mUser;
private @Nullable StorageItemPreferenceAlternate mStoragePreference;
private @Nullable StorageItemPreference mStoragePreference;
private long mSize;
private long mTotalSizeBytes;
/**
* Adds the appropriate controllers to a controller list for handling all secondary users on
@@ -98,14 +100,14 @@ public class SecondaryUserController extends PreferenceController implements
@Override
public void displayPreference(PreferenceScreen screen) {
if (mStoragePreference == null) {
mStoragePreference = new StorageItemPreferenceAlternate(screen.getContext());
mStoragePreference = new StorageItemPreference(screen.getContext());
PreferenceGroup group =
(PreferenceGroup) screen.findPreference(TARGET_PREFERENCE_GROUP_KEY);
mStoragePreference.setTitle(mUser.name);
mStoragePreference.setKey(PREFERENCE_KEY_BASE + mUser.id);
if (mSize != SIZE_NOT_SET) {
mStoragePreference.setStorageSize(mSize);
mStoragePreference.setStorageSize(mSize, mTotalSizeBytes);
}
group.setVisible(true);
group.addPreference(mStoragePreference);
@@ -137,10 +139,18 @@ public class SecondaryUserController extends PreferenceController implements
public void setSize(long size) {
mSize = size;
if (mStoragePreference != null) {
mStoragePreference.setStorageSize(mSize);
mStoragePreference.setStorageSize(mSize, mTotalSizeBytes);
}
}
/**
* Sets the total size for the preference for the progress bar.
* @param totalSizeBytes Total size in bytes.
*/
public void setTotalSize(long totalSizeBytes) {
mTotalSizeBytes = totalSizeBytes;
}
public void handleResult(SparseArray<StorageAsyncLoader.AppsStorageResult> stats) {
int userId = getUser().id;
StorageAsyncLoader.AppsStorageResult result = stats.get(userId);

View File

@@ -1,42 +0,0 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.deviceinfo.storage;
import android.content.Context;
import android.support.v7.preference.Preference;
import android.text.format.Formatter;
import android.util.AttributeSet;
import com.android.settings.R;
public class StorageItemPreferenceAlternate extends Preference {
public StorageItemPreferenceAlternate(Context context) {
this(context, null);
}
public StorageItemPreferenceAlternate(Context context, AttributeSet attrs) {
super(context, attrs);
setLayoutResource(R.layout.storage_item_alternate);
setSummary(R.string.memory_calculating_size);
}
public void setStorageSize(long size) {
setSummary(size == 0
? String.valueOf(0)
: Formatter.formatFileSize(getContext(), size));
}
}

View File

@@ -35,6 +35,7 @@ import com.android.settings.Utils;
import com.android.settings.applications.ManageApplications;
import com.android.settings.core.PreferenceController;
import com.android.settings.core.instrumentation.MetricsFeatureProvider;
import com.android.settings.deviceinfo.StorageItemPreference;
import com.android.settings.overlay.FeatureFactory;
import com.android.settingslib.deviceinfo.StorageMeasurement;
import com.android.settingslib.deviceinfo.StorageVolumeProvider;
@@ -71,13 +72,14 @@ public class StorageItemPreferenceController extends PreferenceController {
private VolumeInfo mVolume;
private int mUserId;
private long mSystemSize;
private long mTotalSize;
private StorageItemPreferenceAlternate mPhotoPreference;
private StorageItemPreferenceAlternate mAudioPreference;
private StorageItemPreferenceAlternate mGamePreference;
private StorageItemPreferenceAlternate mAppPreference;
private StorageItemPreferenceAlternate mFilePreference;
private StorageItemPreferenceAlternate mSystemPreference;
private StorageItemPreference mPhotoPreference;
private StorageItemPreference mAudioPreference;
private StorageItemPreference mGamePreference;
private StorageItemPreference mAppPreference;
private StorageItemPreference mFilePreference;
private StorageItemPreference mSystemPreference;
private static final String AUTHORITY_MEDIA = "com.android.providers.media.documents";
@@ -164,37 +166,38 @@ public class StorageItemPreferenceController extends PreferenceController {
@Override
public void displayPreference(PreferenceScreen screen) {
mPhotoPreference = (StorageItemPreferenceAlternate) screen.findPreference(PHOTO_KEY);
mAudioPreference = (StorageItemPreferenceAlternate) screen.findPreference(AUDIO_KEY);
mGamePreference = (StorageItemPreferenceAlternate) screen.findPreference(GAME_KEY);
mAppPreference = (StorageItemPreferenceAlternate) screen.findPreference(OTHER_APPS_KEY);
mSystemPreference = (StorageItemPreferenceAlternate) screen.findPreference(SYSTEM_KEY);
mFilePreference = (StorageItemPreferenceAlternate) screen.findPreference(FILES_KEY);
mPhotoPreference = (StorageItemPreference) screen.findPreference(PHOTO_KEY);
mAudioPreference = (StorageItemPreference) screen.findPreference(AUDIO_KEY);
mGamePreference = (StorageItemPreference) screen.findPreference(GAME_KEY);
mAppPreference = (StorageItemPreference) screen.findPreference(OTHER_APPS_KEY);
mSystemPreference = (StorageItemPreference) screen.findPreference(SYSTEM_KEY);
mFilePreference = (StorageItemPreference) screen.findPreference(FILES_KEY);
}
public void onLoadFinished(StorageAsyncLoader.AppsStorageResult data) {
// TODO(b/35927909): Figure out how to split out apps which are only installed for work
// profiles in order to attribute those app's code bytes only to that profile.
mPhotoPreference.setStorageSize(
data.externalStats.imageBytes + data.externalStats.videoBytes);
mAudioPreference.setStorageSize(data.musicAppsSize + data.externalStats.audioBytes);
mGamePreference.setStorageSize(data.gamesSize);
mAppPreference.setStorageSize(data.otherAppsSize);
data.externalStats.imageBytes + data.externalStats.videoBytes, mTotalSize);
mAudioPreference.setStorageSize(
data.musicAppsSize + data.externalStats.audioBytes, mTotalSize);
mGamePreference.setStorageSize(data.gamesSize, mTotalSize);
mAppPreference.setStorageSize(data.otherAppsSize, mTotalSize);
if (mSystemPreference != null) {
mSystemPreference.setStorageSize(mSystemSize + data.systemSize);
mSystemPreference.setStorageSize(mSystemSize + data.systemSize, mTotalSize);
}
long unattributedBytes = data.externalStats.totalBytes - data.externalStats.audioBytes
- data.externalStats.videoBytes - data.externalStats.imageBytes;
mFilePreference.setStorageSize(unattributedBytes);
mFilePreference.setStorageSize(unattributedBytes, mTotalSize);
}
/**
* Sets the system size for the system size preference.
* @param systemSize the size of the system in bytes
*/
public void setSystemSize(long systemSize) {
mSystemSize = systemSize;
public void setSystemSize(long systemSizeBytes) {
mSystemSize = systemSizeBytes;
}
public void setTotalSize(long totalSizeBytes) {
mTotalSize = totalSizeBytes;
}
/**

View File

@@ -29,6 +29,7 @@ import com.android.internal.logging.nano.MetricsProto;
import com.android.internal.util.Preconditions;
import com.android.settings.Utils;
import com.android.settings.core.PreferenceController;
import com.android.settings.deviceinfo.StorageItemPreference;
import com.android.settings.deviceinfo.StorageProfileFragment;
import com.android.settingslib.drawer.SettingsDrawerActivity;
@@ -38,8 +39,9 @@ import com.android.settingslib.drawer.SettingsDrawerActivity;
public class UserProfileController extends PreferenceController implements
StorageAsyncLoader.ResultHandler {
private static final String PREFERENCE_KEY_BASE = "pref_profile_";
private StorageItemPreferenceAlternate mStoragePreference;
private StorageItemPreference mStoragePreference;
private UserInfo mUser;
private long mTotalSizeBytes;
private final int mPreferenceOrder;
public UserProfileController(Context context, UserInfo info, int preferenceOrder) {
@@ -60,7 +62,7 @@ public class UserProfileController extends PreferenceController implements
@Override
public void displayPreference(PreferenceScreen screen) {
mStoragePreference = new StorageItemPreferenceAlternate(screen.getContext());
mStoragePreference = new StorageItemPreference(screen.getContext());
mStoragePreference.setOrder(mPreferenceOrder);
mStoragePreference.setKey(PREFERENCE_KEY_BASE + mUser.id);
mStoragePreference.setTitle(mUser.name);
@@ -91,16 +93,20 @@ public class UserProfileController extends PreferenceController implements
int userId = mUser.id;
StorageAsyncLoader.AppsStorageResult result = stats.get(userId);
if (result != null) {
setSize(result.externalStats.totalBytes);
setSize(result.externalStats.totalBytes, mTotalSizeBytes);
}
}
/**
* Sets the size for the preference using a byte count.
*/
public void setSize(long size) {
public void setSize(long size, long totalSize) {
if (mStoragePreference != null) {
mStoragePreference.setStorageSize(size);
mStoragePreference.setStorageSize(size, totalSize);
}
}
public void setTotalSize(long totalSize) {
mTotalSizeBytes = totalSize;
}
}

View File

@@ -0,0 +1,26 @@
/*
* Copyright (C) 2017 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License
*/
package com.android.settings;
/**
* Convenience methods and constants for testing.
*/
public class TestUtils {
public static final long KILOBYTE = 1024L; // TODO: Change to 1000 in O Robolectric.
public static final long MEGABYTE = KILOBYTE * KILOBYTE;
public static final long GIGABYTE = KILOBYTE * MEGABYTE;
}

View File

@@ -13,11 +13,16 @@
* See the License for the specific language governing permissions and
* limitations under the License
*/
package com.android.settings.deviceinfo.storage;
package com.android.settings.deviceinfo;
import static com.android.settings.TestUtils.KILOBYTE;
import static com.google.common.truth.Truth.assertThat;
import android.content.Context;
import android.support.v7.preference.PreferenceViewHolder;
import android.view.LayoutInflater;
import android.widget.ProgressBar;
import com.android.settings.R;
import com.android.settings.SettingsRobolectricTestRunner;
@@ -29,28 +34,41 @@ import org.junit.runner.RunWith;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
public class StorageItemPreferenceAlternateTest {
public class StorageItemPreferenceTest {
private Context mContext;
private StorageItemPreference mPreference;
@Before
public void setUp() throws Exception {
mContext = RuntimeEnvironment.application;
mPreference = new StorageItemPreference(mContext);
}
@Test
public void testBeforeLoad() {
StorageItemPreferenceAlternate pref = new StorageItemPreferenceAlternate(mContext);
assertThat(((String) pref.getSummary())).isEqualTo(
assertThat(mPreference.getSummary()).isEqualTo(
mContext.getString(R.string.memory_calculating_size));
}
@Test
public void testAfterLoad() {
StorageItemPreferenceAlternate pref = new StorageItemPreferenceAlternate(mContext);
pref.setStorageSize(1024L);
assertThat(((String) pref.getSummary())).isEqualTo("1.00KB");
mPreference.setStorageSize(KILOBYTE, KILOBYTE * 10);
assertThat(((String) mPreference.getSummary())).isEqualTo("1.00KB");
}
@Test
public void testProgressBarPercentageSet() {
final PreferenceViewHolder holder = new PreferenceViewHolder(
LayoutInflater.from(mContext).inflate(R.layout.storage_item, null));
final ProgressBar progressBar =
(ProgressBar) holder.itemView.findViewById(android.R.id.progress);
mPreference.onBindViewHolder(holder);
mPreference.setStorageSize(KILOBYTE, KILOBYTE * 10);
assertThat(progressBar.getProgress()).isEqualTo(10);
}
}

View File

@@ -15,6 +15,8 @@
*/
package com.android.settings.deviceinfo.storage;
import static com.android.settings.TestUtils.KILOBYTE;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Matchers.any;
@@ -43,6 +45,7 @@ import com.android.settings.SubSettings;
import com.android.settings.TestConfig;
import com.android.settings.applications.ManageApplications;
import com.android.settings.core.instrumentation.MetricsFeatureProvider;
import com.android.settings.deviceinfo.StorageItemPreference;
import com.android.settings.testutils.FakeFeatureFactory;
import com.android.settingslib.applications.StorageStatsSource;
import com.android.settingslib.deviceinfo.StorageVolumeProvider;
@@ -60,11 +63,6 @@ import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
public class StorageItemPreferenceControllerTest {
/**
* In O, this will change to 1000 instead of 1024 due to the formatter properly defining a
* kilobyte.
*/
private static long KILOBYTE = 1024L;
private Context mContext;
private VolumeInfo mVolume;
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
@@ -72,7 +70,7 @@ public class StorageItemPreferenceControllerTest {
@Mock
private StorageVolumeProvider mSvp;
private StorageItemPreferenceController mController;
private StorageItemPreferenceAlternate mPreference;
private StorageItemPreference mPreference;
private FakeFeatureFactory mFakeFeatureFactory;
private MetricsFeatureProvider mMetricsFeatureProvider;
@@ -87,7 +85,7 @@ public class StorageItemPreferenceControllerTest {
// Note: null is passed as the Lifecycle because we are handling it outside of the normal
// Settings fragment lifecycle for test purposes.
mController = new StorageItemPreferenceController(mContext, mFragment, mVolume, mSvp);
mPreference = new StorageItemPreferenceAlternate(mContext);
mPreference = new StorageItemPreference(mContext);
// Inflate the preference and the widget.
LayoutInflater inflater = LayoutInflater.from(mContext);
@@ -190,12 +188,12 @@ public class StorageItemPreferenceControllerTest {
@Test
public void testMeasurementCompletedUpdatesPreferences() {
StorageItemPreferenceAlternate audio = new StorageItemPreferenceAlternate(mContext);
StorageItemPreferenceAlternate image = new StorageItemPreferenceAlternate(mContext);
StorageItemPreferenceAlternate games = new StorageItemPreferenceAlternate(mContext);
StorageItemPreferenceAlternate apps = new StorageItemPreferenceAlternate(mContext);
StorageItemPreferenceAlternate system = new StorageItemPreferenceAlternate(mContext);
StorageItemPreferenceAlternate files = new StorageItemPreferenceAlternate(mContext);
StorageItemPreference audio = new StorageItemPreference(mContext);
StorageItemPreference image = new StorageItemPreference(mContext);
StorageItemPreference games = new StorageItemPreference(mContext);
StorageItemPreference apps = new StorageItemPreference(mContext);
StorageItemPreference system = new StorageItemPreference(mContext);
StorageItemPreference files = new StorageItemPreference(mContext);
PreferenceScreen screen = mock(PreferenceScreen.class);
when(screen.findPreference(
eq(StorageItemPreferenceController.AUDIO_KEY))).thenReturn(audio);

View File

@@ -52,12 +52,13 @@ import org.robolectric.annotation.Config;
import java.io.File;
import static com.android.settings.TestUtils.KILOBYTE;
import static com.android.settings.TestUtils.MEGABYTE;
import static com.android.settings.TestUtils.GIGABYTE;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
public class StorageSummaryDonutPreferenceControllerTest {
private static final long KILOBYTE = 1024; // Note: When O comes around, this value changes!
private static final long MEGABYTE = KILOBYTE * KILOBYTE;
private static final long GIGABYTE = KILOBYTE * MEGABYTE;
private Context mContext;
private StorageSummaryDonutPreferenceController mController;
private StorageSummaryDonutPreference mPreference;