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:
Eric Seidel
2015-12-08 16:05:53 -08:00
parent bf5ef790fa
commit 09894ec50b
5 changed files with 44 additions and 4 deletions

View File

@@ -4,3 +4,6 @@ dependencies:
path: ../../packages/flutter
intl: '>=0.12.4+2 <0.13.0'
dev_dependencies:
flutter_test:
path: ../../packages/flutter_test

View File

@@ -0,0 +1,23 @@
import 'package:test/test.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/material.dart';
import 'package:stocks/main.dart' as stocks;
import 'package:stocks/stock_data.dart' as stock_data;
void main() {
stock_data.StockDataFetcher.actuallyFetchData = false;
test("Test changing locale", () {
testWidgets((WidgetTester tester) {
stocks.main();
tester.pump(const Duration(seconds: 1)); // Unclear why duration is required.
Element<Text> tab = tester.findText('MARKET');
expect(tab, isNotNull);
tester.setLocale("es", "US");
tester.pump();
expect(tab.widget.data, equals("MERCADO"));
});
});
}