Default locales test for flutter tester. Roll engine 162b2e98c03..7be0217d67969 (#23596)
162b2e98c036a8f8c355fd475dbe0db4f4bc886c..7be0217d6796954694753647b7a757b8e3907f64 7be0217d6 Roll back _countryCode assert - breaking change (#6693) 91a019cfd Fix popSystemNavigator (#6691) 2b2fbf0f6 Add Locale.fromSubtags and support for scriptCode. (#6518) 58c8e30e5 Roll src/third_party/skia ab18c8e6cc20..d48b7a881b24 (5 commits) (#6690) 3b17cfb68 Flutter tester default locales (#6689) 96bbd2b36 Roll buildroot to 11a934e99eaa4aa8e278cd2772aff4f51f1f3c41 (#6687) 0e9defbd6 Roll src/third_party/skia 68825776f4b4..ab18c8e6cc20 (11 commits) (#6688) cc686d7ae Don't populate the external view embedder in PaintContext. (#6686) ab782faa7 Roll src/third_party/skia 1de48d8040aa..68825776f4b4 (1 commits) (#6685) c4aa8d343 Roll src/third_party/skia 797197a772b8..1de48d8040aa (2 commits) (#6684) 7352251eb Roll src/third_party/skia 79c96811863f..797197a772b8 (1 commits) (#6683) 3dac47e4d Roll src/third_party/skia 38e4fd0c5654..79c96811863f (1 commits) (#6682) 2f06a53a8 Roll src/third_party/skia b53f1f46982d..38e4fd0c5654 (1 commits) (#6681) a1d7cad70 Fix inconsistent include syntax (#6680) 236661cd8 Roll src/third_party/skia 3b79aa3a5ad0..b53f1f46982d (13 commits) (#6679) c4f50611d Roll buildroot to pick up Mac toolchain updates. (#6678) ba8f6aa71 Handle Windows headers defining ERROR to 0 in log levels. (#6677) 505d2a923 Roll buildroot to pick up updates to custom toolchains. (#6674) 6c2a0b3a6 Undefine ERROR in platform_view_layer.cc (#6675) 55e12993a Update FlutterPlugin.h docs, suppress warning for older API (#6672) f7970048d Attach and position embedded UIVIews (#6614) df85722fa Plumb the iOS PlatformViewsController into flow. (#6603) 2bfb893cf iOS Embedding Refactor (#6447)
This commit is contained in:
@@ -1 +1 @@
|
||||
162b2e98c036a8f8c355fd475dbe0db4f4bc886c
|
||||
7be0217d6796954694753647b7a757b8e3907f64
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:ui' as ui;
|
||||
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
@@ -537,10 +539,8 @@ void main() {
|
||||
)
|
||||
);
|
||||
|
||||
// Startup time. Default test locale is null, so
|
||||
// no supported matches. Use the first locale.
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('zh_CN'), findsOneWidget);
|
||||
expect(find.text('en_GB'), findsOneWidget);
|
||||
|
||||
// defaultLocaleChangedHandler prefers exact supported locale match
|
||||
await tester.binding.setLocale('en', 'CA');
|
||||
@@ -581,8 +581,7 @@ void main() {
|
||||
)
|
||||
);
|
||||
|
||||
// Initial WidgetTester locale is null due to no platform intitializing it.
|
||||
// The locale gets resolved to "en_US", which is the first supported locale.
|
||||
// Initial WidgetTester locale is `en_US`.
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('en_US TextDirection.ltr'), findsOneWidget);
|
||||
|
||||
@@ -623,8 +622,7 @@ void main() {
|
||||
)
|
||||
);
|
||||
|
||||
// Initial WidgetTester locale is null due to no platform intitializing it.
|
||||
// The locale gets resolved to "en_US", which is the first supported locale.
|
||||
// Initial WidgetTester locale is `en_US`.
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('en_US TextDirection.rtl'), findsOneWidget);
|
||||
|
||||
@@ -657,8 +655,7 @@ void main() {
|
||||
)
|
||||
);
|
||||
|
||||
// Initial WidgetTester locale is null due to no platform intitializing it.
|
||||
// The locale gets resolved to "en_US", which is the first supported locale.
|
||||
// Initial WidgetTester locale is `en_US`.
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('en_US TextDirection.rtl'), findsOneWidget);
|
||||
|
||||
@@ -675,4 +672,27 @@ void main() {
|
||||
expect(find.text('da_DA TextDirection.rtl'), findsOneWidget);
|
||||
});
|
||||
|
||||
// We provide <Locale>[Locale('en', 'US'), Locale('zh', 'CN')] as ui.window.locales
|
||||
// for flutter tester so that the behavior of tests match that of production
|
||||
// environments. Here, we test the default locales.
|
||||
testWidgets('WidgetsApp DefaultWidgetLocalizations', (WidgetTester tester) async {
|
||||
await tester.pumpAndSettle();
|
||||
await tester.pumpWidget(
|
||||
buildFrame(
|
||||
// Accept whatever locale we're given
|
||||
localeResolutionCallback: (Locale locale, Iterable<Locale> supportedLocales) => locale,
|
||||
delegates: <OnlyRTLDefaultWidgetsLocalizationsDelegate>[
|
||||
const OnlyRTLDefaultWidgetsLocalizationsDelegate(),
|
||||
],
|
||||
buildContent: (BuildContext context) {
|
||||
final Locale locale1 = ui.window.locales.first;
|
||||
final Locale locale2 = ui.window.locales[1];
|
||||
return Text('$locale1 $locale2');
|
||||
}
|
||||
)
|
||||
);
|
||||
// Initial WidgetTester default locales is `en_US` and `zh_CN`.
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('en_US zh_CN'), findsOneWidget);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user