@@ -47,9 +47,13 @@ class exampleTests: XCTestCase {
47
47
panelController. openURLs = [ URL ( fileURLWithPath: returnPath) ]
48
48
49
49
let called = XCTestExpectation ( )
50
- let call = FlutterMethodCall ( methodName: " openFile " , arguments: [ : ] )
51
- plugin. handle ( call) { result in
52
- XCTAssertEqual ( ( result as! [ String ] ? ) ![ 0 ] , returnPath)
50
+ let options = OpenPanelOptions (
51
+ allowsMultipleSelection: false ,
52
+ canChooseDirectories: false ,
53
+ canChooseFiles: true ,
54
+ baseOptions: SavePanelOptions ( ) )
55
+ plugin. displayOpenPanel ( options: options) { paths in
56
+ XCTAssertEqual ( paths [ 0 ] , returnPath)
53
57
called. fulfill ( )
54
58
}
55
59
@@ -72,16 +76,16 @@ class exampleTests: XCTestCase {
72
76
panelController. openURLs = [ URL ( fileURLWithPath: returnPath) ]
73
77
74
78
let called = XCTestExpectation ( )
75
- let call = FlutterMethodCall (
76
- methodName : " openFile " ,
77
- arguments : [
78
- " initialDirectory " : " /some/dir " ,
79
- " suggestedName " : " a name " ,
80
- " confirmButtonText " : " Open it! " ,
81
- ]
82
- )
83
- plugin. handle ( call ) { result in
84
- XCTAssertEqual ( ( result as! [ String ] ? ) ! [ 0 ] , returnPath)
79
+ let options = OpenPanelOptions (
80
+ allowsMultipleSelection : false ,
81
+ canChooseDirectories : false ,
82
+ canChooseFiles : true ,
83
+ baseOptions : SavePanelOptions (
84
+ directoryPath : " /some/dir " ,
85
+ nameFieldStringValue : " a name " ,
86
+ prompt : " Open it! " ) )
87
+ plugin. displayOpenPanel ( options : options ) { paths in
88
+ XCTAssertEqual ( paths [ 0 ] , returnPath)
85
89
called. fulfill ( )
86
90
}
87
91
@@ -104,12 +108,12 @@ class exampleTests: XCTestCase {
104
108
panelController. openURLs = returnPaths. map ( { path in URL ( fileURLWithPath: path) } )
105
109
106
110
let called = XCTestExpectation ( )
107
- let call = FlutterMethodCall (
108
- methodName : " openFile " ,
109
- arguments : [ " multiple " : true ]
110
- )
111
- plugin . handle ( call ) { result in
112
- let paths = ( result as! [ String ] ? ) !
111
+ let options = OpenPanelOptions (
112
+ allowsMultipleSelection : true ,
113
+ canChooseDirectories : false ,
114
+ canChooseFiles : true ,
115
+ baseOptions : SavePanelOptions ( ) )
116
+ plugin . displayOpenPanel ( options : options ) { paths in
113
117
XCTAssertEqual ( paths. count, returnPaths. count)
114
118
XCTAssertEqual ( paths [ 0 ] , returnPaths [ 0 ] )
115
119
XCTAssertEqual ( paths [ 1 ] , returnPaths [ 1 ] )
@@ -130,17 +134,17 @@ class exampleTests: XCTestCase {
130
134
panelController. openURLs = [ URL ( fileURLWithPath: returnPath) ]
131
135
132
136
let called = XCTestExpectation ( )
133
- let call = FlutterMethodCall (
134
- methodName : " openFile " ,
135
- arguments : [
136
- " acceptedTypes " : [
137
- " extensions " : [ " txt " , " json " ] ,
138
- " UTIs " : [ " public.text " , " public.image " ] ,
139
- ]
140
- ]
141
- )
142
- plugin. handle ( call ) { result in
143
- XCTAssertEqual ( ( result as! [ String ] ? ) ! [ 0 ] , returnPath)
137
+ let options = OpenPanelOptions (
138
+ allowsMultipleSelection : true ,
139
+ canChooseDirectories : false ,
140
+ canChooseFiles : true ,
141
+ baseOptions : SavePanelOptions (
142
+ allowedFileTypes : AllowedTypes (
143
+ extensions : [ " txt " , " json " ] ,
144
+ mimeTypes : [ ] ,
145
+ utis : [ " public.text " , " public.image " ] ) ) )
146
+ plugin. displayOpenPanel ( options : options ) { paths in
147
+ XCTAssertEqual ( paths [ 0 ] , returnPath)
144
148
called. fulfill ( )
145
149
}
146
150
@@ -158,9 +162,13 @@ class exampleTests: XCTestCase {
158
162
panelController: panelController)
159
163
160
164
let called = XCTestExpectation ( )
161
- let call = FlutterMethodCall ( methodName: " openFile " , arguments: [ : ] )
162
- plugin. handle ( call) { result in
163
- XCTAssertNil ( result)
165
+ let options = OpenPanelOptions (
166
+ allowsMultipleSelection: false ,
167
+ canChooseDirectories: false ,
168
+ canChooseFiles: true ,
169
+ baseOptions: SavePanelOptions ( ) )
170
+ plugin. displayOpenPanel ( options: options) { paths in
171
+ XCTAssertEqual ( paths. count, 0 )
164
172
called. fulfill ( )
165
173
}
166
174
@@ -178,9 +186,9 @@ class exampleTests: XCTestCase {
178
186
panelController. saveURL = URL ( fileURLWithPath: returnPath)
179
187
180
188
let called = XCTestExpectation ( )
181
- let call = FlutterMethodCall ( methodName : " getSavePath " , arguments : [ : ] )
182
- plugin. handle ( call ) { result in
183
- XCTAssertEqual ( result as! String ? , returnPath)
189
+ let options = SavePanelOptions ( )
190
+ plugin. displaySavePanel ( options : options ) { path in
191
+ XCTAssertEqual ( path , returnPath)
184
192
called. fulfill ( )
185
193
}
186
194
@@ -198,15 +206,11 @@ class exampleTests: XCTestCase {
198
206
panelController. saveURL = URL ( fileURLWithPath: returnPath)
199
207
200
208
let called = XCTestExpectation ( )
201
- let call = FlutterMethodCall (
202
- methodName: " getSavePath " ,
203
- arguments: [
204
- " initialDirectory " : " /some/dir " ,
205
- " confirmButtonText " : " Save it! " ,
206
- ]
207
- )
208
- plugin. handle ( call) { result in
209
- XCTAssertEqual ( result as! String ? , returnPath)
209
+ let options = SavePanelOptions (
210
+ directoryPath: " /some/dir " ,
211
+ prompt: " Save it! " )
212
+ plugin. displaySavePanel ( options: options) { path in
213
+ XCTAssertEqual ( path, returnPath)
210
214
called. fulfill ( )
211
215
}
212
216
@@ -225,9 +229,9 @@ class exampleTests: XCTestCase {
225
229
panelController: panelController)
226
230
227
231
let called = XCTestExpectation ( )
228
- let call = FlutterMethodCall ( methodName : " getSavePath " , arguments : [ : ] )
229
- plugin. handle ( call ) { result in
230
- XCTAssertNil ( result )
232
+ let options = SavePanelOptions ( )
233
+ plugin. displaySavePanel ( options : options ) { path in
234
+ XCTAssertNil ( path )
231
235
called. fulfill ( )
232
236
}
233
237
@@ -245,9 +249,13 @@ class exampleTests: XCTestCase {
245
249
panelController. openURLs = [ URL ( fileURLWithPath: returnPath) ]
246
250
247
251
let called = XCTestExpectation ( )
248
- let call = FlutterMethodCall ( methodName: " getDirectoryPath " , arguments: [ : ] )
249
- plugin. handle ( call) { result in
250
- XCTAssertEqual ( result as! String ? , returnPath)
252
+ let options = OpenPanelOptions (
253
+ allowsMultipleSelection: false ,
254
+ canChooseDirectories: true ,
255
+ canChooseFiles: false ,
256
+ baseOptions: SavePanelOptions ( ) )
257
+ plugin. displayOpenPanel ( options: options) { paths in
258
+ XCTAssertEqual ( paths [ 0 ] , returnPath)
251
259
called. fulfill ( )
252
260
}
253
261
@@ -270,9 +278,13 @@ class exampleTests: XCTestCase {
270
278
panelController: panelController)
271
279
272
280
let called = XCTestExpectation ( )
273
- let call = FlutterMethodCall ( methodName: " getDirectoryPath " , arguments: [ : ] )
274
- plugin. handle ( call) { result in
275
- XCTAssertNil ( result)
281
+ let options = OpenPanelOptions (
282
+ allowsMultipleSelection: false ,
283
+ canChooseDirectories: true ,
284
+ canChooseFiles: false ,
285
+ baseOptions: SavePanelOptions ( ) )
286
+ plugin. displayOpenPanel ( options: options) { paths in
287
+ XCTAssertEqual ( paths. count, 0 )
276
288
called. fulfill ( )
277
289
}
278
290
0 commit comments