|
@@ -119,9 +119,9 @@ class EditorSandBox {
|
119
|
119
|
class _ZefyrSandbox extends StatefulWidget {
|
120
|
120
|
const _ZefyrSandbox({
|
121
|
121
|
Key key,
|
122
|
|
- this.controller,
|
123
|
|
- this.focusNode,
|
124
|
|
- this.autofocus,
|
|
122
|
+ @required this.controller,
|
|
123
|
+ @required this.focusNode,
|
|
124
|
+ this.autofocus = false,
|
125
|
125
|
this.imageDelegate,
|
126
|
126
|
}) : super(key: key);
|
127
|
127
|
final ZefyrController controller;
|
|
@@ -153,3 +153,94 @@ class _ZefyrSandboxState extends State<_ZefyrSandbox> {
|
153
|
153
|
});
|
154
|
154
|
}
|
155
|
155
|
}
|
|
156
|
+
|
|
157
|
+class MultiEditorSandbox {
|
|
158
|
+ final WidgetTester tester;
|
|
159
|
+ final Key firstEditorKey;
|
|
160
|
+ final Key secondEditorKey;
|
|
161
|
+ final FocusNode firstFocusNode;
|
|
162
|
+ final FocusNode secondFocusNode;
|
|
163
|
+ final Widget widget;
|
|
164
|
+
|
|
165
|
+ factory MultiEditorSandbox({@required WidgetTester tester}) {
|
|
166
|
+ final firstEditorKey = UniqueKey();
|
|
167
|
+ final secondEditorKey = UniqueKey();
|
|
168
|
+ final firstFocusNode = FocusNode();
|
|
169
|
+ final secondFocusNode = FocusNode();
|
|
170
|
+ Widget first = _ZefyrSandbox(
|
|
171
|
+ key: firstEditorKey,
|
|
172
|
+ controller: ZefyrController(NotusDocument.fromDelta(delta)),
|
|
173
|
+ focusNode: firstFocusNode,
|
|
174
|
+ );
|
|
175
|
+ Widget second = _ZefyrSandbox(
|
|
176
|
+ key: secondEditorKey,
|
|
177
|
+ controller: ZefyrController(NotusDocument.fromDelta(delta)),
|
|
178
|
+ focusNode: secondFocusNode,
|
|
179
|
+ );
|
|
180
|
+
|
|
181
|
+ Widget widget = MaterialApp(
|
|
182
|
+ home: Scaffold(
|
|
183
|
+ body: ZefyrScaffold(
|
|
184
|
+ child: Column(
|
|
185
|
+ children: <Widget>[
|
|
186
|
+ SizedBox(height: 100, child: first),
|
|
187
|
+ SizedBox(height: 10),
|
|
188
|
+ SizedBox(height: 100, child: second),
|
|
189
|
+ ],
|
|
190
|
+ ),
|
|
191
|
+ ),
|
|
192
|
+ ),
|
|
193
|
+ );
|
|
194
|
+
|
|
195
|
+ return MultiEditorSandbox._(
|
|
196
|
+ tester: tester,
|
|
197
|
+ widget: widget,
|
|
198
|
+ firstEditorKey: firstEditorKey,
|
|
199
|
+ secondEditorKey: secondEditorKey,
|
|
200
|
+ firstFocusNode: firstFocusNode,
|
|
201
|
+ secondFocusNode: secondFocusNode,
|
|
202
|
+ );
|
|
203
|
+ }
|
|
204
|
+
|
|
205
|
+ MultiEditorSandbox._({
|
|
206
|
+ @required this.tester,
|
|
207
|
+ @required this.widget,
|
|
208
|
+ @required this.firstEditorKey,
|
|
209
|
+ @required this.secondEditorKey,
|
|
210
|
+ @required this.firstFocusNode,
|
|
211
|
+ @required this.secondFocusNode,
|
|
212
|
+ });
|
|
213
|
+
|
|
214
|
+ Future<void> pump() async {
|
|
215
|
+ await tester.pumpWidget(widget);
|
|
216
|
+ }
|
|
217
|
+
|
|
218
|
+ Future<void> tapFirstEditor() async {
|
|
219
|
+ await tester.tap(find.byKey(firstEditorKey).first);
|
|
220
|
+ await tester.pumpAndSettle();
|
|
221
|
+ }
|
|
222
|
+
|
|
223
|
+ Future<void> tapSecondEditor() async {
|
|
224
|
+ await tester.tap(find.byKey(secondEditorKey).first);
|
|
225
|
+ await tester.pumpAndSettle();
|
|
226
|
+ }
|
|
227
|
+
|
|
228
|
+ ZefyrEditor findFirstEditor() {
|
|
229
|
+ return tester.widget(find.descendant(
|
|
230
|
+ of: find.byKey(firstEditorKey),
|
|
231
|
+ matching: find.byType(ZefyrEditor),
|
|
232
|
+ ));
|
|
233
|
+ }
|
|
234
|
+
|
|
235
|
+ ZefyrEditor findSecondEditor() {
|
|
236
|
+ return tester.widget(find.descendant(
|
|
237
|
+ of: find.byKey(secondEditorKey),
|
|
238
|
+ matching: find.byType(ZefyrEditor),
|
|
239
|
+ ));
|
|
240
|
+ }
|
|
241
|
+
|
|
242
|
+ Future<void> tapButtonWithIcon(IconData icon) async {
|
|
243
|
+ await tester.tap(find.widgetWithIcon(ZefyrButton, icon));
|
|
244
|
+ await tester.pumpAndSettle();
|
|
245
|
+ }
|
|
246
|
+}
|