@@ -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,68 @@ 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 ('passing only macUTIs should fill macUTIs' , () {
83+ const List <String > macUTIs = < String > ['public.plain-text' ];
84+ const 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+ const List <String > uniformTypeIdentifiers = < String > ['public.plain-text' ];
95+ const XTypeGroup group = XTypeGroup (
96+ uniformTypeIdentifiers: uniformTypeIdentifiers,
97+ );
98+
99+ expect (group.uniformTypeIdentifiers, uniformTypeIdentifiers);
100+ });
101+
102+ test ('passing only uniformTypeIdentifiers should fill macUTIs' , () {
103+ const List <String > uniformTypeIdentifiers = < String > ['public.plain-text' ];
104+ const XTypeGroup group = XTypeGroup (
105+ uniformTypeIdentifiers: uniformTypeIdentifiers,
106+ );
107+
108+ expect (group.macUTIs, uniformTypeIdentifiers);
109+ });
110+
111+ test ('passing uniformTypeIdentifiers and macUTIs should throw' , () {
112+ const List <String > macUTIs = < String > ['public.plain-text' ];
113+ const 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+ const XTypeGroup group = XTypeGroup ();
130+
131+ expect (group.uniformTypeIdentifiers, null );
132+ });
133+
134+ test ('leading dots are removed from extensions' , () {
75135 const List <String > extensions = < String > ['.txt' , '.jpg' ];
76136 const XTypeGroup group = XTypeGroup (extensions: extensions);
77137
0 commit comments