Merge "Makes all custom caption settings unsearchable when custom captions are not active." into main
This commit is contained in:
@@ -0,0 +1,35 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2024 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.android.settings.accessibility;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
import com.android.settings.core.BasePreferenceController;
|
||||||
|
|
||||||
|
public class BaseCaptioningCustomController extends BasePreferenceController {
|
||||||
|
protected final CaptionHelper mCaptionHelper;
|
||||||
|
|
||||||
|
public BaseCaptioningCustomController(Context context, String preferenceKey) {
|
||||||
|
super(context, preferenceKey);
|
||||||
|
mCaptionHelper = new CaptionHelper(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getAvailabilityStatus() {
|
||||||
|
return mCaptionHelper.getCustomCaptionAvailability();
|
||||||
|
}
|
||||||
|
}
|
@@ -18,6 +18,8 @@ package com.android.settings.accessibility;
|
|||||||
|
|
||||||
import static com.android.settings.accessibility.AccessibilityUtil.State.OFF;
|
import static com.android.settings.accessibility.AccessibilityUtil.State.OFF;
|
||||||
import static com.android.settings.accessibility.AccessibilityUtil.State.ON;
|
import static com.android.settings.accessibility.AccessibilityUtil.State.ON;
|
||||||
|
import static com.android.settings.core.BasePreferenceController.AVAILABLE;
|
||||||
|
import static com.android.settings.core.BasePreferenceController.AVAILABLE_UNSEARCHABLE;
|
||||||
|
|
||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@@ -211,4 +213,14 @@ public class CaptionHelper {
|
|||||||
public Locale getLocale() {
|
public Locale getLocale() {
|
||||||
return mCaptioningManager.getLocale();
|
return mCaptioningManager.getLocale();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Returns availability for custom caption preferences, depending on current user style. */
|
||||||
|
public int getCustomCaptionAvailability() {
|
||||||
|
if (com.android.settings.accessibility.Flags.fixA11ySettingsSearch()) {
|
||||||
|
return (getRawUserStyle() == CaptionStyle.PRESET_CUSTOM)
|
||||||
|
? AVAILABLE : AVAILABLE_UNSEARCHABLE;
|
||||||
|
} else {
|
||||||
|
return AVAILABLE;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -25,23 +25,15 @@ import androidx.preference.PreferenceScreen;
|
|||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.accessibility.ListDialogPreference.OnValueChangedListener;
|
import com.android.settings.accessibility.ListDialogPreference.OnValueChangedListener;
|
||||||
import com.android.settings.core.BasePreferenceController;
|
|
||||||
|
|
||||||
/** Preference controller for captioning background color. */
|
/** Preference controller for captioning background color. */
|
||||||
public class CaptioningBackgroundColorController extends BasePreferenceController
|
public class CaptioningBackgroundColorController extends BaseCaptioningCustomController
|
||||||
implements OnValueChangedListener {
|
implements OnValueChangedListener {
|
||||||
|
|
||||||
private final CaptionHelper mCaptionHelper;
|
|
||||||
private int mCachedNonDefaultOpacity = CaptionStyle.COLOR_UNSPECIFIED;
|
private int mCachedNonDefaultOpacity = CaptionStyle.COLOR_UNSPECIFIED;
|
||||||
|
|
||||||
public CaptioningBackgroundColorController(Context context, String preferenceKey) {
|
public CaptioningBackgroundColorController(Context context, String preferenceKey) {
|
||||||
super(context, preferenceKey);
|
super(context, preferenceKey);
|
||||||
mCaptionHelper = new CaptionHelper(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getAvailabilityStatus() {
|
|
||||||
return AVAILABLE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -23,22 +23,13 @@ import androidx.preference.PreferenceScreen;
|
|||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.accessibility.ListDialogPreference.OnValueChangedListener;
|
import com.android.settings.accessibility.ListDialogPreference.OnValueChangedListener;
|
||||||
import com.android.settings.core.BasePreferenceController;
|
|
||||||
|
|
||||||
/** Preference controller for captioning background opacity. */
|
/** Preference controller for captioning background opacity. */
|
||||||
public class CaptioningBackgroundOpacityController extends BasePreferenceController
|
public class CaptioningBackgroundOpacityController extends BaseCaptioningCustomController
|
||||||
implements OnValueChangedListener {
|
implements OnValueChangedListener {
|
||||||
|
|
||||||
private final CaptionHelper mCaptionHelper;
|
|
||||||
|
|
||||||
public CaptioningBackgroundOpacityController(Context context, String preferenceKey) {
|
public CaptioningBackgroundOpacityController(Context context, String preferenceKey) {
|
||||||
super(context, preferenceKey);
|
super(context, preferenceKey);
|
||||||
mCaptionHelper = new CaptionHelper(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getAvailabilityStatus() {
|
|
||||||
return AVAILABLE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -28,7 +28,6 @@ import androidx.annotation.VisibleForTesting;
|
|||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
import androidx.preference.PreferenceScreen;
|
import androidx.preference.PreferenceScreen;
|
||||||
|
|
||||||
import com.android.settings.core.BasePreferenceController;
|
|
||||||
import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
||||||
import com.android.settingslib.core.lifecycle.events.OnStart;
|
import com.android.settingslib.core.lifecycle.events.OnStart;
|
||||||
import com.android.settingslib.core.lifecycle.events.OnStop;
|
import com.android.settingslib.core.lifecycle.events.OnStop;
|
||||||
@@ -37,12 +36,11 @@ import java.util.Arrays;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/** Preference controller for captioning custom visibility. */
|
/** Preference controller for captioning custom visibility. */
|
||||||
public class CaptioningCustomController extends BasePreferenceController
|
public class CaptioningCustomController extends BaseCaptioningCustomController
|
||||||
implements LifecycleObserver, OnStart, OnStop {
|
implements LifecycleObserver, OnStart, OnStop {
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private Preference mCustom;
|
private Preference mCustom;
|
||||||
private final CaptionHelper mCaptionHelper;
|
|
||||||
private final ContentResolver mContentResolver;
|
private final ContentResolver mContentResolver;
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
AccessibilitySettingsContentObserver mSettingsContentObserver;
|
AccessibilitySettingsContentObserver mSettingsContentObserver;
|
||||||
@@ -52,16 +50,15 @@ public class CaptioningCustomController extends BasePreferenceController
|
|||||||
);
|
);
|
||||||
|
|
||||||
public CaptioningCustomController(Context context, String preferenceKey) {
|
public CaptioningCustomController(Context context, String preferenceKey) {
|
||||||
this(context, preferenceKey, new CaptionHelper(context),
|
this(context, preferenceKey,
|
||||||
new AccessibilitySettingsContentObserver(new Handler(Looper.getMainLooper())));
|
new AccessibilitySettingsContentObserver(new Handler(Looper.getMainLooper())));
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
CaptioningCustomController(
|
CaptioningCustomController(
|
||||||
Context context, String preferenceKey, CaptionHelper captionHelper,
|
Context context, String preferenceKey,
|
||||||
AccessibilitySettingsContentObserver contentObserver) {
|
AccessibilitySettingsContentObserver contentObserver) {
|
||||||
super(context, preferenceKey);
|
super(context, preferenceKey);
|
||||||
mCaptionHelper = new CaptionHelper(context);
|
|
||||||
mContentResolver = context.getContentResolver();
|
mContentResolver = context.getContentResolver();
|
||||||
mSettingsContentObserver = contentObserver;
|
mSettingsContentObserver = contentObserver;
|
||||||
mSettingsContentObserver.registerKeysToObserverCallback(CAPTIONING_FEATURE_KEYS, key -> {
|
mSettingsContentObserver.registerKeysToObserverCallback(CAPTIONING_FEATURE_KEYS, key -> {
|
||||||
@@ -71,15 +68,6 @@ public class CaptioningCustomController extends BasePreferenceController
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getAvailabilityStatus() {
|
|
||||||
if (com.android.settings.accessibility.Flags.fixA11ySettingsSearch()) {
|
|
||||||
return (shouldShowPreference()) ? AVAILABLE : AVAILABLE_UNSEARCHABLE;
|
|
||||||
} else {
|
|
||||||
return AVAILABLE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void displayPreference(PreferenceScreen screen) {
|
public void displayPreference(PreferenceScreen screen) {
|
||||||
super.displayPreference(screen);
|
super.displayPreference(screen);
|
||||||
|
@@ -23,22 +23,13 @@ import androidx.preference.PreferenceScreen;
|
|||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.accessibility.ListDialogPreference.OnValueChangedListener;
|
import com.android.settings.accessibility.ListDialogPreference.OnValueChangedListener;
|
||||||
import com.android.settings.core.BasePreferenceController;
|
|
||||||
|
|
||||||
/** Preference controller for captioning edge color. */
|
/** Preference controller for captioning edge color. */
|
||||||
public class CaptioningEdgeColorController extends BasePreferenceController
|
public class CaptioningEdgeColorController extends BaseCaptioningCustomController
|
||||||
implements OnValueChangedListener {
|
implements OnValueChangedListener {
|
||||||
|
|
||||||
private final CaptionHelper mCaptionHelper;
|
|
||||||
|
|
||||||
public CaptioningEdgeColorController(Context context, String preferenceKey) {
|
public CaptioningEdgeColorController(Context context, String preferenceKey) {
|
||||||
super(context, preferenceKey);
|
super(context, preferenceKey);
|
||||||
mCaptionHelper = new CaptionHelper(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getAvailabilityStatus() {
|
|
||||||
return AVAILABLE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -21,22 +21,13 @@ import android.content.Context;
|
|||||||
import androidx.preference.PreferenceScreen;
|
import androidx.preference.PreferenceScreen;
|
||||||
|
|
||||||
import com.android.settings.accessibility.ListDialogPreference.OnValueChangedListener;
|
import com.android.settings.accessibility.ListDialogPreference.OnValueChangedListener;
|
||||||
import com.android.settings.core.BasePreferenceController;
|
|
||||||
|
|
||||||
/** Preference controller for captioning edge type. */
|
/** Preference controller for captioning edge type. */
|
||||||
public class CaptioningEdgeTypeController extends BasePreferenceController
|
public class CaptioningEdgeTypeController extends BaseCaptioningCustomController
|
||||||
implements OnValueChangedListener {
|
implements OnValueChangedListener {
|
||||||
|
|
||||||
private final CaptionHelper mCaptionHelper;
|
|
||||||
|
|
||||||
public CaptioningEdgeTypeController(Context context, String preferenceKey) {
|
public CaptioningEdgeTypeController(Context context, String preferenceKey) {
|
||||||
super(context, preferenceKey);
|
super(context, preferenceKey);
|
||||||
mCaptionHelper = new CaptionHelper(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getAvailabilityStatus() {
|
|
||||||
return AVAILABLE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -24,23 +24,15 @@ import androidx.preference.PreferenceScreen;
|
|||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.accessibility.ListDialogPreference.OnValueChangedListener;
|
import com.android.settings.accessibility.ListDialogPreference.OnValueChangedListener;
|
||||||
import com.android.settings.core.BasePreferenceController;
|
|
||||||
|
|
||||||
/** Preference controller for captioning foreground color. */
|
/** Preference controller for captioning foreground color. */
|
||||||
public class CaptioningForegroundColorController extends BasePreferenceController
|
public class CaptioningForegroundColorController extends BaseCaptioningCustomController
|
||||||
implements OnValueChangedListener {
|
implements OnValueChangedListener {
|
||||||
|
|
||||||
private final CaptionHelper mCaptionHelper;
|
|
||||||
private int mCachedNonDefaultOpacity = CaptionStyle.COLOR_UNSPECIFIED;
|
private int mCachedNonDefaultOpacity = CaptionStyle.COLOR_UNSPECIFIED;
|
||||||
|
|
||||||
public CaptioningForegroundColorController(Context context, String preferenceKey) {
|
public CaptioningForegroundColorController(Context context, String preferenceKey) {
|
||||||
super(context, preferenceKey);
|
super(context, preferenceKey);
|
||||||
mCaptionHelper = new CaptionHelper(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getAvailabilityStatus() {
|
|
||||||
return AVAILABLE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -23,22 +23,13 @@ import androidx.preference.PreferenceScreen;
|
|||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.accessibility.ListDialogPreference.OnValueChangedListener;
|
import com.android.settings.accessibility.ListDialogPreference.OnValueChangedListener;
|
||||||
import com.android.settings.core.BasePreferenceController;
|
|
||||||
|
|
||||||
/** Preference controller for captioning foreground opacity. */
|
/** Preference controller for captioning foreground opacity. */
|
||||||
public class CaptioningForegroundOpacityController extends BasePreferenceController
|
public class CaptioningForegroundOpacityController extends BaseCaptioningCustomController
|
||||||
implements OnValueChangedListener {
|
implements OnValueChangedListener {
|
||||||
|
|
||||||
private final CaptionHelper mCaptionHelper;
|
|
||||||
|
|
||||||
public CaptioningForegroundOpacityController(Context context, String preferenceKey) {
|
public CaptioningForegroundOpacityController(Context context, String preferenceKey) {
|
||||||
super(context, preferenceKey);
|
super(context, preferenceKey);
|
||||||
mCaptionHelper = new CaptionHelper(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getAvailabilityStatus() {
|
|
||||||
return AVAILABLE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -23,22 +23,12 @@ import android.view.accessibility.CaptioningManager.CaptionStyle;
|
|||||||
import androidx.preference.ListPreference;
|
import androidx.preference.ListPreference;
|
||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
|
|
||||||
import com.android.settings.core.BasePreferenceController;
|
|
||||||
|
|
||||||
/** Preference controller for captioning type face. */
|
/** Preference controller for captioning type face. */
|
||||||
public class CaptioningTypefaceController extends BasePreferenceController
|
public class CaptioningTypefaceController extends BaseCaptioningCustomController
|
||||||
implements Preference.OnPreferenceChangeListener {
|
implements Preference.OnPreferenceChangeListener {
|
||||||
|
|
||||||
private final CaptionHelper mCaptionHelper;
|
|
||||||
|
|
||||||
public CaptioningTypefaceController(Context context, String preferenceKey) {
|
public CaptioningTypefaceController(Context context, String preferenceKey) {
|
||||||
super(context, preferenceKey);
|
super(context, preferenceKey);
|
||||||
mCaptionHelper = new CaptionHelper(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getAvailabilityStatus() {
|
|
||||||
return AVAILABLE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -19,43 +19,21 @@ package com.android.settings.accessibility;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.view.accessibility.CaptioningManager;
|
|
||||||
import android.view.accessibility.CaptioningManager.CaptionStyle;
|
import android.view.accessibility.CaptioningManager.CaptionStyle;
|
||||||
|
|
||||||
import androidx.preference.PreferenceScreen;
|
import androidx.preference.PreferenceScreen;
|
||||||
|
|
||||||
import com.android.internal.annotations.VisibleForTesting;
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.accessibility.ListDialogPreference.OnValueChangedListener;
|
import com.android.settings.accessibility.ListDialogPreference.OnValueChangedListener;
|
||||||
import com.android.settings.core.BasePreferenceController;
|
|
||||||
|
|
||||||
/** Preference controller for captioning window color. */
|
/** Preference controller for captioning window color. */
|
||||||
public class CaptioningWindowColorController extends BasePreferenceController
|
public class CaptioningWindowColorController extends BaseCaptioningCustomController
|
||||||
implements OnValueChangedListener {
|
implements OnValueChangedListener {
|
||||||
|
|
||||||
private final CaptionHelper mCaptionHelper;
|
|
||||||
private int mCachedNonDefaultOpacity = CaptionStyle.COLOR_UNSPECIFIED;
|
private int mCachedNonDefaultOpacity = CaptionStyle.COLOR_UNSPECIFIED;
|
||||||
|
|
||||||
@VisibleForTesting
|
|
||||||
CaptioningWindowColorController(Context context, String preferenceKey,
|
|
||||||
CaptionHelper captionHelper) {
|
|
||||||
super(context, preferenceKey);
|
|
||||||
mCaptionHelper = captionHelper;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CaptioningWindowColorController(Context context, String preferenceKey) {
|
public CaptioningWindowColorController(Context context, String preferenceKey) {
|
||||||
this(context, preferenceKey, new CaptionHelper(context));
|
super(context, preferenceKey);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getAvailabilityStatus() {
|
|
||||||
if (com.android.settings.accessibility.Flags.fixA11ySettingsSearch()) {
|
|
||||||
return (mCaptionHelper.getRawUserStyle()
|
|
||||||
== CaptioningManager.CaptionStyle.PRESET_CUSTOM)
|
|
||||||
? AVAILABLE : AVAILABLE_UNSEARCHABLE;
|
|
||||||
} else {
|
|
||||||
return AVAILABLE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -18,41 +18,18 @@ package com.android.settings.accessibility;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.view.accessibility.CaptioningManager;
|
|
||||||
|
|
||||||
import androidx.preference.PreferenceScreen;
|
import androidx.preference.PreferenceScreen;
|
||||||
|
|
||||||
import com.android.internal.annotations.VisibleForTesting;
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.accessibility.ListDialogPreference.OnValueChangedListener;
|
import com.android.settings.accessibility.ListDialogPreference.OnValueChangedListener;
|
||||||
import com.android.settings.core.BasePreferenceController;
|
|
||||||
|
|
||||||
/** Preference controller for captioning window opacity. */
|
/** Preference controller for captioning window opacity. */
|
||||||
public class CaptioningWindowOpacityController extends BasePreferenceController
|
public class CaptioningWindowOpacityController extends BaseCaptioningCustomController
|
||||||
implements OnValueChangedListener {
|
implements OnValueChangedListener {
|
||||||
|
|
||||||
private final CaptionHelper mCaptionHelper;
|
|
||||||
|
|
||||||
@VisibleForTesting
|
|
||||||
CaptioningWindowOpacityController(Context context, String preferenceKey,
|
|
||||||
CaptionHelper captionHelper) {
|
|
||||||
super(context, preferenceKey);
|
|
||||||
mCaptionHelper = captionHelper;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CaptioningWindowOpacityController(Context context, String preferenceKey) {
|
public CaptioningWindowOpacityController(Context context, String preferenceKey) {
|
||||||
this(context, preferenceKey, new CaptionHelper(context));
|
super(context, preferenceKey);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getAvailabilityStatus() {
|
|
||||||
if (com.android.settings.accessibility.Flags.fixA11ySettingsSearch()) {
|
|
||||||
return (mCaptionHelper.getRawUserStyle()
|
|
||||||
== CaptioningManager.CaptionStyle.PRESET_CUSTOM)
|
|
||||||
? AVAILABLE : AVAILABLE_UNSEARCHABLE;
|
|
||||||
} else {
|
|
||||||
return AVAILABLE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -26,6 +26,9 @@ import static org.mockito.Mockito.when;
|
|||||||
|
|
||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.platform.test.annotations.DisableFlags;
|
||||||
|
import android.platform.test.annotations.EnableFlags;
|
||||||
|
import android.platform.test.flag.junit.SetFlagsRule;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.accessibility.CaptioningManager;
|
import android.view.accessibility.CaptioningManager;
|
||||||
@@ -35,6 +38,7 @@ import androidx.test.core.app.ApplicationProvider;
|
|||||||
|
|
||||||
import com.android.internal.widget.SubtitleView;
|
import com.android.internal.widget.SubtitleView;
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
|
import com.android.settings.core.BasePreferenceController;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
@@ -54,6 +58,8 @@ public class CaptionHelperTest {
|
|||||||
|
|
||||||
@Rule
|
@Rule
|
||||||
public final MockitoRule mMockitoRule = MockitoJUnit.rule();
|
public final MockitoRule mMockitoRule = MockitoJUnit.rule();
|
||||||
|
@Rule
|
||||||
|
public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
|
||||||
@Mock
|
@Mock
|
||||||
private CaptioningManager mCaptioningManager;
|
private CaptioningManager mCaptioningManager;
|
||||||
@Mock
|
@Mock
|
||||||
@@ -182,4 +188,40 @@ public class CaptionHelperTest {
|
|||||||
Settings.Secure.ACCESSIBILITY_CAPTIONING_PRESET, 0);
|
Settings.Secure.ACCESSIBILITY_CAPTIONING_PRESET, 0);
|
||||||
assertThat(style).isEqualTo(CaptionStyle.PRESET_CUSTOM);
|
assertThat(style).isEqualTo(CaptionStyle.PRESET_CUSTOM);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisableFlags(Flags.FLAG_FIX_A11Y_SETTINGS_SEARCH)
|
||||||
|
public void getAvailabilityStatus_flagOff_customCaption_shouldReturnAvailable() {
|
||||||
|
when(mCaptioningManager.getRawUserStyle()).thenReturn(CaptionStyle.PRESET_CUSTOM);
|
||||||
|
|
||||||
|
assertThat(mCaptionHelper.getCustomCaptionAvailability())
|
||||||
|
.isEqualTo(BasePreferenceController.AVAILABLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisableFlags(Flags.FLAG_FIX_A11Y_SETTINGS_SEARCH)
|
||||||
|
public void getAvailabilityStatus_flagOff_notCustom_shouldReturnAvailable() {
|
||||||
|
when(mCaptioningManager.getRawUserStyle()).thenReturn(0);
|
||||||
|
|
||||||
|
assertThat(mCaptionHelper.getCustomCaptionAvailability())
|
||||||
|
.isEqualTo(BasePreferenceController.AVAILABLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@EnableFlags(Flags.FLAG_FIX_A11Y_SETTINGS_SEARCH)
|
||||||
|
public void getAvailabilityStatus_customCaption_shouldReturnAvailable() {
|
||||||
|
when(mCaptioningManager.getRawUserStyle()).thenReturn(CaptionStyle.PRESET_CUSTOM);
|
||||||
|
|
||||||
|
assertThat(mCaptionHelper.getCustomCaptionAvailability())
|
||||||
|
.isEqualTo(BasePreferenceController.AVAILABLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@EnableFlags(Flags.FLAG_FIX_A11Y_SETTINGS_SEARCH)
|
||||||
|
public void getAvailabilityStatus_notCustom_shouldReturnUnsearchable() {
|
||||||
|
when(mCaptioningManager.getRawUserStyle()).thenReturn(0);
|
||||||
|
|
||||||
|
assertThat(mCaptionHelper.getCustomCaptionAvailability())
|
||||||
|
.isEqualTo(BasePreferenceController.AVAILABLE_UNSEARCHABLE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -32,8 +32,6 @@ import android.view.accessibility.CaptioningManager.CaptionStyle;
|
|||||||
import androidx.preference.PreferenceScreen;
|
import androidx.preference.PreferenceScreen;
|
||||||
import androidx.test.core.app.ApplicationProvider;
|
import androidx.test.core.app.ApplicationProvider;
|
||||||
|
|
||||||
import com.android.settings.core.BasePreferenceController;
|
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -70,12 +68,6 @@ public class CaptioningBackgroundColorControllerTest {
|
|||||||
mShadowCaptioningManager = Shadow.extract(captioningManager);
|
mShadowCaptioningManager = Shadow.extract(captioningManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void getAvailabilityStatus_shouldReturnAvailable() {
|
|
||||||
assertThat(mController.getAvailabilityStatus())
|
|
||||||
.isEqualTo(BasePreferenceController.AVAILABLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getSummary_defaultValue_shouldReturnBlack() {
|
public void getSummary_defaultValue_shouldReturnBlack() {
|
||||||
mController.displayPreference(mScreen);
|
mController.displayPreference(mScreen);
|
||||||
|
@@ -31,8 +31,6 @@ import android.view.accessibility.CaptioningManager;
|
|||||||
import androidx.preference.PreferenceScreen;
|
import androidx.preference.PreferenceScreen;
|
||||||
import androidx.test.core.app.ApplicationProvider;
|
import androidx.test.core.app.ApplicationProvider;
|
||||||
|
|
||||||
import com.android.settings.core.BasePreferenceController;
|
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -69,12 +67,6 @@ public class CaptioningBackgroundOpacityControllerTest {
|
|||||||
mShadowCaptioningManager = Shadow.extract(captioningManager);
|
mShadowCaptioningManager = Shadow.extract(captioningManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void getAvailabilityStatus_shouldReturnAvailable() {
|
|
||||||
assertThat(mController.getAvailabilityStatus())
|
|
||||||
.isEqualTo(BasePreferenceController.AVAILABLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getSummary_defaultValue_shouldReturnNonTransparent() {
|
public void getSummary_defaultValue_shouldReturnNonTransparent() {
|
||||||
mController.displayPreference(mScreen);
|
mController.displayPreference(mScreen);
|
||||||
|
@@ -23,9 +23,6 @@ import static org.mockito.Mockito.when;
|
|||||||
|
|
||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.platform.test.annotations.DisableFlags;
|
|
||||||
import android.platform.test.annotations.EnableFlags;
|
|
||||||
import android.platform.test.flag.junit.SetFlagsRule;
|
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.view.accessibility.CaptioningManager.CaptionStyle;
|
import android.view.accessibility.CaptioningManager.CaptionStyle;
|
||||||
|
|
||||||
@@ -33,8 +30,6 @@ import androidx.preference.Preference;
|
|||||||
import androidx.preference.PreferenceScreen;
|
import androidx.preference.PreferenceScreen;
|
||||||
import androidx.test.core.app.ApplicationProvider;
|
import androidx.test.core.app.ApplicationProvider;
|
||||||
|
|
||||||
import com.android.settings.core.BasePreferenceController;
|
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -52,8 +47,6 @@ public class CaptioningCustomControllerTest {
|
|||||||
|
|
||||||
@Rule
|
@Rule
|
||||||
public final MockitoRule mMockitoRule = MockitoJUnit.rule();
|
public final MockitoRule mMockitoRule = MockitoJUnit.rule();
|
||||||
@Rule
|
|
||||||
public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
|
|
||||||
@Mock
|
@Mock
|
||||||
private PreferenceScreen mScreen;
|
private PreferenceScreen mScreen;
|
||||||
@Mock
|
@Mock
|
||||||
@@ -62,44 +55,16 @@ public class CaptioningCustomControllerTest {
|
|||||||
private ContentResolver mContentResolver;
|
private ContentResolver mContentResolver;
|
||||||
private CaptioningCustomController mController;
|
private CaptioningCustomController mController;
|
||||||
private Preference mPreference;
|
private Preference mPreference;
|
||||||
private CaptionHelper mCaptionHelper;
|
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
mContentResolver = mContext.getContentResolver();
|
mContentResolver = mContext.getContentResolver();
|
||||||
mCaptionHelper = new CaptionHelper(mContext);
|
mController = new CaptioningCustomController(mContext, PREF_KEY,
|
||||||
mController = new CaptioningCustomController(mContext, PREF_KEY, mCaptionHelper,
|
|
||||||
mAccessibilitySettingsContentObserver);
|
mAccessibilitySettingsContentObserver);
|
||||||
mPreference = new Preference(mContext);
|
mPreference = new Preference(mContext);
|
||||||
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
|
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
@DisableFlags(Flags.FLAG_FIX_A11Y_SETTINGS_SEARCH)
|
|
||||||
public void getAvailabilityStatus_shouldReturnAvailable() {
|
|
||||||
assertThat(mController.getAvailabilityStatus())
|
|
||||||
.isEqualTo(BasePreferenceController.AVAILABLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@EnableFlags(Flags.FLAG_FIX_A11Y_SETTINGS_SEARCH)
|
|
||||||
public void getAvailabilityStatus_customCaption_shouldReturnAvailable() {
|
|
||||||
mCaptionHelper.setRawUserStyle(CaptionStyle.PRESET_CUSTOM);
|
|
||||||
|
|
||||||
assertThat(mController.getAvailabilityStatus())
|
|
||||||
.isEqualTo(BasePreferenceController.AVAILABLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@EnableFlags(Flags.FLAG_FIX_A11Y_SETTINGS_SEARCH)
|
|
||||||
public void getAvailabilityStatus_notCustom_shouldReturnUnsearchable() {
|
|
||||||
mCaptionHelper.setRawUserStyle(0);
|
|
||||||
|
|
||||||
assertThat(mController.getAvailabilityStatus())
|
|
||||||
.isEqualTo(BasePreferenceController.AVAILABLE_UNSEARCHABLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void displayPreference_byDefault_shouldIsInvisible() {
|
public void displayPreference_byDefault_shouldIsInvisible() {
|
||||||
mController.displayPreference(mScreen);
|
mController.displayPreference(mScreen);
|
||||||
|
@@ -31,8 +31,6 @@ import android.view.accessibility.CaptioningManager;
|
|||||||
import androidx.preference.PreferenceScreen;
|
import androidx.preference.PreferenceScreen;
|
||||||
import androidx.test.core.app.ApplicationProvider;
|
import androidx.test.core.app.ApplicationProvider;
|
||||||
|
|
||||||
import com.android.settings.core.BasePreferenceController;
|
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -67,12 +65,6 @@ public class CaptioningEdgeColorControllerTest {
|
|||||||
mShadowCaptioningManager = Shadow.extract(captioningManager);
|
mShadowCaptioningManager = Shadow.extract(captioningManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void getAvailabilityStatus_shouldReturnAvailable() {
|
|
||||||
assertThat(mController.getAvailabilityStatus())
|
|
||||||
.isEqualTo(BasePreferenceController.AVAILABLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getSummary_defaultValue_shouldReturnBlack() {
|
public void getSummary_defaultValue_shouldReturnBlack() {
|
||||||
mController.displayPreference(mScreen);
|
mController.displayPreference(mScreen);
|
||||||
|
@@ -32,8 +32,6 @@ import android.view.accessibility.CaptioningManager.CaptionStyle;
|
|||||||
import androidx.preference.PreferenceScreen;
|
import androidx.preference.PreferenceScreen;
|
||||||
import androidx.test.core.app.ApplicationProvider;
|
import androidx.test.core.app.ApplicationProvider;
|
||||||
|
|
||||||
import com.android.settings.core.BasePreferenceController;
|
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -69,12 +67,6 @@ public class CaptioningEdgeTypeControllerTest {
|
|||||||
mShadowCaptioningManager = Shadow.extract(captioningManager);
|
mShadowCaptioningManager = Shadow.extract(captioningManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void getAvailabilityStatus_shouldReturnAvailable() {
|
|
||||||
assertThat(mController.getAvailabilityStatus())
|
|
||||||
.isEqualTo(BasePreferenceController.AVAILABLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getSummary_defaultValue_shouldReturnNone() {
|
public void getSummary_defaultValue_shouldReturnNone() {
|
||||||
mController.displayPreference(mScreen);
|
mController.displayPreference(mScreen);
|
||||||
|
@@ -22,7 +22,6 @@ import static com.android.settings.accessibility.AccessibilityUtil.State.ON;
|
|||||||
import static com.google.common.truth.Truth.assertThat;
|
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 static org.robolectric.Shadows.shadowOf;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
@@ -32,8 +32,6 @@ import android.view.accessibility.CaptioningManager.CaptionStyle;
|
|||||||
import androidx.preference.PreferenceScreen;
|
import androidx.preference.PreferenceScreen;
|
||||||
import androidx.test.core.app.ApplicationProvider;
|
import androidx.test.core.app.ApplicationProvider;
|
||||||
|
|
||||||
import com.android.settings.core.BasePreferenceController;
|
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -70,12 +68,6 @@ public class CaptioningForegroundColorControllerTest {
|
|||||||
mShadowCaptioningManager = Shadow.extract(captioningManager);
|
mShadowCaptioningManager = Shadow.extract(captioningManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void getAvailabilityStatus_shouldReturnAvailable() {
|
|
||||||
assertThat(mController.getAvailabilityStatus())
|
|
||||||
.isEqualTo(BasePreferenceController.AVAILABLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getSummary_defaultValue_shouldReturnWhite() {
|
public void getSummary_defaultValue_shouldReturnWhite() {
|
||||||
mController.displayPreference(mScreen);
|
mController.displayPreference(mScreen);
|
||||||
|
@@ -31,8 +31,6 @@ import android.view.accessibility.CaptioningManager;
|
|||||||
import androidx.preference.PreferenceScreen;
|
import androidx.preference.PreferenceScreen;
|
||||||
import androidx.test.core.app.ApplicationProvider;
|
import androidx.test.core.app.ApplicationProvider;
|
||||||
|
|
||||||
import com.android.settings.core.BasePreferenceController;
|
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -69,12 +67,6 @@ public class CaptioningForegroundOpacityControllerTest {
|
|||||||
mShadowCaptioningManager = Shadow.extract(captioningManager);
|
mShadowCaptioningManager = Shadow.extract(captioningManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void getAvailabilityStatus_shouldReturnAvailable() {
|
|
||||||
assertThat(mController.getAvailabilityStatus())
|
|
||||||
.isEqualTo(BasePreferenceController.AVAILABLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getSummary_defaultValue_shouldReturnNonTransparent() {
|
public void getSummary_defaultValue_shouldReturnNonTransparent() {
|
||||||
mController.displayPreference(mScreen);
|
mController.displayPreference(mScreen);
|
||||||
|
@@ -32,7 +32,6 @@ import androidx.preference.PreferenceScreen;
|
|||||||
import androidx.test.core.app.ApplicationProvider;
|
import androidx.test.core.app.ApplicationProvider;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.core.BasePreferenceController;
|
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
@@ -70,12 +69,6 @@ public class CaptioningTypefaceControllerTest {
|
|||||||
mShadowCaptioningManager = Shadow.extract(captioningManager);
|
mShadowCaptioningManager = Shadow.extract(captioningManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void getAvailabilityStatus_shouldReturnAvailable() {
|
|
||||||
assertThat(mController.getAvailabilityStatus())
|
|
||||||
.isEqualTo(BasePreferenceController.AVAILABLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void updateState_byDefault_shouldReturnDefault() {
|
public void updateState_byDefault_shouldReturnDefault() {
|
||||||
mController.updateState(mPreference);
|
mController.updateState(mPreference);
|
||||||
|
@@ -24,8 +24,6 @@ import static com.google.common.truth.Truth.assertThat;
|
|||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.platform.test.annotations.DisableFlags;
|
|
||||||
import android.platform.test.annotations.EnableFlags;
|
|
||||||
import android.platform.test.flag.junit.SetFlagsRule;
|
import android.platform.test.flag.junit.SetFlagsRule;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
@@ -36,7 +34,6 @@ import androidx.preference.PreferenceScreen;
|
|||||||
import androidx.test.core.app.ApplicationProvider;
|
import androidx.test.core.app.ApplicationProvider;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.core.BasePreferenceController;
|
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
@@ -64,13 +61,11 @@ public class CaptioningWindowColorControllerTest {
|
|||||||
private CaptioningWindowColorController mController;
|
private CaptioningWindowColorController mController;
|
||||||
private ColorPreference mPreference;
|
private ColorPreference mPreference;
|
||||||
private ShadowCaptioningManager mShadowCaptioningManager;
|
private ShadowCaptioningManager mShadowCaptioningManager;
|
||||||
private CaptionHelper mCaptionHelper;
|
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
mCaptionHelper = new CaptionHelper(mContext);
|
|
||||||
mController = new CaptioningWindowColorController(
|
mController = new CaptioningWindowColorController(
|
||||||
mContext, "captioning_window_color", mCaptionHelper);
|
mContext, "captioning_window_color");
|
||||||
final AttributeSet attributeSet = Robolectric.buildAttributeSet().build();
|
final AttributeSet attributeSet = Robolectric.buildAttributeSet().build();
|
||||||
mPreference = new ColorPreference(mContext, attributeSet);
|
mPreference = new ColorPreference(mContext, attributeSet);
|
||||||
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
|
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
|
||||||
@@ -78,31 +73,6 @@ public class CaptioningWindowColorControllerTest {
|
|||||||
mShadowCaptioningManager = Shadow.extract(captioningManager);
|
mShadowCaptioningManager = Shadow.extract(captioningManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
@DisableFlags(Flags.FLAG_FIX_A11Y_SETTINGS_SEARCH)
|
|
||||||
public void getAvailabilityStatus_shouldReturnAvailable() {
|
|
||||||
assertThat(mController.getAvailabilityStatus())
|
|
||||||
.isEqualTo(BasePreferenceController.AVAILABLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@EnableFlags(Flags.FLAG_FIX_A11Y_SETTINGS_SEARCH)
|
|
||||||
public void getAvailabilityStatus_customCaption_shouldReturnAvailable() {
|
|
||||||
mCaptionHelper.setRawUserStyle(CaptionStyle.PRESET_CUSTOM);
|
|
||||||
|
|
||||||
assertThat(mController.getAvailabilityStatus())
|
|
||||||
.isEqualTo(BasePreferenceController.AVAILABLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@EnableFlags(Flags.FLAG_FIX_A11Y_SETTINGS_SEARCH)
|
|
||||||
public void getAvailabilityStatus_noCustom_shouldReturnUnsearchable() {
|
|
||||||
mCaptionHelper.setRawUserStyle(0);
|
|
||||||
|
|
||||||
assertThat(mController.getAvailabilityStatus())
|
|
||||||
.isEqualTo(BasePreferenceController.AVAILABLE_UNSEARCHABLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getSummary_defaultValue_shouldReturnNone() {
|
public void getSummary_defaultValue_shouldReturnNone() {
|
||||||
mController.displayPreference(mScreen);
|
mController.displayPreference(mScreen);
|
||||||
|
@@ -24,8 +24,6 @@ import static com.google.common.truth.Truth.assertThat;
|
|||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.platform.test.annotations.DisableFlags;
|
|
||||||
import android.platform.test.annotations.EnableFlags;
|
|
||||||
import android.platform.test.flag.junit.SetFlagsRule;
|
import android.platform.test.flag.junit.SetFlagsRule;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
@@ -34,8 +32,6 @@ import android.view.accessibility.CaptioningManager;
|
|||||||
import androidx.preference.PreferenceScreen;
|
import androidx.preference.PreferenceScreen;
|
||||||
import androidx.test.core.app.ApplicationProvider;
|
import androidx.test.core.app.ApplicationProvider;
|
||||||
|
|
||||||
import com.android.settings.core.BasePreferenceController;
|
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -62,13 +58,11 @@ public class CaptioningWindowOpacityControllerTest {
|
|||||||
private CaptioningWindowOpacityController mController;
|
private CaptioningWindowOpacityController mController;
|
||||||
private ColorPreference mPreference;
|
private ColorPreference mPreference;
|
||||||
private ShadowCaptioningManager mShadowCaptioningManager;
|
private ShadowCaptioningManager mShadowCaptioningManager;
|
||||||
private CaptionHelper mCaptionHelper;
|
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
mCaptionHelper = new CaptionHelper(mContext);
|
|
||||||
mController = new CaptioningWindowOpacityController(
|
mController = new CaptioningWindowOpacityController(
|
||||||
mContext, "captioning_window_opacity", mCaptionHelper);
|
mContext, "captioning_window_opacity");
|
||||||
final AttributeSet attributeSet = Robolectric.buildAttributeSet().build();
|
final AttributeSet attributeSet = Robolectric.buildAttributeSet().build();
|
||||||
mPreference = new ColorPreference(mContext, attributeSet);
|
mPreference = new ColorPreference(mContext, attributeSet);
|
||||||
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
|
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
|
||||||
@@ -76,31 +70,6 @@ public class CaptioningWindowOpacityControllerTest {
|
|||||||
mShadowCaptioningManager = Shadow.extract(captioningManager);
|
mShadowCaptioningManager = Shadow.extract(captioningManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
@DisableFlags(Flags.FLAG_FIX_A11Y_SETTINGS_SEARCH)
|
|
||||||
public void getAvailabilityStatus_shouldReturnAvailable() {
|
|
||||||
assertThat(mController.getAvailabilityStatus())
|
|
||||||
.isEqualTo(BasePreferenceController.AVAILABLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@EnableFlags(Flags.FLAG_FIX_A11Y_SETTINGS_SEARCH)
|
|
||||||
public void getAvailabilityStatus_customCaption_shouldReturnAvailable() {
|
|
||||||
mCaptionHelper.setRawUserStyle(CaptioningManager.CaptionStyle.PRESET_CUSTOM);
|
|
||||||
|
|
||||||
assertThat(mController.getAvailabilityStatus()).isEqualTo(
|
|
||||||
BasePreferenceController.AVAILABLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@EnableFlags(Flags.FLAG_FIX_A11Y_SETTINGS_SEARCH)
|
|
||||||
public void getAvailabilityStatus_notCustom_shouldReturnUnsearchable() {
|
|
||||||
mCaptionHelper.setRawUserStyle(0);
|
|
||||||
|
|
||||||
assertThat(mController.getAvailabilityStatus()).isEqualTo(
|
|
||||||
BasePreferenceController.AVAILABLE_UNSEARCHABLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getSummary_defaultValue_shouldReturnNonTransparent() {
|
public void getSummary_defaultValue_shouldReturnNonTransparent() {
|
||||||
mController.displayPreference(mScreen);
|
mController.displayPreference(mScreen);
|
||||||
|
Reference in New Issue
Block a user