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