mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-10 03:16:17 +01:00
tests: find update-desktop-database
Disable tests that require update-desktop-database when it is missing. It requires glib to build so it will be missing when bootstrapping glib. Refactor the ifdef for Windows and MacOS while at it and reduce number of ifdefs. Ref: https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3658 Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
This commit is contained in:
parent
7322a925e2
commit
2c042cd466
@ -125,6 +125,20 @@ create_app_info (const char *name)
|
||||
return info;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
skip_missing_update_desktop_database (void)
|
||||
{
|
||||
gchar *path = g_find_program_in_path ("update-desktop-database");
|
||||
|
||||
if (path == NULL)
|
||||
{
|
||||
g_test_skip ("update-desktop-database is required to run this test");
|
||||
return TRUE;
|
||||
}
|
||||
g_free (path);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
test_delete (void)
|
||||
{
|
||||
@ -134,6 +148,9 @@ test_delete (void)
|
||||
char *filename;
|
||||
gboolean res;
|
||||
|
||||
if (skip_missing_update_desktop_database ())
|
||||
return;
|
||||
|
||||
info = create_app_info ("Blah");
|
||||
|
||||
id = g_app_info_get_id (info);
|
||||
@ -177,6 +194,9 @@ test_default (void)
|
||||
GList *list;
|
||||
GError *error = NULL;
|
||||
|
||||
if (skip_missing_update_desktop_database ())
|
||||
return;
|
||||
|
||||
info1 = create_app_info ("Blah1");
|
||||
info2 = create_app_info ("Blah2");
|
||||
info3 = create_app_info ("Blah3");
|
||||
@ -316,6 +336,9 @@ test_default_async (void)
|
||||
GList *list;
|
||||
GError *error = NULL;
|
||||
|
||||
if (skip_missing_update_desktop_database ())
|
||||
return;
|
||||
|
||||
data.loop = g_main_loop_new (NULL, TRUE);
|
||||
|
||||
info1 = create_app_info ("Blah1");
|
||||
@ -418,6 +441,9 @@ test_fallback (void)
|
||||
GError *error = NULL;
|
||||
gint old_length;
|
||||
|
||||
if (skip_missing_update_desktop_database ())
|
||||
return;
|
||||
|
||||
info1 = create_app_info ("Test1");
|
||||
info2 = create_app_info ("Test2");
|
||||
|
||||
@ -492,6 +518,9 @@ test_last_used (void)
|
||||
GAppInfo *info1, *info2, *default_app;
|
||||
GError *error = NULL;
|
||||
|
||||
if (skip_missing_update_desktop_database ())
|
||||
return;
|
||||
|
||||
info1 = create_app_info ("Test1");
|
||||
info2 = create_app_info ("Test2");
|
||||
|
||||
@ -1222,6 +1251,9 @@ test_default_uri_handler (void)
|
||||
gchar *file_path = NULL;
|
||||
GAppInfo *info;
|
||||
|
||||
if (skip_missing_update_desktop_database ())
|
||||
return;
|
||||
|
||||
info = create_app_info_toucher ("Touch Handled", "handled",
|
||||
"x-scheme-handler/glib-touch",
|
||||
&file_path);
|
||||
@ -1298,6 +1330,9 @@ test_default_uri_handler_async (void)
|
||||
gboolean called = FALSE;
|
||||
gint64 start_time, touch_time;
|
||||
|
||||
if (skip_missing_update_desktop_database ())
|
||||
return;
|
||||
|
||||
loop = g_main_loop_new (NULL, FALSE);
|
||||
info = create_app_info_toucher ("Touch Handled", "handled-async",
|
||||
"x-scheme-handler/glib-async-touch",
|
||||
|
@ -3784,6 +3784,20 @@ create_command_line_app_info (const char *name,
|
||||
return g_steal_pointer (&info);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
skip_missing_update_desktop_database (void)
|
||||
{
|
||||
gchar *path = g_find_program_in_path ("update-desktop-database");
|
||||
|
||||
if (path == NULL)
|
||||
{
|
||||
g_test_skip ("update-desktop-database is required to run this test");
|
||||
return TRUE;
|
||||
}
|
||||
g_free (path);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
test_query_default_handler_uri (void)
|
||||
{
|
||||
@ -3793,10 +3807,8 @@ test_query_default_handler_uri (void)
|
||||
GFile *file;
|
||||
GFile *invalid_file;
|
||||
|
||||
#if defined(G_OS_WIN32) || defined(__APPLE__)
|
||||
g_test_skip ("Default URI handlers are not currently supported on Windows or macOS");
|
||||
return;
|
||||
#endif
|
||||
if (skip_missing_update_desktop_database ())
|
||||
return;
|
||||
|
||||
info = create_command_line_app_info ("Gio File Handler", "true",
|
||||
"x-scheme-handler/gio-file");
|
||||
@ -3878,10 +3890,8 @@ test_query_default_handler_file (void)
|
||||
const char buffer[] = "Text file!\n";
|
||||
const guint8 binary_buffer[] = "\xde\xad\xbe\xff";
|
||||
|
||||
#if defined(G_OS_WIN32) || defined(__APPLE__)
|
||||
g_test_skip ("Default URI handlers are not currently supported on Windows or macOS");
|
||||
return;
|
||||
#endif
|
||||
if (skip_missing_update_desktop_database ())
|
||||
return;
|
||||
|
||||
text_file = g_file_new_tmp ("query-default-handler-XXXXXX", &iostream, &error);
|
||||
g_assert_no_error (error);
|
||||
@ -3974,10 +3984,8 @@ test_query_default_handler_file_async (void)
|
||||
const guint8 binary_buffer[] = "\xde\xad\xbe\xff";
|
||||
GError *error = NULL;
|
||||
|
||||
#if defined(G_OS_WIN32) || defined(__APPLE__)
|
||||
g_test_skip ("Default URI handlers are not currently supported on Windows or macOS");
|
||||
return;
|
||||
#endif
|
||||
if (skip_missing_update_desktop_database ())
|
||||
return;
|
||||
|
||||
data.loop = g_main_loop_new (NULL, FALSE);
|
||||
|
||||
@ -4064,10 +4072,8 @@ test_query_default_handler_uri_async (void)
|
||||
GFile *file;
|
||||
GFile *invalid_file;
|
||||
|
||||
#if defined(G_OS_WIN32) || defined(__APPLE__)
|
||||
g_test_skip ("Default URI handlers are not currently supported on Windows or macOS");
|
||||
return;
|
||||
#endif
|
||||
if (skip_missing_update_desktop_database ())
|
||||
return;
|
||||
|
||||
info = create_command_line_app_info ("Gio File Handler", "true",
|
||||
"x-scheme-handler/gio-file");
|
||||
|
Loading…
Reference in New Issue
Block a user