Skip to content

Migrate time picker tests cases relying on localization from material_ui to flutter_localization#188753

Draft
elliette wants to merge 3 commits into
flutter:masterfrom
elliette:time-picker-localizations
Draft

Migrate time picker tests cases relying on localization from material_ui to flutter_localization#188753
elliette wants to merge 3 commits into
flutter:masterfrom
elliette:time-picker-localizations

Conversation

@elliette

@elliette elliette commented Jun 29, 2026

Copy link
Copy Markdown
Member

Work towards #188757

The added test cases in this PR were split out of flutter/packages#12061. To avoid a circular dependency in material_ui, we are moving any test cases that depend on flutter_localizations out of the material_ui package and into flutter_localizations.

Note: One of those test cases is currently skipped, since it relies on golden testing infrastructure that is not currently enabled for flutter_localizations. I've filed #188758 to track re-enabling it.

@github-actions github-actions Bot added framework flutter/packages/flutter repository. See also f: labels. f: material design flutter/packages/flutter/material repository. a: internationalization Supporting other languages or locales. (aka i18n) labels Jun 29, 2026
@elliette elliette added the CICD Run CI/CD label Jun 29, 2026
@elliette
elliette force-pushed the time-picker-localizations branch from 234b7ab to 7184892 Compare June 30, 2026 17:26

// This file is run as part of a reduced test set in CI on Mac and Windows
// machines.
@Tags(<String>['reduced-test-set'])

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems a bit weird to need to add this when the only golden test is currently skipped. I could also move that test case to a temporarily_disabled_test directory (like we had in cupertino_ui/material_ui) if that's preferred.

@elliette elliette changed the title [Draft] Migrate time picker tests cases relying on localization from material_ui to flutter_localization Migrate time picker tests cases relying on localization from material_ui to flutter_localization Jun 30, 2026
@elliette
elliette marked this pull request as ready for review June 30, 2026 18:42

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the mediaQueryBoilerplate helper in time_picker_test.dart to support custom locales and adds regression tests for Farsi 24-hour formatting, non-English separator alignment, and Korean day period spacing. The review feedback suggests extending mediaQueryBoilerplate with a textDirection parameter to properly support and test right-to-left (RTL) layouts, specifically for the new Farsi test case.

Comment on lines 659 to +681
WidgetTester tester, {
required bool alwaysUse24HourFormat,
required bool useMaterial3,
Locale locale = const Locale('en', 'US'),
}) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeData(useMaterial3: useMaterial3),
builder: (BuildContext context, Widget? child) {
return MediaQuery(
data: MediaQueryData(alwaysUse24HourFormat: alwaysUse24HourFormat),
child: child!,
);
},
home: Material(
child: Directionality(
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),
Theme(
data: ThemeData(useMaterial3: useMaterial3),
child: Localizations(
locale: locale,
delegates: const <LocalizationsDelegate<dynamic>>[
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
],
child: MediaQuery(
data: MediaQueryData(
alwaysUse24HourFormat: alwaysUse24HourFormat,
size: tester.view.physicalSize / tester.view.devicePixelRatio,
),
child: Material(
child: Directionality(
textDirection: TextDirection.ltr,
child: Navigator(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The mediaQueryBoilerplate helper currently hardcodes textDirection: TextDirection.ltr. Since this helper is now being used for localized tests (including RTL locales like Farsi fa_IR), hardcoding LTR prevents the time picker from being tested in its actual RTL layout.

To fix this, we should add an optional textDirection parameter to mediaQueryBoilerplate and pass it to the Directionality widget.

    WidgetTester tester, {
    required bool alwaysUse24HourFormat,
    required bool useMaterial3,
    Locale locale = const Locale('en', 'US'),
    TextDirection textDirection = TextDirection.ltr,
  }) async {
    await tester.pumpWidget(
      Theme(
        data: ThemeData(useMaterial3: useMaterial3),
        child: Localizations(
          locale: locale,
          delegates: const <LocalizationsDelegate<dynamic>>[
            GlobalMaterialLocalizations.delegate,
            GlobalWidgetsLocalizations.delegate,
          ],
          child: MediaQuery(
            data: MediaQueryData(
              alwaysUse24HourFormat: alwaysUse24HourFormat,
              size: tester.view.physicalSize / tester.view.devicePixelRatio,
            ),
            child: Material(
              child: Directionality(
                textDirection: textDirection,
                child: Navigator(

Comment on lines +873 to +878
await mediaQueryBoilerplate(
tester,
locale: const Locale('fa', 'IR'),
useMaterial3: true,
alwaysUse24HourFormat: true,
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Pass textDirection: TextDirection.rtl to mediaQueryBoilerplate so that the Farsi time picker test runs with the correct RTL layout.

    await mediaQueryBoilerplate(
      tester,
      locale: const Locale('fa', 'IR'),
      textDirection: TextDirection.rtl,
      useMaterial3: true,
      alwaysUse24HourFormat: true,
    );

auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Jun 30, 2026
Port over `time_picker_test` from flutter/flutter#184279

The test cases that depend on `flutter_localizations` are being moved to `flutter_localizations` in PR flutter/flutter#188753, see flutter/flutter#188757 for rationale.

Work towards flutter/flutter#182636 and flutter/flutter#188395

## Pre-Review Checklist

**Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

[^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling.
@Piinks
Piinks marked this pull request as draft July 15, 2026 21:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: internationalization Supporting other languages or locales. (aka i18n) CICD Run CI/CD f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.

Projects

Development

Successfully merging this pull request may close these issues.

2 participants