Skip to content

Commit 79fc557

Browse files
committed
feat: Adding test with image picker. #1
1 parent 6a69831 commit 79fc557

File tree

1 file changed

+40
-6
lines changed

1 file changed

+40
-6
lines changed

test/widget_test.dart

+40-6
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import 'package:app/home_page.dart';
99
import 'package:flutter/material.dart';
1010
import 'package:flutter_quill/flutter_quill.dart';
11+
import 'package:flutter_quill_extensions/embeds/toolbar/image_button.dart';
1112
import 'package:flutter_test/flutter_test.dart';
1213
import 'package:flutter_quill/flutter_quill_test.dart';
1314

@@ -26,9 +27,11 @@ void main() {
2627
when(platformServiceMock.isWebPlatform()).thenAnswer((_) => false);
2728

2829
// Build our app and trigger a frame.
29-
await tester.pumpWidget(App(
30-
platformService: platformServiceMock,
31-
),);
30+
await tester.pumpWidget(
31+
App(
32+
platformService: platformServiceMock,
33+
),
34+
);
3235
await tester.pumpAndSettle();
3336

3437
// Expect to find the normal page setup
@@ -40,6 +43,35 @@ void main() {
4043
await tester.pumpAndSettle();
4144
});
4245

46+
testWidgets('Select image', (WidgetTester tester) async {
47+
final platformServiceMock = MockPlatformService();
48+
49+
// Platform is mobile
50+
when(platformServiceMock.isWebPlatform()).thenAnswer((_) => false);
51+
52+
// Build our app and trigger a frame.
53+
await tester.pumpWidget(
54+
App(
55+
platformService: platformServiceMock,
56+
),
57+
);
58+
await tester.pumpAndSettle();
59+
60+
// Expect to find the normal page setup
61+
expect(find.text('Flutter Quill'), findsOneWidget);
62+
63+
// Enter 'hi' into Quill Editor.
64+
await tester.tap(find.byType(QuillEditor));
65+
await tester.quillEnterText(find.byType(QuillEditor), 'hi\n');
66+
await tester.pumpAndSettle();
67+
68+
final imageButton = find.byType(ImageButton);
69+
await tester.tap(imageButton);
70+
await tester.pumpAndSettle();
71+
72+
//TODO add image picker
73+
});
74+
4375
testWidgets('Normal setup (web version)', (WidgetTester tester) async {
4476
tester.view.physicalSize = const Size(400, 600);
4577
tester.view.devicePixelRatio = 1.0;
@@ -49,9 +81,11 @@ void main() {
4981
when(platformServiceMock.isWebPlatform()).thenAnswer((_) => true);
5082

5183
// Build our app and trigger a frame.
52-
await tester.pumpWidget(App(
53-
platformService: platformServiceMock,
54-
),);
84+
await tester.pumpWidget(
85+
App(
86+
platformService: platformServiceMock,
87+
),
88+
);
5589
await tester.pumpAndSettle();
5690

5791
// Expect to find the normal page setup

0 commit comments

Comments
 (0)