Merge "Adapt to the new API of ShadowCaptioningManager
." into main am: 1d591b26a9
am: ae15c01dcc
Original change: https://android-review.googlesource.com/c/platform/packages/apps/Settings/+/3080265 Change-Id: Ib0297be4453b1450eca244ce94705eebc31ef090 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -17,8 +17,10 @@
|
||||
package com.android.settings.accessibility;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static org.robolectric.Shadows.shadowOf;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Looper;
|
||||
import android.provider.Settings;
|
||||
import android.view.accessibility.CaptioningManager;
|
||||
|
||||
@@ -68,7 +70,9 @@ public class CaptioningAppearancePreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void getSummary_smallestScale_shouldReturnExpectedSummary() {
|
||||
mShadowCaptioningManager.setFontScale(0.25f);
|
||||
Settings.Secure.putFloat(mContext.getContentResolver(),
|
||||
Settings.Secure.ACCESSIBILITY_CAPTIONING_FONT_SCALE, 0.25f);
|
||||
shadowOf(Looper.getMainLooper()).idle();
|
||||
|
||||
final String expectedSummary =
|
||||
getSummaryCombo(/* fontScaleIndex= */ 0, DEFAULT_PRESET_INDEX);
|
||||
@@ -77,7 +81,9 @@ public class CaptioningAppearancePreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void getSummary_smallScale_shouldReturnExpectedSummary() {
|
||||
mShadowCaptioningManager.setFontScale(0.5f);
|
||||
Settings.Secure.putFloat(mContext.getContentResolver(),
|
||||
Settings.Secure.ACCESSIBILITY_CAPTIONING_FONT_SCALE, 0.5f);
|
||||
shadowOf(Looper.getMainLooper()).idle();
|
||||
|
||||
final String expectedSummary =
|
||||
getSummaryCombo(/* fontScaleIndex= */ 1, DEFAULT_PRESET_INDEX);
|
||||
@@ -86,7 +92,9 @@ public class CaptioningAppearancePreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void getSummary_mediumScale_shouldReturnExpectedSummary() {
|
||||
mShadowCaptioningManager.setFontScale(1.0f);
|
||||
Settings.Secure.putFloat(mContext.getContentResolver(),
|
||||
Settings.Secure.ACCESSIBILITY_CAPTIONING_FONT_SCALE, 1.0f);
|
||||
shadowOf(Looper.getMainLooper()).idle();
|
||||
|
||||
final String expectedSummary =
|
||||
getSummaryCombo(/* fontScaleIndex= */ 2, DEFAULT_PRESET_INDEX);
|
||||
@@ -95,7 +103,9 @@ public class CaptioningAppearancePreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void getSummary_largeScale_shouldReturnExpectedSummary() {
|
||||
mShadowCaptioningManager.setFontScale(1.5f);
|
||||
Settings.Secure.putFloat(mContext.getContentResolver(),
|
||||
Settings.Secure.ACCESSIBILITY_CAPTIONING_FONT_SCALE, 1.5f);
|
||||
shadowOf(Looper.getMainLooper()).idle();
|
||||
|
||||
final String expectedSummary =
|
||||
getSummaryCombo(/* fontScaleIndex= */ 3, DEFAULT_PRESET_INDEX);
|
||||
@@ -104,7 +114,9 @@ public class CaptioningAppearancePreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void getSummary_largestScale_shouldReturnExpectedSummary() {
|
||||
mShadowCaptioningManager.setFontScale(2.0f);
|
||||
Settings.Secure.putFloat(mContext.getContentResolver(),
|
||||
Settings.Secure.ACCESSIBILITY_CAPTIONING_FONT_SCALE, 2.0f);
|
||||
shadowOf(Looper.getMainLooper()).idle();
|
||||
|
||||
final String expectedSummary =
|
||||
getSummaryCombo(/* fontScaleIndex= */ 4, DEFAULT_PRESET_INDEX);
|
||||
|
@@ -127,7 +127,8 @@ public class CaptioningBackgroundColorControllerTest {
|
||||
|
||||
@Test
|
||||
public void onValueChanged_shouldSetCaptionEnabled() {
|
||||
mShadowCaptioningManager.setEnabled(false);
|
||||
Settings.Secure.putInt(
|
||||
mContext.getContentResolver(), Settings.Secure.ACCESSIBILITY_CAPTIONING_ENABLED, OFF);
|
||||
mController.displayPreference(mScreen);
|
||||
|
||||
mController.onValueChanged(mPreference, 0xFFFF0000);
|
||||
|
@@ -103,7 +103,8 @@ public class CaptioningBackgroundOpacityControllerTest {
|
||||
|
||||
@Test
|
||||
public void onValueChanged_shouldSetCaptionEnabled() {
|
||||
mShadowCaptioningManager.setEnabled(false);
|
||||
Settings.Secure.putInt(
|
||||
mContext.getContentResolver(), Settings.Secure.ACCESSIBILITY_CAPTIONING_ENABLED, OFF);
|
||||
mController.displayPreference(mScreen);
|
||||
|
||||
mController.onValueChanged(mPreference, 0x80FFFFFF);
|
||||
|
@@ -101,7 +101,8 @@ public class CaptioningEdgeColorControllerTest {
|
||||
|
||||
@Test
|
||||
public void onValueChanged_shouldSetCaptionEnabled() {
|
||||
mShadowCaptioningManager.setEnabled(false);
|
||||
Settings.Secure.putInt(
|
||||
mContext.getContentResolver(), Settings.Secure.ACCESSIBILITY_CAPTIONING_ENABLED, OFF);
|
||||
mController.displayPreference(mScreen);
|
||||
|
||||
mController.onValueChanged(mPreference, 0xFFFF0000);
|
||||
|
@@ -103,7 +103,8 @@ public class CaptioningEdgeTypeControllerTest {
|
||||
|
||||
@Test
|
||||
public void onValueChanged_shouldSetCaptionEnabled() {
|
||||
mShadowCaptioningManager.setEnabled(false);
|
||||
Settings.Secure.putInt(
|
||||
mContext.getContentResolver(), Settings.Secure.ACCESSIBILITY_CAPTIONING_ENABLED, OFF);
|
||||
mController.displayPreference(mScreen);
|
||||
|
||||
mController.onValueChanged(mPreference, CaptionStyle.EDGE_TYPE_OUTLINE);
|
||||
|
@@ -23,7 +23,10 @@ import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import static org.robolectric.Shadows.shadowOf;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Looper;
|
||||
import android.provider.Settings;
|
||||
import android.view.accessibility.CaptioningManager;
|
||||
|
||||
@@ -85,7 +88,9 @@ public class CaptioningFontSizeControllerTest {
|
||||
|
||||
@Test
|
||||
public void updateState_bySmallValue_shouldReturnSmall() {
|
||||
mShadowCaptioningManager.setFontScale(0.5f);
|
||||
Settings.Secure.putFloat(mContext.getContentResolver(),
|
||||
Settings.Secure.ACCESSIBILITY_CAPTIONING_FONT_SCALE, 0.5f);
|
||||
shadowOf(Looper.getMainLooper()).idle();
|
||||
|
||||
mController.updateState(mPreference);
|
||||
|
||||
@@ -94,7 +99,8 @@ public class CaptioningFontSizeControllerTest {
|
||||
|
||||
@Test
|
||||
public void onPreferenceChange_shouldSetCaptionEnabled() {
|
||||
mShadowCaptioningManager.setEnabled(false);
|
||||
Settings.Secure.putInt(
|
||||
mContext.getContentResolver(), Settings.Secure.ACCESSIBILITY_CAPTIONING_ENABLED, OFF);
|
||||
mController.displayPreference(mScreen);
|
||||
|
||||
mController.onPreferenceChange(mPreference, "0.5");
|
||||
|
@@ -127,7 +127,8 @@ public class CaptioningForegroundColorControllerTest {
|
||||
|
||||
@Test
|
||||
public void onValueChanged_shouldSetCaptionEnabled() {
|
||||
mShadowCaptioningManager.setEnabled(false);
|
||||
Settings.Secure.putInt(
|
||||
mContext.getContentResolver(), Settings.Secure.ACCESSIBILITY_CAPTIONING_ENABLED, OFF);
|
||||
mController.displayPreference(mScreen);
|
||||
|
||||
mController.onValueChanged(mPreference, 0xFFFF0000);
|
||||
|
@@ -103,7 +103,8 @@ public class CaptioningForegroundOpacityControllerTest {
|
||||
|
||||
@Test
|
||||
public void onValueChanged_shouldSetCaptionEnabled() {
|
||||
mShadowCaptioningManager.setEnabled(false);
|
||||
Settings.Secure.putInt(
|
||||
mContext.getContentResolver(), Settings.Secure.ACCESSIBILITY_CAPTIONING_ENABLED, OFF);
|
||||
mController.displayPreference(mScreen);
|
||||
|
||||
mController.onValueChanged(mPreference, 0x80FFFFFF);
|
||||
|
@@ -103,7 +103,8 @@ public class CaptioningPresetControllerTest {
|
||||
|
||||
@Test
|
||||
public void onValueChanged_shouldSetCaptionEnabled() {
|
||||
mShadowCaptioningManager.setEnabled(false);
|
||||
Settings.Secure.putInt(
|
||||
mContext.getContentResolver(), Settings.Secure.ACCESSIBILITY_CAPTIONING_ENABLED, OFF);
|
||||
mController.displayPreference(mScreen);
|
||||
|
||||
mController.onValueChanged(mPreference, CaptionStyle.PRESET_CUSTOM);
|
||||
|
@@ -82,7 +82,8 @@ public class CaptioningTogglePreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void displayPreference_captionEnabled_shouldSetChecked() {
|
||||
mShadowCaptioningManager.setEnabled(true);
|
||||
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||
Settings.Secure.ACCESSIBILITY_CAPTIONING_ENABLED, ON);
|
||||
|
||||
mController.displayPreference(mScreen);
|
||||
|
||||
@@ -91,7 +92,8 @@ public class CaptioningTogglePreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void displayPreference_captionDisabled_shouldSetUnchecked() {
|
||||
mShadowCaptioningManager.setEnabled(false);
|
||||
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||
Settings.Secure.ACCESSIBILITY_CAPTIONING_ENABLED, OFF);
|
||||
|
||||
mController.displayPreference(mScreen);
|
||||
|
||||
@@ -100,7 +102,8 @@ public class CaptioningTogglePreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void performClick_captionEnabled_shouldSetCaptionDisabled() {
|
||||
mShadowCaptioningManager.setEnabled(true);
|
||||
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||
Settings.Secure.ACCESSIBILITY_CAPTIONING_ENABLED, ON);
|
||||
mController.displayPreference(mScreen);
|
||||
|
||||
mSwitchPreference.performClick();
|
||||
@@ -111,7 +114,8 @@ public class CaptioningTogglePreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void performClick_captionDisabled_shouldSetCaptionEnabled() {
|
||||
mShadowCaptioningManager.setEnabled(false);
|
||||
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||
Settings.Secure.ACCESSIBILITY_CAPTIONING_ENABLED, OFF);
|
||||
mController.displayPreference(mScreen);
|
||||
|
||||
mSwitchPreference.performClick();
|
||||
|
@@ -95,7 +95,8 @@ public class CaptioningTypefaceControllerTest {
|
||||
|
||||
@Test
|
||||
public void onPreferenceChange_shouldSetCaptionEnabled() {
|
||||
mShadowCaptioningManager.setEnabled(false);
|
||||
Settings.Secure.putInt(
|
||||
mContext.getContentResolver(), Settings.Secure.ACCESSIBILITY_CAPTIONING_ENABLED, OFF);
|
||||
mController.displayPreference(mScreen);
|
||||
|
||||
mController.onPreferenceChange(mPreference, "serif");
|
||||
|
@@ -128,7 +128,8 @@ public class CaptioningWindowColorControllerTest {
|
||||
|
||||
@Test
|
||||
public void onValueChanged_shouldSetCaptionEnabled() {
|
||||
mShadowCaptioningManager.setEnabled(false);
|
||||
Settings.Secure.putInt(
|
||||
mContext.getContentResolver(), Settings.Secure.ACCESSIBILITY_CAPTIONING_ENABLED, OFF);
|
||||
mController.displayPreference(mScreen);
|
||||
|
||||
mController.onValueChanged(mPreference, 0xFFFF0000);
|
||||
|
@@ -102,7 +102,8 @@ public class CaptioningWindowOpacityControllerTest {
|
||||
|
||||
@Test
|
||||
public void onValueChanged_shouldSetCaptionEnabled() {
|
||||
mShadowCaptioningManager.setEnabled(false);
|
||||
Settings.Secure.putInt(
|
||||
mContext.getContentResolver(), Settings.Secure.ACCESSIBILITY_CAPTIONING_ENABLED, OFF);
|
||||
mController.displayPreference(mScreen);
|
||||
|
||||
mController.onValueChanged(mPreference, 0x80FFFFFF);
|
||||
|
Reference in New Issue
Block a user