widget_test.dart
3.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
// Copyright 2019 The FlutterCandies author. All rights reserved.
// Use of this source code is governed by an Apache license that can be found
// in the LICENSE file.
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:wechat_assets_picker/wechat_assets_picker.dart';
import 'test_utils.dart';
void main() {
PhotoManager.withPlugin(TestPhotoManagerPlugin());
AssetPicker.setPickerDelegate(TestAssetPickerDelegate());
group('Confirm button', () {
group('when enabled preview', () {
testWidgets('with multiple assets picking', (WidgetTester tester) async {
await tester.pumpWidget(
defaultPickerTestApp(
onButtonPressed: (BuildContext context) {
AssetPicker.pickAssets(
context,
pickerConfig: const AssetPickerConfig(
maxAssets: 10,
specialPickerType: null, // Explicitly null.
),
);
},
),
);
await tester.tap(defaultButtonFinder);
await tester.pumpAndSettle();
expect(
find.text(const AssetPickerTextDelegate().confirm),
findsOneWidget,
);
});
testWidgets('with single asset picking', (WidgetTester tester) async {
await tester.pumpWidget(
defaultPickerTestApp(
onButtonPressed: (BuildContext context) {
AssetPicker.pickAssets(
context,
pickerConfig: const AssetPickerConfig(
maxAssets: 1,
specialPickerType: null, // Explicitly null.
),
);
},
),
);
await tester.tap(defaultButtonFinder);
await tester.pumpAndSettle();
expect(
find.text(const AssetPickerTextDelegate().confirm),
findsOneWidget,
);
});
});
group('when disabled preview', () {
testWidgets('with multiple assets picker', (WidgetTester tester) async {
await tester.pumpWidget(
defaultPickerTestApp(
onButtonPressed: (BuildContext context) {
AssetPicker.pickAssets(
context,
pickerConfig: const AssetPickerConfig(
maxAssets: 2,
specialPickerType: SpecialPickerType.noPreview,
),
);
},
),
);
await tester.tap(defaultButtonFinder);
await tester.pumpAndSettle();
expect(
find.text(const AssetPickerTextDelegate().confirm),
findsOneWidget,
);
});
testWidgets('with single asset picker', (WidgetTester tester) async {
await tester.pumpWidget(
defaultPickerTestApp(
onButtonPressed: (BuildContext context) {
AssetPicker.pickAssets(
context,
pickerConfig: const AssetPickerConfig(
maxAssets: 1,
specialPickerType: SpecialPickerType.noPreview,
),
);
},
),
);
await tester.tap(defaultButtonFinder);
await tester.pumpAndSettle();
expect(
find.text(const AssetPickerTextDelegate().confirm),
findsNothing,
);
});
});
});
}