Commit 60c2533f authored by Philip Withnall's avatar Philip Withnall

tests: Port appinfo test from g_assert() to g_assert_*()

Signed-off-by: Philip Withnall's avatarPhilip Withnall <withnall@endlessm.com>
parent 707c3f24
......@@ -9,7 +9,8 @@
static void
test_launch_for_app_info (GAppInfo *appinfo)
{
GError *error;
GError *error = NULL;
gboolean success;
GFile *file;
GList *l;
const gchar *path;
......@@ -21,20 +22,22 @@ test_launch_for_app_info (GAppInfo *appinfo)
return;
}
error = NULL;
g_assert (g_app_info_launch (appinfo, NULL, NULL, &error));
success = g_app_info_launch (appinfo, NULL, NULL, &error);
g_assert_no_error (error);
g_assert_true (success);
g_assert (g_app_info_launch_uris (appinfo, NULL, NULL, &error));
success = g_app_info_launch_uris (appinfo, NULL, NULL, &error);
g_assert_no_error (error);
g_assert_true (success);
path = g_test_get_filename (G_TEST_BUILT, "appinfo-test.desktop", NULL);
file = g_file_new_for_path (path);
l = NULL;
l = g_list_append (l, file);
g_assert (g_app_info_launch (appinfo, l, NULL, &error));
success = g_app_info_launch (appinfo, l, NULL, &error);
g_assert_no_error (error);
g_assert_true (success);
g_list_free (l);
g_object_unref (file);
......@@ -43,8 +46,10 @@ test_launch_for_app_info (GAppInfo *appinfo)
l = g_list_append (l, uri);
l = g_list_append (l, "file:///etc/group#adm");
g_assert (g_app_info_launch_uris (appinfo, l, NULL, &error));
success = g_app_info_launch_uris (appinfo, l, NULL, &error);
g_assert_no_error (error);
g_assert_true (success);
g_list_free (l);
g_free (uri);
}
......@@ -57,7 +62,7 @@ test_launch (void)
path = g_test_get_filename (G_TEST_BUILT, "appinfo-test.desktop", NULL);
appinfo = (GAppInfo*)g_desktop_app_info_new_from_filename (path);
g_assert (appinfo != NULL);
g_assert_nonnull (appinfo);
test_launch_for_app_info (appinfo);
g_object_unref (appinfo);
......@@ -117,7 +122,7 @@ test_launch_no_app_id (void)
g_assert_true (loaded);
appinfo = (GAppInfo*)g_desktop_app_info_new_from_keyfile (fake_desktop_file);
g_assert (appinfo != NULL);
g_assert_nonnull (appinfo);
test_launch_for_app_info (appinfo);
......@@ -189,14 +194,15 @@ test_basic (void)
path = g_test_get_filename (G_TEST_BUILT, "appinfo-test.desktop", NULL);
appinfo = (GAppInfo*)g_desktop_app_info_new_from_filename (path);
g_assert_nonnull (appinfo);
g_assert_cmpstr (g_app_info_get_id (appinfo), ==, "appinfo-test.desktop");
g_assert (strstr (g_app_info_get_executable (appinfo), "appinfo-test") != NULL);
g_assert_nonnull (strstr (g_app_info_get_executable (appinfo), "appinfo-test"));
icon = g_app_info_get_icon (appinfo);
g_assert (G_IS_THEMED_ICON (icon));
g_assert_true (G_IS_THEMED_ICON (icon));
icon2 = g_themed_icon_new ("testicon");
g_assert (g_icon_equal (icon, icon2));
g_assert_true (g_icon_equal (icon, icon2));
g_object_unref (icon2);
appinfo2 = g_app_info_dup (appinfo);
......@@ -215,17 +221,17 @@ test_show_in (void)
path = g_test_get_filename (G_TEST_BUILT, "appinfo-test.desktop", NULL);
appinfo = (GAppInfo*)g_desktop_app_info_new_from_filename (path);
g_assert (g_app_info_should_show (appinfo));
g_assert_true (g_app_info_should_show (appinfo));
g_object_unref (appinfo);
path = g_test_get_filename (G_TEST_BUILT, "appinfo-test-gnome.desktop", NULL);
appinfo = (GAppInfo*)g_desktop_app_info_new_from_filename (path);
g_assert (g_app_info_should_show (appinfo));
g_assert_true (g_app_info_should_show (appinfo));
g_object_unref (appinfo);
path = g_test_get_filename (G_TEST_BUILT, "appinfo-test-notgnome.desktop", NULL);
appinfo = (GAppInfo*)g_desktop_app_info_new_from_filename (path);
g_assert (!g_app_info_should_show (appinfo));
g_assert_false (g_app_info_should_show (appinfo));
g_object_unref (appinfo);
}
......@@ -245,12 +251,12 @@ test_commandline (void)
"cmdline-app-test",
G_APP_INFO_CREATE_SUPPORTS_URIS,
&error);
g_assert (appinfo != NULL);
g_assert_no_error (error);
g_assert_nonnull (appinfo);
g_assert_cmpstr (g_app_info_get_name (appinfo), ==, "cmdline-app-test");
g_assert_cmpstr (g_app_info_get_commandline (appinfo), ==, cmdline_out);
g_assert (g_app_info_supports_uris (appinfo));
g_assert (!g_app_info_supports_files (appinfo));
g_assert_true (g_app_info_supports_uris (appinfo));
g_assert_false (g_app_info_supports_files (appinfo));
g_object_unref (appinfo);
......@@ -262,12 +268,12 @@ test_commandline (void)
"cmdline-app-test",
G_APP_INFO_CREATE_NONE,
&error);
g_assert (appinfo != NULL);
g_assert_no_error (error);
g_assert_nonnull (appinfo);
g_assert_cmpstr (g_app_info_get_name (appinfo), ==, "cmdline-app-test");
g_assert_cmpstr (g_app_info_get_commandline (appinfo), ==, cmdline_out);
g_assert (!g_app_info_supports_uris (appinfo));
g_assert (g_app_info_supports_files (appinfo));
g_assert_false (g_app_info_supports_uris (appinfo));
g_assert_true (g_app_info_supports_files (appinfo));
g_object_unref (appinfo);
......@@ -292,10 +298,10 @@ test_launch_context (void)
NULL);
str = g_app_launch_context_get_display (context, appinfo, NULL);
g_assert (str == NULL);
g_assert_null (str);
str = g_app_launch_context_get_startup_notify_id (context, appinfo, NULL);
g_assert (str == NULL);
g_assert_null (str);
g_object_unref (appinfo);
g_object_unref (context);
......@@ -314,8 +320,8 @@ launched (GAppLaunchContext *context,
gint pid;
pid = 0;
g_assert (g_variant_lookup (platform_data, "pid", "i", &pid));
g_assert (pid != 0);
g_assert_true (g_variant_lookup (platform_data, "pid", "i", &pid));
g_assert_cmpint (pid, !=, 0);
launched_reached = TRUE;
}
......@@ -333,6 +339,7 @@ test_launch_context_signals (void)
GAppLaunchContext *context;
GAppInfo *appinfo;
GError *error = NULL;
gboolean success;
gchar *cmdline;
cmdline = g_strconcat (g_test_get_dir (G_TEST_BUILT), "/appinfo-test --option", NULL);
......@@ -345,11 +352,11 @@ test_launch_context_signals (void)
G_APP_INFO_CREATE_SUPPORTS_URIS,
NULL);
error = NULL;
g_assert (g_app_info_launch (appinfo, NULL, context, &error));
success = g_app_info_launch (appinfo, NULL, context, &error);
g_assert_no_error (error);
g_assert_true (success);
g_assert (launched_reached);
g_assert_true (launched_reached);
g_object_unref (appinfo);
g_object_unref (context);
......@@ -366,7 +373,7 @@ test_tryexec (void)
path = g_test_get_filename (G_TEST_BUILT, "appinfo-test2.desktop", NULL);
appinfo = (GAppInfo*)g_desktop_app_info_new_from_filename (path);
g_assert (appinfo == NULL);
g_assert_null (appinfo);
}
/* Test that we can set an appinfo as default for a mime type or
......@@ -377,7 +384,7 @@ test_associations (void)
{
GAppInfo *appinfo;
GAppInfo *appinfo2;
GError *error;
GError *error = NULL;
gboolean result;
GList *list;
gchar *cmdline;
......@@ -389,33 +396,31 @@ test_associations (void)
NULL);
g_free (cmdline);
error = NULL;
result = g_app_info_set_as_default_for_type (appinfo, "application/x-glib-test", &error);
g_assert (result);
g_assert_no_error (error);
g_assert_true (result);
appinfo2 = g_app_info_get_default_for_type ("application/x-glib-test", FALSE);
g_assert (appinfo2);
g_assert_nonnull (appinfo2);
g_assert_cmpstr (g_app_info_get_commandline (appinfo), ==, g_app_info_get_commandline (appinfo2));
g_object_unref (appinfo2);
result = g_app_info_set_as_default_for_extension (appinfo, "gio-tests", &error);
g_assert (result);
g_assert_no_error (error);
g_assert_true (result);
appinfo2 = g_app_info_get_default_for_type ("application/x-extension-gio-tests", FALSE);
g_assert (appinfo2);
g_assert_nonnull (appinfo2);
g_assert_cmpstr (g_app_info_get_commandline (appinfo), ==, g_app_info_get_commandline (appinfo2));
g_object_unref (appinfo2);
result = g_app_info_add_supports_type (appinfo, "application/x-gio-test", &error);
g_assert (result);
g_assert_no_error (error);
g_assert_true (result);
list = g_app_info_get_all_for_type ("application/x-gio-test");
g_assert_cmpint (g_list_length (list), ==, 1);
......@@ -424,12 +429,13 @@ test_associations (void)
g_object_unref (appinfo2);
g_list_free (list);
g_assert (g_app_info_can_remove_supports_type (appinfo));
g_assert (g_app_info_remove_supports_type (appinfo, "application/x-gio-test", &error));
g_assert_true (g_app_info_can_remove_supports_type (appinfo));
result = g_app_info_remove_supports_type (appinfo, "application/x-gio-test", &error);
g_assert_no_error (error);
g_assert_true (result);
g_assert (g_app_info_can_delete (appinfo));
g_assert (g_app_info_delete (appinfo));
g_assert_true (g_app_info_can_delete (appinfo));
g_assert_true (g_app_info_delete (appinfo));
g_object_unref (appinfo);
}
......@@ -448,8 +454,8 @@ test_environment (void)
env = g_app_launch_context_get_environment (ctx);
g_assert (g_environ_getenv (env, "FOO") == NULL);
g_assert (g_environ_getenv (env, "BLA") == NULL);
g_assert_null (g_environ_getenv (env, "FOO"));
g_assert_null (g_environ_getenv (env, "BLA"));
g_assert_cmpstr (g_environ_getenv (env, "PATH"), ==, path);
g_strfreev (env);
......@@ -471,7 +477,7 @@ test_environment (void)
env = g_app_launch_context_get_environment (ctx);
g_assert_cmpstr (g_environ_getenv (env, "FOO"), ==, "baz");
g_assert (g_environ_getenv (env, "BLA") == NULL);
g_assert_null (g_environ_getenv (env, "BLA"));
g_strfreev (env);
......@@ -531,13 +537,13 @@ test_from_keyfile (void)
g_assert_no_error (error);
info = g_desktop_app_info_new_from_keyfile (kf);
g_key_file_unref (kf);
g_assert (info != NULL);
g_assert_nonnull (info);
g_object_get (info, "filename", &file, NULL);
g_assert (file == NULL);
g_assert_null (file);
file = g_desktop_app_info_get_filename (info);
g_assert (file == NULL);
g_assert_null (file);
categories = g_desktop_app_info_get_categories (info);
g_assert_cmpstr (categories, ==, "GNOME;GTK;");
categories_list = g_desktop_app_info_get_string_list (info, "Categories", &categories_count);
......@@ -551,7 +557,7 @@ test_from_keyfile (void)
g_assert_cmpstr (keywords[1], ==, "test keyword");
name = g_desktop_app_info_get_generic_name (info);
g_assert_cmpstr (name, ==, "generic-appinfo-test");
g_assert (!g_desktop_app_info_get_nodisplay (info));
g_assert_false (g_desktop_app_info_get_nodisplay (info));
g_strfreev (categories_list);
g_object_unref (info);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment