New locale resolution algorithm to use full preferred locale list, include scriptCode in Locale. (#23583)

This commit is contained in:
Gary Qian
2018-11-09 11:33:42 -08:00
committed by GitHub
parent 5071657e8e
commit dfd0229560
6 changed files with 904 additions and 44 deletions

View File

@@ -225,13 +225,25 @@ abstract class TestWidgetsFlutterBinding extends BindingBase
Duration additionalTime = const Duration(milliseconds: 250),
});
/// Artificially calls dispatchLocaleChanged on the Widget binding,
/// Artificially calls dispatchLocalesChanged on the Widget binding,
/// then flushes microtasks.
///
/// Passes only one single Locale. Use [setLocales] to pass a full preferred
/// locales list.
Future<void> setLocale(String languageCode, String countryCode) {
return TestAsyncUtils.guard<void>(() async {
assert(inTest);
final Locale locale = Locale(languageCode, countryCode);
dispatchLocaleChanged(locale);
final Locale locale = Locale(languageCode, countryCode == '' ? null : countryCode);
dispatchLocalesChanged(<Locale>[locale]);
});
}
/// Artificially calls dispatchLocalesChanged on the Widget binding,
/// then flushes microtasks.
Future<void> setLocales(List<Locale> locales) {
return TestAsyncUtils.guard<void>(() async {
assert(inTest);
dispatchLocalesChanged(locales);
});
}