Refactor CaptionAppearanceFragment to improve maintainability (2/n)
Root cause: There is a bunch of different logic of preferences in CaptionAppearanceFragment. It’s hard to implement new features and hard to maintain and hard to be testable. Solution: Move out font size and type face preference logic of CaptionAppearanceFragment into controllers to reduce the complexity of the relationship between preference and fragment. Bug: 197695932 Test: make RunSettingsRoboTests ROBOTEST_FILTER=com.android.settings.accessibility Change-Id: Ia52cd272495d49a772c981f51e190ff7d29ee14f
This commit is contained in:
@@ -16,10 +16,16 @@
|
||||
|
||||
package com.android.settings.accessibility;
|
||||
|
||||
import static com.android.settings.accessibility.AccessibilityUtil.State.OFF;
|
||||
import static com.android.settings.accessibility.AccessibilityUtil.State.ON;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.content.Context;
|
||||
import android.provider.Settings;
|
||||
import android.view.View;
|
||||
import android.view.accessibility.CaptioningManager;
|
||||
|
||||
@@ -101,4 +107,26 @@ public class CaptionHelperTest {
|
||||
|
||||
verify(mSubtitleView).setText(text);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void enableCaptioningManager_shouldSetCaptionEnabled() {
|
||||
when(mCaptioningManager.isEnabled()).thenReturn(false);
|
||||
|
||||
mCaptionHelper.setEnabled(true);
|
||||
|
||||
final boolean isCaptionEnabled = Settings.Secure.getInt(mContext.getContentResolver(),
|
||||
Settings.Secure.ACCESSIBILITY_CAPTIONING_ENABLED, OFF) == ON;
|
||||
assertThat(isCaptionEnabled).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void disableCaptioningManager_shouldSetCaptionDisabled() {
|
||||
when(mCaptioningManager.isEnabled()).thenReturn(true);
|
||||
|
||||
mCaptionHelper.setEnabled(false);
|
||||
|
||||
final boolean isCaptionEnabled = Settings.Secure.getInt(mContext.getContentResolver(),
|
||||
Settings.Secure.ACCESSIBILITY_CAPTIONING_ENABLED, OFF) == ON;
|
||||
assertThat(isCaptionEnabled).isFalse();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user