macos: Add test case for invalid scheme

You may not always know which schemes are available.

The library should not bail out, but only show
an informal message. It's the responsibility of
the application to deal with invalid URI schemes.
This commit is contained in:
Arjan Molenaar 2024-07-24 17:24:46 +02:00
parent fac8a8c8d8
commit 1053c016d9
2 changed files with 12 additions and 2 deletions

View File

@ -800,7 +800,7 @@ g_app_info_get_default_for_uri_scheme_impl (const char *uri_scheme)
if (!bundle_id)
{
g_warning ("No default handler found for url scheme '%s'.", uri_scheme);
g_info ("No default handler found for url scheme '%s'.", uri_scheme);
return NULL;
}

View File

@ -62,13 +62,23 @@ test_launch_async (void)
g_clear_object (&app_info);
}
static void
test_invalid_uri_scheme (void)
{
GAppInfo *app_info;
app_info = g_app_info_get_default_for_uri_scheme("thisisnotanurlscheme");
g_assert_null (app_info);
}
int
main (int argc,
char *argv[])
{
g_test_init (&argc, &argv, G_TEST_OPTION_ISOLATE_DIRS, NULL);
g_test_init (&argc, &argv, NULL, NULL);
g_test_add_func ("/osx-app-info/launch-async", test_launch_async);
g_test_add_func ("/osx-app-info/invalid-uri-scheme", test_invalid_uri_scheme);
return g_test_run ();
}