Skip to content

Commit 13d38e0

Browse files
authored
[material_ui] Unskip long press drag test on web (#13358)
Follow-up to flutter/flutter#194877. `long press drag extends the selection to the word under the drag and shows toolbar on lift on non-Apple platforms` is skipped on the web, but the only thing that actually breaks there is the drag geometry: `textOffsetToPosition` nudges the position by 1px on web, so `moveBy(const Offset(-200, 0))` lands exactly on the glyph boundary between `Peel` and the following space, and `getWordAtOffset` resolves to the whitespace instead of the word. `_expectMaterialToolbarForPartialSelection()` already handles `isContextMenuProvidedByPlatform`, so the skip is not needed once the drag targets are fixed. This PR drags to the middle of each target word instead of relative offsets, drops the skip, and tags the test with `reduced-web-test-set` so it runs on the web shards. Verified with `flutter test`, `flutter test --platform chrome`, and `flutter test --platform chrome --wasm`. Test-only change, so no version bump or CHANGELOG entry is needed.
1 parent 8cdc6e5 commit 13d38e0

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

‎packages/material_ui/test/text_field_test.dart‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12714,24 +12714,26 @@ void main() {
1271412714
// Cursor move doesn't trigger a toolbar initially.
1271512715
_expectNoMaterialToolbar();
1271612716

12717-
await gesture.moveBy(const Offset(100, 0));
12717+
// Drag into the middle of 'Bonaventure'.
12718+
await gesture.moveTo(textOffsetToPosition(tester, 30));
1271812719
await tester.pump();
1271912720

1272012721
// The selection is now moved with the drag.
1272112722
expect(controller.selection, const TextSelection(baseOffset: 13, extentOffset: 35));
1272212723
// Still no toolbar.
1272312724
_expectNoMaterialToolbar();
1272412725

12725-
// The selection is moved on a backwards drag.
12726-
await gesture.moveBy(const Offset(-200, 0));
12726+
// The selection is moved on a backwards drag into the middle of 'Peel'.
12727+
await gesture.moveTo(textOffsetToPosition(tester, 10));
1272712728
await tester.pump();
1272812729

1272912730
// The selection is now moved with the drag.
1273012731
expect(controller.selection, const TextSelection(baseOffset: 23, extentOffset: 8));
1273112732
// Still no toolbar.
1273212733
_expectNoMaterialToolbar();
1273312734

12734-
await gesture.moveBy(const Offset(-100, 0));
12735+
// Drag into the middle of 'Atwater'.
12736+
await gesture.moveTo(textOffsetToPosition(tester, 3));
1273512737
await tester.pump();
1273612738

1273712739
// The selection is now moved with the drag.
@@ -12750,7 +12752,7 @@ void main() {
1275012752
variant: TargetPlatformVariant.all(
1275112753
excluding: <TargetPlatform>{TargetPlatform.iOS, TargetPlatform.macOS},
1275212754
),
12753-
skip: isContextMenuProvidedByPlatform, // [intended] only applies to platforms where we supply the context menu.
12755+
tags: 'reduced-web-test-set',
1275412756
);
1275512757

1275612758
testWidgets(

0 commit comments

Comments
 (0)