Auto-format Framework (#160545)
This auto-formats all *.dart files in the repository outside of the `engine` subdirectory and enforces that these files stay formatted with a presubmit check. **Reviewers:** Please carefully review all the commits except for the one titled "formatted". The "formatted" commit was auto-generated by running `dev/tools/format.sh -a -f`. The other commits were hand-crafted to prepare the repo for the formatting change. I recommend reviewing the commits one-by-one via the "Commits" tab and avoiding Github's "Files changed" tab as it will likely slow down your browser because of the size of this PR. --------- Co-authored-by: Kate Lovett <katelovett@google.com> Co-authored-by: LongCatIsLooong <31859944+LongCatIsLooong@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
8e0993eda8
commit
5491c8c146
@@ -31,7 +31,7 @@ void main() {
|
||||
// Tests a different first day of week.
|
||||
const Locale('ru', 'RU'): <String, dynamic>{
|
||||
'textDirection': TextDirection.ltr,
|
||||
'expectedDaysOfWeek': <String>['В', 'П', 'В', 'С', 'Ч', 'П', 'С',],
|
||||
'expectedDaysOfWeek': <String>['В', 'П', 'В', 'С', 'Ч', 'П', 'С'],
|
||||
'expectedDaysOfMonth': List<String>.generate(30, (int i) => '${i + 1}'),
|
||||
'expectedMonthYearHeader': 'сентябрь 2017 г.',
|
||||
},
|
||||
@@ -52,18 +52,26 @@ void main() {
|
||||
|
||||
for (final Locale locale in testLocales.keys) {
|
||||
testWidgets('shows dates for $locale', (WidgetTester tester) async {
|
||||
final List<String> expectedDaysOfWeek = testLocales[locale]!['expectedDaysOfWeek'] as List<String>;
|
||||
final List<String> expectedDaysOfMonth = testLocales[locale]!['expectedDaysOfMonth'] as List<String>;
|
||||
final String expectedMonthYearHeader = testLocales[locale]!['expectedMonthYearHeader'] as String;
|
||||
final List<String> expectedDaysOfWeek =
|
||||
testLocales[locale]!['expectedDaysOfWeek'] as List<String>;
|
||||
final List<String> expectedDaysOfMonth =
|
||||
testLocales[locale]!['expectedDaysOfMonth'] as List<String>;
|
||||
final String expectedMonthYearHeader =
|
||||
testLocales[locale]!['expectedMonthYearHeader'] as String;
|
||||
final TextDirection textDirection = testLocales[locale]!['textDirection'] as TextDirection;
|
||||
final DateTime baseDate = DateTime(2017, 9, 27);
|
||||
|
||||
await _pumpBoilerplate(tester, CalendarDatePicker(
|
||||
initialDate: baseDate,
|
||||
firstDate: baseDate.subtract(const Duration(days: 90)),
|
||||
lastDate: baseDate.add(const Duration(days: 90)),
|
||||
onDateChanged: (DateTime newValue) {},
|
||||
), locale: locale, textDirection: textDirection);
|
||||
await _pumpBoilerplate(
|
||||
tester,
|
||||
CalendarDatePicker(
|
||||
initialDate: baseDate,
|
||||
firstDate: baseDate.subtract(const Duration(days: 90)),
|
||||
lastDate: baseDate.add(const Duration(days: 90)),
|
||||
onDateChanged: (DateTime newValue) {},
|
||||
),
|
||||
locale: locale,
|
||||
textDirection: textDirection,
|
||||
);
|
||||
|
||||
expect(find.text(expectedMonthYearHeader), findsOneWidget);
|
||||
|
||||
@@ -73,7 +81,10 @@ void main() {
|
||||
|
||||
Offset? previousCellOffset;
|
||||
for (final String dayOfMonth in expectedDaysOfMonth) {
|
||||
final Finder dayCell = find.descendant(of: find.byType(GridView), matching: find.text(dayOfMonth));
|
||||
final Finder dayCell = find.descendant(
|
||||
of: find.byType(GridView),
|
||||
matching: find.text(dayOfMonth),
|
||||
);
|
||||
expect(dayCell, findsOneWidget);
|
||||
|
||||
// Check that cells are correctly positioned relative to each other,
|
||||
@@ -81,9 +92,17 @@ void main() {
|
||||
final Offset offset = tester.getCenter(dayCell);
|
||||
if (previousCellOffset != null) {
|
||||
if (textDirection == TextDirection.ltr) {
|
||||
expect(offset.dx > previousCellOffset.dx && offset.dy == previousCellOffset.dy || offset.dy > previousCellOffset.dy, true);
|
||||
expect(
|
||||
offset.dx > previousCellOffset.dx && offset.dy == previousCellOffset.dy ||
|
||||
offset.dy > previousCellOffset.dy,
|
||||
true,
|
||||
);
|
||||
} else {
|
||||
expect(offset.dx < previousCellOffset.dx && offset.dy == previousCellOffset.dy || offset.dy > previousCellOffset.dy, true);
|
||||
expect(
|
||||
offset.dx < previousCellOffset.dx && offset.dy == previousCellOffset.dy ||
|
||||
offset.dy > previousCellOffset.dy,
|
||||
true,
|
||||
);
|
||||
}
|
||||
}
|
||||
previousCellOffset = offset;
|
||||
@@ -97,10 +116,7 @@ void main() {
|
||||
return MaterialApp(
|
||||
theme: ThemeData(useMaterial3: false),
|
||||
locale: const Locale('en', 'US'),
|
||||
supportedLocales: const <Locale>[
|
||||
Locale('en', 'US'),
|
||||
Locale('fr', 'CA'),
|
||||
],
|
||||
supportedLocales: const <Locale>[Locale('en', 'US'), Locale('fr', 'CA')],
|
||||
localizationsDelegates: GlobalMaterialLocalizations.delegates,
|
||||
home: Material(
|
||||
child: Builder(
|
||||
@@ -129,14 +145,8 @@ void main() {
|
||||
await tester.tap(find.text('X'));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(
|
||||
Localizations.localeOf(getPicker()),
|
||||
const Locale('fr', 'CA'),
|
||||
);
|
||||
expect(
|
||||
Directionality.of(getPicker()),
|
||||
TextDirection.ltr,
|
||||
);
|
||||
expect(Localizations.localeOf(getPicker()), const Locale('fr', 'CA'));
|
||||
expect(Directionality.of(getPicker()), TextDirection.ltr);
|
||||
|
||||
await tester.tap(find.text('ANNULER'));
|
||||
});
|
||||
@@ -146,10 +156,7 @@ void main() {
|
||||
return MaterialApp(
|
||||
theme: ThemeData(useMaterial3: true),
|
||||
locale: const Locale('en', 'US'),
|
||||
supportedLocales: const <Locale>[
|
||||
Locale('en', 'US'),
|
||||
Locale('fr', 'CA'),
|
||||
],
|
||||
supportedLocales: const <Locale>[Locale('en', 'US'), Locale('fr', 'CA')],
|
||||
localizationsDelegates: GlobalMaterialLocalizations.delegates,
|
||||
home: Material(
|
||||
child: Builder(
|
||||
@@ -178,19 +185,15 @@ void main() {
|
||||
await tester.tap(find.text('X'));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(
|
||||
Localizations.localeOf(getPicker()),
|
||||
const Locale('fr', 'CA'),
|
||||
);
|
||||
expect(
|
||||
Directionality.of(getPicker()),
|
||||
TextDirection.ltr,
|
||||
);
|
||||
expect(Localizations.localeOf(getPicker()), const Locale('fr', 'CA'));
|
||||
expect(Directionality.of(getPicker()), TextDirection.ltr);
|
||||
|
||||
await tester.tap(find.text('Annuler'));
|
||||
});
|
||||
|
||||
testWidgets('Material2 - textDirection parameter overrides ambient textDirection', (WidgetTester tester) async {
|
||||
testWidgets('Material2 - textDirection parameter overrides ambient textDirection', (
|
||||
WidgetTester tester,
|
||||
) async {
|
||||
Widget buildFrame() {
|
||||
return MaterialApp(
|
||||
theme: ThemeData(useMaterial3: false),
|
||||
@@ -222,15 +225,14 @@ void main() {
|
||||
await tester.tap(find.text('X'));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(
|
||||
Directionality.of(getPicker()),
|
||||
TextDirection.rtl,
|
||||
);
|
||||
expect(Directionality.of(getPicker()), TextDirection.rtl);
|
||||
|
||||
await tester.tap(find.text('CANCEL'));
|
||||
});
|
||||
|
||||
testWidgets('Material3 - textDirection parameter overrides ambient textDirection', (WidgetTester tester) async {
|
||||
testWidgets('Material3 - textDirection parameter overrides ambient textDirection', (
|
||||
WidgetTester tester,
|
||||
) async {
|
||||
Widget buildFrame() {
|
||||
return MaterialApp(
|
||||
theme: ThemeData(useMaterial3: true),
|
||||
@@ -262,23 +264,19 @@ void main() {
|
||||
await tester.tap(find.text('X'));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(
|
||||
Directionality.of(getPicker()),
|
||||
TextDirection.rtl,
|
||||
);
|
||||
expect(Directionality.of(getPicker()), TextDirection.rtl);
|
||||
|
||||
await tester.tap(find.text('Cancel'));
|
||||
});
|
||||
|
||||
testWidgets('Material2 - textDirection parameter takes precedence over locale parameter', (WidgetTester tester) async {
|
||||
testWidgets('Material2 - textDirection parameter takes precedence over locale parameter', (
|
||||
WidgetTester tester,
|
||||
) async {
|
||||
Widget buildFrame() {
|
||||
return MaterialApp(
|
||||
theme: ThemeData(useMaterial3: false),
|
||||
locale: const Locale('en', 'US'),
|
||||
supportedLocales: const <Locale>[
|
||||
Locale('en', 'US'),
|
||||
Locale('fr', 'CA'),
|
||||
],
|
||||
supportedLocales: const <Locale>[Locale('en', 'US'), Locale('fr', 'CA')],
|
||||
localizationsDelegates: GlobalMaterialLocalizations.delegates,
|
||||
home: Material(
|
||||
child: Builder(
|
||||
@@ -308,28 +306,21 @@ void main() {
|
||||
await tester.tap(find.text('X'));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(
|
||||
Localizations.localeOf(getPicker()),
|
||||
const Locale('fr', 'CA'),
|
||||
);
|
||||
expect(Localizations.localeOf(getPicker()), const Locale('fr', 'CA'));
|
||||
|
||||
expect(
|
||||
Directionality.of(getPicker()),
|
||||
TextDirection.rtl,
|
||||
);
|
||||
expect(Directionality.of(getPicker()), TextDirection.rtl);
|
||||
|
||||
await tester.tap(find.text('ANNULER'));
|
||||
});
|
||||
|
||||
testWidgets('Material3 - textDirection parameter takes precedence over locale parameter', (WidgetTester tester) async {
|
||||
testWidgets('Material3 - textDirection parameter takes precedence over locale parameter', (
|
||||
WidgetTester tester,
|
||||
) async {
|
||||
Widget buildFrame() {
|
||||
return MaterialApp(
|
||||
theme: ThemeData(useMaterial3: true),
|
||||
locale: const Locale('en', 'US'),
|
||||
supportedLocales: const <Locale>[
|
||||
Locale('en', 'US'),
|
||||
Locale('fr', 'CA'),
|
||||
],
|
||||
supportedLocales: const <Locale>[Locale('en', 'US'), Locale('fr', 'CA')],
|
||||
localizationsDelegates: GlobalMaterialLocalizations.delegates,
|
||||
home: Material(
|
||||
child: Builder(
|
||||
@@ -359,15 +350,9 @@ void main() {
|
||||
await tester.tap(find.text('X'));
|
||||
await tester.pumpAndSettle(const Duration(seconds: 1));
|
||||
|
||||
expect(
|
||||
Localizations.localeOf(getPicker()),
|
||||
const Locale('fr', 'CA'),
|
||||
);
|
||||
expect(Localizations.localeOf(getPicker()), const Locale('fr', 'CA'));
|
||||
|
||||
expect(
|
||||
Directionality.of(getPicker()),
|
||||
TextDirection.rtl,
|
||||
);
|
||||
expect(Directionality.of(getPicker()), TextDirection.rtl);
|
||||
|
||||
await tester.tap(find.text('Annuler'));
|
||||
});
|
||||
@@ -405,7 +390,7 @@ void main() {
|
||||
);
|
||||
},
|
||||
),
|
||||
)
|
||||
),
|
||||
);
|
||||
await tester.tap(find.text('X'));
|
||||
await tester.pumpAndSettle();
|
||||
@@ -432,7 +417,6 @@ void main() {
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
Future<void> _pumpBoilerplate(
|
||||
@@ -441,16 +425,16 @@ Future<void> _pumpBoilerplate(
|
||||
Locale locale = const Locale('en', 'US'),
|
||||
TextDirection textDirection = TextDirection.ltr,
|
||||
}) async {
|
||||
await tester.pumpWidget(MaterialApp(
|
||||
home: Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
child: Localizations(
|
||||
locale: locale,
|
||||
delegates: GlobalMaterialLocalizations.delegates,
|
||||
child: Material(
|
||||
child: child,
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
child: Localizations(
|
||||
locale: locale,
|
||||
delegates: GlobalMaterialLocalizations.delegates,
|
||||
child: Material(child: child),
|
||||
),
|
||||
),
|
||||
),
|
||||
));
|
||||
);
|
||||
}
|
||||
|
||||
@@ -13,13 +13,15 @@ void main() {
|
||||
group(GlobalMaterialLocalizations, () {
|
||||
test('uses exact locale when exists', () async {
|
||||
final GlobalMaterialLocalizations localizations =
|
||||
await GlobalMaterialLocalizations.delegate.load(const Locale('pt', 'PT')) as GlobalMaterialLocalizations;
|
||||
await GlobalMaterialLocalizations.delegate.load(const Locale('pt', 'PT'))
|
||||
as GlobalMaterialLocalizations;
|
||||
expect(localizations.formatDecimal(10000), '10\u00A0000');
|
||||
});
|
||||
|
||||
test('falls back to language code when exact locale is missing', () async {
|
||||
final GlobalMaterialLocalizations localizations =
|
||||
await GlobalMaterialLocalizations.delegate.load(const Locale('pt', 'XX')) as GlobalMaterialLocalizations;
|
||||
await GlobalMaterialLocalizations.delegate.load(const Locale('pt', 'XX'))
|
||||
as GlobalMaterialLocalizations;
|
||||
expect(localizations.formatDecimal(10000), '10.000');
|
||||
});
|
||||
|
||||
@@ -32,120 +34,225 @@ void main() {
|
||||
group('formatHour', () {
|
||||
Future<String> formatHour(WidgetTester tester, Locale locale, TimeOfDay timeOfDay) async {
|
||||
final Completer<String> completer = Completer<String>();
|
||||
await tester.pumpWidget(MaterialApp(
|
||||
supportedLocales: <Locale>[locale],
|
||||
locale: locale,
|
||||
localizationsDelegates: GlobalMaterialLocalizations.delegates,
|
||||
home: Builder(builder: (BuildContext context) {
|
||||
completer.complete(MaterialLocalizations.of(context).formatHour(timeOfDay));
|
||||
return Container();
|
||||
}),
|
||||
));
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
supportedLocales: <Locale>[locale],
|
||||
locale: locale,
|
||||
localizationsDelegates: GlobalMaterialLocalizations.delegates,
|
||||
home: Builder(
|
||||
builder: (BuildContext context) {
|
||||
completer.complete(MaterialLocalizations.of(context).formatHour(timeOfDay));
|
||||
return Container();
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
return completer.future;
|
||||
}
|
||||
|
||||
testWidgets('formats h', (WidgetTester tester) async {
|
||||
expect(await formatHour(tester, const Locale('en', 'US'), const TimeOfDay(hour: 10, minute: 0)), '10');
|
||||
expect(await formatHour(tester, const Locale('en', 'US'), const TimeOfDay(hour: 20, minute: 0)), '8');
|
||||
expect(
|
||||
await formatHour(tester, const Locale('en', 'US'), const TimeOfDay(hour: 10, minute: 0)),
|
||||
'10',
|
||||
);
|
||||
expect(
|
||||
await formatHour(tester, const Locale('en', 'US'), const TimeOfDay(hour: 20, minute: 0)),
|
||||
'8',
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('formats HH', (WidgetTester tester) async {
|
||||
expect(await formatHour(tester, const Locale('de'), const TimeOfDay(hour: 9, minute: 0)), '09');
|
||||
expect(await formatHour(tester, const Locale('de'), const TimeOfDay(hour: 20, minute: 0)), '20');
|
||||
expect(
|
||||
await formatHour(tester, const Locale('de'), const TimeOfDay(hour: 9, minute: 0)),
|
||||
'09',
|
||||
);
|
||||
expect(
|
||||
await formatHour(tester, const Locale('de'), const TimeOfDay(hour: 20, minute: 0)),
|
||||
'20',
|
||||
);
|
||||
|
||||
expect(await formatHour(tester, const Locale('en', 'GB'), const TimeOfDay(hour: 9, minute: 0)), '09');
|
||||
expect(await formatHour(tester, const Locale('en', 'GB'), const TimeOfDay(hour: 20, minute: 0)), '20');
|
||||
expect(
|
||||
await formatHour(tester, const Locale('en', 'GB'), const TimeOfDay(hour: 9, minute: 0)),
|
||||
'09',
|
||||
);
|
||||
expect(
|
||||
await formatHour(tester, const Locale('en', 'GB'), const TimeOfDay(hour: 20, minute: 0)),
|
||||
'20',
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('formats H', (WidgetTester tester) async {
|
||||
expect(await formatHour(tester, const Locale('es'), const TimeOfDay(hour: 9, minute: 0)), '9');
|
||||
expect(await formatHour(tester, const Locale('es'), const TimeOfDay(hour: 20, minute: 0)), '20');
|
||||
expect(
|
||||
await formatHour(tester, const Locale('es'), const TimeOfDay(hour: 9, minute: 0)),
|
||||
'9',
|
||||
);
|
||||
expect(
|
||||
await formatHour(tester, const Locale('es'), const TimeOfDay(hour: 20, minute: 0)),
|
||||
'20',
|
||||
);
|
||||
|
||||
expect(await formatHour(tester, const Locale('fa'), const TimeOfDay(hour: 9, minute: 0)), '۹');
|
||||
expect(await formatHour(tester, const Locale('fa'), const TimeOfDay(hour: 20, minute: 0)), '۲۰');
|
||||
expect(
|
||||
await formatHour(tester, const Locale('fa'), const TimeOfDay(hour: 9, minute: 0)),
|
||||
'۹',
|
||||
);
|
||||
expect(
|
||||
await formatHour(tester, const Locale('fa'), const TimeOfDay(hour: 20, minute: 0)),
|
||||
'۲۰',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
group('formatMinute', () {
|
||||
test('formats English', () async {
|
||||
final GlobalMaterialLocalizations localizations =
|
||||
await GlobalMaterialLocalizations.delegate.load(const Locale('en', 'US')) as GlobalMaterialLocalizations;
|
||||
await GlobalMaterialLocalizations.delegate.load(const Locale('en', 'US'))
|
||||
as GlobalMaterialLocalizations;
|
||||
expect(localizations.formatMinute(const TimeOfDay(hour: 1, minute: 32)), '32');
|
||||
});
|
||||
});
|
||||
|
||||
group('formatTimeOfDay', () {
|
||||
Future<String> formatTimeOfDay(WidgetTester tester, Locale locale, TimeOfDay timeOfDay) async {
|
||||
Future<String> formatTimeOfDay(
|
||||
WidgetTester tester,
|
||||
Locale locale,
|
||||
TimeOfDay timeOfDay,
|
||||
) async {
|
||||
final Completer<String> completer = Completer<String>();
|
||||
await tester.pumpWidget(MaterialApp(
|
||||
supportedLocales: <Locale>[locale],
|
||||
locale: locale,
|
||||
localizationsDelegates: GlobalMaterialLocalizations.delegates,
|
||||
home: Builder(builder: (BuildContext context) {
|
||||
completer.complete(MaterialLocalizations.of(context).formatTimeOfDay(timeOfDay));
|
||||
return Container();
|
||||
}),
|
||||
));
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
supportedLocales: <Locale>[locale],
|
||||
locale: locale,
|
||||
localizationsDelegates: GlobalMaterialLocalizations.delegates,
|
||||
home: Builder(
|
||||
builder: (BuildContext context) {
|
||||
completer.complete(MaterialLocalizations.of(context).formatTimeOfDay(timeOfDay));
|
||||
return Container();
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
return completer.future;
|
||||
}
|
||||
|
||||
testWidgets('formats ${TimeOfDayFormat.h_colon_mm_space_a}', (WidgetTester tester) async {
|
||||
expect(await formatTimeOfDay(tester, const Locale('en'), const TimeOfDay(hour: 9, minute: 32)), '9:32 AM');
|
||||
expect(await formatTimeOfDay(tester, const Locale('en'), const TimeOfDay(hour: 20, minute: 32)), '8:32 PM');
|
||||
expect(
|
||||
await formatTimeOfDay(tester, const Locale('en'), const TimeOfDay(hour: 9, minute: 32)),
|
||||
'9:32 AM',
|
||||
);
|
||||
expect(
|
||||
await formatTimeOfDay(tester, const Locale('en'), const TimeOfDay(hour: 20, minute: 32)),
|
||||
'8:32 PM',
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('formats ${TimeOfDayFormat.HH_colon_mm}', (WidgetTester tester) async {
|
||||
expect(await formatTimeOfDay(tester, const Locale('de'), const TimeOfDay(hour: 9, minute: 32)), '09:32');
|
||||
expect(await formatTimeOfDay(tester, const Locale('en', 'ZA'), const TimeOfDay(hour: 9, minute: 32)), '09:32');
|
||||
expect(
|
||||
await formatTimeOfDay(tester, const Locale('de'), const TimeOfDay(hour: 9, minute: 32)),
|
||||
'09:32',
|
||||
);
|
||||
expect(
|
||||
await formatTimeOfDay(
|
||||
tester,
|
||||
const Locale('en', 'ZA'),
|
||||
const TimeOfDay(hour: 9, minute: 32),
|
||||
),
|
||||
'09:32',
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('formats ${TimeOfDayFormat.H_colon_mm}', (WidgetTester tester) async {
|
||||
expect(await formatTimeOfDay(tester, const Locale('es'), const TimeOfDay(hour: 9, minute: 32)), '9:32');
|
||||
expect(await formatTimeOfDay(tester, const Locale('es'), const TimeOfDay(hour: 20, minute: 32)), '20:32');
|
||||
expect(
|
||||
await formatTimeOfDay(tester, const Locale('es'), const TimeOfDay(hour: 9, minute: 32)),
|
||||
'9:32',
|
||||
);
|
||||
expect(
|
||||
await formatTimeOfDay(tester, const Locale('es'), const TimeOfDay(hour: 20, minute: 32)),
|
||||
'20:32',
|
||||
);
|
||||
|
||||
expect(await formatTimeOfDay(tester, const Locale('ja'), const TimeOfDay(hour: 9, minute: 32)), '9:32');
|
||||
expect(await formatTimeOfDay(tester, const Locale('ja'), const TimeOfDay(hour: 20, minute: 32)), '20:32');
|
||||
expect(
|
||||
await formatTimeOfDay(tester, const Locale('ja'), const TimeOfDay(hour: 9, minute: 32)),
|
||||
'9:32',
|
||||
);
|
||||
expect(
|
||||
await formatTimeOfDay(tester, const Locale('ja'), const TimeOfDay(hour: 20, minute: 32)),
|
||||
'20:32',
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('formats ${TimeOfDayFormat.HH_dot_mm}', (WidgetTester tester) async {
|
||||
expect(await formatTimeOfDay(tester, const Locale('fi'), const TimeOfDay(hour: 20, minute: 32)), '20.32');
|
||||
expect(await formatTimeOfDay(tester, const Locale('fi'), const TimeOfDay(hour: 9, minute: 32)), '09.32');
|
||||
expect(await formatTimeOfDay(tester, const Locale('da'), const TimeOfDay(hour: 9, minute: 32)), '09.32');
|
||||
expect(
|
||||
await formatTimeOfDay(tester, const Locale('fi'), const TimeOfDay(hour: 20, minute: 32)),
|
||||
'20.32',
|
||||
);
|
||||
expect(
|
||||
await formatTimeOfDay(tester, const Locale('fi'), const TimeOfDay(hour: 9, minute: 32)),
|
||||
'09.32',
|
||||
);
|
||||
expect(
|
||||
await formatTimeOfDay(tester, const Locale('da'), const TimeOfDay(hour: 9, minute: 32)),
|
||||
'09.32',
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('formats ${TimeOfDayFormat.frenchCanadian}', (WidgetTester tester) async {
|
||||
expect(await formatTimeOfDay(tester, const Locale('fr', 'CA'), const TimeOfDay(hour: 9, minute: 32)), '09 h 32');
|
||||
expect(
|
||||
await formatTimeOfDay(
|
||||
tester,
|
||||
const Locale('fr', 'CA'),
|
||||
const TimeOfDay(hour: 9, minute: 32),
|
||||
),
|
||||
'09 h 32',
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('formats ${TimeOfDayFormat.a_space_h_colon_mm}', (WidgetTester tester) async {
|
||||
expect(await formatTimeOfDay(tester, const Locale('zh'), const TimeOfDay(hour: 9, minute: 32)), '上午 9:32');
|
||||
expect(await formatTimeOfDay(tester, const Locale('ta'), const TimeOfDay(hour: 9, minute: 32)), '9:32 AM');
|
||||
expect(
|
||||
await formatTimeOfDay(tester, const Locale('zh'), const TimeOfDay(hour: 9, minute: 32)),
|
||||
'上午 9:32',
|
||||
);
|
||||
expect(
|
||||
await formatTimeOfDay(tester, const Locale('ta'), const TimeOfDay(hour: 9, minute: 32)),
|
||||
'9:32 AM',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
group('date formatters', () {
|
||||
Future<Map<DateType, String>> formatDate(WidgetTester tester, Locale locale, DateTime dateTime) async {
|
||||
Future<Map<DateType, String>> formatDate(
|
||||
WidgetTester tester,
|
||||
Locale locale,
|
||||
DateTime dateTime,
|
||||
) async {
|
||||
final Completer<Map<DateType, String>> completer = Completer<Map<DateType, String>>();
|
||||
await tester.pumpWidget(MaterialApp(
|
||||
supportedLocales: <Locale>[locale],
|
||||
locale: locale,
|
||||
localizationsDelegates: GlobalMaterialLocalizations.delegates,
|
||||
home: Builder(builder: (BuildContext context) {
|
||||
final MaterialLocalizations localizations = MaterialLocalizations.of(context);
|
||||
completer.complete(<DateType, String>{
|
||||
DateType.year: localizations.formatYear(dateTime),
|
||||
DateType.medium: localizations.formatMediumDate(dateTime),
|
||||
DateType.full: localizations.formatFullDate(dateTime),
|
||||
DateType.monthYear: localizations.formatMonthYear(dateTime),
|
||||
});
|
||||
return Container();
|
||||
}),
|
||||
));
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
supportedLocales: <Locale>[locale],
|
||||
locale: locale,
|
||||
localizationsDelegates: GlobalMaterialLocalizations.delegates,
|
||||
home: Builder(
|
||||
builder: (BuildContext context) {
|
||||
final MaterialLocalizations localizations = MaterialLocalizations.of(context);
|
||||
completer.complete(<DateType, String>{
|
||||
DateType.year: localizations.formatYear(dateTime),
|
||||
DateType.medium: localizations.formatMediumDate(dateTime),
|
||||
DateType.full: localizations.formatFullDate(dateTime),
|
||||
DateType.monthYear: localizations.formatMonthYear(dateTime),
|
||||
});
|
||||
return Container();
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
return completer.future;
|
||||
}
|
||||
|
||||
testWidgets('formats dates in English', (WidgetTester tester) async {
|
||||
final Map<DateType, String> formatted = await formatDate(tester, const Locale('en'), DateTime(2018, 8));
|
||||
final Map<DateType, String> formatted = await formatDate(
|
||||
tester,
|
||||
const Locale('en'),
|
||||
DateTime(2018, 8),
|
||||
);
|
||||
expect(formatted[DateType.year], '2018');
|
||||
expect(formatted[DateType.medium], 'Wed, Aug 1');
|
||||
expect(formatted[DateType.full], 'Wednesday, August 1, 2018');
|
||||
@@ -153,7 +260,11 @@ void main() {
|
||||
});
|
||||
|
||||
testWidgets('formats dates in German', (WidgetTester tester) async {
|
||||
final Map<DateType, String> formatted = await formatDate(tester, const Locale('de'), DateTime(2018, 8));
|
||||
final Map<DateType, String> formatted = await formatDate(
|
||||
tester,
|
||||
const Locale('de'),
|
||||
DateTime(2018, 8),
|
||||
);
|
||||
expect(formatted[DateType.year], '2018');
|
||||
expect(formatted[DateType.medium], 'Mi., 1. Aug.');
|
||||
expect(formatted[DateType.full], 'Mittwoch, 1. August 2018');
|
||||
@@ -161,7 +272,11 @@ void main() {
|
||||
});
|
||||
|
||||
testWidgets('formats dates in Serbian', (WidgetTester tester) async {
|
||||
final Map<DateType, String> formatted = await formatDate(tester, const Locale('sr'), DateTime(2018, 8));
|
||||
final Map<DateType, String> formatted = await formatDate(
|
||||
tester,
|
||||
const Locale('sr'),
|
||||
DateTime(2018, 8),
|
||||
);
|
||||
expect(formatted[DateType.year], '2018.');
|
||||
expect(formatted[DateType.medium], 'сре 1. авг');
|
||||
expect(formatted[DateType.full], 'среда, 1. август 2018.');
|
||||
@@ -169,8 +284,11 @@ void main() {
|
||||
});
|
||||
|
||||
testWidgets('formats dates in Serbian (Latin)', (WidgetTester tester) async {
|
||||
final Map<DateType, String> formatted = await formatDate(tester,
|
||||
const Locale.fromSubtags(languageCode:'sr', scriptCode: 'Latn'), DateTime(2018, 8));
|
||||
final Map<DateType, String> formatted = await formatDate(
|
||||
tester,
|
||||
const Locale.fromSubtags(languageCode: 'sr', scriptCode: 'Latn'),
|
||||
DateTime(2018, 8),
|
||||
);
|
||||
expect(formatted[DateType.year], '2018.');
|
||||
expect(formatted[DateType.medium], 'sre 1. avg');
|
||||
expect(formatted[DateType.full], 'sreda, 1. avgust 2018.');
|
||||
@@ -180,32 +298,44 @@ void main() {
|
||||
});
|
||||
|
||||
// Regression test for https://github.com/flutter/flutter/issues/67644.
|
||||
testWidgets('en_US is initialized correctly by Flutter when DateFormat is used', (WidgetTester tester) async {
|
||||
testWidgets('en_US is initialized correctly by Flutter when DateFormat is used', (
|
||||
WidgetTester tester,
|
||||
) async {
|
||||
late DateFormat dateFormat;
|
||||
|
||||
await tester.pumpWidget(MaterialApp(
|
||||
locale: const Locale('en', 'US'),
|
||||
localizationsDelegates: GlobalMaterialLocalizations.delegates,
|
||||
home: Builder(builder: (BuildContext context) {
|
||||
dateFormat = DateFormat('EEE, d MMM yyyy HH:mm:ss', 'en_US');
|
||||
return Container();
|
||||
}),
|
||||
));
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
locale: const Locale('en', 'US'),
|
||||
localizationsDelegates: GlobalMaterialLocalizations.delegates,
|
||||
home: Builder(
|
||||
builder: (BuildContext context) {
|
||||
dateFormat = DateFormat('EEE, d MMM yyyy HH:mm:ss', 'en_US');
|
||||
return Container();
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(dateFormat.locale, 'en_US');
|
||||
});
|
||||
|
||||
testWidgets('cy is initialized correctly by Flutter when DateFormat is used', (WidgetTester tester) async {
|
||||
testWidgets('cy is initialized correctly by Flutter when DateFormat is used', (
|
||||
WidgetTester tester,
|
||||
) async {
|
||||
late DateFormat dateFormat;
|
||||
|
||||
await tester.pumpWidget(MaterialApp(
|
||||
locale: const Locale('cy'),
|
||||
localizationsDelegates: GlobalMaterialLocalizations.delegates,
|
||||
home: Builder(builder: (BuildContext context) {
|
||||
dateFormat = DateFormat.yMMMd('cy');
|
||||
return Container();
|
||||
}),
|
||||
));
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
locale: const Locale('cy'),
|
||||
localizationsDelegates: GlobalMaterialLocalizations.delegates,
|
||||
home: Builder(
|
||||
builder: (BuildContext context) {
|
||||
dateFormat = DateFormat.yMMMd('cy');
|
||||
return Container();
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(dateFormat.locale, 'cy');
|
||||
expect(dateFormat.format(DateTime(2023, 4, 10, 2, 32)), equals('10 Ebr 2023'));
|
||||
|
||||
@@ -7,12 +7,8 @@ import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('Test semantics of TabPageSelector in pt-BR',
|
||||
(WidgetTester tester) async {
|
||||
final TabController controller = TabController(
|
||||
vsync: const TestVSync(),
|
||||
length: 2,
|
||||
);
|
||||
testWidgets('Test semantics of TabPageSelector in pt-BR', (WidgetTester tester) async {
|
||||
final TabController controller = TabController(vsync: const TestVSync(), length: 2);
|
||||
|
||||
await tester.pumpWidget(
|
||||
Localizations(
|
||||
@@ -47,8 +43,10 @@ void main() {
|
||||
|
||||
final SemanticsHandle handle = tester.ensureSemantics();
|
||||
|
||||
expect(tester.getSemantics(find.byType(TabPageSelector)),
|
||||
matchesSemantics(label: 'Guia 1 de 2'));
|
||||
expect(
|
||||
tester.getSemantics(find.byType(TabPageSelector)),
|
||||
matchesSemantics(label: 'Guia 1 de 2'),
|
||||
);
|
||||
|
||||
handle.dispose();
|
||||
});
|
||||
|
||||
@@ -7,19 +7,32 @@ import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('Material2 - can localize the header in all known formats - portrait', (WidgetTester tester) async {
|
||||
testWidgets('Material2 - can localize the header in all known formats - portrait', (
|
||||
WidgetTester tester,
|
||||
) async {
|
||||
// Ensure picker is displayed in portrait mode.
|
||||
tester.view.physicalSize = const Size(400, 800);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.reset);
|
||||
|
||||
final Finder timeSelectorSeparatorFinder = find.descendant(
|
||||
of: find.byWidgetPredicate((Widget w) => '${w.runtimeType}' == '_TimeSelectorSeparator'),
|
||||
matching: find.byType(Text),
|
||||
).first;
|
||||
final Finder hourControlFinder = find.byWidgetPredicate((Widget w) => '${w.runtimeType}' == '_HourControl');
|
||||
final Finder minuteControlFinder = find.byWidgetPredicate((Widget w) => '${w.runtimeType}' == '_MinuteControl');
|
||||
final Finder dayPeriodControlFinder = find.byWidgetPredicate((Widget w) => '${w.runtimeType}' == '_DayPeriodControl');
|
||||
final Finder timeSelectorSeparatorFinder =
|
||||
find
|
||||
.descendant(
|
||||
of: find.byWidgetPredicate(
|
||||
(Widget w) => '${w.runtimeType}' == '_TimeSelectorSeparator',
|
||||
),
|
||||
matching: find.byType(Text),
|
||||
)
|
||||
.first;
|
||||
final Finder hourControlFinder = find.byWidgetPredicate(
|
||||
(Widget w) => '${w.runtimeType}' == '_HourControl',
|
||||
);
|
||||
final Finder minuteControlFinder = find.byWidgetPredicate(
|
||||
(Widget w) => '${w.runtimeType}' == '_MinuteControl',
|
||||
);
|
||||
final Finder dayPeriodControlFinder = find.byWidgetPredicate(
|
||||
(Widget w) => '${w.runtimeType}' == '_DayPeriodControl',
|
||||
);
|
||||
|
||||
// TODO(yjbanov): also test `HH.mm` (in_ID), `a h:mm` (ko_KR) and `HH:mm น.` (th_TH) when we have .arb files for them
|
||||
final List<Locale> locales = <Locale>[
|
||||
@@ -32,7 +45,12 @@ void main() {
|
||||
];
|
||||
|
||||
for (final Locale locale in locales) {
|
||||
final Offset center = await startPicker(tester, (TimeOfDay? time) { }, locale: locale, useMaterial3: false);
|
||||
final Offset center = await startPicker(
|
||||
tester,
|
||||
(TimeOfDay? time) {},
|
||||
locale: locale,
|
||||
useMaterial3: false,
|
||||
);
|
||||
final Text stringFragmentText = tester.widget(timeSelectorSeparatorFinder);
|
||||
final double hourLeftOffset = tester.getTopLeft(hourControlFinder).dx;
|
||||
final double minuteLeftOffset = tester.getTopLeft(minuteControlFinder).dx;
|
||||
@@ -77,19 +95,32 @@ void main() {
|
||||
}
|
||||
});
|
||||
|
||||
testWidgets('Material3 - can localize the header in all known formats - portrait', (WidgetTester tester) async {
|
||||
testWidgets('Material3 - can localize the header in all known formats - portrait', (
|
||||
WidgetTester tester,
|
||||
) async {
|
||||
// Ensure picker is displayed in portrait mode.
|
||||
tester.view.physicalSize = const Size(400, 800);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.reset);
|
||||
|
||||
final Finder timeSelectorSeparatorFinder = find.descendant(
|
||||
of: find.byWidgetPredicate((Widget w) => '${w.runtimeType}' == '_TimeSelectorSeparator'),
|
||||
matching: find.byType(Text),
|
||||
).first;
|
||||
final Finder hourControlFinder = find.byWidgetPredicate((Widget w) => '${w.runtimeType}' == '_HourControl');
|
||||
final Finder minuteControlFinder = find.byWidgetPredicate((Widget w) => '${w.runtimeType}' == '_MinuteControl');
|
||||
final Finder dayPeriodControlFinder = find.byWidgetPredicate((Widget w) => '${w.runtimeType}' == '_DayPeriodControl');
|
||||
final Finder timeSelectorSeparatorFinder =
|
||||
find
|
||||
.descendant(
|
||||
of: find.byWidgetPredicate(
|
||||
(Widget w) => '${w.runtimeType}' == '_TimeSelectorSeparator',
|
||||
),
|
||||
matching: find.byType(Text),
|
||||
)
|
||||
.first;
|
||||
final Finder hourControlFinder = find.byWidgetPredicate(
|
||||
(Widget w) => '${w.runtimeType}' == '_HourControl',
|
||||
);
|
||||
final Finder minuteControlFinder = find.byWidgetPredicate(
|
||||
(Widget w) => '${w.runtimeType}' == '_MinuteControl',
|
||||
);
|
||||
final Finder dayPeriodControlFinder = find.byWidgetPredicate(
|
||||
(Widget w) => '${w.runtimeType}' == '_DayPeriodControl',
|
||||
);
|
||||
|
||||
// TODO(yjbanov): also test `HH.mm` (in_ID), `a h:mm` (ko_KR) and `HH:mm น.` (th_TH) when we have .arb files for them
|
||||
final List<Locale> locales = <Locale>[
|
||||
@@ -102,7 +133,12 @@ void main() {
|
||||
];
|
||||
|
||||
for (final Locale locale in locales) {
|
||||
final Offset center = await startPicker(tester, (TimeOfDay? time) { }, locale: locale, useMaterial3: true);
|
||||
final Offset center = await startPicker(
|
||||
tester,
|
||||
(TimeOfDay? time) {},
|
||||
locale: locale,
|
||||
useMaterial3: true,
|
||||
);
|
||||
final Text stringFragmentText = tester.widget(timeSelectorSeparatorFinder);
|
||||
final double hourLeftOffset = tester.getTopLeft(hourControlFinder).dx;
|
||||
final double minuteLeftOffset = tester.getTopLeft(minuteControlFinder).dx;
|
||||
@@ -147,19 +183,32 @@ void main() {
|
||||
}
|
||||
});
|
||||
|
||||
testWidgets('Material2 - can localize the header in all known formats - landscape', (WidgetTester tester) async {
|
||||
testWidgets('Material2 - can localize the header in all known formats - landscape', (
|
||||
WidgetTester tester,
|
||||
) async {
|
||||
// Ensure picker is displayed in landscape mode.
|
||||
tester.view.physicalSize = const Size(800, 400);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.reset);
|
||||
|
||||
final Finder timeSelectorSeparatorFinder = find.descendant(
|
||||
of: find.byWidgetPredicate((Widget w) => '${w.runtimeType}' == '_TimeSelectorSeparator'),
|
||||
matching: find.byType(Text),
|
||||
).first;
|
||||
final Finder hourControlFinder = find.byWidgetPredicate((Widget w) => '${w.runtimeType}' == '_HourControl');
|
||||
final Finder minuteControlFinder = find.byWidgetPredicate((Widget w) => '${w.runtimeType}' == '_MinuteControl');
|
||||
final Finder dayPeriodControlFinder = find.byWidgetPredicate((Widget w) => '${w.runtimeType}' == '_DayPeriodControl');
|
||||
final Finder timeSelectorSeparatorFinder =
|
||||
find
|
||||
.descendant(
|
||||
of: find.byWidgetPredicate(
|
||||
(Widget w) => '${w.runtimeType}' == '_TimeSelectorSeparator',
|
||||
),
|
||||
matching: find.byType(Text),
|
||||
)
|
||||
.first;
|
||||
final Finder hourControlFinder = find.byWidgetPredicate(
|
||||
(Widget w) => '${w.runtimeType}' == '_HourControl',
|
||||
);
|
||||
final Finder minuteControlFinder = find.byWidgetPredicate(
|
||||
(Widget w) => '${w.runtimeType}' == '_MinuteControl',
|
||||
);
|
||||
final Finder dayPeriodControlFinder = find.byWidgetPredicate(
|
||||
(Widget w) => '${w.runtimeType}' == '_DayPeriodControl',
|
||||
);
|
||||
|
||||
// TODO(yjbanov): also test `HH.mm` (in_ID), `a h:mm` (ko_KR) and `HH:mm น.` (th_TH) when we have .arb files for them
|
||||
final List<Locale> locales = <Locale>[
|
||||
@@ -172,7 +221,12 @@ void main() {
|
||||
];
|
||||
|
||||
for (final Locale locale in locales) {
|
||||
final Offset center = await startPicker(tester, (TimeOfDay? time) { }, locale: locale, useMaterial3: false);
|
||||
final Offset center = await startPicker(
|
||||
tester,
|
||||
(TimeOfDay? time) {},
|
||||
locale: locale,
|
||||
useMaterial3: false,
|
||||
);
|
||||
final Text stringFragmentText = tester.widget(timeSelectorSeparatorFinder);
|
||||
final double hourLeftOffset = tester.getTopLeft(hourControlFinder).dx;
|
||||
final double hourTopOffset = tester.getTopLeft(hourControlFinder).dy;
|
||||
@@ -222,19 +276,32 @@ void main() {
|
||||
}
|
||||
});
|
||||
|
||||
testWidgets('Material3 - can localize the header in all known formats - landscape', (WidgetTester tester) async {
|
||||
testWidgets('Material3 - can localize the header in all known formats - landscape', (
|
||||
WidgetTester tester,
|
||||
) async {
|
||||
// Ensure picker is displayed in landscape mode.
|
||||
tester.view.physicalSize = const Size(800, 400);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.reset);
|
||||
|
||||
final Finder timeSelectorSeparatorFinder = find.descendant(
|
||||
of: find.byWidgetPredicate((Widget w) => '${w.runtimeType}' == '_TimeSelectorSeparator'),
|
||||
matching: find.byType(Text),
|
||||
).first;
|
||||
final Finder hourControlFinder = find.byWidgetPredicate((Widget w) => '${w.runtimeType}' == '_HourControl');
|
||||
final Finder minuteControlFinder = find.byWidgetPredicate((Widget w) => '${w.runtimeType}' == '_MinuteControl');
|
||||
final Finder dayPeriodControlFinder = find.byWidgetPredicate((Widget w) => '${w.runtimeType}' == '_DayPeriodControl');
|
||||
final Finder timeSelectorSeparatorFinder =
|
||||
find
|
||||
.descendant(
|
||||
of: find.byWidgetPredicate(
|
||||
(Widget w) => '${w.runtimeType}' == '_TimeSelectorSeparator',
|
||||
),
|
||||
matching: find.byType(Text),
|
||||
)
|
||||
.first;
|
||||
final Finder hourControlFinder = find.byWidgetPredicate(
|
||||
(Widget w) => '${w.runtimeType}' == '_HourControl',
|
||||
);
|
||||
final Finder minuteControlFinder = find.byWidgetPredicate(
|
||||
(Widget w) => '${w.runtimeType}' == '_MinuteControl',
|
||||
);
|
||||
final Finder dayPeriodControlFinder = find.byWidgetPredicate(
|
||||
(Widget w) => '${w.runtimeType}' == '_DayPeriodControl',
|
||||
);
|
||||
|
||||
// TODO(yjbanov): also test `HH.mm` (in_ID), `a h:mm` (ko_KR) and `HH:mm น.` (th_TH) when we have .arb files for them
|
||||
final List<Locale> locales = <Locale>[
|
||||
@@ -247,7 +314,12 @@ void main() {
|
||||
];
|
||||
|
||||
for (final Locale locale in locales) {
|
||||
final Offset center = await startPicker(tester, (TimeOfDay? time) { }, locale: locale, useMaterial3: true);
|
||||
final Offset center = await startPicker(
|
||||
tester,
|
||||
(TimeOfDay? time) {},
|
||||
locale: locale,
|
||||
useMaterial3: true,
|
||||
);
|
||||
final Text stringFragmentText = tester.widget(timeSelectorSeparatorFinder);
|
||||
final double hourLeftOffset = tester.getTopLeft(hourControlFinder).dx;
|
||||
final double hourTopOffset = tester.getTopLeft(hourControlFinder).dy;
|
||||
@@ -297,14 +369,27 @@ void main() {
|
||||
}
|
||||
});
|
||||
|
||||
testWidgets('Material2 - can localize input mode in all known formats', (WidgetTester tester) async {
|
||||
final Finder hourControlFinder = find.byWidgetPredicate((Widget w) => '${w.runtimeType}' == '_HourTextField');
|
||||
final Finder minuteControlFinder = find.byWidgetPredicate((Widget w) => '${w.runtimeType}' == '_MinuteTextField');
|
||||
final Finder dayPeriodControlFinder = find.byWidgetPredicate((Widget w) => '${w.runtimeType}' == '_DayPeriodControl');
|
||||
final Finder timeSelectorSeparatorFinder = find.descendant(
|
||||
of: find.byWidgetPredicate((Widget w) => '${w.runtimeType}' == '_TimeSelectorSeparator'),
|
||||
matching: find.byType(Text),
|
||||
).first;
|
||||
testWidgets('Material2 - can localize input mode in all known formats', (
|
||||
WidgetTester tester,
|
||||
) async {
|
||||
final Finder hourControlFinder = find.byWidgetPredicate(
|
||||
(Widget w) => '${w.runtimeType}' == '_HourTextField',
|
||||
);
|
||||
final Finder minuteControlFinder = find.byWidgetPredicate(
|
||||
(Widget w) => '${w.runtimeType}' == '_MinuteTextField',
|
||||
);
|
||||
final Finder dayPeriodControlFinder = find.byWidgetPredicate(
|
||||
(Widget w) => '${w.runtimeType}' == '_DayPeriodControl',
|
||||
);
|
||||
final Finder timeSelectorSeparatorFinder =
|
||||
find
|
||||
.descendant(
|
||||
of: find.byWidgetPredicate(
|
||||
(Widget w) => '${w.runtimeType}' == '_TimeSelectorSeparator',
|
||||
),
|
||||
matching: find.byType(Text),
|
||||
)
|
||||
.first;
|
||||
|
||||
// TODO(yjbanov): also test `HH.mm` (in_ID), `a h:mm` (ko_KR) and `HH:mm น.` (th_TH) when we have .arb files for them
|
||||
final List<Locale> locales = <Locale>[
|
||||
@@ -317,7 +402,14 @@ void main() {
|
||||
];
|
||||
|
||||
for (final Locale locale in locales) {
|
||||
await tester.pumpWidget(_TimePickerLauncher(onChanged: (TimeOfDay? time) { }, locale: locale, entryMode: TimePickerEntryMode.input, useMaterial3 : false));
|
||||
await tester.pumpWidget(
|
||||
_TimePickerLauncher(
|
||||
onChanged: (TimeOfDay? time) {},
|
||||
locale: locale,
|
||||
entryMode: TimePickerEntryMode.input,
|
||||
useMaterial3: false,
|
||||
),
|
||||
);
|
||||
await tester.tap(find.text('X'));
|
||||
await tester.pumpAndSettle(const Duration(seconds: 1));
|
||||
|
||||
@@ -365,14 +457,27 @@ void main() {
|
||||
}
|
||||
});
|
||||
|
||||
testWidgets('Material3 - can localize input mode in all known formats', (WidgetTester tester) async {
|
||||
final Finder hourControlFinder = find.byWidgetPredicate((Widget w) => '${w.runtimeType}' == '_HourTextField');
|
||||
final Finder minuteControlFinder = find.byWidgetPredicate((Widget w) => '${w.runtimeType}' == '_MinuteTextField');
|
||||
final Finder dayPeriodControlFinder = find.byWidgetPredicate((Widget w) => '${w.runtimeType}' == '_DayPeriodControl');
|
||||
final Finder timeSelectorSeparatorFinder = find.descendant(
|
||||
of: find.byWidgetPredicate((Widget w) => '${w.runtimeType}' == '_TimeSelectorSeparator'),
|
||||
matching: find.byType(Text),
|
||||
).first;
|
||||
testWidgets('Material3 - can localize input mode in all known formats', (
|
||||
WidgetTester tester,
|
||||
) async {
|
||||
final Finder hourControlFinder = find.byWidgetPredicate(
|
||||
(Widget w) => '${w.runtimeType}' == '_HourTextField',
|
||||
);
|
||||
final Finder minuteControlFinder = find.byWidgetPredicate(
|
||||
(Widget w) => '${w.runtimeType}' == '_MinuteTextField',
|
||||
);
|
||||
final Finder dayPeriodControlFinder = find.byWidgetPredicate(
|
||||
(Widget w) => '${w.runtimeType}' == '_DayPeriodControl',
|
||||
);
|
||||
final Finder timeSelectorSeparatorFinder =
|
||||
find
|
||||
.descendant(
|
||||
of: find.byWidgetPredicate(
|
||||
(Widget w) => '${w.runtimeType}' == '_TimeSelectorSeparator',
|
||||
),
|
||||
matching: find.byType(Text),
|
||||
)
|
||||
.first;
|
||||
|
||||
// TODO(yjbanov): also test `HH.mm` (in_ID), `a h:mm` (ko_KR) and `HH:mm น.` (th_TH) when we have .arb files for them
|
||||
final List<Locale> locales = <Locale>[
|
||||
@@ -385,7 +490,14 @@ void main() {
|
||||
];
|
||||
|
||||
for (final Locale locale in locales) {
|
||||
await tester.pumpWidget(_TimePickerLauncher(onChanged: (TimeOfDay? time) { }, locale: locale, entryMode: TimePickerEntryMode.input, useMaterial3 : true));
|
||||
await tester.pumpWidget(
|
||||
_TimePickerLauncher(
|
||||
onChanged: (TimeOfDay? time) {},
|
||||
locale: locale,
|
||||
entryMode: TimePickerEntryMode.input,
|
||||
useMaterial3: true,
|
||||
),
|
||||
);
|
||||
await tester.tap(find.text('X'));
|
||||
await tester.pumpAndSettle(const Duration(seconds: 1));
|
||||
|
||||
@@ -433,7 +545,9 @@ void main() {
|
||||
}
|
||||
});
|
||||
|
||||
testWidgets('Material2 uses single-ring 24-hour dial for all locales', (WidgetTester tester) async {
|
||||
testWidgets('Material2 uses single-ring 24-hour dial for all locales', (
|
||||
WidgetTester tester,
|
||||
) async {
|
||||
const List<Locale> locales = <Locale>[
|
||||
Locale('en', 'US'), // h
|
||||
Locale('en', 'GB'), // HH
|
||||
@@ -445,7 +559,14 @@ void main() {
|
||||
// DatePicker no matter where you tap the time will be the same.
|
||||
for (int i = 1; i < 10; i++) {
|
||||
TimeOfDay? result;
|
||||
final Offset center = await startPicker(tester, (TimeOfDay? time) { result = time; }, locale: locale, useMaterial3: false);
|
||||
final Offset center = await startPicker(
|
||||
tester,
|
||||
(TimeOfDay? time) {
|
||||
result = time;
|
||||
},
|
||||
locale: locale,
|
||||
useMaterial3: false,
|
||||
);
|
||||
final Size size = tester.getSize(find.byKey(const Key('time-picker-dial')));
|
||||
final double dy = (size.height / 2.0 / 10) * i;
|
||||
await tester.tapAt(Offset(center.dx, center.dy - dy));
|
||||
@@ -455,34 +576,127 @@ void main() {
|
||||
}
|
||||
});
|
||||
|
||||
testWidgets('Material3 uses a double-ring 24-hour dial for 24 hour locales', (WidgetTester tester) async {
|
||||
Future<void> testLocale(Locale locale, int startFactor, int endFactor, TimeOfDay expectedTime) async {
|
||||
testWidgets('Material3 uses a double-ring 24-hour dial for 24 hour locales', (
|
||||
WidgetTester tester,
|
||||
) async {
|
||||
Future<void> testLocale(
|
||||
Locale locale,
|
||||
int startFactor,
|
||||
int endFactor,
|
||||
TimeOfDay expectedTime,
|
||||
) async {
|
||||
// For locales that display 24 hour time, factors 1-5 put the tap on the
|
||||
// inner ring's "12" (the inner ring goes from 12-23). Otherwise the offset
|
||||
// should land on the outer ring's "00".
|
||||
for (int factor = startFactor; factor < endFactor; factor += 1) {
|
||||
TimeOfDay? result;
|
||||
final Offset center = await startPicker(tester, (TimeOfDay? time) { result = time; }, locale: locale, useMaterial3: true);
|
||||
final Offset center = await startPicker(
|
||||
tester,
|
||||
(TimeOfDay? time) {
|
||||
result = time;
|
||||
},
|
||||
locale: locale,
|
||||
useMaterial3: true,
|
||||
);
|
||||
final Size size = tester.getSize(find.byKey(const Key('time-picker-dial')));
|
||||
final double dy = (size.height / 2.0 / 10) * factor;
|
||||
await tester.tapAt(Offset(center.dx, center.dy - dy));
|
||||
await finishPicker(tester);
|
||||
expect(result, equals(expectedTime), reason: 'Failed for locale=$locale with factor=$factor');
|
||||
expect(
|
||||
result,
|
||||
equals(expectedTime),
|
||||
reason: 'Failed for locale=$locale with factor=$factor',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
await testLocale(const Locale('en', 'US'), 1, 10, const TimeOfDay(hour: 0, minute: 0)); // 12 hour
|
||||
await testLocale(const Locale('en', 'ES'), 1, 10, const TimeOfDay(hour: 0, minute: 0)); // 12 hour
|
||||
await testLocale(const Locale('en', 'GB'), 1, 5, const TimeOfDay(hour: 12, minute: 0)); // 24 hour, inner ring
|
||||
await testLocale(const Locale('en', 'GB'), 6, 10, const TimeOfDay(hour: 0, minute: 0)); // 24 hour, outer ring
|
||||
await testLocale(
|
||||
const Locale('en', 'US'),
|
||||
1,
|
||||
10,
|
||||
const TimeOfDay(hour: 0, minute: 0),
|
||||
); // 12 hour
|
||||
await testLocale(
|
||||
const Locale('en', 'ES'),
|
||||
1,
|
||||
10,
|
||||
const TimeOfDay(hour: 0, minute: 0),
|
||||
); // 12 hour
|
||||
await testLocale(
|
||||
const Locale('en', 'GB'),
|
||||
1,
|
||||
5,
|
||||
const TimeOfDay(hour: 12, minute: 0),
|
||||
); // 24 hour, inner ring
|
||||
await testLocale(
|
||||
const Locale('en', 'GB'),
|
||||
6,
|
||||
10,
|
||||
const TimeOfDay(hour: 0, minute: 0),
|
||||
); // 24 hour, outer ring
|
||||
});
|
||||
|
||||
const List<String> labels12To11 = <String>['12', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11'];
|
||||
const List<String> labels00To22TwoDigit = <String>['00', '02', '04', '06', '08', '10', '12', '14', '16', '18', '20', '22']; // Material 2
|
||||
const List<String> labels00To23TwoDigit = <String>[ // Material 3
|
||||
'00', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23'];
|
||||
const List<String> labels12To11 = <String>[
|
||||
'12',
|
||||
'1',
|
||||
'2',
|
||||
'3',
|
||||
'4',
|
||||
'5',
|
||||
'6',
|
||||
'7',
|
||||
'8',
|
||||
'9',
|
||||
'10',
|
||||
'11',
|
||||
];
|
||||
const List<String> labels00To22TwoDigit = <String>[
|
||||
'00',
|
||||
'02',
|
||||
'04',
|
||||
'06',
|
||||
'08',
|
||||
'10',
|
||||
'12',
|
||||
'14',
|
||||
'16',
|
||||
'18',
|
||||
'20',
|
||||
'22',
|
||||
]; // Material 2
|
||||
const List<String> labels00To23TwoDigit = <String>[
|
||||
// Material 3
|
||||
'00',
|
||||
'1',
|
||||
'2',
|
||||
'3',
|
||||
'4',
|
||||
'5',
|
||||
'6',
|
||||
'7',
|
||||
'8',
|
||||
'9',
|
||||
'10',
|
||||
'11',
|
||||
'12',
|
||||
'13',
|
||||
'14',
|
||||
'15',
|
||||
'16',
|
||||
'17',
|
||||
'18',
|
||||
'19',
|
||||
'20',
|
||||
'21',
|
||||
'22',
|
||||
'23',
|
||||
];
|
||||
|
||||
Future<void> mediaQueryBoilerplate(WidgetTester tester, {required bool alwaysUse24HourFormat, required bool useMaterial3}) async {
|
||||
Future<void> mediaQueryBoilerplate(
|
||||
WidgetTester tester, {
|
||||
required bool alwaysUse24HourFormat,
|
||||
required bool useMaterial3,
|
||||
}) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: ThemeData(useMaterial3: useMaterial3),
|
||||
@@ -497,14 +711,19 @@ void main() {
|
||||
textDirection: TextDirection.ltr,
|
||||
child: Navigator(
|
||||
onGenerateRoute: (RouteSettings settings) {
|
||||
return MaterialPageRoute<void>(builder: (BuildContext context) {
|
||||
return TextButton(
|
||||
onPressed: () {
|
||||
showTimePicker(context: context, initialTime: const TimeOfDay(hour: 7, minute: 0));
|
||||
},
|
||||
child: const Text('X'),
|
||||
);
|
||||
});
|
||||
return MaterialPageRoute<void>(
|
||||
builder: (BuildContext context) {
|
||||
return TextButton(
|
||||
onPressed: () {
|
||||
showTimePicker(
|
||||
context: context,
|
||||
initialTime: const TimeOfDay(hour: 7, minute: 0),
|
||||
);
|
||||
},
|
||||
child: const Text('X'),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
@@ -516,10 +735,14 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
testWidgets('Material2 respects MediaQueryData.alwaysUse24HourFormat == false', (WidgetTester tester) async {
|
||||
await mediaQueryBoilerplate(tester, alwaysUse24HourFormat: false, useMaterial3: false);
|
||||
testWidgets('Material2 respects MediaQueryData.alwaysUse24HourFormat == false', (
|
||||
WidgetTester tester,
|
||||
) async {
|
||||
await mediaQueryBoilerplate(tester, alwaysUse24HourFormat: false, useMaterial3: false);
|
||||
|
||||
final CustomPaint dialPaint = tester.widget(find.byKey(const ValueKey<String>('time-picker-dial')));
|
||||
final CustomPaint dialPaint = tester.widget(
|
||||
find.byKey(const ValueKey<String>('time-picker-dial')),
|
||||
);
|
||||
final dynamic dialPainter = dialPaint.painter;
|
||||
// ignore: avoid_dynamic_calls
|
||||
final List<dynamic> primaryLabels = dialPainter.primaryLabels as List<dynamic>;
|
||||
@@ -542,10 +765,14 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('Material3 respects MediaQueryData.alwaysUse24HourFormat == false', (WidgetTester tester) async {
|
||||
await mediaQueryBoilerplate(tester, alwaysUse24HourFormat: false, useMaterial3: true);
|
||||
testWidgets('Material3 respects MediaQueryData.alwaysUse24HourFormat == false', (
|
||||
WidgetTester tester,
|
||||
) async {
|
||||
await mediaQueryBoilerplate(tester, alwaysUse24HourFormat: false, useMaterial3: true);
|
||||
|
||||
final CustomPaint dialPaint = tester.widget(find.byKey(const ValueKey<String>('time-picker-dial')));
|
||||
final CustomPaint dialPaint = tester.widget(
|
||||
find.byKey(const ValueKey<String>('time-picker-dial')),
|
||||
);
|
||||
final dynamic dialPainter = dialPaint.painter;
|
||||
// ignore: avoid_dynamic_calls
|
||||
final List<dynamic> primaryLabels = dialPainter.primaryLabels as List<dynamic>;
|
||||
@@ -568,10 +795,14 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('Material3 respects MediaQueryData.alwaysUse24HourFormat == true', (WidgetTester tester) async {
|
||||
testWidgets('Material3 respects MediaQueryData.alwaysUse24HourFormat == true', (
|
||||
WidgetTester tester,
|
||||
) async {
|
||||
await mediaQueryBoilerplate(tester, alwaysUse24HourFormat: true, useMaterial3: true);
|
||||
|
||||
final CustomPaint dialPaint = tester.widget(find.byKey(const ValueKey<String>('time-picker-dial')));
|
||||
final CustomPaint dialPaint = tester.widget(
|
||||
find.byKey(const ValueKey<String>('time-picker-dial')),
|
||||
);
|
||||
final dynamic dialPainter = dialPaint.painter;
|
||||
// ignore: avoid_dynamic_calls
|
||||
final List<dynamic> primaryLabels = dialPainter.primaryLabels as List<dynamic>;
|
||||
@@ -594,10 +825,14 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('Material2 respects MediaQueryData.alwaysUse24HourFormat == true', (WidgetTester tester) async {
|
||||
testWidgets('Material2 respects MediaQueryData.alwaysUse24HourFormat == true', (
|
||||
WidgetTester tester,
|
||||
) async {
|
||||
await mediaQueryBoilerplate(tester, alwaysUse24HourFormat: true, useMaterial3: false);
|
||||
|
||||
final CustomPaint dialPaint = tester.widget(find.byKey(const ValueKey<String>('time-picker-dial')));
|
||||
final CustomPaint dialPaint = tester.widget(
|
||||
find.byKey(const ValueKey<String>('time-picker-dial')),
|
||||
);
|
||||
final dynamic dialPainter = dialPaint.painter;
|
||||
// ignore: avoid_dynamic_calls
|
||||
final List<dynamic> primaryLabels = dialPainter.primaryLabels as List<dynamic>;
|
||||
@@ -621,13 +856,21 @@ void main() {
|
||||
});
|
||||
|
||||
// Regression test for https://github.com/flutter/flutter/issues/156565
|
||||
testWidgets('AM/PM buttons should be aligned to LTR in Hindi language - Portrait', (WidgetTester tester) async {
|
||||
testWidgets('AM/PM buttons should be aligned to LTR in Hindi language - Portrait', (
|
||||
WidgetTester tester,
|
||||
) async {
|
||||
const Locale locale = Locale('hi', 'HI');
|
||||
|
||||
final Offset centerPortrait = await startPicker(tester, (TimeOfDay? time) {}, locale: locale, useMaterial3: false, orientation: Orientation.portrait);
|
||||
final Offset centerPortrait = await startPicker(
|
||||
tester,
|
||||
(TimeOfDay? time) {},
|
||||
locale: locale,
|
||||
useMaterial3: false,
|
||||
orientation: Orientation.portrait,
|
||||
);
|
||||
|
||||
final Finder amButtonPortrait = find.text('AM');
|
||||
final Finder pmButtonPortrait = find.text('PM') ;
|
||||
final Finder pmButtonPortrait = find.text('PM');
|
||||
|
||||
final Offset amButtonPositionPortrait = tester.getCenter(amButtonPortrait);
|
||||
final Offset pmButtonPositionPortrait = tester.getCenter(pmButtonPortrait);
|
||||
@@ -637,10 +880,18 @@ void main() {
|
||||
});
|
||||
|
||||
// Regression test for https://github.com/flutter/flutter/issues/156565
|
||||
testWidgets('AM/PM buttons should be aligned to LTR in Hindi language - Landscape', (WidgetTester tester) async {
|
||||
testWidgets('AM/PM buttons should be aligned to LTR in Hindi language - Landscape', (
|
||||
WidgetTester tester,
|
||||
) async {
|
||||
const Locale locale = Locale('hi', 'HI');
|
||||
|
||||
final Offset centerLandscape = await startPicker(tester, (TimeOfDay? time) {}, locale: locale, useMaterial3: false, orientation: Orientation.landscape);
|
||||
final Offset centerLandscape = await startPicker(
|
||||
tester,
|
||||
(TimeOfDay? time) {},
|
||||
locale: locale,
|
||||
useMaterial3: false,
|
||||
orientation: Orientation.landscape,
|
||||
);
|
||||
|
||||
final Finder amButtonLandscape = find.text('AM');
|
||||
final Finder pmButtonLandscape = find.text('PM');
|
||||
@@ -682,15 +933,17 @@ class _TimePickerLauncher extends StatelessWidget {
|
||||
return ElevatedButton(
|
||||
child: const Text('X'),
|
||||
onPressed: () async {
|
||||
onChanged?.call(await showTimePicker(
|
||||
context: context,
|
||||
initialEntryMode: entryMode,
|
||||
orientation: orientation,
|
||||
initialTime: const TimeOfDay(hour: 7, minute: 0),
|
||||
));
|
||||
onChanged?.call(
|
||||
await showTimePicker(
|
||||
context: context,
|
||||
initialEntryMode: entryMode,
|
||||
orientation: orientation,
|
||||
initialTime: const TimeOfDay(hour: 7, minute: 0),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -701,9 +954,9 @@ class _TimePickerLauncher extends StatelessWidget {
|
||||
Future<Offset> startPicker(
|
||||
WidgetTester tester,
|
||||
ValueChanged<TimeOfDay?> onChanged, {
|
||||
Locale locale = const Locale('en', 'US'),
|
||||
bool? useMaterial3,
|
||||
Orientation? orientation,
|
||||
Locale locale = const Locale('en', 'US'),
|
||||
bool? useMaterial3,
|
||||
Orientation? orientation,
|
||||
}) async {
|
||||
await tester.pumpWidget(
|
||||
_TimePickerLauncher(
|
||||
@@ -719,7 +972,9 @@ Future<Offset> startPicker(
|
||||
}
|
||||
|
||||
Future<void> finishPicker(WidgetTester tester) async {
|
||||
final MaterialLocalizations materialLocalizations = MaterialLocalizations.of(tester.element(find.byType(ElevatedButton)));
|
||||
final MaterialLocalizations materialLocalizations = MaterialLocalizations.of(
|
||||
tester.element(find.byType(ElevatedButton)),
|
||||
);
|
||||
await tester.tap(find.text(materialLocalizations.okButtonLabel));
|
||||
await tester.pumpAndSettle(const Duration(seconds: 1));
|
||||
}
|
||||
|
||||
@@ -21,7 +21,9 @@ void main() {
|
||||
|
||||
expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue);
|
||||
|
||||
final MaterialLocalizations localizations = await GlobalMaterialLocalizations.delegate.load(locale);
|
||||
final MaterialLocalizations localizations = await GlobalMaterialLocalizations.delegate.load(
|
||||
locale,
|
||||
);
|
||||
|
||||
expect(localizations.openAppDrawerTooltip, isNotNull);
|
||||
expect(localizations.backButtonTooltip, isNotNull);
|
||||
@@ -63,9 +65,18 @@ void main() {
|
||||
expect(localizations.remainingTextFieldCharacterCount(0), isNotNull);
|
||||
expect(localizations.remainingTextFieldCharacterCount(1), isNotNull);
|
||||
expect(localizations.remainingTextFieldCharacterCount(10), isNotNull);
|
||||
expect(localizations.remainingTextFieldCharacterCount(0), isNot(contains(r'$remainingCount')));
|
||||
expect(localizations.remainingTextFieldCharacterCount(1), isNot(contains(r'$remainingCount')));
|
||||
expect(localizations.remainingTextFieldCharacterCount(10), isNot(contains(r'$remainingCount')));
|
||||
expect(
|
||||
localizations.remainingTextFieldCharacterCount(0),
|
||||
isNot(contains(r'$remainingCount')),
|
||||
);
|
||||
expect(
|
||||
localizations.remainingTextFieldCharacterCount(1),
|
||||
isNot(contains(r'$remainingCount')),
|
||||
);
|
||||
expect(
|
||||
localizations.remainingTextFieldCharacterCount(10),
|
||||
isNot(contains(r'$remainingCount')),
|
||||
);
|
||||
|
||||
expect(localizations.aboutListTileTitle('FOO'), isNotNull);
|
||||
expect(localizations.aboutListTileTitle('FOO'), contains('FOO'));
|
||||
@@ -125,13 +136,17 @@ void main() {
|
||||
testWidgets('translations spot check expansionTileExpandedHint', (WidgetTester tester) async {
|
||||
const Locale locale = Locale.fromSubtags(languageCode: 'en');
|
||||
expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue);
|
||||
final MaterialLocalizations localizations = await GlobalMaterialLocalizations.delegate.load(locale);
|
||||
final MaterialLocalizations localizations = await GlobalMaterialLocalizations.delegate.load(
|
||||
locale,
|
||||
);
|
||||
expect(localizations, isA<MaterialLocalizationEn>());
|
||||
expect(localizations.expansionTileExpandedHint, 'double tap to collapse');
|
||||
});
|
||||
|
||||
testWidgets('spot check selectedRowCount translations', (WidgetTester tester) async {
|
||||
MaterialLocalizations localizations = await GlobalMaterialLocalizations.delegate.load(const Locale('en'));
|
||||
MaterialLocalizations localizations = await GlobalMaterialLocalizations.delegate.load(
|
||||
const Locale('en'),
|
||||
);
|
||||
expect(localizations.selectedRowCountTitle(0), 'No items selected');
|
||||
expect(localizations.selectedRowCountTitle(1), '1 item selected');
|
||||
expect(localizations.selectedRowCountTitle(2), '2 items selected');
|
||||
@@ -178,8 +193,12 @@ void main() {
|
||||
expect(localizations.selectedRowCountTitle(123456789), 'បានជ្រើសរើសធាតុ 123,456,789');
|
||||
});
|
||||
|
||||
testWidgets('spot check formatMediumDate(), formatFullDate() translations', (WidgetTester tester) async {
|
||||
MaterialLocalizations localizations = await GlobalMaterialLocalizations.delegate.load(const Locale('en'));
|
||||
testWidgets('spot check formatMediumDate(), formatFullDate() translations', (
|
||||
WidgetTester tester,
|
||||
) async {
|
||||
MaterialLocalizations localizations = await GlobalMaterialLocalizations.delegate.load(
|
||||
const Locale('en'),
|
||||
);
|
||||
expect(localizations.formatMediumDate(DateTime(2015, 7, 23)), 'Thu, Jul 23');
|
||||
expect(localizations.formatFullDate(DateTime(2015, 7, 23)), 'Thursday, July 23, 2015');
|
||||
|
||||
@@ -506,13 +525,10 @@ void main() {
|
||||
|
||||
// Regression test for https://github.com/flutter/flutter/issues/36704.
|
||||
testWidgets('kn arb file should be properly Unicode escaped', (WidgetTester tester) async {
|
||||
final File file = File(
|
||||
path.join(rootDirectoryPath, 'lib', 'src', 'l10n', 'material_kn.arb'),
|
||||
);
|
||||
final File file = File(path.join(rootDirectoryPath, 'lib', 'src', 'l10n', 'material_kn.arb'));
|
||||
|
||||
final Map<String, dynamic> bundle = json.decode(
|
||||
file.readAsStringSync(),
|
||||
) as Map<String, dynamic>;
|
||||
final Map<String, dynamic> bundle =
|
||||
json.decode(file.readAsStringSync()) as Map<String, dynamic>;
|
||||
|
||||
// Encodes the arb resource values if they have not already been
|
||||
// encoded.
|
||||
@@ -537,7 +553,9 @@ void main() {
|
||||
testWidgets('Finnish translation for tab label', (WidgetTester tester) async {
|
||||
const Locale locale = Locale('fi');
|
||||
expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue);
|
||||
final MaterialLocalizations localizations = await GlobalMaterialLocalizations.delegate.load(locale);
|
||||
final MaterialLocalizations localizations = await GlobalMaterialLocalizations.delegate.load(
|
||||
locale,
|
||||
);
|
||||
expect(localizations, isA<MaterialLocalizationFi>());
|
||||
expect(localizations.tabLabel(tabIndex: 1, tabCount: 2), 'Välilehti 1 kautta 2');
|
||||
});
|
||||
@@ -546,7 +564,9 @@ void main() {
|
||||
testWidgets('Share button label on Material', (WidgetTester tester) async {
|
||||
const Locale locale = Locale('en');
|
||||
expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue);
|
||||
final MaterialLocalizations localizations = await GlobalMaterialLocalizations.delegate.load(locale);
|
||||
final MaterialLocalizations localizations = await GlobalMaterialLocalizations.delegate.load(
|
||||
locale,
|
||||
);
|
||||
expect(localizations, isA<MaterialLocalizationEn>());
|
||||
expect(localizations.shareButtonLabel, 'Share');
|
||||
});
|
||||
@@ -555,16 +575,22 @@ void main() {
|
||||
testWidgets('zh-CN translation for look up label', (WidgetTester tester) async {
|
||||
const Locale locale = Locale('zh');
|
||||
expect(GlobalCupertinoLocalizations.delegate.isSupported(locale), isTrue);
|
||||
final MaterialLocalizations localizations = await GlobalMaterialLocalizations.delegate.load(locale);
|
||||
final MaterialLocalizations localizations = await GlobalMaterialLocalizations.delegate.load(
|
||||
locale,
|
||||
);
|
||||
expect(localizations, isA<MaterialLocalizationZh>());
|
||||
expect(localizations.lookUpButtonLabel, '查询');
|
||||
});
|
||||
|
||||
// Regression test for https://github.com/flutter/flutter/pull/151364
|
||||
testWidgets('ko-KR translation for cut, copy, paste label in ButtonLabel', (WidgetTester tester) async {
|
||||
testWidgets('ko-KR translation for cut, copy, paste label in ButtonLabel', (
|
||||
WidgetTester tester,
|
||||
) async {
|
||||
const Locale locale = Locale('ko');
|
||||
expect(GlobalCupertinoLocalizations.delegate.isSupported(locale), isTrue);
|
||||
final MaterialLocalizations localizations = await GlobalMaterialLocalizations.delegate.load(locale);
|
||||
final MaterialLocalizations localizations = await GlobalMaterialLocalizations.delegate.load(
|
||||
locale,
|
||||
);
|
||||
expect(localizations, isA<MaterialLocalizationKo>());
|
||||
expect(localizations.cutButtonLabel, '잘라내기');
|
||||
expect(localizations.copyButtonLabel, '복사');
|
||||
|
||||
Reference in New Issue
Block a user