Merge "[Language] Should show confirm dialog when deleting the system language and making the second language automatically become the system language" into udc-qpr-dev am: 7fd3730909
am: 6572d4d09e
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/24069201 Change-Id: If40a1678b673aa4331fa3e9624f4c7b858da3ebf Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -67,6 +67,7 @@ import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
import org.robolectric.annotation.Config;
|
||||
import org.robolectric.util.ReflectionHelpers;
|
||||
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -105,6 +106,8 @@ public class LocaleListEditorTest {
|
||||
private View mView;
|
||||
@Mock
|
||||
private IActivityManager mActivityService;
|
||||
@Mock
|
||||
private MetricsFeatureProvider mMetricsFeatureProvider;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
@@ -123,6 +126,8 @@ public class LocaleListEditorTest {
|
||||
ReflectionHelpers.setField(mLocaleListEditor, "mAdapter", mAdapter);
|
||||
ReflectionHelpers.setField(mLocaleListEditor, "mAddLanguage", mAddLanguage);
|
||||
ReflectionHelpers.setField(mLocaleListEditor, "mFragmentManager", mFragmentManager);
|
||||
ReflectionHelpers.setField(mLocaleListEditor, "mMetricsFeatureProvider",
|
||||
mMetricsFeatureProvider);
|
||||
when(mFragmentManager.beginTransaction()).thenReturn(mFragmentTransaction);
|
||||
FakeFeatureFactory.setupForTest();
|
||||
}
|
||||
@@ -216,6 +221,38 @@ public class LocaleListEditorTest {
|
||||
assertThat(shadowDialog.getMessage()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void showConfirmDialog_systemLocaleSelected_shouldShowLocaleChangeDialog()
|
||||
throws Exception {
|
||||
//pre-condition
|
||||
setUpLocaleConditions();
|
||||
final Configuration config = new Configuration();
|
||||
config.setLocales((LocaleList.forLanguageTags("zh-TW,en-US")));
|
||||
when(mActivityService.getConfiguration()).thenReturn(config);
|
||||
when(mAdapter.getFeedItemList()).thenReturn(mLocaleList);
|
||||
when(mAdapter.getCheckedCount()).thenReturn(1);
|
||||
when(mAdapter.getItemCount()).thenReturn(2);
|
||||
when(mAdapter.isFirstLocaleChecked()).thenReturn(true);
|
||||
ReflectionHelpers.setField(mLocaleListEditor, "mRemoveMode", true);
|
||||
ReflectionHelpers.setField(mLocaleListEditor, "mShowingRemoveDialog", true);
|
||||
|
||||
//launch the first dialog
|
||||
mLocaleListEditor.showRemoveLocaleWarningDialog();
|
||||
|
||||
final AlertDialog dialog = ShadowAlertDialogCompat.getLatestAlertDialog();
|
||||
|
||||
assertThat(dialog).isNotNull();
|
||||
|
||||
// click the remove button
|
||||
dialog.getButton(DialogInterface.BUTTON_POSITIVE).performClick();
|
||||
|
||||
assertThat(dialog.isShowing()).isFalse();
|
||||
|
||||
// check the second dialog is showing
|
||||
verify(mFragmentTransaction).add(any(LocaleDialogFragment.class),
|
||||
eq(TAG_DIALOG_CONFIRM_SYSTEM_DEFAULT));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void mayAppendUnicodeTags_appendUnicodeTags_success() {
|
||||
LocaleStore.LocaleInfo localeInfo = LocaleStore.fromLocale(Locale.forLanguageTag("en-US"));
|
||||
|
Reference in New Issue
Block a user