Merge "Caption settings cleanup" into main
This commit is contained in:
@@ -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() {
|
||||
|
@@ -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;
|
||||
@@ -53,16 +56,21 @@ public class CaptioningWindowColorControllerTest {
|
||||
|
||||
@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 CaptioningWindowColorController mController;
|
||||
private ColorPreference mPreference;
|
||||
private ShadowCaptioningManager mShadowCaptioningManager;
|
||||
private CaptionHelper mCaptionHelper;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
mController = new CaptioningWindowColorController(mContext, "captioning_window_color");
|
||||
mCaptionHelper = new CaptionHelper(mContext);
|
||||
mController = new CaptioningWindowColorController(
|
||||
mContext, "captioning_window_color", mCaptionHelper);
|
||||
final AttributeSet attributeSet = Robolectric.buildAttributeSet().build();
|
||||
mPreference = new ColorPreference(mContext, attributeSet);
|
||||
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
|
||||
@@ -71,11 +79,30 @@ public class CaptioningWindowColorControllerTest {
|
||||
}
|
||||
|
||||
@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
|
||||
public void getSummary_defaultValue_shouldReturnNone() {
|
||||
mController.displayPreference(mScreen);
|
||||
|
@@ -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);
|
||||
|
Reference in New Issue
Block a user