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

@@ -23,6 +23,9 @@ import static org.mockito.Mockito.when;
import android.content.ContentResolver;
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.view.accessibility.CaptioningManager.CaptionStyle;
@@ -49,6 +52,8 @@ public class CaptioningCustomControllerTest {
@Rule
public final MockitoRule mMockitoRule = MockitoJUnit.rule();
@Rule
public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
@Mock
private PreferenceScreen mScreen;
@Mock
@@ -57,22 +62,43 @@ public class CaptioningCustomControllerTest {
private ContentResolver mContentResolver;
private CaptioningCustomController mController;
private Preference mPreference;
private CaptionHelper mCaptionHelper;
@Before
public void setUp() {
mContentResolver = mContext.getContentResolver();
mController = new CaptioningCustomController(mContext, PREF_KEY,
mCaptionHelper = new CaptionHelper(mContext);
mController = new CaptioningCustomController(mContext, PREF_KEY, mCaptionHelper,
mAccessibilitySettingsContentObserver);
mPreference = new Preference(mContext);
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
public void displayPreference_byDefault_shouldIsInvisible() {