Caption settings cleanup

Bug: 353757664
Test: atest com.android.settings.accessibility
Test: Manually verify conditions described in bug
Flag: com.android.settings.accessibility.fix_a11y_settings_search
Change-Id: Iff25702843e5dd3e7ebcca1a13f190d48cf83e7a
This commit is contained in:
Riley Jones
2024-11-05 23:08:44 +00:00
parent cc8e87b0a5
commit b3eea625ec
6 changed files with 142 additions and 25 deletions

View File

@@ -24,6 +24,9 @@ import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.when;
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.util.AttributeSet;
import android.view.accessibility.CaptioningManager;
@@ -48,19 +51,24 @@ import org.robolectric.shadows.ShadowCaptioningManager;
/** Tests for {@link CaptioningWindowOpacityController}. */
@RunWith(RobolectricTestRunner.class)
public class CaptioningWindowOpacityControllerTest {
@Rule
public final MockitoRule mMockitoRule = MockitoJUnit.rule();
@Rule
public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
@Mock
private PreferenceScreen mScreen;
private final Context mContext = ApplicationProvider.getApplicationContext();
private CaptioningWindowOpacityController mController;
private ColorPreference mPreference;
private ShadowCaptioningManager mShadowCaptioningManager;
private CaptionHelper mCaptionHelper;
@Before
public void setUp() {
mController = new CaptioningWindowOpacityController(mContext, "captioning_window_opacity");
mCaptionHelper = new CaptionHelper(mContext);
mController = new CaptioningWindowOpacityController(
mContext, "captioning_window_opacity", mCaptionHelper);
final AttributeSet attributeSet = Robolectric.buildAttributeSet().build();
mPreference = new ColorPreference(mContext, attributeSet);
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
@@ -69,11 +77,30 @@ public class CaptioningWindowOpacityControllerTest {
}
@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
public void getSummary_defaultValue_shouldReturnNonTransparent() {
mController.displayPreference(mScreen);