Commit 1ea4ba8d authored by Philip Withnall's avatar Philip Withnall

tests: Use static appinfo .desktop file when not launching

The appinfo-test.desktop file is set up with an Exec= path which points
to the compiled and installed appinfo-test utility. When running the
tests uninstalled, however, this might not be present, which causes
loading appinfo-test.desktop to fail.

Split appinfo-test.desktop in two: keep the existing
appinfo-test.desktop for tests which need to launch appinfo-test, and
add a new appinfo-test-static.desktop for tests which don’t launch
anything (and, for example, just inspect GAppInfo properties).
appinfo-test-static.desktop uses an Exec= line which should always be
present (`true`) so it should never fail to load.

Allow the tests using appinfo-test-static.desktop to be run uninstalled
or installed. Allow the tests using appinfo-test.desktop to be skipped
if loading appinfo-test.desktop fails, which is an indicator that the
test is running uninstalled.
Signed-off-by: Philip Withnall's avatarPhilip Withnall <withnall@endlessm.com>
parent 60c2533f
......@@ -339,6 +339,7 @@ dist_test_data += \
dist_test_data += \
appinfo-test-actions.desktop \
appinfo-test-static.desktop \
file.c \
org.gtk.test.dbusappinfo.desktop \
x-content/image-dcf/DCIM/Camera/20130831_203925.jpg \
......
[Desktop Entry]
Type=Application
GenericName=generic-appinfo-test
Name=appinfo-test
Name[de]=appinfo-test-de
X-GNOME-FullName=example
X-GNOME-FullName[de]=Beispiel
Comment=GAppInfo example
Comment[de]=GAppInfo Beispiel
Exec=true --option %U %i --name %c --filename %k %m %%
Icon=testicon.svg
Terminal=true
StartupNotify=true
StartupWMClass=appinfo-class
MimeType=image/png;image/jpeg;
Keywords=keyword1;test keyword;
Categories=GNOME;GTK;
X-JunkFood=Burger
X-JunkFood[de]=Bratwurst
\ No newline at end of file
......@@ -62,7 +62,12 @@ 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_nonnull (appinfo);
if (appinfo == NULL)
{
g_test_skip ("appinfo-test binary not installed");
return;
}
test_launch_for_app_info (appinfo);
g_object_unref (appinfo);
......@@ -146,7 +151,7 @@ test_locale (const char *locale)
g_setenv ("LANGUAGE", locale, TRUE);
setlocale (LC_ALL, "");
path = g_test_get_filename (G_TEST_BUILT, "appinfo-test.desktop", NULL);
path = g_test_get_filename (G_TEST_DIST, "appinfo-test-static.desktop", NULL);
appinfo = (GAppInfo*)g_desktop_app_info_new_from_filename (path);
if (g_strcmp0 (locale, "C") == 0)
......@@ -192,12 +197,12 @@ test_basic (void)
GIcon *icon, *icon2;
const gchar *path;
path = g_test_get_filename (G_TEST_BUILT, "appinfo-test.desktop", NULL);
path = g_test_get_filename (G_TEST_DIST, "appinfo-test-static.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_nonnull (strstr (g_app_info_get_executable (appinfo), "appinfo-test"));
g_assert_cmpstr (g_app_info_get_id (appinfo), ==, "appinfo-test-static.desktop");
g_assert_nonnull (strstr (g_app_info_get_executable (appinfo), "true"));
icon = g_app_info_get_icon (appinfo);
g_assert_true (G_IS_THEMED_ICON (icon));
......@@ -221,6 +226,13 @@ 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);
if (appinfo == NULL)
{
g_test_skip ("appinfo-test binary not installed");
return;
}
g_assert_true (g_app_info_should_show (appinfo));
g_object_unref (appinfo);
......@@ -491,7 +503,7 @@ test_startup_wm_class (void)
const char *wm_class;
const gchar *path;
path = g_test_get_filename (G_TEST_BUILT, "appinfo-test.desktop", NULL);
path = g_test_get_filename (G_TEST_DIST, "appinfo-test-static.desktop", NULL);
appinfo = g_desktop_app_info_new_from_filename (path);
wm_class = g_desktop_app_info_get_startup_wm_class (appinfo);
......@@ -507,7 +519,7 @@ test_supported_types (void)
const char * const *content_types;
const gchar *path;
path = g_test_get_filename (G_TEST_BUILT, "appinfo-test.desktop", NULL);
path = g_test_get_filename (G_TEST_DIST, "appinfo-test-static.desktop", NULL);
appinfo = G_APP_INFO (g_desktop_app_info_new_from_filename (path));
content_types = g_app_info_get_supported_types (appinfo);
......@@ -531,7 +543,7 @@ test_from_keyfile (void)
const gchar *name;
const gchar *path;
path = g_test_get_filename (G_TEST_BUILT, "appinfo-test.desktop", NULL);
path = g_test_get_filename (G_TEST_DIST, "appinfo-test-static.desktop", NULL);
kf = g_key_file_new ();
g_key_file_load_from_file (kf, path, G_KEY_FILE_NONE, &error);
g_assert_no_error (error);
......
......@@ -288,7 +288,7 @@ test_extra_getters (void)
g_setenv ("LANGUAGE", "de_DE.UTF8", TRUE);
setlocale (LC_ALL, "");
appinfo = g_desktop_app_info_new_from_filename (g_test_get_filename (G_TEST_BUILT, "appinfo-test.desktop", NULL));
appinfo = g_desktop_app_info_new_from_filename (g_test_get_filename (G_TEST_DIST, "appinfo-test-static.desktop", NULL));
g_assert_nonnull (appinfo);
g_assert_true (g_desktop_app_info_has_key (appinfo, "Terminal"));
......@@ -739,7 +739,12 @@ test_launch_as_manager (void)
path = g_test_get_filename (G_TEST_BUILT, "appinfo-test.desktop", NULL);
appinfo = g_desktop_app_info_new_from_filename (path);
g_assert_nonnull (appinfo);
if (appinfo == NULL)
{
g_test_skip ("appinfo-test binary not installed");
return;
}
retval = g_desktop_app_info_launch_uris_as_manager (appinfo, NULL, NULL, 0,
NULL, NULL,
......
......@@ -424,6 +424,7 @@ if installed_tests_enabled
'contexts.c',
'g-icon.c',
'appinfo-test-actions.desktop',
'appinfo-test-static.desktop',
'file.c',
'org.gtk.test.dbusappinfo.desktop',
install_dir : installed_tests_execdir,
......
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