@@ -247,26 +247,81 @@ public void testGetProcess() {
247
247
process .getFunction ("printf" );
248
248
}
249
249
250
- private String expected (String f ) {
251
- return new File (f ).exists () ? f : null ;
250
+ public void testLoadFoundationFramework () {
251
+ if (!Platform .isMac ()) {
252
+ return ;
253
+ }
254
+ assertNotNull (NativeLibrary .getInstance ("Foundation" ));
252
255
}
253
256
254
- public void testMatchFramework () {
257
+ public void testMatchSystemFramework () {
255
258
if (!Platform .isMac ()) {
256
259
return ;
257
260
}
258
- final String [][] MAPPINGS = {
259
- // Depending on the system, /Library/Frameworks may or may not
260
- // have anything in it.
261
- { "QtCore" , expected ("/Library/Frameworks/QtCore.framework/QtCore" ) },
262
- { "Adobe AIR" , expected ("/Library/Frameworks/Adobe AIR.framework/Adobe AIR" ) },
263
-
264
- { "QuickTime" , expected ("/System/Library/Frameworks/QuickTime.framework/QuickTime" ) },
265
- { "QuickTime.framework/Versions/Current/QuickTime" , expected ("/System/Library/Frameworks/QuickTime.framework/Versions/Current/QuickTime" ) },
266
- };
267
- for (int i =0 ;i < MAPPINGS .length ;i ++) {
268
- assertEquals ("Wrong framework mapping" , MAPPINGS [i ][1 ], NativeLibrary .matchFramework (MAPPINGS [i ][0 ]));
261
+
262
+ assertEquals ("Wrong framework mapping" , 1 ,
263
+ NativeLibrary .matchFramework ("/System/Library/Frameworks/Foundation.framework/Foundation" ).length );
264
+ assertEquals ("Wrong framework mapping" , "/System/Library/Frameworks/Foundation.framework/Foundation" ,
265
+ NativeLibrary .matchFramework ("/System/Library/Frameworks/Foundation.framework/Foundation" )[0 ]);
266
+
267
+ assertEquals ("Wrong framework mapping" , 1 ,
268
+ NativeLibrary .matchFramework ("/System/Library/Frameworks/Foundation" ).length );
269
+ assertEquals ("Wrong framework mapping" , "/System/Library/Frameworks/Foundation.framework/Foundation" ,
270
+ NativeLibrary .matchFramework ("/System/Library/Frameworks/Foundation" )[0 ]);
271
+ }
272
+
273
+ public void testMatchOptionalFrameworkExists () {
274
+ if (!Platform .isMac ()) {
275
+ return ;
276
+ }
277
+
278
+ if (!new File ("/System/Library/Frameworks/QuickTime.framework" ).exists ()) {
279
+ return ;
280
+ }
281
+
282
+ assertEquals ("Wrong framework mapping" , 1 ,
283
+ NativeLibrary .matchFramework ("QuickTime" ).length );
284
+ assertEquals ("Wrong framework mapping" , "/System/Library/Frameworks/QuickTime.framework/QuickTime" ,
285
+ NativeLibrary .matchFramework ("QuickTime" )[0 ]);
286
+
287
+ assertEquals ("Wrong framework mapping" , 1 ,
288
+ NativeLibrary .matchFramework ("QuickTime.framework/Versions/Current/QuickTime" ).length );
289
+ assertEquals ("Wrong framework mapping" , "/System/Library/Frameworks/QuickTime.framework/Versions/Current/QuickTime" ,
290
+ NativeLibrary .matchFramework ("QuickTime.framework/Versions/Current/QuickTime" )[0 ]);
291
+ }
292
+
293
+ public void testMatchOptionalFrameworkNotFound () {
294
+ if (!Platform .isMac ()) {
295
+ return ;
269
296
}
297
+
298
+ if (new File (System .getProperty ("user.home" ) + "/Library/Frameworks/QuickTime.framework" ).exists ()) {
299
+ return ;
300
+ }
301
+ if (new File ("/Library/Frameworks/QuickTime.framework" ).exists ()) {
302
+ return ;
303
+ }
304
+ if (new File ("/System/Library/Frameworks/QuickTime.framework" ).exists ()) {
305
+ return ;
306
+ }
307
+
308
+ assertEquals ("Wrong framework mapping" , 3 ,
309
+ NativeLibrary .matchFramework ("QuickTime" ).length );
310
+ assertEquals ("Wrong framework mapping" , System .getProperty ("user.home" ) + "/Library/Frameworks/QuickTime.framework/QuickTime" ,
311
+ NativeLibrary .matchFramework ("QuickTime" )[0 ]);
312
+ assertEquals ("Wrong framework mapping" , "/Library/Frameworks/QuickTime.framework/QuickTime" ,
313
+ NativeLibrary .matchFramework ("QuickTime" )[1 ]);
314
+ assertEquals ("Wrong framework mapping" , "/System/Library/Frameworks/QuickTime.framework/QuickTime" ,
315
+ NativeLibrary .matchFramework ("QuickTime" )[2 ]);
316
+
317
+ assertEquals ("Wrong framework mapping" , 3 ,
318
+ NativeLibrary .matchFramework ("QuickTime.framework/Versions/Current/QuickTime" ).length );
319
+ assertEquals ("Wrong framework mapping" , System .getProperty ("user.home" ) + "/Library/Frameworks/QuickTime.framework/Versions/Current/QuickTime" ,
320
+ NativeLibrary .matchFramework ("QuickTime.framework/Versions/Current/QuickTime" )[0 ]);
321
+ assertEquals ("Wrong framework mapping" , "/Library/Frameworks/QuickTime.framework/Versions/Current/QuickTime" ,
322
+ NativeLibrary .matchFramework ("QuickTime.framework/Versions/Current/QuickTime" )[1 ]);
323
+ assertEquals ("Wrong framework mapping" , "/System/Library/Frameworks/QuickTime.framework/Versions/Current/QuickTime" ,
324
+ NativeLibrary .matchFramework ("QuickTime.framework/Versions/Current/QuickTime" )[2 ]);
270
325
}
271
326
272
327
public void testLoadLibraryWithOptions () {
0 commit comments