Follow-up improvements to zen mode icon picker
* Propose icons from com.android.internal.R instead of android.R (as a proof of concept) since this is what we'll be doing with the final icons. * Provide the icon options as a parameter to the controller (can also be used for testing). * Fix some Lint warnings. Test: atest ZenModeIconPickerListPreferenceControllerTest Bug: 333901673 Flag: android.app.modes_ui Change-Id: I023eed0fd5719c5c4540f8d145335f60d088e7fb
This commit is contained in:
@@ -34,6 +34,8 @@ import com.android.settings.R;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settingslib.widget.LayoutPreference;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -61,7 +63,8 @@ public class ZenModeIconPickerListPreferenceControllerTest {
|
||||
|
||||
DashboardFragment fragment = mock(DashboardFragment.class);
|
||||
mController = new ZenModeIconPickerListPreferenceController(
|
||||
RuntimeEnvironment.getApplication(), "icon_list", fragment, mBackend);
|
||||
RuntimeEnvironment.getApplication(), "icon_list", fragment,
|
||||
new TestIconOptionsProvider(), mBackend);
|
||||
|
||||
mRecyclerView = new RecyclerView(context);
|
||||
mRecyclerView.setId(R.id.icon_list);
|
||||
@@ -75,7 +78,7 @@ public class ZenModeIconPickerListPreferenceControllerTest {
|
||||
mController.displayPreference(mPreferenceScreen);
|
||||
|
||||
assertThat(mRecyclerView.getAdapter()).isNotNull();
|
||||
assertThat(mRecyclerView.getAdapter().getItemCount()).isEqualTo(20);
|
||||
assertThat(mRecyclerView.getAdapter().getItemCount()).isEqualTo(3);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -88,4 +91,15 @@ public class ZenModeIconPickerListPreferenceControllerTest {
|
||||
verify(mBackend).updateMode(captor.capture());
|
||||
assertThat(captor.getValue().getRule().getIconResId()).isEqualTo(R.drawable.ic_android);
|
||||
}
|
||||
|
||||
private static class TestIconOptionsProvider implements IconOptionsProvider {
|
||||
|
||||
@Override
|
||||
public ImmutableList<IconInfo> getIcons() {
|
||||
return ImmutableList.of(
|
||||
new IconInfo(R.drawable.ic_android, "android"),
|
||||
new IconInfo(R.drawable.ic_info, "info"),
|
||||
new IconInfo(R.drawable.ic_hearing, "hearing"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user