@@ -10,23 +10,25 @@ void main() {
10
10
test ('toJSON() creates correct map' , () {
11
11
const List <String > extensions = < String > ['txt' , 'jpg' ];
12
12
const List <String > mimeTypes = < String > ['text/plain' ];
13
- const List <String > macUTIs = < String > ['public.plain-text' ];
13
+ const List <String > uniformTypeIdentifiers = < String > ['public.plain-text' ];
14
14
const List <String > webWildCards = < String > ['image/*' ];
15
15
const String label = 'test group' ;
16
16
const XTypeGroup group = XTypeGroup (
17
17
label: label,
18
18
extensions: extensions,
19
19
mimeTypes: mimeTypes,
20
- macUTIs : macUTIs ,
20
+ uniformTypeIdentifiers : uniformTypeIdentifiers ,
21
21
webWildCards: webWildCards,
22
22
);
23
23
24
24
final Map <String , dynamic > jsonMap = group.toJSON ();
25
25
expect (jsonMap['label' ], label);
26
26
expect (jsonMap['extensions' ], extensions);
27
27
expect (jsonMap['mimeTypes' ], mimeTypes);
28
- expect (jsonMap['macUTIs ' ], macUTIs );
28
+ expect (jsonMap['uniformTypeIdentifiers ' ], uniformTypeIdentifiers );
29
29
expect (jsonMap['webWildCards' ], webWildCards);
30
+ // Validate the legacy key for backwards compatibility.
31
+ expect (jsonMap['macUTIs' ], uniformTypeIdentifiers);
30
32
});
31
33
32
34
test ('a wildcard group can be created' , () {
@@ -37,7 +39,7 @@ void main() {
37
39
final Map <String , dynamic > jsonMap = group.toJSON ();
38
40
expect (jsonMap['extensions' ], null );
39
41
expect (jsonMap['mimeTypes' ], null );
40
- expect (jsonMap['macUTIs ' ], null );
42
+ expect (jsonMap['uniformTypeIdentifiers ' ], null );
41
43
expect (jsonMap['webWildCards' ], null );
42
44
expect (group.allowsAny, true );
43
45
});
@@ -47,7 +49,7 @@ void main() {
47
49
label: 'Any' ,
48
50
extensions: < String > [],
49
51
mimeTypes: < String > [],
50
- macUTIs : < String > [],
52
+ uniformTypeIdentifiers : < String > [],
51
53
webWildCards: < String > [],
52
54
);
53
55
@@ -59,8 +61,8 @@ void main() {
59
61
XTypeGroup (label: 'extensions' , extensions: < String > ['txt' ]);
60
62
const XTypeGroup mimeOnly =
61
63
XTypeGroup (label: 'mime' , mimeTypes: < String > ['text/plain' ]);
62
- const XTypeGroup utiOnly =
63
- XTypeGroup ( label: 'utis' , macUTIs : < String > ['public.text' ]);
64
+ const XTypeGroup utiOnly = XTypeGroup (
65
+ label: 'utis' , uniformTypeIdentifiers : < String > ['public.text' ]);
64
66
const XTypeGroup webOnly =
65
67
XTypeGroup (label: 'web' , webWildCards: < String > ['.txt' ]);
66
68
@@ -70,67 +72,73 @@ void main() {
70
72
expect (webOnly.allowsAny, false );
71
73
});
72
74
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 );
75
+ group ('macUTIs -> uniformTypeIdentifiers transition' , () {
76
+ test ('passing only macUTIs should fill uniformTypeIdentifiers' , () {
77
+ const List <String > uniformTypeIdentifiers = < String > [
78
+ 'public.plain-text'
79
+ ];
80
+ const XTypeGroup group = XTypeGroup (
81
+ macUTIs: uniformTypeIdentifiers,
82
+ );
83
+
84
+ expect (group.uniformTypeIdentifiers, uniformTypeIdentifiers);
85
+ });
86
+
87
+ test (
88
+ 'passing only uniformTypeIdentifiers should fill uniformTypeIdentifiers' ,
89
+ () {
90
+ const List <String > uniformTypeIdentifiers = < String > [
91
+ 'public.plain-text'
92
+ ];
93
+ const XTypeGroup group = XTypeGroup (
94
+ uniformTypeIdentifiers: uniformTypeIdentifiers,
95
+ );
96
+
97
+ expect (group.uniformTypeIdentifiers, uniformTypeIdentifiers);
98
+ });
99
+
100
+ test ('macUTIs getter return macUTIs value passed in constructor' , () {
101
+ const List <String > uniformTypeIdentifiers = < String > [
102
+ 'public.plain-text'
103
+ ];
104
+ const XTypeGroup group = XTypeGroup (
105
+ macUTIs: uniformTypeIdentifiers,
106
+ );
107
+
108
+ expect (group.macUTIs, uniformTypeIdentifiers);
109
+ });
110
+
111
+ test (
112
+ 'macUTIs getter returns uniformTypeIdentifiers value passed in constructor' ,
113
+ () {
114
+ const List <String > uniformTypeIdentifiers = < String > [
115
+ 'public.plain-text'
116
+ ];
117
+ const XTypeGroup group = XTypeGroup (
118
+ uniformTypeIdentifiers: uniformTypeIdentifiers,
119
+ );
120
+
121
+ expect (group.macUTIs, uniformTypeIdentifiers);
122
+ });
123
+
124
+ test ('passing both uniformTypeIdentifiers and macUTIs should throw' , () {
125
+ expect (
126
+ () => XTypeGroup (
127
+ macUTIs: const < String > ['public.plain-text' ],
128
+ uniformTypeIdentifiers: const < String > ['public.plain-images' ]),
129
+ throwsA (predicate ((Object ? e) =>
130
+ e is AssertionError &&
131
+ e.message ==
132
+ 'Only one of uniformTypeIdentifiers or macUTIs can be non-null' )));
133
+ });
134
+
135
+ test (
136
+ 'having uniformTypeIdentifiers and macUTIs as null should leave uniformTypeIdentifiers as null' ,
137
+ () {
138
+ const XTypeGroup group = XTypeGroup ();
139
+
140
+ expect (group.uniformTypeIdentifiers, null );
141
+ });
134
142
});
135
143
136
144
test ('leading dots are removed from extensions' , () {
0 commit comments