Repository navigation
Commit 9562905
committed
Make material/text_field_test.dart independent of test order
The overlay() and overlayWithEntry() helpers in this file pump a TextField
with no Theme ancestor, so Theme.of resolves to the process-wide fallback
ThemeData. That fallback is built once, at the first theme-less Theme.of
call in the run, and freezes `platform` to whatever defaultTargetPlatform
was at that moment. In declaration order that first call happens on
android, so every test in the file, including the TargetPlatformVariant
iOS/macOS/windows/linux/fuchsia variants, ran with Material selection
handles, toolbar, and cursor behavior. Under
--test-randomize-ordering-seed=20261008 the first theme-less call happens
inside an iOS variant, the fallback becomes iOS for the whole run, and 17
tests fail (handle drags land on the Cupertino toolbar, 'Select all' is not
in the Cupertino menu, the cursor animates instead of blinking, the caret
is offset by the iOS cursorOffset). Those failures then leak a semantics
handle that breaks 28 more semantics tests later in the run.
Give the helpers an explicit `theme` parameter that defaults to a ThemeData
built for the platform in effect, so each test gets the theme for its own
TargetPlatformVariant regardless of test order. The 14 tests that wrapped
overlay() in their own Theme pass it through the parameter instead, so an
inner Theme does not shadow them.
Five variant instances of the two handle-drag tests only passed because of
the frozen android fallback: macOS, Linux, and Windows selection controls
draw no handles at all, and the Cupertino start handle is not where the
test grabbed it. Replace them with tests of what each platform does: iOS
drags Cupertino handles (with the toolbar hidden, since it overlaps the
start handle), Android and Fuchsia drag Material handles (Fuchsia's
desktop-style toolbar otherwise covers them), and desktop platforms show
no handles.
Also drop the `no-shuffle` tag, whose definition was removed from
dart_test.yaml in flutter#191499, along with the stale TODO that pointed at an
unrelated closed issue.
Fixes flutter#1940081 parent 9b57590 commit 9562905
1 file changed
Lines changed: 296 additions & 281 deletions
0 commit comments