|
@@ -34,8 +34,7 @@ void main() {
|
34
|
34
|
expect(editor.findSelectionHandle(), findsNothing);
|
35
|
35
|
});
|
36
|
36
|
|
37
|
|
- testWidgets('tap outside of text area finds closest paragraph',
|
38
|
|
- (tester) async {
|
|
37
|
+ testWidgets('tap on padding area finds closest paragraph', (tester) async {
|
39
|
38
|
final editor = new EditorSandBox(tester: tester);
|
40
|
39
|
await editor.tapEditor();
|
41
|
40
|
editor.controller
|
|
@@ -52,5 +51,33 @@ void main() {
|
52
|
51
|
expect(editor.controller.selection.isCollapsed, isTrue);
|
53
|
52
|
expect(editor.controller.selection.extentOffset, 0);
|
54
|
53
|
});
|
|
54
|
+
|
|
55
|
+ testWidgets('tap on empty space finds closest paragraph', (tester) async {
|
|
56
|
+ final editor = new EditorSandBox(tester: tester);
|
|
57
|
+ await editor.tapEditor();
|
|
58
|
+ editor.controller.replaceText(10, 1, '\n',
|
|
59
|
+ selection: new TextSelection.collapsed(offset: 0));
|
|
60
|
+ await tester.pumpAndSettle();
|
|
61
|
+ expect(editor.controller.document.toPlainText(),
|
|
62
|
+ 'This House\nIs A Circus\n');
|
|
63
|
+ expect(editor.controller.selection.extentOffset, 0);
|
|
64
|
+
|
|
65
|
+ RenderBox renderObject =
|
|
66
|
+ tester.firstRenderObject(find.byType(ZefyrEditableText));
|
|
67
|
+ var offset = renderObject.localToGlobal(Offset.zero);
|
|
68
|
+ offset += Offset(50.0, renderObject.size.height - 5.0);
|
|
69
|
+ await tester.tapAt(offset);
|
|
70
|
+ await tester.pumpAndSettle();
|
|
71
|
+ expect(editor.controller.selection.isCollapsed, isTrue);
|
|
72
|
+ expect(editor.controller.selection.extentOffset,
|
|
73
|
+ 13); // Note that this is probably too fragile.
|
|
74
|
+
|
|
75
|
+ offset = renderObject.localToGlobal(Offset.zero) + Offset(50.0, 1.0);
|
|
76
|
+ await tester.tapAt(offset);
|
|
77
|
+ await tester.pumpAndSettle();
|
|
78
|
+ expect(editor.controller.selection.isCollapsed, isTrue);
|
|
79
|
+ expect(editor.controller.selection.extentOffset,
|
|
80
|
+ 2); // Note that this is probably too fragile.
|
|
81
|
+ });
|
55
|
82
|
});
|
56
|
83
|
}
|