|
@@ -2,6 +2,7 @@
|
2
|
2
|
// for details. All rights reserved. Use of this source code is governed by a
|
3
|
3
|
// BSD-style license that can be found in the LICENSE file.
|
4
|
4
|
import 'package:flutter/material.dart';
|
|
5
|
+import 'package:flutter/services.dart';
|
5
|
6
|
import 'package:flutter_test/flutter_test.dart';
|
6
|
7
|
import 'package:zefyr/src/widgets/buttons.dart';
|
7
|
8
|
import 'package:zefyr/zefyr.dart';
|
|
@@ -67,6 +68,15 @@ void main() {
|
67
|
68
|
await editor.tapButtonWithText('H2');
|
68
|
69
|
expect(line.style.containsSame(NotusAttribute.heading.level2), isTrue);
|
69
|
70
|
});
|
|
71
|
+
|
|
72
|
+ testWidgets('close overlay', (tester) async {
|
|
73
|
+ final editor = new EditorSandBox(tester: tester);
|
|
74
|
+ await editor.tapEditor();
|
|
75
|
+ await editor.tapButtonWithIcon(Icons.format_size);
|
|
76
|
+ expect(find.text('H1'), findsOneWidget);
|
|
77
|
+ await editor.tapButtonWithIcon(Icons.close);
|
|
78
|
+ expect(find.text('H1'), findsNothing);
|
|
79
|
+ });
|
70
|
80
|
});
|
71
|
81
|
|
72
|
82
|
group('$LinkButton', () {
|
|
@@ -132,4 +142,67 @@ void main() {
|
132
|
142
|
expect(line.childCount, 1);
|
133
|
143
|
});
|
134
|
144
|
});
|
|
145
|
+
|
|
146
|
+ group('$ImageButton', () {
|
|
147
|
+ const MethodChannel channel =
|
|
148
|
+ const MethodChannel('plugins.flutter.io/image_picker');
|
|
149
|
+
|
|
150
|
+ final List<MethodCall> log = <MethodCall>[];
|
|
151
|
+
|
|
152
|
+ setUp(() {
|
|
153
|
+ channel.setMockMethodCallHandler((MethodCall methodCall) async {
|
|
154
|
+ log.add(methodCall);
|
|
155
|
+ return 'file:///tmp/test.jpg';
|
|
156
|
+ });
|
|
157
|
+ log.clear();
|
|
158
|
+ });
|
|
159
|
+
|
|
160
|
+ testWidgets('toggle overlay', (tester) async {
|
|
161
|
+ final editor = new EditorSandBox(tester: tester);
|
|
162
|
+ await editor.tapEditor();
|
|
163
|
+ await editor.tapButtonWithIcon(Icons.photo);
|
|
164
|
+
|
|
165
|
+ expect(find.byIcon(Icons.photo_camera), findsOneWidget);
|
|
166
|
+ await editor.tapButtonWithIcon(Icons.close);
|
|
167
|
+ expect(find.byIcon(Icons.photo_camera), findsNothing);
|
|
168
|
+ });
|
|
169
|
+
|
|
170
|
+ testWidgets('pick from camera', (tester) async {
|
|
171
|
+ final editor = new EditorSandBox(tester: tester);
|
|
172
|
+ await editor.tapEditor();
|
|
173
|
+ await editor.tapButtonWithIcon(Icons.photo);
|
|
174
|
+ await editor.tapButtonWithIcon(Icons.photo_camera);
|
|
175
|
+ expect(log, hasLength(1));
|
|
176
|
+ expect(
|
|
177
|
+ log.single,
|
|
178
|
+ isMethodCall(
|
|
179
|
+ 'pickImage',
|
|
180
|
+ arguments: <String, dynamic>{
|
|
181
|
+ 'source': 0,
|
|
182
|
+ 'maxWidth': null,
|
|
183
|
+ 'maxHeight': null,
|
|
184
|
+ },
|
|
185
|
+ ),
|
|
186
|
+ );
|
|
187
|
+ });
|
|
188
|
+
|
|
189
|
+ testWidgets('pick from gallery', (tester) async {
|
|
190
|
+ final editor = new EditorSandBox(tester: tester);
|
|
191
|
+ await editor.tapEditor();
|
|
192
|
+ await editor.tapButtonWithIcon(Icons.photo);
|
|
193
|
+ await editor.tapButtonWithIcon(Icons.photo_library);
|
|
194
|
+ expect(log, hasLength(1));
|
|
195
|
+ expect(
|
|
196
|
+ log.single,
|
|
197
|
+ isMethodCall(
|
|
198
|
+ 'pickImage',
|
|
199
|
+ arguments: <String, dynamic>{
|
|
200
|
+ 'source': 1,
|
|
201
|
+ 'maxWidth': null,
|
|
202
|
+ 'maxHeight': null,
|
|
203
|
+ },
|
|
204
|
+ ),
|
|
205
|
+ );
|
|
206
|
+ });
|
|
207
|
+ });
|
135
|
208
|
}
|