locale_test.dart 857 Bytes
Newer Older
Ian Hickson's avatar
Ian Hickson committed
1
// Copyright 2014 The Flutter Authors. All rights reserved.
2 3
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
4

Devon Carew's avatar
Devon Carew committed
5
import 'package:flutter_test/flutter_test.dart';
6 7 8 9
import 'package:stocks/main.dart' as stocks;
import 'package:stocks/stock_data.dart' as stock_data;

void main() {
10
  stock_data.StockData.actuallyFetchData = false;
11

12
  testWidgets('Changing locale', (WidgetTester tester) async {
13
    stocks.main();
14
    await tester.pump();
15
    // The initial test app's locale is "_", so we're seeing the fallback translation here.
16
    expect(find.text('MARKET'), findsOneWidget);
17
    await tester.binding.setLocale('es', '');
18 19 20

    // The localized strings have finished loading and dependent
    // widgets have been updated.
21
    await tester.pump();
22
    expect(find.text('MERCADO'), findsOneWidget);
23 24
  });
}