@@ -8,12 +8,11 @@ import 'package:flutter_test/flutter_test.dart';
88void main () {
99 group ('XTypeGroup' , () {
1010 test ('toJSON() creates correct map' , () {
11- const String label = 'test group' ;
1211 const List <String > extensions = < String > ['txt' , 'jpg' ];
1312 const List <String > mimeTypes = < String > ['text/plain' ];
1413 const List <String > macUTIs = < String > ['public.plain-text' ];
1514 const List <String > webWildCards = < String > ['image/*' ];
16-
15+ const String label = 'test group' ;
1716 const XTypeGroup group = XTypeGroup (
1817 label: label,
1918 extensions: extensions,
@@ -30,7 +29,7 @@ void main() {
3029 expect (jsonMap['webWildCards' ], webWildCards);
3130 });
3231
33- test ('A wildcard group can be created' , () {
32+ test ('a wildcard group can be created' , () {
3433 const XTypeGroup group = XTypeGroup (
3534 label: 'Any' ,
3635 );
@@ -71,7 +70,70 @@ void main() {
7170 expect (webOnly.allowsAny, false );
7271 });
7372
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' , () {
75137 const List <String > extensions = < String > ['.txt' , '.jpg' ];
76138 const XTypeGroup group = XTypeGroup (extensions: extensions);
77139
0 commit comments