Unified service and shortcut state summary on a11y settings page.
Bug: 210026562 Test: manual Test: atest Change-Id: I4d5ff6b10d6bfd2fe6b3de1849d00a9d084bf269
This commit is contained in:
@@ -24,6 +24,8 @@ import static com.google.common.truth.Truth.assertThat;
|
||||
import android.content.Context;
|
||||
import android.provider.Settings;
|
||||
|
||||
import androidx.test.core.app.ApplicationProvider;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
|
||||
@@ -31,7 +33,6 @@ import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
|
||||
/** Tests for {@link CaptioningPreferenceController}. */
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
@@ -42,7 +43,7 @@ public class CaptioningPreferenceControllerTest {
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
mContext = RuntimeEnvironment.application;
|
||||
mContext = ApplicationProvider.getApplicationContext();
|
||||
mController = new CaptioningPreferenceController(mContext, "captioning_pref");
|
||||
}
|
||||
|
||||
@@ -54,19 +55,22 @@ public class CaptioningPreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void getSummary_enabledCaptions_shouldReturnOnSummary() {
|
||||
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||
Settings.Secure.ACCESSIBILITY_CAPTIONING_ENABLED, ON);
|
||||
setCaptioningEnabled(true);
|
||||
|
||||
assertThat(mController.getSummary()).isEqualTo(
|
||||
mContext.getText(R.string.accessibility_feature_state_on));
|
||||
mContext.getText(R.string.show_captions_enabled));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSummary_disabledCaptions_shouldReturnOffSummary() {
|
||||
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||
Settings.Secure.ACCESSIBILITY_CAPTIONING_ENABLED, OFF);
|
||||
setCaptioningEnabled(false);
|
||||
|
||||
assertThat(mController.getSummary()).isEqualTo(
|
||||
mContext.getText(R.string.accessibility_feature_state_off));
|
||||
mContext.getText(R.string.show_captions_disabled));
|
||||
}
|
||||
|
||||
private void setCaptioningEnabled(boolean enabled) {
|
||||
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||
Settings.Secure.ACCESSIBILITY_CAPTIONING_ENABLED, enabled ? ON : OFF);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user