Browse Source

Merge pull request #75 from memspace/autofocus-fix

Fix for autofocus not working
Anatoly Pulyaevskiy 6 years ago
parent
commit
03d95a582b
No account linked to committer's email address

+ 4
- 0
packages/zefyr/CHANGELOG.md View File

1
+## Unreleased
2
+
3
+- Fixed autofocus not being triggered when set to `true` for the first time.
4
+
1
 ## 0.3.0
5
 ## 0.3.0
2
 
6
 
3
 This version introduces new widget `ZefyrScaffold` which allows embedding Zefyr in custom
7
 This version introduces new widget `ZefyrScaffold` which allows embedding Zefyr in custom

+ 1
- 1
packages/zefyr/example/lib/src/form.dart View File

56
         decoration: InputDecoration(labelText: 'Description'),
56
         decoration: InputDecoration(labelText: 'Description'),
57
         controller: _controller,
57
         controller: _controller,
58
         focusNode: _focusNode,
58
         focusNode: _focusNode,
59
-        autofocus: false,
59
+        autofocus: true,
60
         imageDelegate: new CustomImageDelegate(),
60
         imageDelegate: new CustomImageDelegate(),
61
         physics: ClampingScrollPhysics(),
61
         physics: ClampingScrollPhysics(),
62
       ),
62
       ),

+ 1
- 1
packages/zefyr/example/lib/src/full_page.dart View File

31
     r'g":2}},{"insert":"Of course:\nimport ‘package:flutter/material.dart’;"},{"insert":"\n","attributes":{"block":"code"}},{"insert":"import ‘package:zefyr/zefyr.dart’;"},{"insert":"\n\n","attributes":{"block":"code"}},{"insert":"void main() {"},{"insert":"\n","attributes":{"block":"code"}},{"insert":" runApp(MyZefyrApp());"},{"insert":"\n","attributes":{"block":"code"}},{"insert":"}"},{"insert":"\n","attributes":{"block":"code"}},{"insert":"\n\n\n"}]';
31
     r'g":2}},{"insert":"Of course:\nimport ‘package:flutter/material.dart’;"},{"insert":"\n","attributes":{"block":"code"}},{"insert":"import ‘package:zefyr/zefyr.dart’;"},{"insert":"\n\n","attributes":{"block":"code"}},{"insert":"void main() {"},{"insert":"\n","attributes":{"block":"code"}},{"insert":" runApp(MyZefyrApp());"},{"insert":"\n","attributes":{"block":"code"}},{"insert":"}"},{"insert":"\n","attributes":{"block":"code"}},{"insert":"\n\n\n"}]';
32
 
32
 
33
 Delta getDelta() {
33
 Delta getDelta() {
34
-  return Delta.fromJson(json.decode(doc));
34
+  return Delta.fromJson(json.decode(doc) as List);
35
 }
35
 }
36
 
36
 
37
 class _FullPageEditorScreenState extends State<FullPageEditorScreen> {
37
 class _FullPageEditorScreenState extends State<FullPageEditorScreen> {

+ 18
- 8
packages/zefyr/lib/src/widgets/editable_text.dart View File

119
       FocusScope.of(context).requestFocus(focusNode);
119
       FocusScope.of(context).requestFocus(focusNode);
120
   }
120
   }
121
 
121
 
122
+  void focusOrUnfocusIfNeeded() {
123
+    if (!_didAutoFocus && widget.autofocus && widget.enabled) {
124
+      FocusScope.of(context).autofocus(focusNode);
125
+      _didAutoFocus = true;
126
+    }
127
+    if (!widget.enabled && focusNode.hasFocus) {
128
+      _didAutoFocus = false;
129
+      focusNode.unfocus();
130
+    }
131
+  }
132
+
122
   //
133
   //
123
   // Overridden members of State
134
   // Overridden members of State
124
   //
135
   //
