@@ -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
final List <String > extensions = < String > ['txt' , 'jpg' ];
13
12
final List <String > mimeTypes = < String > ['text/plain' ];
14
13
final List <String > macUTIs = < String > ['public.plain-text' ];
15
14
final List <String > webWildCards = < String > ['image/*' ];
16
-
15
+ const String label = 'test group' ;
17
16
final XTypeGroup group = XTypeGroup (
18
17
label: label,
19
18
extensions: extensions,
@@ -71,6 +70,67 @@ void main() {
71
70
expect (webOnly.allowsAny, false );
72
71
});
73
72
73
+ test ('passing only macUTIs should fill uniformTypeIdentifiers' , () {
74
+ final List <String > macUTIs = < String > ['public.plain-text' ];
75
+ final XTypeGroup group = XTypeGroup (
76
+ macUTIs: macUTIs,
77
+ );
78
+
79
+ expect (group.uniformTypeIdentifiers, macUTIs);
80
+ });
81
+
82
+ test ('passing only macUTIs should fill macUTIs' , () {
83
+ final List <String > macUTIs = < String > ['public.plain-text' ];
84
+ final XTypeGroup group = XTypeGroup (
85
+ macUTIs: macUTIs,
86
+ );
87
+
88
+ expect (group.macUTIs, macUTIs);
89
+ });
90
+
91
+ test (
92
+ 'passing only uniformTypeIdentifiers should fill uniformTypeIdentifiers' ,
93
+ () {
94
+ final List <String > uniformTypeIdentifiers = < String > ['public.plain-text' ];
95
+ final XTypeGroup group = XTypeGroup (
96
+ uniformTypeIdentifiers: uniformTypeIdentifiers,
97
+ );
98
+
99
+ expect (group.uniformTypeIdentifiers, uniformTypeIdentifiers);
100
+ });
101
+
102
+ test ('passing only uniformTypeIdentifiers should fill macUTIs' , () {
103
+ final List <String > uniformTypeIdentifiers = < String > ['public.plain-text' ];
104
+ final XTypeGroup group = XTypeGroup (
105
+ uniformTypeIdentifiers: uniformTypeIdentifiers,
106
+ );
107
+
108
+ expect (group.macUTIs, uniformTypeIdentifiers);
109
+ });
110
+
111
+ test ('passing uniformTypeIdentifiers and macUTIs should throw' , () {
112
+ final List <String > macUTIs = < String > ['public.plain-text' ];
113
+ final List <String > uniformTypeIndentifiers = < String > [
114
+ 'public.plain-images'
115
+ ];
116
+ expect (
117
+ () => XTypeGroup (
118
+ macUTIs: macUTIs,
119
+ uniformTypeIdentifiers: uniformTypeIndentifiers),
120
+ throwsA (predicate ((Object ? e) =>
121
+ e is AssertionError &&
122
+ e.message ==
123
+ 'It is only allowed to specify either macUTIs or uniformTypeIdentifiers' )));
124
+ });
125
+
126
+ test (
127
+ 'having uniformTypeIdentifiers and macUTIs as null should leave uniformTypeIdentifiers as null' ,
128
+ () {
129
+ final XTypeGroup group = XTypeGroup ();
130
+
131
+ expect (group.uniformTypeIdentifiers, null );
132
+ });
133
+
74
134
test ('Leading dots are removed from extensions' , () {
75
135
final List <String > extensions = < String > ['.txt' , '.jpg' ];
76
136
final XTypeGroup group = XTypeGroup (extensions: extensions);
0 commit comments