Skip to content

Commit

Permalink
Test start handle drag
Browse files Browse the repository at this point in the history
  • Loading branch information
amantoux committed Dec 28, 2023
1 parent c4afea7 commit 2c0e22c
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion packages/fleather/test/widgets/editor_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ void main() {
const TypeMatcher<MaterialTextSelectionControls>());
}, [TargetPlatform.android]);

testWidgets('Dragging selection handle shows magnifier', (tester) async {
testWidgets('drag selection end handle shows magnifier', (tester) async {
final document = ParchmentDocument.fromJson([
{'insert': 'Some piece of text\n'}
]);
Expand Down Expand Up @@ -470,6 +470,36 @@ void main() {
expect(magnifier, findsNothing);
});

testWidgets('drag selection start handle shows magnifier',
(tester) async {
final document = ParchmentDocument.fromJson([
{'insert': 'Some piece of text\n'}
]);
final editor =
EditorSandBox(tester: tester, document: document, autofocus: true);
await editor.pump();
await tester.tapAt(tester.getBottomLeft(find.byType(FleatherEditor)) +
const Offset(100, -1));
await tester.tapAt(tester.getBottomLeft(find.byType(FleatherEditor)) +
const Offset(100, -1));
tester.binding.scheduleWarmUpFrame();
await tester.pump();
final handleOverlays = find.byType(SelectionHandleOverlay);
expect(handleOverlays, findsNWidgets(2));
final startHandle = find.descendant(
of: handleOverlays.first, matching: find.byType(SizedBox));
expect(startHandle, findsOneWidget);
final gesture = await tester.startGesture(
tester.getBottomRight(startHandle) - const Offset(-1, 1));
await gesture.moveBy(const Offset(-15, 0));
await tester.pump();
final magnifier = find.byType(TextMagnifier);
expect(magnifier, findsOneWidget);
await gesture.up();
await tester.pump();
expect(magnifier, findsNothing);
});

testWidgetsWithPlatform('selection handles for Windows', (tester) async {
final document = ParchmentDocument();
final editor =
Expand Down

0 comments on commit 2c0e22c

Please sign in to comment.