169
   void didUpdateWidget(ZefyrEditableText oldWidget) {
180
   void didUpdateWidget(ZefyrEditableText oldWidget) {
170
     super.didUpdateWidget(oldWidget);
181
     super.didUpdateWidget(oldWidget);
171
     _updateSubscriptions(oldWidget);
182
     _updateSubscriptions(oldWidget);
172
-    if (!_didAutoFocus && widget.autofocus && widget.enabled) {
173
-      FocusScope.of(context).autofocus(focusNode);
174
-      _didAutoFocus = true;
175
-    }
176
-    if (!widget.enabled && focusNode.hasFocus) {
177
-      _didAutoFocus = false;
178
-      focusNode.unfocus();
179
-    }
183
+    focusOrUnfocusIfNeeded();
184
+  }
185
+
186
+  @override
187
+  void didChangeDependencies() {
188
+    super.didChangeDependencies();
189
+    focusOrUnfocusIfNeeded();
180
   }
190
   }
181
 
191
 
182
   @override
192
   @override

+ 20
- 3
packages/zefyr/test/testing.dart View File

21
     FocusNode focusNode,
21
     FocusNode focusNode,
22
     NotusDocument document,
22
     NotusDocument document,
23
     ZefyrThemeData theme,
23
     ZefyrThemeData theme,
24
+    bool autofocus: false,
24
   }) {
25
   }) {
25
     focusNode ??= FocusNode();
26
     focusNode ??= FocusNode();
26
     document ??= NotusDocument.fromDelta(delta);
27
     document ??= NotusDocument.fromDelta(delta);
27
     var controller = ZefyrController(document);
28
     var controller = ZefyrController(document);
28
 
29
 
29
-    Widget widget = _ZefyrSandbox(controller: controller, focusNode: focusNode);
30
+    Widget widget = _ZefyrSandbox(
31
+      controller: controller,
32
+      focusNode: focusNode,
33
+      autofocus: autofocus,
34
+    );
35
+
30
     if (theme != null) {
36
     if (theme != null) {
31
       widget = ZefyrTheme(data: theme, child: widget);
37
       widget = ZefyrTheme(data: theme, child: widget);
32
     }
38
     }
60
     return tester.pumpAndSettle();
66
     return tester.pumpAndSettle();
61
   }
67
   }
62
 
68
 
63
-  Future<void> tapEditor() async {
69
+  Future<void> pump() async {
64
     await tester.pumpWidget(widget);
70
     await tester.pumpWidget(widget);
71
+  }
72
+
73
+  Future<void> tap() async {
65
     await tester.tap(find.byType(ZefyrParagraph).first);
74
     await tester.tap(find.byType(ZefyrParagraph).first);
66
     await tester.pumpAndSettle();
75
     await tester.pumpAndSettle();
67
     expect(focusNode.hasFocus, isTrue);
76
     expect(focusNode.hasFocus, isTrue);
68
   }
77
   }
69
 
78
 
79
+  Future<void> pumpAndTap() async {
80
+    await pump();
81
+    await tap();
82
+  }
83
+
70
   Future<void> tapHideKeyboardButton() async {
84
   Future<void> tapHideKeyboardButton() async {
71
     await tapButtonWithIcon(Icons.keyboard_hide);
85
     await tapButtonWithIcon(Icons.keyboard_hide);
72
   }
86
   }
101
 }
115
 }
102
 
116
 
103
 class _ZefyrSandbox extends StatefulWidget {
117
 class _ZefyrSandbox extends StatefulWidget {
104
-  const _ZefyrSandbox({Key key, this.controller, this.focusNode})
118
+  const _ZefyrSandbox(
119
+      {Key key, this.controller, this.focusNode, this.autofocus})
105
       : super(key: key);
120
       : super(key: key);
106
   final ZefyrController controller;
121
   final ZefyrController controller;
107
   final FocusNode focusNode;
122
   final FocusNode focusNode;
123
+  final bool autofocus;
108
 
124
 
109
   @override
125
   @override
110
   _ZefyrSandboxState createState() => _ZefyrSandboxState();
126
   _ZefyrSandboxState createState() => _ZefyrSandboxState();
119
       controller: widget.controller,
135
       controller: widget.controller,
120
       focusNode: widget.focusNode,
136
       focusNode: widget.focusNode,
121
       enabled: _enabled,
137
       enabled: _enabled,
138
+      autofocus: widget.autofocus,
122
     );
139
     );
