Unverified Commit 1fe24956 authored by Bruno Leroux's avatar Bruno Leroux Committed by GitHub

Update SelectableRegion test for M3 (#129627)

## Description

This PR  fixes one selectable region test failure when switching to M3.
The failure is somewhat tricky because it is related to the M3 typography (line height set to 1.43).

## Related Issue

fixes https://github.com/flutter/flutter/issues/129626

## Tests

Updates 1 test.
parent 56ea352c
...@@ -2052,15 +2052,15 @@ abstract class MultiSelectableSelectionContainerDelegate extends SelectionContai ...@@ -2052,15 +2052,15 @@ abstract class MultiSelectableSelectionContainerDelegate extends SelectionContai
if (globalRect.contains(event.globalPosition)) { if (globalRect.contains(event.globalPosition)) {
final SelectionGeometry existingGeometry = selectables[index].value; final SelectionGeometry existingGeometry = selectables[index].value;
lastSelectionResult = dispatchSelectionEventToChild(selectables[index], event); lastSelectionResult = dispatchSelectionEventToChild(selectables[index], event);
if (index == selectables.length - 1 && lastSelectionResult == SelectionResult.next) {
return SelectionResult.next;
}
if (lastSelectionResult == SelectionResult.next) { if (lastSelectionResult == SelectionResult.next) {
continue; continue;
} }
if (index == 0 && lastSelectionResult == SelectionResult.previous) { if (index == 0 && lastSelectionResult == SelectionResult.previous) {
return SelectionResult.previous; return SelectionResult.previous;
} }
if (index == selectables.length - 1 && lastSelectionResult == SelectionResult.next) {
return SelectionResult.next;
}
if (selectables[index].value != existingGeometry) { if (selectables[index].value != existingGeometry) {
// Geometry has changed as a result of select word, need to clear the // Geometry has changed as a result of select word, need to clear the
// selection of other selectables to keep selection in sync. // selection of other selectables to keep selection in sync.
......
...@@ -1570,7 +1570,6 @@ void main() { ...@@ -1570,7 +1570,6 @@ void main() {
final UniqueKey outerText = UniqueKey(); final UniqueKey outerText = UniqueKey();
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
theme: ThemeData(useMaterial3: false),
home: SelectableRegion( home: SelectableRegion(
focusNode: FocusNode(), focusNode: FocusNode(),
selectionControls: materialTextSelectionControls, selectionControls: materialTextSelectionControls,
...@@ -1595,8 +1594,13 @@ void main() { ...@@ -1595,8 +1594,13 @@ void main() {
), ),
); );
final RenderParagraph paragraph = tester.renderObject<RenderParagraph>(find.descendant(of: find.byKey(outerText), matching: find.byType(RichText)).first); final RenderParagraph paragraph = tester.renderObject<RenderParagraph>(find.descendant(of: find.byKey(outerText), matching: find.byType(RichText)).first);
// Adjust `textOffsetToPosition` result because it returns the wrong vertical position (wrong line).
// TODO(bleroux): Remove when https://github.com/flutter/flutter/issues/133637 is fixed.
final Offset gestureOffset = textOffsetToPosition(paragraph, 125).translate(0, 10);
// Right click to select word at position. // Right click to select word at position.
final TestGesture gesture = await tester.startGesture(textOffsetToPosition(paragraph, 125), kind: PointerDeviceKind.mouse, buttons: kSecondaryMouseButton); final TestGesture gesture = await tester.startGesture(gestureOffset, kind: PointerDeviceKind.mouse, buttons: kSecondaryMouseButton);
addTearDown(gesture.removePointer); addTearDown(gesture.removePointer);
await tester.pump(); await tester.pump();
await gesture.up(); await gesture.up();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment