[Reduce Bright Colors] Use a switch preference

Test: atest ReduceBrightColorsPreferenceControllerTest, manual
Bug: 128465252
Change-Id: I824af24e545d38bad74613147328cf51108a9127
This commit is contained in:
sallyyuen
2021-02-28 13:45:56 -08:00
committed by Sally Yuen
parent 9724bd9e0c
commit 166c89890e
3 changed files with 85 additions and 5 deletions

View File

@@ -19,6 +19,7 @@ package com.android.settings.accessibility;
import static com.google.common.truth.Truth.assertThat;
import android.content.Context;
import android.provider.Settings;
import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4;
@@ -31,7 +32,6 @@ import org.junit.runner.RunWith;
@RunWith(AndroidJUnit4.class)
public class ReduceBrightColorsPreferenceControllerTest {
private static final String PREF_KEY = "rbc_preference";
private final Context mContext = ApplicationProvider.getApplicationContext();
private final ReduceBrightColorsPreferenceController mController =
new ReduceBrightColorsPreferenceController(mContext, PREF_KEY);
@@ -41,4 +41,18 @@ public class ReduceBrightColorsPreferenceControllerTest {
assertThat(mController.getSummary().toString().contains(
mContext.getText(R.string.reduce_bright_colors_preference_summary))).isTrue();
}
@Test
public void isChecked_reduceBrightColorsIsActivated_returnTrue() {
Settings.Secure.putInt(mContext.getContentResolver(),
Settings.Secure.REDUCE_BRIGHT_COLORS_ACTIVATED, 1);
assertThat(mController.isChecked()).isTrue();
}
@Test
public void isChecked_reduceBrightColorsIsNotActivated_returnFalse() {
Settings.Secure.putInt(mContext.getContentResolver(),
Settings.Secure.REDUCE_BRIGHT_COLORS_ACTIVATED, 0);
assertThat(mController.isChecked()).isFalse();
}
}