Refactor CaptionAppearanceFragment to improve maintainability (4/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 preset preference logic of CaptionAppearanceFragment into controllers to reduce the complexity of the relationship between preference and fragment. Bug: 197695932 Test: make RunSettingsRoboTests ROBOTEST_FILTER=CaptionPresetControllerTest CaptionAppearanceFragmentTest Change-Id: I5409c1e8a6bdfc633abc304d8cf800ea0943de78
This commit is contained in:
@@ -24,6 +24,7 @@ import static com.google.common.truth.Truth.assertThat;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.provider.Settings;
|
||||
import android.view.View;
|
||||
@@ -61,12 +62,14 @@ public class CaptionHelperTest {
|
||||
private View mPreviewWindow;
|
||||
@Spy
|
||||
private final Context mContext = ApplicationProvider.getApplicationContext();
|
||||
private ContentResolver mContentResolver;
|
||||
private CaptionHelper mCaptionHelper;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
when(mContext.getSystemService(CaptioningManager.class)).thenReturn(mCaptioningManager);
|
||||
mCaptionHelper = new CaptionHelper(mContext);
|
||||
mContentResolver = mContext.getContentResolver();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -170,4 +173,13 @@ public class CaptionHelperTest {
|
||||
final int edgeType = mCaptionHelper.getEdgeType();
|
||||
assertThat(edgeType).isEqualTo(CaptionStyle.EDGE_TYPE_OUTLINE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setRawUserStyle_shouldReturnSpecificStyle() {
|
||||
mCaptionHelper.setRawUserStyle(CaptionStyle.PRESET_CUSTOM);
|
||||
|
||||
final int style = Settings.Secure.getInt(mContentResolver,
|
||||
Settings.Secure.ACCESSIBILITY_CAPTIONING_PRESET, 0);
|
||||
assertThat(style).isEqualTo(CaptionStyle.PRESET_CUSTOM);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user