Unverified Commit 29618f0b authored by Gary Qian's avatar Gary Qian Committed by GitHub

Roll engine for flutter/engine#7791 - Add trailing whitespace tracking.

parent 70dfe01a
3757390fa4b00d2d261bfdf5182d2e87c9113ff9
033f2072c315d48b4d7680d4cbbe856012b1259b
......@@ -4620,4 +4620,93 @@ void main() {
'selection disabled'
]);
});
testWidgets('Caret center position', (WidgetTester tester) async {
await tester.pumpWidget(
overlay(
child: Container(
width: 300.0,
child: const TextField(
textAlign: TextAlign.center,
decoration: null,
),
),
),
);
final RenderEditable editable = findRenderEditable(tester);
await tester.enterText(find.byType(TextField), 'abcd');
await tester.pump();
Offset topLeft = editable.localToGlobal(
editable.getLocalRectForCaret(const TextPosition(offset: 4)).topLeft,
);
expect(topLeft.dx, equals(431));
topLeft = editable.localToGlobal(
editable.getLocalRectForCaret(const TextPosition(offset: 3)).topLeft,
);
expect(topLeft.dx, equals(415));
topLeft = editable.localToGlobal(
editable.getLocalRectForCaret(const TextPosition(offset: 2)).topLeft,
);
expect(topLeft.dx, equals(399));
topLeft = editable.localToGlobal(
editable.getLocalRectForCaret(const TextPosition(offset: 1)).topLeft,
);
expect(topLeft.dx, equals(383));
});
testWidgets('Caret indexes into trailing whitespace center align', (WidgetTester tester) async {
await tester.pumpWidget(
overlay(
child: Container(
width: 300.0,
child: const TextField(
textAlign: TextAlign.center,
decoration: null,
),
),
),
);
final RenderEditable editable = findRenderEditable(tester);
await tester.enterText(find.byType(TextField), 'abcd ');
await tester.pump();
Offset topLeft = editable.localToGlobal(
editable.getLocalRectForCaret(const TextPosition(offset: 7)).topLeft,
);
expect(topLeft.dx, equals(479));
topLeft = editable.localToGlobal(
editable.getLocalRectForCaret(const TextPosition(offset: 8)).topLeft,
);
expect(topLeft.dx, equals(495));
topLeft = editable.localToGlobal(
editable.getLocalRectForCaret(const TextPosition(offset: 4)).topLeft,
);
expect(topLeft.dx, equals(431));
topLeft = editable.localToGlobal(
editable.getLocalRectForCaret(const TextPosition(offset: 3)).topLeft,
);
expect(topLeft.dx, equals(415)); // Should be same as equivalent in 'Caret center position'
topLeft = editable.localToGlobal(
editable.getLocalRectForCaret(const TextPosition(offset: 2)).topLeft,
);
expect(topLeft.dx, equals(399)); // Should be same as equivalent in 'Caret center position'
topLeft = editable.localToGlobal(
editable.getLocalRectForCaret(const TextPosition(offset: 1)).topLeft,
);
expect(topLeft.dx, equals(383)); // Should be same as equivalent in 'Caret center position'
});
}
......@@ -133,7 +133,7 @@ void main() {
Offset caretOffset = painter.getOffsetForCaret(const ui.TextPosition(offset: 0), ui.Rect.zero);
expect(caretOffset.dx, 21);
caretOffset = painter.getOffsetForCaret(const ui.TextPosition(offset: text.length), ui.Rect.zero);
expect(caretOffset.dx, 399);
expect(caretOffset.dx, 441);
caretOffset = painter.getOffsetForCaret(const ui.TextPosition(offset: 1), ui.Rect.zero);
expect(caretOffset.dx, 35);
......
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