@@ -396,7 +396,6 @@ describe('Gio.FileEnumerator overrides', function () {
396396} ) ;
397397
398398describe ( 'Gio.DesktopAppInfo fallback' , function ( ) {
399- let writerFunc ;
400399 const requiredVersion =
401400 GLib . MAJOR_VERSION > 2 ||
402401 ( GLib . MAJOR_VERSION === 2 && GLib . MINOR_VERSION >= 86 ) ;
@@ -409,51 +408,39 @@ Exec=${GLib.find_program_in_path('sh')}
409408` ;
410409 beforeAll ( function ( ) {
411410 // Set up log writer for tests to override
412- writerFunc = jasmine . createSpy ( 'parsed writer func' ) ;
413- const writerFuncWrapper = jasmine . createSpy ( 'log writer func' , ( level , fields ) => {
414- const decoder = new TextDecoder ( 'utf-8' ) ;
415- const domain = decoder . decode ( fields ?. GLIB_DOMAIN ) ;
416- const message = `${ decoder . decode ( fields ?. MESSAGE ) } ` ;
417- if ( level < GLib . LogLevelFlags . LEVEL_WARNING ) {
418- level |= GLib . LogLevelFlags . FLAG_RECURSION ;
419- GLib . log_default_handler ( domain , level , `${ message } \n` , null ) ;
420- }
421- writerFunc ( domain , level , message ) ;
422- return GLib . LogWriterOutput . HANDLED ;
423- } ) ;
424- writerFuncWrapper . and . callThrough ( ) ;
425- GLib . log_set_writer_func ( writerFuncWrapper ) ;
426-
427411 keyFile = new GLib . KeyFile ( ) ;
428412 keyFile . load_from_data ( desktopFileContent , desktopFileContent . length ,
429413 GLib . KeyFileFlags . NONE ) ;
430414 } ) ;
431415
432- afterAll ( function ( ) {
433- GLib . log_set_writer_default ( ) ;
434- } ) ;
435-
436416 beforeEach ( function ( ) {
437417 if ( ! GioUnix )
438418 pending ( 'Not supported platform' ) ;
439419
440- writerFunc . calls . reset ( ) ;
420+ if ( ! requiredVersion )
421+ pending ( 'Installed Gio is not new enough for this test' ) ;
441422 } ) ;
442423
424+ function expectDeprecationWarning ( testFunction ) {
425+ if ( ! requiredVersion )
426+ pending ( 'Installed Gio is not new enough for this test' ) ;
427+
428+ GLib . test_expect_message ( 'Cjs' , GLib . LogLevelFlags . LEVEL_WARNING ,
429+ '*Gio.DesktopAppInfo has been moved to a separate platform-specific library. ' +
430+ 'Please update your code to use GioUnix.DesktopAppInfo instead*' ) ;
431+ testFunction ( ) ;
432+ GLib . test_assert_expected_messages_internal ( 'Cjs' , 'testGio.js' , 0 ,
433+ 'Gio.DesktopAppInfo expectWarnsOnNewerGio' ) ;
434+ }
435+
443436 it ( 'can be created using GioUnix' , function ( ) {
444437 expect ( GioUnix . DesktopAppInfo . new_from_keyfile ( keyFile ) ) . not . toBeNull ( ) ;
445- expect ( writerFunc ) . not . toHaveBeenCalled ( ) ;
446438 } ) ;
447439
448440 it ( 'can be created using Gio wrapper' , function ( ) {
441+ expectDeprecationWarning ( ( ) =>
442+ expect ( Gio . DesktopAppInfo . new_from_keyfile ( keyFile ) ) . not . toBeNull ( ) ) ;
449443 expect ( Gio . DesktopAppInfo . new_from_keyfile ( keyFile ) ) . not . toBeNull ( ) ;
450- expect ( writerFunc ) . toHaveBeenCalledWith ( 'Cjs-Console' ,
451- GLib . LogLevelFlags . LEVEL_WARNING ,
452- 'Gio.DesktopAppInfo is deprecated, please use GioUnix.DesktopAppInfo instead' ) ;
453-
454- writerFunc . calls . reset ( ) ;
455- expect ( Gio . DesktopAppInfo . new_from_keyfile ( keyFile ) ) . not . toBeNull ( ) ;
456- expect ( writerFunc ) . not . toHaveBeenCalled ( ) ;
457444 } ) ;
458445
459446 describe ( 'provides platform-independent functions' , function ( ) {
0 commit comments