@@ -8,12 +8,11 @@ import 'package:flutter_test/flutter_test.dart';
8
8
void main () {
9
9
group ('XTypeGroup' , () {
10
10
test ('toJSON() creates correct map' , () {
11
- const String label = 'test group' ;
12
11
const List <String > extensions = < String > ['txt' , 'jpg' ];
13
12
const List <String > mimeTypes = < String > ['text/plain' ];
14
13
const List <String > macUTIs = < String > ['public.plain-text' ];
15
14
const List <String > webWildCards = < String > ['image/*' ];
16
-
15
+ const String label = 'test group' ;
17
16
const XTypeGroup group = XTypeGroup (
18
17
label: label,
19
18
extensions: extensions,
@@ -30,7 +29,7 @@ void main() {
30
29
expect (jsonMap['webWildCards' ], webWildCards);
31
30
});
32
31
33
- test ('A wildcard group can be created' , () {
32
+ test ('a wildcard group can be created' , () {
34
33
const XTypeGroup group = XTypeGroup (
35
34
label: 'Any' ,
36
35
);
@@ -71,7 +70,70 @@ void main() {
71
70
expect (webOnly.allowsAny, false );
72
71
});
73
72
74
- test ('Leading dots are removed from extensions' , () {
73
+ test ('passing only macUTIs should fill uniformTypeIdentifiers' , () {
74
+ const List <String > macUTIs = < String > ['public.plain-text' ];
75
+ const XTypeGroup group = XTypeGroup (
76
+ macUTIs: macUTIs,
77
+ );
78
+
79
+ expect (group.uniformTypeIdentifiers, macUTIs);
80
+ });
81
+
82
+ test (
83
+ 'passing only uniformTypeIdentifiers should fill uniformTypeIdentifiers' ,
84
+ () {
85
+ const List <String > uniformTypeIdentifiers = < String > ['public.plain-text' ];
86
+ const XTypeGroup group = XTypeGroup (
87
+ uniformTypeIdentifiers: uniformTypeIdentifiers,
88
+ );
89
+
90
+ expect (group.uniformTypeIdentifiers, uniformTypeIdentifiers);
91
+ });
92
+
93
+ test ('macUTIs getter return macUTIs value passed in constructor' , () {
94
+ const List <String > macUTIs = < String > ['public.plain-text' ];
95
+ const XTypeGroup group = XTypeGroup (
96
+ macUTIs: macUTIs,
97
+ );
98
+
99
+ expect (group.macUTIs, macUTIs);
100
+ });
101
+
102
+ test (
103
+ 'macUTIs getter returns uniformTypeIdentifiers value passed in constructor' ,
104
+ () {
105
+ const List <String > uniformTypeIdentifiers = < String > ['public.plain-text' ];
106
+ const XTypeGroup group = XTypeGroup (
107
+ uniformTypeIdentifiers: uniformTypeIdentifiers,
108
+ );
109
+
110
+ expect (group.macUTIs, uniformTypeIdentifiers);
111
+ });
112
+
113
+ test ('passing both uniformTypeIdentifiers and macUTIs should throw' , () {
114
+ const List <String > macUTIs = < String > ['public.plain-text' ];
115
+ const List <String > uniformTypeIndentifiers = < String > [
116
+ 'public.plain-images'
117
+ ];
118
+ expect (
119
+ () => XTypeGroup (
120
+ macUTIs: macUTIs,
121
+ uniformTypeIdentifiers: uniformTypeIndentifiers),
122
+ throwsA (predicate ((Object ? e) =>
123
+ e is AssertionError &&
124
+ e.message ==
125
+ 'Only one of uniformTypeIdentifiers or macUTIs can be non-null' )));
126
+ });
127
+
128
+ test (
129
+ 'having uniformTypeIdentifiers and macUTIs as null should leave uniformTypeIdentifiers as null' ,
130
+ () {
131
+ const XTypeGroup group = XTypeGroup ();
132
+
133
+ expect (group.uniformTypeIdentifiers, null );
134
+ });
135
+
136
+ test ('leading dots are removed from extensions' , () {
75
137
const List <String > extensions = < String > ['.txt' , '.jpg' ];
76
138
const XTypeGroup group = XTypeGroup (extensions: extensions);
77
139
0 commit comments