locale_test.dart 1.07 KB
Newer Older
1 2 3
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
4 5 6 7 8 9 10 11 12 13 14 15 16

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();
17 18
      tester.async.flushMicrotasks(); // see https://github.com/flutter/flutter/issues/1865
      tester.pump();
19

20
      Element tab = tester.findText('MARKET');
21 22 23
      expect(tab, isNotNull);
      tester.setLocale("es", "US");
      tester.pump();
24 25
      Text text = tab.widget;
      expect(text.data, equals("MERCADO"));
26 27 28 29

      // TODO(abarth): We're leaking an animation. We should track down the leak
      // and plug it rather than waiting for the animation to end here.
      tester.pump(const Duration(seconds: 1));
30 31 32
    });
  });
}