diff options
author | Philip Withnall <pwithnall@endlessos.org> | 2023-03-22 14:42:22 +0000 |
---|---|---|
committer | Philip Withnall <pwithnall@endlessos.org> | 2023-03-22 15:12:49 +0000 |
commit | c0ca3f995ba7755c797f15981429ba4156afc8ed (patch) | |
tree | 75b3f22f0b1f4ee252f8c2dbb989df492cf3940f | |
parent | 9279f3b0f9f08b63ea89245c175c5f872e9947e6 (diff) | |
download | glib-c0ca3f995ba7755c797f15981429ba4156afc8ed.tar.gz |
tests: Fix a FIXME in the appmonitor test
The test thought that calling `g_app_info_get()` was a bit of a hack,
but actually it (or calling another `g_app_info_*()` function) is the
right way to use the `GAppInfoMonitor` API.
See the documentation improvements a couple of commits back for details.
The remaining FIXME higher up in the test should probably be fixed by
getting `g_app_info_monitor_get()` to arm the signal. That requires
changes in `g_app_info_monitor_get()` to call `desktop_file_dir_init()`.
That will have to happen another time.
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
Helps: #799
-rw-r--r-- | gio/tests/appmonitor.c | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/gio/tests/appmonitor.c b/gio/tests/appmonitor.c index 50a0c5863..e973b990d 100644 --- a/gio/tests/appmonitor.c +++ b/gio/tests/appmonitor.c @@ -22,6 +22,10 @@ #include <gio/gio.h> #include <gstdio.h> +#ifdef G_OS_UNIX +#include <gio/gdesktopappinfo.h> +#endif + typedef struct { gchar *applications_dir; @@ -45,6 +49,7 @@ teardown (Fixture *fixture, g_clear_pointer (&fixture->applications_dir, g_free); } +#ifdef G_OS_UNIX static gboolean create_app (gpointer data) { @@ -90,19 +95,17 @@ quit_loop (gpointer data) return G_SOURCE_REMOVE; } +#endif /* G_OS_UNIX */ static void test_app_monitor (Fixture *fixture, gconstpointer user_data) { +#ifdef G_OS_UNIX gchar *app_path; GAppInfoMonitor *monitor; GMainLoop *loop; - -#ifdef G_OS_WIN32 - g_test_skip (".desktop monitor on win32"); - return; -#endif + GDesktopAppInfo *app = NULL; app_path = g_build_filename (fixture->applications_dir, "app.desktop", NULL); @@ -121,8 +124,11 @@ test_app_monitor (Fixture *fixture, g_assert_true (changed_fired); changed_fired = FALSE; - /* FIXME: this shouldn't be required */ - g_list_free_full (g_app_info_get_all (), g_object_unref); + /* Check that the app is now queryable. This has the side-effect of re-arming + * the #GAppInfoMonitor::changed signal for the next part of the test. */ + app = g_desktop_app_info_new ("app.desktop"); + g_assert_nonnull (app); + g_clear_object (&app); g_timeout_add_seconds (3, quit_loop, loop); @@ -138,6 +144,9 @@ test_app_monitor (Fixture *fixture, g_object_unref (monitor); g_free (app_path); +#else /* if !G_OS_UNIX */ + g_test_skip (".desktop monitor on win32"); +#endif /* !G_OS_UNIX */ } int |