123
   }
140
   }
124
 
141
 

+ 12
- 12
packages/zefyr/test/widgets/buttons_test.dart View File

13
   group('$ZefyrButton', () {
13
   group('$ZefyrButton', () {
14
     testWidgets('toggle style', (tester) async {
14
     testWidgets('toggle style', (tester) async {
15
       final editor = new EditorSandBox(tester: tester);
15
       final editor = new EditorSandBox(tester: tester);
16
-      await editor.tapEditor();
16
+      await editor.pumpAndTap();
17
       await editor.updateSelection(base: 5, extent: 10);
17
       await editor.updateSelection(base: 5, extent: 10);
18
       await editor.tapButtonWithIcon(Icons.format_bold);
18
       await editor.tapButtonWithIcon(Icons.format_bold);
19
 
19
 
31
     testWidgets('toggle state for different styles of the same attribute',
31
     testWidgets('toggle state for different styles of the same attribute',
32
         (tester) async {
32
         (tester) async {
33
       final editor = new EditorSandBox(tester: tester);
33
       final editor = new EditorSandBox(tester: tester);
34
-      await editor.tapEditor();
34
+      await editor.pumpAndTap();
35
 
35
 
36
       await editor.tapButtonWithIcon(Icons.format_list_bulleted);
36
       await editor.tapButtonWithIcon(Icons.format_list_bulleted);
37
       expect(editor.document.root.children.first, isInstanceOf<BlockNode>());
37
       expect(editor.document.root.children.first, isInstanceOf<BlockNode>());
46
   group('$HeadingButton', () {
46
   group('$HeadingButton', () {
47
     testWidgets('toggle menu', (tester) async {
47
     testWidgets('toggle menu', (tester) async {
48
       final editor = new EditorSandBox(tester: tester);
48
       final editor = new EditorSandBox(tester: tester);
49
-      await editor.tapEditor();
49
+      await editor.pumpAndTap();
50
       await editor.tapButtonWithIcon(Icons.format_size);
50
       await editor.tapButtonWithIcon(Icons.format_size);
51
 
51
 
52
       expect(find.text('H1'), findsOneWidget);
52
       expect(find.text('H1'), findsOneWidget);
60
 
60
 
61
     testWidgets('toggle styles', (tester) async {
61
     testWidgets('toggle styles', (tester) async {
62
       final editor = new EditorSandBox(tester: tester);
62
       final editor = new EditorSandBox(tester: tester);
63
-      await editor.tapEditor();
63
+      await editor.pumpAndTap();
64
       await editor.tapButtonWithIcon(Icons.format_size);
64
       await editor.tapButtonWithIcon(Icons.format_size);
65
       await editor.tapButtonWithText('H3');
65
       await editor.tapButtonWithText('H3');
66
       LineNode line = editor.document.root.children.first;
66
       LineNode line = editor.document.root.children.first;
71
 
71
 
72
     testWidgets('close overlay', (tester) async {
72
     testWidgets('close overlay', (tester) async {
73
       final editor = new EditorSandBox(tester: tester);
73
       final editor = new EditorSandBox(tester: tester);
74
-      await editor.tapEditor();
74
+      await editor.pumpAndTap();
75
       await editor.tapButtonWithIcon(Icons.format_size);
75
       await editor.tapButtonWithIcon(Icons.format_size);
76
       expect(find.text('H1'), findsOneWidget);
76
       expect(find.text('H1'), findsOneWidget);
77
       await editor.tapButtonWithIcon(Icons.close);
77
       await editor.tapButtonWithIcon(Icons.close);
82
   group('$LinkButton', () {
82
   group('$LinkButton', () {
83
     testWidgets('disabled when selection is collapsed', (tester) async {
83
     testWidgets('disabled when selection is collapsed', (tester) async {
84
       final editor = new EditorSandBox(tester: tester);
84
       final editor = new EditorSandBox(tester: tester);
85
-      await editor.tapEditor();
85
+      await editor.pumpAndTap();
86
       await editor.tapButtonWithIcon(Icons.link);
86
       await editor.tapButtonWithIcon(Icons.link);
87
       expect(find.byIcon(Icons.link_off), findsNothing);
87
       expect(find.byIcon(Icons.link_off), findsNothing);
88
     });
88
     });
90
     testWidgets('enabled and toggles menu with non-empty selection',
90
     testWidgets('enabled and toggles menu with non-empty selection',
91
         (tester) async {
91
         (tester) async {
92
       final editor = new EditorSandBox(tester: tester);
92
       final editor = new EditorSandBox(tester: tester);
93
-      await editor.tapEditor();
93
+      await editor.pumpAndTap();
94
       await editor.updateSelection(base: 5, extent: 10);
94
       await editor.updateSelection(base: 5, extent: 10);
95
       await editor.tapButtonWithIcon(Icons.link);
95
       await editor.tapButtonWithIcon(Icons.link);
96
       expect(find.byIcon(Icons.link_off), findsOneWidget);
96
       expect(find.byIcon(Icons.link_off), findsOneWidget);
98
 
98
 
99
     testWidgets('auto cancels edit on selection update', (tester) async {
99
     testWidgets('auto cancels edit on selection update', (tester) async {
100
       final editor = new EditorSandBox(tester: tester);
100
       final editor = new EditorSandBox(tester: tester);
101
-      await editor.tapEditor();
101
+      await editor.pumpAndTap();
102
       await editor.updateSelection(base: 5, extent: 10);
102
       await editor.updateSelection(base: 5, extent: 10);
103
       await editor.tapButtonWithIcon(Icons.link);
103
       await editor.tapButtonWithIcon(Icons.link);
104
       await tester
104
       await tester
111
 
111
 
112
     testWidgets('editing link', (tester) async {
112
     testWidgets('editing link', (tester) async {
113
       final editor = new EditorSandBox(tester: tester);
113
       final editor = new EditorSandBox(tester: tester);
114
-      await editor.tapEditor();
114
+      await editor.pumpAndTap();
115
       await editor.updateSelection(base: 5, extent: 10);
115
       await editor.updateSelection(base: 5, extent: 10);
116
 
116
 
117
       await editor.tapButtonWithIcon(Icons.link);
117
       await editor.tapButtonWithIcon(Icons.link);
160
 
160
 
161
     testWidgets('toggle overlay', (tester) async {
161
     testWidgets('toggle overlay', (tester) async {
162
       final editor = new EditorSandBox(tester: tester);
162
       final editor = new EditorSandBox(tester: tester);
163
-      await editor.tapEditor();
163
+      await editor.pumpAndTap();
164
       await editor.tapButtonWithIcon(Icons.photo);
164
       await editor.tapButtonWithIcon(Icons.photo);
165
 
165
 
166
       expect(find.byIcon(Icons.photo_camera), findsOneWidget);
166
       expect(find.byIcon(Icons.photo_camera), findsOneWidget);
170
 
170
 
171
     testWidgets('pick from camera', (tester) async {
171
     testWidgets('pick from camera', (tester) async {
172
       final editor = new EditorSandBox(tester: tester);
172
       final editor = new EditorSandBox(tester: tester);
173
-      await editor.tapEditor();
173
+      await editor.pumpAndTap();
174
       await editor.tapButtonWithIcon(Icons.photo);
174
       await editor.tapButtonWithIcon(Icons.photo);
175
       await editor.tapButtonWithIcon(Icons.photo_camera);
175
       await editor.tapButtonWithIcon(Icons.photo_camera);
176
       expect(log, hasLength(1));
176
       expect(log, hasLength(1));
189
 
189
 
190
     testWidgets('pick from gallery', (tester) async {
190
     testWidgets('pick from gallery', (tester) async {
191
       final editor = new EditorSandBox(tester: tester);
191
       final editor = new EditorSandBox(tester: tester);
192
-      await editor.tapEditor();
192
+      await editor.pumpAndTap();
193
       await editor.tapButtonWithIcon(Icons.photo);
193
       await editor.tapButtonWithIcon(Icons.photo);
194
       await editor.tapButtonWithIcon(Icons.photo_library);
194
       await editor.tapButtonWithIcon(Icons.photo_library);
195
       expect(log, hasLength(1));
195
       expect(log, hasLength(1));

+ 1
- 1
packages/zefyr/test/widgets/code_test.dart View File

11
   group('$ZefyrCode', () {
11
   group('$ZefyrCode', () {
12
     testWidgets('format as code', (tester) async {
12
     testWidgets('format as code', (tester) async {
13
       final editor = new EditorSandBox(tester: tester);
13
       final editor = new EditorSandBox(tester: tester);
14
-      await editor.tapEditor();
14
+      await editor.pumpAndTap();
15
       await editor.tapButtonWithIcon(Icons.code);
15
       await editor.tapButtonWithIcon(Icons.code);
16
 
16
 
17
       BlockNode block = editor.document.root.children.first;
17
       BlockNode block = editor.document.root.children.first;

+ 13
- 1
packages/zefyr/test/widgets/editable_text_test.dart View File

11
   group('$ZefyrEditableText', () {
11
   group('$ZefyrEditableText', () {
12
     testWidgets('user input', (tester) async {
12
     testWidgets('user input', (tester) async {
13
       final editor = new EditorSandBox(tester: tester);
13
       final editor = new EditorSandBox(tester: tester);
14
-      await editor.tapEditor();
14
+      await editor.pumpAndTap();
15
       final currentValue = editor.document.toPlainText();
15
       final currentValue = editor.document.toPlainText();
16
       await enterText(tester, 'Added $currentValue');
16
       await enterText(tester, 'Added $currentValue');
17
       expect(editor.document.toPlainText(), 'Added This House Is A Circus\n');
17
       expect(editor.document.toPlainText(), 'Added This House Is A Circus\n');
18
     });
18
     });
19
+
20
+    testWidgets('autofocus', (tester) async {
21
+      final editor = new EditorSandBox(tester: tester, autofocus: true);
22
+      await editor.pump();
23
+      expect(editor.focusNode.hasFocus, isTrue);
24
+    });
25
+
26
+    testWidgets('no autofocus', (tester) async {
27
+      final editor = new EditorSandBox(tester: tester);
28
+      await editor.pump();
29
+      expect(editor.focusNode.hasFocus, isFalse);
30
+    });
19
   });
31
   });
20
 }
32
 }
21
 
33
 

+ 3
- 3
packages/zefyr/test/widgets/editor_test.dart View File

22
       var theme = ZefyrThemeData(linkStyle: TextStyle(color: Colors.red));
22
       var theme = ZefyrThemeData(linkStyle: TextStyle(color: Colors.red));
23
       var editor =
23
       var editor =
24
           new EditorSandBox(tester: tester, document: doc, theme: theme);
24
           new EditorSandBox(tester: tester, document: doc, theme: theme);
25
-      await editor.tapEditor();
25
+      await editor.pumpAndTap();
26
       // TODO: figure out why this extra pump is needed here
26
       // TODO: figure out why this extra pump is needed here
27
       await tester.pumpAndSettle();
27
       await tester.pumpAndSettle();
28
       EditableRichText p = tester.widget(find.byType(EditableRichText).first);
28
       EditableRichText p = tester.widget(find.byType(EditableRichText).first);
31
 
31
 
32
     testWidgets('collapses selection when unfocused', (tester) async {
32
     testWidgets('collapses selection when unfocused', (tester) async {
33
       final editor = new EditorSandBox(tester: tester);
33
       final editor = new EditorSandBox(tester: tester);
34
-      await editor.tapEditor();
34
+      await editor.pumpAndTap();
35
       await editor.updateSelection(base: 0, extent: 3);
35
       await editor.updateSelection(base: 0, extent: 3);
36
       expect(editor.findSelectionHandle(), findsNWidgets(2));
36
       expect(editor.findSelectionHandle(), findsNWidgets(2));
37
       await editor.tapHideKeyboardButton();
37
       await editor.tapHideKeyboardButton();
41
 
41
 
42
     testWidgets('toggle enabled state', (tester) async {
42
     testWidgets('toggle enabled state', (tester) async {
43
       final editor = new EditorSandBox(tester: tester);
43
       final editor = new EditorSandBox(tester: tester);
44
-      await editor.tapEditor();
44
+      await editor.pumpAndTap();
45
       await editor.updateSelection(base: 0, extent: 3);
45
       await editor.updateSelection(base: 0, extent: 3);
46
       await editor.disable();
46
       await editor.disable();
47
       ZefyrEditor widget = tester.widget(find.byType(ZefyrEditor));
47
       ZefyrEditor widget = tester.widget(find.byType(ZefyrEditor));

+ 4
- 4
packages/zefyr/test/widgets/horizontal_rule_test.dart View File

11
   group('$ZefyrHorizontalRule', () {
11
   group('$ZefyrHorizontalRule', () {
12
     testWidgets('format as horizontal rule', (tester) async {
12
     testWidgets('format as horizontal rule', (tester) async {
13
       final editor = new EditorSandBox(tester: tester);
13
       final editor = new EditorSandBox(tester: tester);
14
-      await editor.tapEditor();
14
+      await editor.pumpAndTap();
15
       await editor.tapButtonWithIcon(Icons.remove);
15
       await editor.tapButtonWithIcon(Icons.remove);
16
 
16
 
17
       LineNode line = editor.document.root.children.last;
17
       LineNode line = editor.document.root.children.last;
21
     testWidgets('tap left side of horizontal rule puts caret before it',
21
     testWidgets('tap left side of horizontal rule puts caret before it',
22
         (tester) async {
22
         (tester) async {
23
       final editor = new EditorSandBox(tester: tester);
23
       final editor = new EditorSandBox(tester: tester);
24
-      await editor.tapEditor();
24
+      await editor.pumpAndTap();
25
       await editor.tapButtonWithIcon(Icons.remove);
25
       await editor.tapButtonWithIcon(Icons.remove);
26
       await editor.updateSelection(base: 0, extent: 0);
26
       await editor.updateSelection(base: 0, extent: 0);
27
 
27
 
35
     testWidgets('tap right side of horizontal rule puts caret after it',
35
     testWidgets('tap right side of horizontal rule puts caret after it',
36
         (tester) async {
36
         (tester) async {
37
       final editor = new EditorSandBox(tester: tester);
37
       final editor = new EditorSandBox(tester: tester);
38
-      await editor.tapEditor();
38
+      await editor.pumpAndTap();
39
       await editor.tapButtonWithIcon(Icons.remove);
39
       await editor.tapButtonWithIcon(Icons.remove);
40
       await editor.updateSelection(base: 0, extent: 0);
40
       await editor.updateSelection(base: 0, extent: 0);
41
 
41
 
51
     testWidgets('selects on long press',
51
     testWidgets('selects on long press',
52
         (tester) async {
52
         (tester) async {
53
       final editor = new EditorSandBox(tester: tester);
53
       final editor = new EditorSandBox(tester: tester);
54
-      await editor.tapEditor();
54
+      await editor.pumpAndTap();
55
       await editor.tapButtonWithIcon(Icons.remove);
55
       await editor.tapButtonWithIcon(Icons.remove);
56
       await editor.updateSelection(base: 0, extent: 0);
56
       await editor.updateSelection(base: 0, extent: 0);
57
 
57
 

+ 4
- 4
packages/zefyr/test/widgets/image_test.dart View File

47
 
47
 
48
     testWidgets('embed image', (tester) async {
48
     testWidgets('embed image', (tester) async {
49
       final editor = new EditorSandBox(tester: tester);
49
       final editor = new EditorSandBox(tester: tester);
50
-      await editor.tapEditor();
50
+      await editor.pumpAndTap();
51
       await editor.tapButtonWithIcon(Icons.photo);
51
       await editor.tapButtonWithIcon(Icons.photo);
52
       await editor.tapButtonWithIcon(Icons.photo_camera);
52
       await editor.tapButtonWithIcon(Icons.photo_camera);
53
       LineNode line = editor.document.root.children.last;
53
       LineNode line = editor.document.root.children.last;
63
     testWidgets('tap on left side of image puts caret before it',
63
     testWidgets('tap on left side of image puts caret before it',
64
         (tester) async {
64
         (tester) async {
65
       final editor = new EditorSandBox(tester: tester);
65
       final editor = new EditorSandBox(tester: tester);
66
-      await editor.tapEditor();
66
+      await editor.pumpAndTap();
67
       await editor.tapButtonWithIcon(Icons.photo);
67
       await editor.tapButtonWithIcon(Icons.photo);
68
       await editor.tapButtonWithIcon(Icons.photo_camera);
68
       await editor.tapButtonWithIcon(Icons.photo_camera);
69
       await editor.updateSelection(base: 0, extent: 0);
69
       await editor.updateSelection(base: 0, extent: 0);
78
     testWidgets('tap right side of image puts caret after it',
78
     testWidgets('tap right side of image puts caret after it',
79
         (tester) async {
79
         (tester) async {
80
       final editor = new EditorSandBox(tester: tester);
80
       final editor = new EditorSandBox(tester: tester);
81
-      await editor.tapEditor();
81
+      await editor.pumpAndTap();
82
       await editor.tapButtonWithIcon(Icons.photo);
82
       await editor.tapButtonWithIcon(Icons.photo);
83
       await editor.tapButtonWithIcon(Icons.photo_camera);
83
       await editor.tapButtonWithIcon(Icons.photo_camera);
84
       await editor.updateSelection(base: 0, extent: 0);
84
       await editor.updateSelection(base: 0, extent: 0);
94
 
94
 
95
     testWidgets('selects on long press', (tester) async {
95
     testWidgets('selects on long press', (tester) async {
96
       final editor = new EditorSandBox(tester: tester);
96
       final editor = new EditorSandBox(tester: tester);
97
-      await editor.tapEditor();
97
+      await editor.pumpAndTap();
98
       await editor.tapButtonWithIcon(Icons.photo);
98
       await editor.tapButtonWithIcon(Icons.photo);
99
       await editor.tapButtonWithIcon(Icons.photo_camera);
99
       await editor.tapButtonWithIcon(Icons.photo_camera);
100
       await editor.updateSelection(base: 0, extent: 0);
100
       await editor.updateSelection(base: 0, extent: 0);

+ 1
- 1
packages/zefyr/test/widgets/list_test.dart View File

11
   group('$ZefyrList', () {
11
   group('$ZefyrList', () {
12
     testWidgets('format as list', (tester) async {
12
     testWidgets('format as list', (tester) async {
13
       final editor = new EditorSandBox(tester: tester);
13
       final editor = new EditorSandBox(tester: tester);
14
-      await editor.tapEditor();
14
+      await editor.pumpAndTap();
15
       await editor.tapButtonWithIcon(Icons.format_list_bulleted);
15
       await editor.tapButtonWithIcon(Icons.format_list_bulleted);
16
       BlockNode block = editor.document.root.children.first;
16
       BlockNode block = editor.document.root.children.first;
17
       expect(block.style.get(NotusAttribute.block),
17
       expect(block.style.get(NotusAttribute.block),

+ 1
- 1
packages/zefyr/test/widgets/quote_test.dart View File

11
   group('$ZefyrQuote', () {
11
   group('$ZefyrQuote', () {
12
     testWidgets('format as quote', (tester) async {
12
     testWidgets('format as quote', (tester) async {
13
       final editor = new EditorSandBox(tester: tester);
13
       final editor = new EditorSandBox(tester: tester);
14
-      await editor.tapEditor();
14
+      await editor.pumpAndTap();
15
       await editor.tapButtonWithIcon(Icons.format_quote);
15
       await editor.tapButtonWithIcon(Icons.format_quote);
16
 
16
 
17
       BlockNode block = editor.document.root.children.first;
17
       BlockNode block = editor.document.root.children.first;

+ 4
- 4
packages/zefyr/test/widgets/selection_test.dart View File

12
   group('$ZefyrSelectionOverlay', () {
12
   group('$ZefyrSelectionOverlay', () {
13
     testWidgets('double tap caret shows toolbar', (tester) async {
13
     testWidgets('double tap caret shows toolbar', (tester) async {
14
       final editor = new EditorSandBox(tester: tester);
14
       final editor = new EditorSandBox(tester: tester);
15
-      await editor.tapEditor();
15
+      await editor.pumpAndTap();
16
 
16
 
17
       RenderEditableParagraph renderObject =
17
       RenderEditableParagraph renderObject =
18
           tester.firstRenderObject(find.byType(EditableRichText));
18
           tester.firstRenderObject(find.byType(EditableRichText));
27
 
27
 
28
     testWidgets('hides when editor lost focus', (tester) async {
28
     testWidgets('hides when editor lost focus', (tester) async {
29
       final editor = new EditorSandBox(tester: tester);
29
       final editor = new EditorSandBox(tester: tester);
30
-      await editor.tapEditor();
30
+      await editor.pumpAndTap();
31
       await editor.updateSelection(base: 0, extent: 5);
31
       await editor.updateSelection(base: 0, extent: 5);
32
       expect(editor.findSelectionHandle(), findsNWidgets(2));
32
       expect(editor.findSelectionHandle(), findsNWidgets(2));
33
       await editor.unfocus();
33
       await editor.unfocus();
36
 
36
 
37
     testWidgets('tap on padding area finds closest paragraph', (tester) async {
37
     testWidgets('tap on padding area finds closest paragraph', (tester) async {
38
       final editor = new EditorSandBox(tester: tester);
38
       final editor = new EditorSandBox(tester: tester);
39
-      await editor.tapEditor();
39
+      await editor.pumpAndTap();
40
       editor.controller
40
       editor.controller
41
           .updateSelection(new TextSelection.collapsed(offset: 10));
41
           .updateSelection(new TextSelection.collapsed(offset: 10));
42
       await tester.pumpAndSettle();
42
       await tester.pumpAndSettle();
54
 
54
 
55
     testWidgets('tap on empty space finds closest paragraph', (tester) async {
55
     testWidgets('tap on empty space finds closest paragraph', (tester) async {
56
       final editor = new EditorSandBox(tester: tester);
56
       final editor = new EditorSandBox(tester: tester);
57
-      await editor.tapEditor();
57
+      await editor.pumpAndTap();
58
       editor.controller.replaceText(10, 1, '\n',
58
       editor.controller.replaceText(10, 1, '\n',
59
           selection: new TextSelection.collapsed(offset: 0));
59
           selection: new TextSelection.collapsed(offset: 0));
60
       await tester.pumpAndSettle();
60
       await tester.pumpAndSettle();