Add a test to stocks for changing the locale
I had to add a setLocale method to WidgetTester and split the code in FlutterBinding which handled locale changes to allow me to dispatch a locale change w/o actually changing what the c++ code reports as the locale. Also added the test to Travis. @abarth @jason-simmons
This commit is contained in:
@@ -29,7 +29,7 @@ class _PointerState {
|
||||
_pointerCount += 1;
|
||||
_pointer = _pointerCount;
|
||||
}
|
||||
|
||||
|
||||
bool get down => _down;
|
||||
bool _down = false;
|
||||
void setDown() {
|
||||
@@ -247,8 +247,12 @@ class FlutterBinding extends HitTestTarget {
|
||||
}
|
||||
|
||||
void _handleLocaleChanged() {
|
||||
dispatchLocaleChanged(ui.window.locale);
|
||||
}
|
||||
|
||||
void dispatchLocaleChanged(ui.Locale locale) {
|
||||
for (BindingObserver observer in _observers)
|
||||
observer.didChangeLocale(ui.window.locale);
|
||||
observer.didChangeLocale(locale);
|
||||
}
|
||||
|
||||
void _handlePersistentFrameCallback(Duration timeStamp) {
|
||||
|
||||
@@ -32,6 +32,12 @@ class WidgetTester {
|
||||
pump(duration);
|
||||
}
|
||||
|
||||
void setLocale(String languageCode, String countryCode) {
|
||||
ui.Locale locale = new ui.Locale(languageCode, countryCode);
|
||||
FlutterBinding.instance.dispatchLocaleChanged(locale);
|
||||
async.flushMicrotasks();
|
||||
}
|
||||
|
||||
void pump([ Duration duration ]) {
|
||||
if (duration != null)
|
||||
async.elapse(duration);
|
||||
|
||||
Reference in New Issue
Block a user