mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-11 15:06:14 +01:00
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 <withnall@endlessm.com>
This commit is contained in:
parent
60c2533f44
commit
1ea4ba8d6e
@ -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 \
|
||||
|
19
gio/tests/appinfo-test-static.desktop
Normal file
19
gio/tests/appinfo-test-static.desktop
Normal file
@ -0,0 +1,19 @@
|
||||
[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
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user