From aa450d566016b2553052e0b315fbfd103f6f4724 Mon Sep 17 00:00:00 2001 From: xster Date: Tue, 7 May 2019 11:47:59 -0700 Subject: [PATCH] Cupertino localization step 9: add tests (#29954) --- .../lib/flutter_localizations.dart | 2 + .../test/cupertino/translations_test.dart | 105 ++++++++++++++++++ .../test/{ => material}/date_picker_test.dart | 0 .../test/{ => material}/date_time_test.dart | 0 .../test/{ => material}/time_picker_test.dart | 0 .../{ => material}/translations_test.dart | 0 6 files changed, 107 insertions(+) create mode 100644 packages/flutter_localizations/test/cupertino/translations_test.dart rename packages/flutter_localizations/test/{ => material}/date_picker_test.dart (100%) rename packages/flutter_localizations/test/{ => material}/date_time_test.dart (100%) rename packages/flutter_localizations/test/{ => material}/time_picker_test.dart (100%) rename packages/flutter_localizations/test/{ => material}/translations_test.dart (100%) diff --git a/packages/flutter_localizations/lib/flutter_localizations.dart b/packages/flutter_localizations/lib/flutter_localizations.dart index 354a9254f6..1cbaf9de33 100644 --- a/packages/flutter_localizations/lib/flutter_localizations.dart +++ b/packages/flutter_localizations/lib/flutter_localizations.dart @@ -5,6 +5,8 @@ /// Localizations for the Flutter library library flutter_localizations; +export 'src/cupertino_localizations.dart'; +export 'src/l10n/generated_cupertino_localizations.dart'; export 'src/l10n/generated_material_localizations.dart'; export 'src/material_localizations.dart'; export 'src/widgets_localizations.dart'; diff --git a/packages/flutter_localizations/test/cupertino/translations_test.dart b/packages/flutter_localizations/test/cupertino/translations_test.dart new file mode 100644 index 0000000000..78db6d24c2 --- /dev/null +++ b/packages/flutter_localizations/test/cupertino/translations_test.dart @@ -0,0 +1,105 @@ +// Copyright 2017 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. + +import 'package:flutter/cupertino.dart'; +import 'package:flutter_localizations/flutter_localizations.dart'; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + for (String language in kCupertinoSupportedLanguages) { + testWidgets('translations exist for $language', (WidgetTester tester) async { + final Locale locale = Locale(language); + + expect(GlobalCupertinoLocalizations.delegate.isSupported(locale), isTrue); + + final CupertinoLocalizations localizations = await GlobalCupertinoLocalizations.delegate.load(locale); + + expect(localizations.datePickerYear(0), isNotNull); + expect(localizations.datePickerYear(1), isNotNull); + expect(localizations.datePickerYear(2), isNotNull); + expect(localizations.datePickerYear(10), isNotNull); + + expect(localizations.datePickerMonth(1), isNotNull); + expect(localizations.datePickerMonth(2), isNotNull); + expect(localizations.datePickerMonth(11), isNotNull); + expect(localizations.datePickerMonth(12), isNotNull); + + expect(localizations.datePickerDayOfMonth(0), isNotNull); + expect(localizations.datePickerDayOfMonth(1), isNotNull); + expect(localizations.datePickerDayOfMonth(2), isNotNull); + expect(localizations.datePickerDayOfMonth(10), isNotNull); + + expect(localizations.datePickerMediumDate(DateTime(2019, 3, 25)), isNotNull); + + expect(localizations.datePickerHour(0), isNotNull); + expect(localizations.datePickerHour(1), isNotNull); + expect(localizations.datePickerHour(2), isNotNull); + expect(localizations.datePickerHour(10), isNotNull); + + expect(localizations.datePickerHourSemanticsLabel(0), isNotNull); + expect(localizations.datePickerHourSemanticsLabel(1), isNotNull); + expect(localizations.datePickerHourSemanticsLabel(2), isNotNull); + expect(localizations.datePickerHourSemanticsLabel(10), isNotNull); + expect(localizations.datePickerHourSemanticsLabel(0), isNot(contains(r'$hour'))); + expect(localizations.datePickerHourSemanticsLabel(1), isNot(contains(r'$hour'))); + expect(localizations.datePickerHourSemanticsLabel(2), isNot(contains(r'$hour'))); + expect(localizations.datePickerHourSemanticsLabel(10), isNot(contains(r'$hour'))); + + expect(localizations.datePickerDateOrder, isNotNull); + expect(localizations.datePickerDateTimeOrder, isNotNull); + expect(localizations.anteMeridiemAbbreviation, isNotNull); + expect(localizations.postMeridiemAbbreviation, isNotNull); + expect(localizations.alertDialogLabel, isNotNull); + + expect(localizations.timerPickerHour(0), isNotNull); + expect(localizations.timerPickerHour(1), isNotNull); + expect(localizations.timerPickerHour(2), isNotNull); + expect(localizations.timerPickerHour(10), isNotNull); + + expect(localizations.timerPickerMinute(0), isNotNull); + expect(localizations.timerPickerMinute(1), isNotNull); + expect(localizations.timerPickerMinute(2), isNotNull); + expect(localizations.timerPickerMinute(10), isNotNull); + + expect(localizations.timerPickerSecond(0), isNotNull); + expect(localizations.timerPickerSecond(1), isNotNull); + expect(localizations.timerPickerSecond(2), isNotNull); + expect(localizations.timerPickerSecond(10), isNotNull); + + expect(localizations.timerPickerHourLabel(0), isNotNull); + expect(localizations.timerPickerHourLabel(1), isNotNull); + expect(localizations.timerPickerHourLabel(2), isNotNull); + expect(localizations.timerPickerHourLabel(10), isNotNull); + + expect(localizations.timerPickerMinuteLabel(0), isNotNull); + expect(localizations.timerPickerMinuteLabel(1), isNotNull); + expect(localizations.timerPickerMinuteLabel(2), isNotNull); + expect(localizations.timerPickerMinuteLabel(10), isNotNull); + + expect(localizations.timerPickerSecondLabel(0), isNotNull); + expect(localizations.timerPickerSecondLabel(1), isNotNull); + expect(localizations.timerPickerSecondLabel(2), isNotNull); + expect(localizations.timerPickerSecondLabel(10), isNotNull); + + expect(localizations.cutButtonLabel, isNotNull); + expect(localizations.copyButtonLabel, isNotNull); + expect(localizations.pasteButtonLabel, isNotNull); + expect(localizations.selectAllButtonLabel, isNotNull); + }); + } + + testWidgets('Spot check French', (WidgetTester tester) async { + const Locale locale = Locale.fromSubtags(languageCode: 'fr', scriptCode: null, countryCode: null); + expect(GlobalCupertinoLocalizations.delegate.isSupported(locale), isTrue); + final CupertinoLocalizations localizations = await GlobalCupertinoLocalizations.delegate.load(locale); + expect(localizations is CupertinoLocalizationFr, true); + expect(localizations.alertDialogLabel, 'Alerte'); + expect(localizations.datePickerHourSemanticsLabel(1), 'une heure'); + expect(localizations.pasteButtonLabel, 'Coller'); + expect(localizations.datePickerDateOrder, DatePickerDateOrder.dmy); + expect(localizations.timerPickerSecondLabel(20), 's'); + expect(localizations.selectAllButtonLabel, 'Tout sélect.'); + expect(localizations.timerPickerMinute(10), '10'); + }); +} diff --git a/packages/flutter_localizations/test/date_picker_test.dart b/packages/flutter_localizations/test/material/date_picker_test.dart similarity index 100% rename from packages/flutter_localizations/test/date_picker_test.dart rename to packages/flutter_localizations/test/material/date_picker_test.dart diff --git a/packages/flutter_localizations/test/date_time_test.dart b/packages/flutter_localizations/test/material/date_time_test.dart similarity index 100% rename from packages/flutter_localizations/test/date_time_test.dart rename to packages/flutter_localizations/test/material/date_time_test.dart diff --git a/packages/flutter_localizations/test/time_picker_test.dart b/packages/flutter_localizations/test/material/time_picker_test.dart similarity index 100% rename from packages/flutter_localizations/test/time_picker_test.dart rename to packages/flutter_localizations/test/material/time_picker_test.dart diff --git a/packages/flutter_localizations/test/translations_test.dart b/packages/flutter_localizations/test/material/translations_test.dart similarity index 100% rename from packages/flutter_localizations/test/translations_test.dart rename to packages/flutter_localizations/test/material/translations_test.dart