2008-09-26 21:57:36 +02:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2008 Red Hat, Inc
|
|
|
|
*
|
2022-05-18 10:20:07 +02:00
|
|
|
* SPDX-License-Identifier: LGPL-2.1-or-later
|
|
|
|
*
|
2008-09-26 21:57:36 +02:00
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
2017-05-27 17:19:21 +02:00
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
2008-09-26 21:57:36 +02:00
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General
|
2014-01-23 12:58:29 +01:00
|
|
|
* Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
2008-09-26 21:57:36 +02:00
|
|
|
*
|
|
|
|
* Author: Matthias Clasen
|
|
|
|
*/
|
|
|
|
|
2018-01-07 12:14:46 +01:00
|
|
|
#include <locale.h>
|
|
|
|
|
2008-09-26 21:57:36 +02:00
|
|
|
#include <glib/glib.h>
|
2017-02-24 10:46:36 +01:00
|
|
|
#include <glib/gstdio.h>
|
2008-09-26 21:57:36 +02:00
|
|
|
#include <gio/gio.h>
|
|
|
|
#include <gio/gdesktopappinfo.h>
|
2022-09-13 00:22:02 +02:00
|
|
|
#include <gio/gunixinputstream.h>
|
|
|
|
#include <glib-unix.h>
|
2008-09-26 21:57:36 +02:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2013-07-11 18:46:59 +02:00
|
|
|
#include <unistd.h>
|
2022-10-17 20:44:14 +02:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
2008-09-26 21:57:36 +02:00
|
|
|
|
2022-10-24 13:02:40 +02:00
|
|
|
G_DECLARE_FINAL_TYPE (TestLaunchContext, test_launch_context, TEST,
|
|
|
|
LAUNCH_CONTEXT, GAppLaunchContext);
|
|
|
|
|
|
|
|
struct _TestLaunchContext {
|
|
|
|
GAppLaunchContext parent;
|
|
|
|
|
|
|
|
char *overriden_startup_notify_id;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct _TestLaunchContextClass {
|
|
|
|
GAppLaunchContextClass parent;
|
|
|
|
};
|
|
|
|
|
|
|
|
G_DEFINE_FINAL_TYPE (TestLaunchContext, test_launch_context,
|
|
|
|
G_TYPE_APP_LAUNCH_CONTEXT);
|
|
|
|
|
|
|
|
static void
|
|
|
|
test_launch_context_init (TestLaunchContext *test_context)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *
|
|
|
|
test_launch_context_get_startup_notify_id (GAppLaunchContext *context,
|
|
|
|
GAppInfo *app_info,
|
|
|
|
GList *files)
|
|
|
|
{
|
|
|
|
TestLaunchContext *test_context = TEST_LAUNCH_CONTEXT (context);
|
|
|
|
|
|
|
|
if (test_context->overriden_startup_notify_id)
|
|
|
|
return g_strdup (test_context->overriden_startup_notify_id);
|
|
|
|
|
|
|
|
if (g_app_info_get_id (app_info))
|
|
|
|
return g_strdup (g_app_info_get_id (app_info));
|
|
|
|
|
|
|
|
if (g_app_info_get_display_name (app_info))
|
|
|
|
return g_strdup (g_app_info_get_display_name (app_info));
|
|
|
|
|
|
|
|
return g_strdup (g_app_info_get_commandline (app_info));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
test_launch_context_get_startup_notify_dispose (GObject *object)
|
|
|
|
{
|
|
|
|
TestLaunchContext *test_context = TEST_LAUNCH_CONTEXT (object);
|
|
|
|
|
|
|
|
g_clear_pointer (&test_context->overriden_startup_notify_id, g_free);
|
|
|
|
G_OBJECT_CLASS (test_launch_context_parent_class)->dispose (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
test_launch_context_class_init (TestLaunchContextClass *klass)
|
|
|
|
{
|
|
|
|
G_APP_LAUNCH_CONTEXT_CLASS (klass)->get_startup_notify_id = test_launch_context_get_startup_notify_id;
|
|
|
|
G_OBJECT_CLASS (klass)->dispose = test_launch_context_get_startup_notify_dispose;
|
|
|
|
}
|
|
|
|
|
2018-11-30 19:03:41 +01:00
|
|
|
static GAppInfo *
|
2022-06-14 21:47:33 +02:00
|
|
|
create_command_line_app_info (const char *name,
|
|
|
|
const char *command_line,
|
|
|
|
const char *default_for_type)
|
2008-09-26 21:57:36 +02:00
|
|
|
{
|
|
|
|
GAppInfo *info;
|
2022-06-14 21:47:33 +02:00
|
|
|
GError *error = NULL;
|
2008-09-26 21:57:36 +02:00
|
|
|
|
2022-06-14 21:47:33 +02:00
|
|
|
info = g_app_info_create_from_commandline (command_line,
|
2008-09-26 21:57:36 +02:00
|
|
|
name,
|
|
|
|
G_APP_INFO_CREATE_NONE,
|
|
|
|
&error);
|
2018-12-03 15:50:30 +01:00
|
|
|
g_assert_no_error (error);
|
2008-09-26 21:57:36 +02:00
|
|
|
|
2022-06-14 21:47:33 +02:00
|
|
|
g_app_info_set_as_default_for_type (info, default_for_type, &error);
|
2018-12-03 15:50:30 +01:00
|
|
|
g_assert_no_error (error);
|
2022-06-14 21:47:33 +02:00
|
|
|
|
|
|
|
return g_steal_pointer (&info);
|
|
|
|
}
|
|
|
|
|
|
|
|
static GAppInfo *
|
|
|
|
create_app_info (const char *name)
|
|
|
|
{
|
|
|
|
GError *error = NULL;
|
|
|
|
GAppInfo *info;
|
|
|
|
|
|
|
|
info = create_command_line_app_info (name, "true blah", "application/x-blah");
|
|
|
|
|
|
|
|
/* this is necessary to ensure that the info is saved */
|
2008-09-26 21:57:36 +02:00
|
|
|
g_app_info_remove_supports_type (info, "application/x-blah", &error);
|
2018-12-03 15:50:30 +01:00
|
|
|
g_assert_no_error (error);
|
2008-09-26 21:57:36 +02:00
|
|
|
g_app_info_reset_type_associations ("application/x-blah");
|
|
|
|
|
|
|
|
return info;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
test_delete (void)
|
|
|
|
{
|
|
|
|
GAppInfo *info;
|
|
|
|
|
|
|
|
const char *id;
|
|
|
|
char *filename;
|
|
|
|
gboolean res;
|
|
|
|
|
|
|
|
info = create_app_info ("Blah");
|
|
|
|
|
|
|
|
id = g_app_info_get_id (info);
|
2018-12-03 15:50:30 +01:00
|
|
|
g_assert_nonnull (id);
|
2008-09-26 21:57:36 +02:00
|
|
|
|
2018-11-30 19:03:41 +01:00
|
|
|
filename = g_build_filename (g_get_user_data_dir (), "applications", id, NULL);
|
2008-09-26 21:57:36 +02:00
|
|
|
|
|
|
|
res = g_file_test (filename, G_FILE_TEST_EXISTS);
|
2018-12-03 15:50:30 +01:00
|
|
|
g_assert_true (res);
|
2008-09-26 21:57:36 +02:00
|
|
|
|
|
|
|
res = g_app_info_can_delete (info);
|
2018-12-03 15:50:30 +01:00
|
|
|
g_assert_true (res);
|
2008-09-26 21:57:36 +02:00
|
|
|
|
|
|
|
res = g_app_info_delete (info);
|
2018-12-03 15:50:30 +01:00
|
|
|
g_assert_true (res);
|
2008-09-26 21:57:36 +02:00
|
|
|
|
|
|
|
res = g_file_test (filename, G_FILE_TEST_EXISTS);
|
2018-12-03 15:50:30 +01:00
|
|
|
g_assert_false (res);
|
2008-09-26 21:57:36 +02:00
|
|
|
|
|
|
|
g_object_unref (info);
|
|
|
|
|
|
|
|
if (g_file_test ("/usr/share/applications/gedit.desktop", G_FILE_TEST_EXISTS))
|
|
|
|
{
|
2010-12-28 12:17:10 +01:00
|
|
|
info = (GAppInfo*)g_desktop_app_info_new_from_filename ("/usr/share/applications/gedit.desktop");
|
2018-12-03 15:50:30 +01:00
|
|
|
g_assert_nonnull (info);
|
2008-09-26 21:57:36 +02:00
|
|
|
|
|
|
|
res = g_app_info_can_delete (info);
|
2018-12-03 15:50:30 +01:00
|
|
|
g_assert_false (res);
|
2008-09-26 21:57:36 +02:00
|
|
|
|
|
|
|
res = g_app_info_delete (info);
|
2018-12-03 15:50:30 +01:00
|
|
|
g_assert_false (res);
|
2008-09-26 21:57:36 +02:00
|
|
|
}
|
2018-06-27 10:57:21 +02:00
|
|
|
|
|
|
|
g_free (filename);
|
2008-09-26 21:57:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
test_default (void)
|
|
|
|
{
|
|
|
|
GAppInfo *info, *info1, *info2, *info3;
|
|
|
|
GList *list;
|
|
|
|
GError *error = NULL;
|
|
|
|
|
|
|
|
info1 = create_app_info ("Blah1");
|
|
|
|
info2 = create_app_info ("Blah2");
|
|
|
|
info3 = create_app_info ("Blah3");
|
|
|
|
|
|
|
|
g_app_info_set_as_default_for_type (info1, "application/x-test", &error);
|
2018-12-03 15:50:30 +01:00
|
|
|
g_assert_no_error (error);
|
2008-09-26 21:57:36 +02:00
|
|
|
|
|
|
|
g_app_info_set_as_default_for_type (info2, "application/x-test", &error);
|
2018-12-03 15:50:30 +01:00
|
|
|
g_assert_no_error (error);
|
2008-09-26 21:57:36 +02:00
|
|
|
|
2014-04-11 04:32:28 +02:00
|
|
|
info = g_app_info_get_default_for_type ("application/x-test", FALSE);
|
2018-12-03 15:50:30 +01:00
|
|
|
g_assert_nonnull (info);
|
2014-04-10 01:23:27 +02:00
|
|
|
g_assert_cmpstr (g_app_info_get_id (info), ==, g_app_info_get_id (info2));
|
2018-06-27 10:57:21 +02:00
|
|
|
g_object_unref (info);
|
2008-09-26 21:57:36 +02:00
|
|
|
|
2022-06-14 16:30:42 +02:00
|
|
|
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
|
|
|
|
"*assertion*uri_scheme*failed*");
|
|
|
|
g_assert_null (g_app_info_get_default_for_uri_scheme (NULL));
|
|
|
|
g_test_assert_expected_messages ();
|
|
|
|
|
|
|
|
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
|
|
|
|
"*assertion*uri_scheme*failed*");
|
|
|
|
g_assert_null (g_app_info_get_default_for_uri_scheme (""));
|
|
|
|
g_test_assert_expected_messages ();
|
|
|
|
|
|
|
|
g_app_info_set_as_default_for_type (info3, "x-scheme-handler/glib", &error);
|
|
|
|
g_assert_no_error (error);
|
|
|
|
info = g_app_info_get_default_for_uri_scheme ("glib");
|
|
|
|
g_assert_nonnull (info);
|
|
|
|
g_assert_true (g_app_info_equal (info, info3));
|
|
|
|
g_object_unref (info);
|
|
|
|
|
2014-04-11 04:32:28 +02:00
|
|
|
/* now try adding something, but not setting as default */
|
2008-09-26 21:57:36 +02:00
|
|
|
g_app_info_add_supports_type (info3, "application/x-test", &error);
|
2018-12-03 15:50:30 +01:00
|
|
|
g_assert_no_error (error);
|
2008-09-26 21:57:36 +02:00
|
|
|
|
2014-04-11 04:32:28 +02:00
|
|
|
/* check that info2 is still default */
|
|
|
|
info = g_app_info_get_default_for_type ("application/x-test", FALSE);
|
2018-12-03 15:50:30 +01:00
|
|
|
g_assert_nonnull (info);
|
2014-04-10 01:23:27 +02:00
|
|
|
g_assert_cmpstr (g_app_info_get_id (info), ==, g_app_info_get_id (info2));
|
2018-06-27 10:57:21 +02:00
|
|
|
g_object_unref (info);
|
2008-09-26 21:57:36 +02:00
|
|
|
|
|
|
|
/* now remove info1 again */
|
|
|
|
g_app_info_remove_supports_type (info1, "application/x-test", &error);
|
2018-12-03 15:50:30 +01:00
|
|
|
g_assert_no_error (error);
|
2008-09-26 21:57:36 +02:00
|
|
|
|
2014-04-11 04:32:28 +02:00
|
|
|
/* and make sure info2 is still default */
|
|
|
|
info = g_app_info_get_default_for_type ("application/x-test", FALSE);
|
2018-12-03 15:50:30 +01:00
|
|
|
g_assert_nonnull (info);
|
2014-04-10 01:23:27 +02:00
|
|
|
g_assert_cmpstr (g_app_info_get_id (info), ==, g_app_info_get_id (info2));
|
2018-06-27 10:57:21 +02:00
|
|
|
g_object_unref (info);
|
2008-09-26 21:57:36 +02:00
|
|
|
|
|
|
|
/* now clean it all up */
|
|
|
|
g_app_info_reset_type_associations ("application/x-test");
|
2022-06-14 16:30:42 +02:00
|
|
|
g_app_info_reset_type_associations ("x-scheme-handler/glib");
|
2008-09-26 21:57:36 +02:00
|
|
|
|
|
|
|
list = g_app_info_get_all_for_type ("application/x-test");
|
2018-12-03 15:50:30 +01:00
|
|
|
g_assert_null (list);
|
2014-04-11 04:32:28 +02:00
|
|
|
|
2022-06-14 16:30:42 +02:00
|
|
|
list = g_app_info_get_all_for_type ("x-scheme-handler/glib");
|
|
|
|
g_assert_null (list);
|
|
|
|
|
2008-09-26 21:57:36 +02:00
|
|
|
g_app_info_delete (info1);
|
|
|
|
g_app_info_delete (info2);
|
|
|
|
g_app_info_delete (info3);
|
|
|
|
|
|
|
|
g_object_unref (info1);
|
|
|
|
g_object_unref (info2);
|
2018-06-27 10:57:21 +02:00
|
|
|
g_object_unref (info3);
|
2008-09-26 21:57:36 +02:00
|
|
|
}
|
|
|
|
|
2022-06-01 21:45:58 +02:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
GAppInfo *expected_info;
|
|
|
|
GMainLoop *loop;
|
|
|
|
} DefaultForTypeData;
|
|
|
|
|
|
|
|
static void
|
2022-06-01 21:45:58 +02:00
|
|
|
ensure_default_type_result (GAppInfo *info,
|
|
|
|
DefaultForTypeData *data,
|
|
|
|
GError *error)
|
2022-06-01 21:45:58 +02:00
|
|
|
{
|
|
|
|
if (data->expected_info)
|
|
|
|
{
|
|
|
|
g_assert_nonnull (info);
|
|
|
|
g_assert_no_error (error);
|
|
|
|
g_assert_true (g_app_info_equal (info, data->expected_info));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_assert_null (info);
|
|
|
|
g_assert_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_main_loop_quit (data->loop);
|
|
|
|
g_clear_object (&info);
|
|
|
|
g_clear_error (&error);
|
|
|
|
}
|
|
|
|
|
2022-06-01 21:45:58 +02:00
|
|
|
static void
|
|
|
|
on_default_for_type_cb (GObject *object,
|
|
|
|
GAsyncResult *result,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
GAppInfo *info;
|
|
|
|
GError *error = NULL;
|
|
|
|
DefaultForTypeData *data = user_data;
|
|
|
|
|
|
|
|
g_assert_null (object);
|
|
|
|
|
|
|
|
info = g_app_info_get_default_for_type_finish (result, &error);
|
|
|
|
|
|
|
|
ensure_default_type_result (info, data, error);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
on_default_for_uri_cb (GObject *object,
|
|
|
|
GAsyncResult *result,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
GAppInfo *info;
|
|
|
|
GError *error = NULL;
|
|
|
|
DefaultForTypeData *data = user_data;
|
|
|
|
|
|
|
|
g_assert_null (object);
|
|
|
|
|
|
|
|
info = g_app_info_get_default_for_uri_scheme_finish (result, &error);
|
|
|
|
|
|
|
|
ensure_default_type_result (info, data, error);
|
|
|
|
}
|
|
|
|
|
2022-06-01 21:45:58 +02:00
|
|
|
static void
|
|
|
|
test_default_async (void)
|
|
|
|
{
|
|
|
|
DefaultForTypeData data;
|
|
|
|
GAppInfo *info1, *info2, *info3;
|
|
|
|
GList *list;
|
|
|
|
GError *error = NULL;
|
|
|
|
|
|
|
|
data.loop = g_main_loop_new (NULL, TRUE);
|
|
|
|
|
|
|
|
info1 = create_app_info ("Blah1");
|
|
|
|
info2 = create_app_info ("Blah2");
|
|
|
|
info3 = create_app_info ("Blah3");
|
|
|
|
|
|
|
|
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
|
|
|
|
"*assertion*content_type*failed*");
|
|
|
|
g_app_info_get_default_for_type_async (NULL, FALSE, NULL, NULL, NULL);
|
|
|
|
g_test_assert_expected_messages ();
|
|
|
|
|
|
|
|
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
|
|
|
|
"*assertion*content_type*failed*");
|
|
|
|
g_app_info_get_default_for_type_async ("", FALSE, NULL, NULL, NULL);
|
|
|
|
g_test_assert_expected_messages ();
|
|
|
|
|
|
|
|
g_app_info_set_as_default_for_type (info1, "application/x-test", &error);
|
|
|
|
g_assert_no_error (error);
|
|
|
|
|
|
|
|
g_app_info_set_as_default_for_type (info2, "application/x-test", &error);
|
|
|
|
g_assert_no_error (error);
|
|
|
|
|
|
|
|
data.expected_info = info2;
|
|
|
|
g_app_info_get_default_for_type_async ("application/x-test", FALSE,
|
|
|
|
NULL, on_default_for_type_cb, &data);
|
|
|
|
g_main_loop_run (data.loop);
|
|
|
|
|
|
|
|
/* now try adding something, but not setting as default */
|
|
|
|
g_app_info_add_supports_type (info3, "application/x-test", &error);
|
|
|
|
g_assert_no_error (error);
|
|
|
|
|
|
|
|
/* check that info2 is still default */
|
|
|
|
data.expected_info = info2;
|
|
|
|
g_app_info_get_default_for_type_async ("application/x-test", FALSE,
|
|
|
|
NULL, on_default_for_type_cb, &data);
|
|
|
|
g_main_loop_run (data.loop);
|
|
|
|
|
|
|
|
/* now remove info1 again */
|
|
|
|
g_app_info_remove_supports_type (info1, "application/x-test", &error);
|
|
|
|
g_assert_no_error (error);
|
|
|
|
|
|
|
|
/* and make sure info2 is still default */
|
|
|
|
data.expected_info = info2;
|
|
|
|
g_app_info_get_default_for_type_async ("application/x-test", FALSE,
|
|
|
|
NULL, on_default_for_type_cb, &data);
|
|
|
|
g_main_loop_run (data.loop);
|
|
|
|
|
2022-06-01 21:45:58 +02:00
|
|
|
g_app_info_set_as_default_for_type (info3, "x-scheme-handler/glib-async", &error);
|
|
|
|
g_assert_no_error (error);
|
|
|
|
|
|
|
|
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
|
|
|
|
"*assertion*uri_scheme*failed*");
|
|
|
|
g_assert_null (g_app_info_get_default_for_uri_scheme (NULL));
|
|
|
|
g_test_assert_expected_messages ();
|
|
|
|
|
|
|
|
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
|
|
|
|
"*assertion*uri_scheme*failed*");
|
|
|
|
g_assert_null (g_app_info_get_default_for_uri_scheme (""));
|
|
|
|
g_test_assert_expected_messages ();
|
|
|
|
|
|
|
|
data.expected_info = info3;
|
|
|
|
g_app_info_get_default_for_uri_scheme_async ("glib-async", NULL,
|
|
|
|
on_default_for_uri_cb, &data);
|
|
|
|
g_main_loop_run (data.loop);
|
|
|
|
|
2022-06-01 21:45:58 +02:00
|
|
|
/* now clean it all up */
|
|
|
|
g_app_info_reset_type_associations ("application/x-test");
|
|
|
|
|
|
|
|
data.expected_info = NULL;
|
|
|
|
g_app_info_get_default_for_type_async ("application/x-test", FALSE,
|
|
|
|
NULL, on_default_for_type_cb, &data);
|
|
|
|
g_main_loop_run (data.loop);
|
|
|
|
|
2022-06-01 21:45:58 +02:00
|
|
|
g_app_info_reset_type_associations ("x-scheme-handler/glib-async");
|
|
|
|
|
|
|
|
data.expected_info = NULL;
|
|
|
|
g_app_info_get_default_for_uri_scheme_async ("glib-async", NULL,
|
|
|
|
on_default_for_uri_cb, &data);
|
|
|
|
g_main_loop_run (data.loop);
|
|
|
|
|
2022-06-01 21:45:58 +02:00
|
|
|
list = g_app_info_get_all_for_type ("application/x-test");
|
|
|
|
g_assert_null (list);
|
|
|
|
|
|
|
|
g_app_info_delete (info1);
|
|
|
|
g_app_info_delete (info2);
|
|
|
|
g_app_info_delete (info3);
|
|
|
|
|
|
|
|
g_object_unref (info1);
|
|
|
|
g_object_unref (info2);
|
|
|
|
g_object_unref (info3);
|
|
|
|
|
|
|
|
g_main_loop_unref (data.loop);
|
|
|
|
}
|
|
|
|
|
2010-11-19 11:37:44 +01:00
|
|
|
static void
|
|
|
|
test_fallback (void)
|
|
|
|
{
|
2019-01-24 15:37:23 +01:00
|
|
|
GAppInfo *info1, *info2, *app = NULL;
|
2010-11-19 11:37:44 +01:00
|
|
|
GList *apps, *recomm, *fallback, *list, *l, *m;
|
|
|
|
GError *error = NULL;
|
|
|
|
gint old_length;
|
|
|
|
|
|
|
|
info1 = create_app_info ("Test1");
|
|
|
|
info2 = create_app_info ("Test2");
|
|
|
|
|
2018-12-03 15:50:30 +01:00
|
|
|
g_assert_true (g_content_type_is_a ("text/x-python", "text/plain"));
|
2010-11-19 11:37:44 +01:00
|
|
|
|
|
|
|
apps = g_app_info_get_all_for_type ("text/x-python");
|
|
|
|
old_length = g_list_length (apps);
|
|
|
|
g_list_free_full (apps, g_object_unref);
|
|
|
|
|
2014-04-11 04:32:28 +02:00
|
|
|
g_app_info_add_supports_type (info1, "text/x-python", &error);
|
2018-12-03 15:50:30 +01:00
|
|
|
g_assert_no_error (error);
|
2010-11-19 11:37:44 +01:00
|
|
|
|
2014-04-11 04:32:28 +02:00
|
|
|
g_app_info_add_supports_type (info2, "text/plain", &error);
|
2018-12-03 15:50:30 +01:00
|
|
|
g_assert_no_error (error);
|
2010-11-19 11:37:44 +01:00
|
|
|
|
|
|
|
/* check that both apps are registered */
|
|
|
|
apps = g_app_info_get_all_for_type ("text/x-python");
|
2014-04-11 04:32:28 +02:00
|
|
|
g_assert_cmpint (g_list_length (apps), ==, old_length + 2);
|
2010-11-19 11:37:44 +01:00
|
|
|
|
2015-10-26 18:51:30 +01:00
|
|
|
/* check that Test1 is among the recommended apps */
|
2010-11-19 11:37:44 +01:00
|
|
|
recomm = g_app_info_get_recommended_for_type ("text/x-python");
|
2018-12-03 15:50:30 +01:00
|
|
|
g_assert_nonnull (recomm);
|
2015-10-26 18:51:30 +01:00
|
|
|
for (l = recomm; l; l = l->next)
|
|
|
|
{
|
|
|
|
app = l->data;
|
|
|
|
if (g_app_info_equal (info1, app))
|
|
|
|
break;
|
|
|
|
}
|
2019-01-24 15:37:23 +01:00
|
|
|
g_assert_nonnull (app);
|
2018-12-03 15:50:30 +01:00
|
|
|
g_assert_true (g_app_info_equal (info1, app));
|
2010-11-19 11:37:44 +01:00
|
|
|
|
2014-07-14 14:27:30 +02:00
|
|
|
/* and that Test2 is among the fallback apps */
|
2010-11-19 11:37:44 +01:00
|
|
|
fallback = g_app_info_get_fallback_for_type ("text/x-python");
|
2018-12-03 15:50:30 +01:00
|
|
|
g_assert_nonnull (fallback);
|
2014-07-14 14:27:30 +02:00
|
|
|
for (l = fallback; l; l = l->next)
|
|
|
|
{
|
|
|
|
app = l->data;
|
|
|
|
if (g_app_info_equal (info2, app))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
g_assert_cmpstr (g_app_info_get_name (app), ==, "Test2");
|
2010-11-19 11:37:44 +01:00
|
|
|
|
|
|
|
/* check that recomm + fallback = all applications */
|
|
|
|
list = g_list_concat (g_list_copy (recomm), g_list_copy (fallback));
|
2018-12-03 15:50:30 +01:00
|
|
|
g_assert_cmpuint (g_list_length (list), ==, g_list_length (apps));
|
2010-11-19 11:37:44 +01:00
|
|
|
|
|
|
|
for (l = list, m = apps; l != NULL && m != NULL; l = l->next, m = m->next)
|
|
|
|
{
|
2018-12-03 15:50:30 +01:00
|
|
|
g_assert_true (g_app_info_equal (l->data, m->data));
|
2010-11-19 11:37:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
g_list_free (list);
|
|
|
|
|
|
|
|
g_list_free_full (apps, g_object_unref);
|
|
|
|
g_list_free_full (recomm, g_object_unref);
|
|
|
|
g_list_free_full (fallback, g_object_unref);
|
|
|
|
|
|
|
|
g_app_info_reset_type_associations ("text/x-python");
|
|
|
|
g_app_info_reset_type_associations ("text/plain");
|
|
|
|
|
|
|
|
g_app_info_delete (info1);
|
|
|
|
g_app_info_delete (info2);
|
|
|
|
|
|
|
|
g_object_unref (info1);
|
|
|
|
g_object_unref (info2);
|
|
|
|
}
|
|
|
|
|
2010-12-15 17:56:22 +01:00
|
|
|
static void
|
|
|
|
test_last_used (void)
|
|
|
|
{
|
|
|
|
GList *applications;
|
|
|
|
GAppInfo *info1, *info2, *default_app;
|
|
|
|
GError *error = NULL;
|
|
|
|
|
|
|
|
info1 = create_app_info ("Test1");
|
|
|
|
info2 = create_app_info ("Test2");
|
|
|
|
|
|
|
|
g_app_info_set_as_default_for_type (info1, "application/x-test", &error);
|
2018-12-03 15:50:30 +01:00
|
|
|
g_assert_no_error (error);
|
2010-12-15 17:56:22 +01:00
|
|
|
|
|
|
|
g_app_info_add_supports_type (info2, "application/x-test", &error);
|
2018-12-03 15:50:30 +01:00
|
|
|
g_assert_no_error (error);
|
2010-12-15 17:56:22 +01:00
|
|
|
|
|
|
|
applications = g_app_info_get_recommended_for_type ("application/x-test");
|
2018-12-03 15:50:30 +01:00
|
|
|
g_assert_cmpuint (g_list_length (applications), ==, 2);
|
2010-12-15 17:56:22 +01:00
|
|
|
|
|
|
|
/* the first should be the default app now */
|
2018-12-03 15:50:30 +01:00
|
|
|
g_assert_true (g_app_info_equal (g_list_nth_data (applications, 0), info1));
|
|
|
|
g_assert_true (g_app_info_equal (g_list_nth_data (applications, 1), info2));
|
2010-12-15 17:56:22 +01:00
|
|
|
|
|
|
|
g_list_free_full (applications, g_object_unref);
|
|
|
|
|
|
|
|
g_app_info_set_as_last_used_for_type (info2, "application/x-test", &error);
|
2018-12-03 15:50:30 +01:00
|
|
|
g_assert_no_error (error);
|
2010-12-15 17:56:22 +01:00
|
|
|
|
|
|
|
applications = g_app_info_get_recommended_for_type ("application/x-test");
|
2018-12-03 15:50:30 +01:00
|
|
|
g_assert_cmpuint (g_list_length (applications), ==, 2);
|
2010-12-15 17:56:22 +01:00
|
|
|
|
|
|
|
default_app = g_app_info_get_default_for_type ("application/x-test", FALSE);
|
2018-12-03 15:50:30 +01:00
|
|
|
g_assert_true (g_app_info_equal (default_app, info1));
|
2010-12-15 17:56:22 +01:00
|
|
|
|
|
|
|
/* the first should be the other app now */
|
2018-12-03 15:50:30 +01:00
|
|
|
g_assert_true (g_app_info_equal (g_list_nth_data (applications, 0), info2));
|
|
|
|
g_assert_true (g_app_info_equal (g_list_nth_data (applications, 1), info1));
|
2010-12-15 17:56:22 +01:00
|
|
|
|
|
|
|
g_list_free_full (applications, g_object_unref);
|
|
|
|
|
|
|
|
g_app_info_reset_type_associations ("application/x-test");
|
|
|
|
|
|
|
|
g_app_info_delete (info1);
|
|
|
|
g_app_info_delete (info2);
|
|
|
|
|
|
|
|
g_object_unref (info1);
|
|
|
|
g_object_unref (info2);
|
|
|
|
g_object_unref (default_app);
|
|
|
|
}
|
|
|
|
|
2012-11-21 22:15:14 +01:00
|
|
|
static void
|
|
|
|
test_extra_getters (void)
|
|
|
|
{
|
|
|
|
GDesktopAppInfo *appinfo;
|
2018-01-07 12:14:46 +01:00
|
|
|
const gchar *lang;
|
2012-11-21 22:15:14 +01:00
|
|
|
gchar *s;
|
|
|
|
gboolean b;
|
|
|
|
|
2018-01-07 12:14:46 +01:00
|
|
|
lang = setlocale (LC_ALL, NULL);
|
|
|
|
g_setenv ("LANGUAGE", "de_DE.UTF8", TRUE);
|
|
|
|
setlocale (LC_ALL, "");
|
|
|
|
|
2018-12-14 14:05:17 +01:00
|
|
|
appinfo = g_desktop_app_info_new_from_filename (g_test_get_filename (G_TEST_DIST, "appinfo-test-static.desktop", NULL));
|
2018-12-03 15:50:30 +01:00
|
|
|
g_assert_nonnull (appinfo);
|
2012-11-21 22:15:14 +01:00
|
|
|
|
2018-12-03 15:50:30 +01:00
|
|
|
g_assert_true (g_desktop_app_info_has_key (appinfo, "Terminal"));
|
|
|
|
g_assert_false (g_desktop_app_info_has_key (appinfo, "Bratwurst"));
|
2012-11-21 22:15:14 +01:00
|
|
|
|
|
|
|
s = g_desktop_app_info_get_string (appinfo, "StartupWMClass");
|
|
|
|
g_assert_cmpstr (s, ==, "appinfo-class");
|
|
|
|
g_free (s);
|
|
|
|
|
2018-01-07 12:14:46 +01:00
|
|
|
s = g_desktop_app_info_get_locale_string (appinfo, "X-JunkFood");
|
|
|
|
g_assert_cmpstr (s, ==, "Bratwurst");
|
|
|
|
g_free (s);
|
|
|
|
|
2021-02-14 15:43:12 +01:00
|
|
|
g_setenv ("LANGUAGE", "sv_SE.UTF8", TRUE);
|
2018-01-07 12:14:46 +01:00
|
|
|
setlocale (LC_ALL, "");
|
|
|
|
|
|
|
|
s = g_desktop_app_info_get_locale_string (appinfo, "X-JunkFood");
|
|
|
|
g_assert_cmpstr (s, ==, "Burger"); /* fallback */
|
|
|
|
g_free (s);
|
|
|
|
|
2012-11-21 22:15:14 +01:00
|
|
|
b = g_desktop_app_info_get_boolean (appinfo, "Terminal");
|
2018-12-03 15:50:30 +01:00
|
|
|
g_assert_true (b);
|
2012-11-21 22:15:14 +01:00
|
|
|
|
|
|
|
g_object_unref (appinfo);
|
2018-01-07 12:14:46 +01:00
|
|
|
|
|
|
|
g_setenv ("LANGUAGE", lang, TRUE);
|
|
|
|
setlocale (LC_ALL, "");
|
2012-11-21 22:15:14 +01:00
|
|
|
}
|
|
|
|
|
2013-07-11 18:46:59 +02:00
|
|
|
static void
|
|
|
|
wait_for_file (const gchar *want_this,
|
|
|
|
const gchar *but_not_this,
|
|
|
|
const gchar *or_this)
|
|
|
|
{
|
2018-12-03 15:50:30 +01:00
|
|
|
guint retries = 600;
|
2013-07-11 18:46:59 +02:00
|
|
|
|
|
|
|
/* I hate time-based conditions in tests, but this will wait up to one
|
|
|
|
* whole minute for "touch file" to finish running. I think it should
|
|
|
|
* be OK.
|
|
|
|
*
|
|
|
|
* 600 * 100ms = 60 seconds.
|
|
|
|
*/
|
|
|
|
while (access (want_this, F_OK) != 0)
|
|
|
|
{
|
|
|
|
g_usleep (100000); /* 100ms */
|
2018-12-03 15:50:30 +01:00
|
|
|
g_assert_cmpuint (retries, >, 0);
|
2013-07-11 18:46:59 +02:00
|
|
|
retries--;
|
|
|
|
}
|
|
|
|
|
2018-12-03 15:50:30 +01:00
|
|
|
g_assert_cmpuint (access (but_not_this, F_OK), !=, 0);
|
|
|
|
g_assert_cmpuint (access (or_this, F_OK), !=, 0);
|
2013-07-11 18:46:59 +02:00
|
|
|
|
|
|
|
unlink (want_this);
|
|
|
|
unlink (but_not_this);
|
|
|
|
unlink (or_this);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
test_actions (void)
|
|
|
|
{
|
2020-11-12 19:05:25 +01:00
|
|
|
const char *expected[] = { "frob", "tweak", "twiddle", "broken", NULL };
|
2013-07-11 18:46:59 +02:00
|
|
|
const gchar * const *actions;
|
|
|
|
GDesktopAppInfo *appinfo;
|
2022-09-13 02:44:25 +02:00
|
|
|
const gchar *tmpdir;
|
2013-07-11 18:46:59 +02:00
|
|
|
gchar *name;
|
2022-09-13 02:44:25 +02:00
|
|
|
gchar *frob_path;
|
|
|
|
gchar *tweak_path;
|
|
|
|
gchar *twiddle_path;
|
2013-07-11 18:46:59 +02:00
|
|
|
|
|
|
|
appinfo = g_desktop_app_info_new_from_filename (g_test_get_filename (G_TEST_DIST, "appinfo-test-actions.desktop", NULL));
|
2018-12-03 15:50:30 +01:00
|
|
|
g_assert_nonnull (appinfo);
|
2013-07-11 18:46:59 +02:00
|
|
|
|
|
|
|
actions = g_desktop_app_info_list_actions (appinfo);
|
2020-11-12 19:05:25 +01:00
|
|
|
g_assert_cmpstrv (actions, expected);
|
2013-07-11 18:46:59 +02:00
|
|
|
|
|
|
|
name = g_desktop_app_info_get_action_name (appinfo, "frob");
|
|
|
|
g_assert_cmpstr (name, ==, "Frobnicate");
|
|
|
|
g_free (name);
|
|
|
|
|
|
|
|
name = g_desktop_app_info_get_action_name (appinfo, "tweak");
|
|
|
|
g_assert_cmpstr (name, ==, "Tweak");
|
|
|
|
g_free (name);
|
|
|
|
|
|
|
|
name = g_desktop_app_info_get_action_name (appinfo, "twiddle");
|
|
|
|
g_assert_cmpstr (name, ==, "Twiddle");
|
|
|
|
g_free (name);
|
|
|
|
|
|
|
|
name = g_desktop_app_info_get_action_name (appinfo, "broken");
|
2018-12-03 15:50:30 +01:00
|
|
|
g_assert_nonnull (name);
|
|
|
|
g_assert_true (g_utf8_validate (name, -1, NULL));
|
2013-07-11 18:46:59 +02:00
|
|
|
g_free (name);
|
|
|
|
|
2022-09-13 02:44:25 +02:00
|
|
|
tmpdir = g_getenv ("G_TEST_TMPDIR");
|
|
|
|
g_assert_nonnull (tmpdir);
|
|
|
|
frob_path = g_build_filename (tmpdir, "frob", NULL);
|
|
|
|
tweak_path = g_build_filename (tmpdir, "tweak", NULL);
|
|
|
|
twiddle_path = g_build_filename (tmpdir, "twiddle", NULL);
|
|
|
|
|
|
|
|
g_assert_false (g_file_test (frob_path, G_FILE_TEST_EXISTS));
|
|
|
|
g_assert_false (g_file_test (tweak_path, G_FILE_TEST_EXISTS));
|
|
|
|
g_assert_false (g_file_test (twiddle_path, G_FILE_TEST_EXISTS));
|
2013-07-11 18:46:59 +02:00
|
|
|
|
|
|
|
g_desktop_app_info_launch_action (appinfo, "frob", NULL);
|
2022-09-13 02:44:25 +02:00
|
|
|
wait_for_file (frob_path, tweak_path, twiddle_path);
|
2013-07-11 18:46:59 +02:00
|
|
|
|
|
|
|
g_desktop_app_info_launch_action (appinfo, "tweak", NULL);
|
2022-09-13 02:44:25 +02:00
|
|
|
wait_for_file (tweak_path, frob_path, twiddle_path);
|
2013-07-11 18:46:59 +02:00
|
|
|
|
|
|
|
g_desktop_app_info_launch_action (appinfo, "twiddle", NULL);
|
2022-09-13 02:44:25 +02:00
|
|
|
wait_for_file (twiddle_path, frob_path, tweak_path);
|
2013-07-11 18:46:59 +02:00
|
|
|
|
2022-09-13 02:44:25 +02:00
|
|
|
g_free (frob_path);
|
|
|
|
g_free (tweak_path);
|
|
|
|
g_free (twiddle_path);
|
2013-07-11 18:46:59 +02:00
|
|
|
g_object_unref (appinfo);
|
|
|
|
}
|
|
|
|
|
2013-10-10 15:28:30 +02:00
|
|
|
static gchar *
|
|
|
|
run_apps (const gchar *command,
|
|
|
|
const gchar *arg,
|
|
|
|
gboolean with_usr,
|
|
|
|
gboolean with_home,
|
|
|
|
const gchar *locale_name,
|
2014-05-08 22:16:35 +02:00
|
|
|
const gchar *language,
|
|
|
|
const gchar *xdg_current_desktop)
|
2013-10-10 15:28:30 +02:00
|
|
|
{
|
|
|
|
gboolean success;
|
|
|
|
gchar **envp;
|
|
|
|
gchar **argv;
|
|
|
|
gint status;
|
|
|
|
gchar *out;
|
2018-12-14 14:43:45 +01:00
|
|
|
gchar *argv_str = NULL;
|
2013-10-10 15:28:30 +02:00
|
|
|
|
|
|
|
argv = g_new (gchar *, 4);
|
|
|
|
argv[0] = g_test_build_filename (G_TEST_BUILT, "apps", NULL);
|
|
|
|
argv[1] = g_strdup (command);
|
|
|
|
argv[2] = g_strdup (arg);
|
|
|
|
argv[3] = NULL;
|
|
|
|
|
2022-10-24 22:19:21 +02:00
|
|
|
g_assert_true (g_file_test (argv[0], G_FILE_TEST_IS_EXECUTABLE));
|
2013-10-10 15:28:30 +02:00
|
|
|
envp = g_get_environ ();
|
|
|
|
|
|
|
|
if (with_usr)
|
|
|
|
{
|
|
|
|
gchar *tmp = g_test_build_filename (G_TEST_DIST, "desktop-files", "usr", NULL);
|
|
|
|
envp = g_environ_setenv (envp, "XDG_DATA_DIRS", tmp, TRUE);
|
|
|
|
g_free (tmp);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
envp = g_environ_setenv (envp, "XDG_DATA_DIRS", "/does-not-exist", TRUE);
|
|
|
|
|
|
|
|
if (with_home)
|
|
|
|
{
|
|
|
|
gchar *tmp = g_test_build_filename (G_TEST_DIST, "desktop-files", "home", NULL);
|
|
|
|
envp = g_environ_setenv (envp, "XDG_DATA_HOME", tmp, TRUE);
|
|
|
|
g_free (tmp);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
envp = g_environ_setenv (envp, "XDG_DATA_HOME", "/does-not-exist", TRUE);
|
|
|
|
|
|
|
|
if (locale_name)
|
|
|
|
envp = g_environ_setenv (envp, "LC_ALL", locale_name, TRUE);
|
|
|
|
else
|
|
|
|
envp = g_environ_setenv (envp, "LC_ALL", "C", TRUE);
|
|
|
|
|
|
|
|
if (language)
|
|
|
|
envp = g_environ_setenv (envp, "LANGUAGE", language, TRUE);
|
|
|
|
else
|
|
|
|
envp = g_environ_unsetenv (envp, "LANGUAGE");
|
|
|
|
|
2014-05-08 22:16:35 +02:00
|
|
|
if (xdg_current_desktop)
|
|
|
|
envp = g_environ_setenv (envp, "XDG_CURRENT_DESKTOP", xdg_current_desktop, TRUE);
|
|
|
|
else
|
|
|
|
envp = g_environ_unsetenv (envp, "XDG_CURRENT_DESKTOP");
|
|
|
|
|
2018-12-14 14:44:09 +01:00
|
|
|
envp = g_environ_setenv (envp, "G_MESSAGES_DEBUG", "", TRUE);
|
|
|
|
|
2013-10-10 15:28:30 +02:00
|
|
|
success = g_spawn_sync (NULL, argv, envp, 0, NULL, NULL, &out, NULL, &status, NULL);
|
2018-12-03 15:50:30 +01:00
|
|
|
g_assert_true (success);
|
|
|
|
g_assert_cmpuint (status, ==, 0);
|
2013-10-10 15:28:30 +02:00
|
|
|
|
2018-12-14 14:43:45 +01:00
|
|
|
argv_str = g_strjoinv (" ", argv);
|
|
|
|
g_test_message ("%s: `%s` returned: %s", G_STRFUNC, argv_str, out);
|
|
|
|
g_free (argv_str);
|
|
|
|
|
2013-10-10 15:28:30 +02:00
|
|
|
g_strfreev (envp);
|
|
|
|
g_strfreev (argv);
|
|
|
|
|
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
assert_strings_equivalent (const gchar *expected,
|
|
|
|
const gchar *result)
|
|
|
|
{
|
|
|
|
gchar **expected_words;
|
|
|
|
gchar **result_words;
|
|
|
|
gint i, j;
|
|
|
|
|
|
|
|
expected_words = g_strsplit (expected, " ", 0);
|
2013-11-15 20:44:33 +01:00
|
|
|
result_words = g_strsplit_set (result, " \n", 0);
|
2013-10-10 15:28:30 +02:00
|
|
|
|
|
|
|
for (i = 0; expected_words[i]; i++)
|
|
|
|
{
|
|
|
|
for (j = 0; result_words[j]; j++)
|
|
|
|
if (g_str_equal (expected_words[i], result_words[j]))
|
|
|
|
goto got_it;
|
|
|
|
|
2021-08-05 12:45:11 +02:00
|
|
|
g_test_fail_printf ("Unable to find expected string '%s' in result '%s'", expected_words[i], result);
|
2013-11-24 00:15:04 +01:00
|
|
|
|
2013-10-10 15:28:30 +02:00
|
|
|
got_it:
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_assert_cmpint (g_strv_length (expected_words), ==, g_strv_length (result_words));
|
|
|
|
g_strfreev (expected_words);
|
|
|
|
g_strfreev (result_words);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
assert_list (const gchar *expected,
|
|
|
|
gboolean with_usr,
|
|
|
|
gboolean with_home,
|
|
|
|
const gchar *locale_name,
|
|
|
|
const gchar *language)
|
|
|
|
{
|
|
|
|
gchar *result;
|
|
|
|
|
2014-05-08 22:16:35 +02:00
|
|
|
result = run_apps ("list", NULL, with_usr, with_home, locale_name, language, NULL);
|
2013-10-10 15:28:30 +02:00
|
|
|
g_strchomp (result);
|
|
|
|
assert_strings_equivalent (expected, result);
|
|
|
|
g_free (result);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
assert_info (const gchar *desktop_id,
|
|
|
|
const gchar *expected,
|
|
|
|
gboolean with_usr,
|
|
|
|
gboolean with_home,
|
|
|
|
const gchar *locale_name,
|
|
|
|
const gchar *language)
|
|
|
|
{
|
|
|
|
gchar *result;
|
|
|
|
|
2014-05-08 22:16:35 +02:00
|
|
|
result = run_apps ("show-info", desktop_id, with_usr, with_home, locale_name, language, NULL);
|
2013-10-10 15:28:30 +02:00
|
|
|
g_assert_cmpstr (result, ==, expected);
|
|
|
|
g_free (result);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
assert_search (const gchar *search_string,
|
|
|
|
const gchar *expected,
|
|
|
|
gboolean with_usr,
|
|
|
|
gboolean with_home,
|
|
|
|
const gchar *locale_name,
|
|
|
|
const gchar *language)
|
|
|
|
{
|
|
|
|
gchar **expected_lines;
|
|
|
|
gchar **result_lines;
|
|
|
|
gchar *result;
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
expected_lines = g_strsplit (expected, "\n", -1);
|
2014-05-08 22:16:35 +02:00
|
|
|
result = run_apps ("search", search_string, with_usr, with_home, locale_name, language, NULL);
|
2013-10-10 15:28:30 +02:00
|
|
|
result_lines = g_strsplit (result, "\n", -1);
|
|
|
|
g_assert_cmpint (g_strv_length (expected_lines), ==, g_strv_length (result_lines));
|
|
|
|
for (i = 0; expected_lines[i]; i++)
|
|
|
|
assert_strings_equivalent (expected_lines[i], result_lines[i]);
|
|
|
|
g_strfreev (expected_lines);
|
|
|
|
g_strfreev (result_lines);
|
|
|
|
g_free (result);
|
|
|
|
}
|
|
|
|
|
2013-11-15 20:44:33 +01:00
|
|
|
static void
|
|
|
|
assert_implementations (const gchar *interface,
|
|
|
|
const gchar *expected,
|
|
|
|
gboolean with_usr,
|
|
|
|
gboolean with_home)
|
|
|
|
{
|
|
|
|
gchar *result;
|
|
|
|
|
2014-05-08 22:16:35 +02:00
|
|
|
result = run_apps ("implementations", interface, with_usr, with_home, NULL, NULL, NULL);
|
2013-11-15 20:44:33 +01:00
|
|
|
g_strchomp (result);
|
|
|
|
assert_strings_equivalent (expected, result);
|
|
|
|
g_free (result);
|
|
|
|
}
|
|
|
|
|
2013-10-10 15:28:30 +02:00
|
|
|
#define ALL_USR_APPS "evince-previewer.desktop nautilus-classic.desktop gnome-font-viewer.desktop " \
|
2018-04-23 23:21:59 +02:00
|
|
|
"baobab.desktop yelp.desktop eog.desktop cheese.desktop org.gnome.clocks.desktop " \
|
2013-10-10 15:28:30 +02:00
|
|
|
"gnome-contacts.desktop kde4-kate.desktop gcr-prompter.desktop totem.desktop " \
|
|
|
|
"gnome-terminal.desktop nautilus-autorun-software.desktop gcr-viewer.desktop " \
|
|
|
|
"nautilus-connect-server.desktop kde4-dolphin.desktop gnome-music.desktop " \
|
|
|
|
"kde4-konqbrowser.desktop gucharmap.desktop kde4-okular.desktop nautilus.desktop " \
|
2021-01-09 15:29:03 +01:00
|
|
|
"gedit.desktop evince.desktop file-roller.desktop dconf-editor.desktop glade.desktop " \
|
|
|
|
"invalid-desktop.desktop"
|
2013-10-10 15:28:30 +02:00
|
|
|
#define HOME_APPS "epiphany-weather-for-toronto-island-9c6a4e022b17686306243dada811d550d25eb1fb.desktop"
|
|
|
|
#define ALL_HOME_APPS HOME_APPS " eog.desktop"
|
|
|
|
|
|
|
|
static void
|
|
|
|
test_search (void)
|
|
|
|
{
|
|
|
|
assert_list ("", FALSE, FALSE, NULL, NULL);
|
|
|
|
assert_list (ALL_USR_APPS, TRUE, FALSE, NULL, NULL);
|
|
|
|
assert_list (ALL_HOME_APPS, FALSE, TRUE, NULL, NULL);
|
|
|
|
assert_list (ALL_USR_APPS " " HOME_APPS, TRUE, TRUE, NULL, NULL);
|
|
|
|
|
|
|
|
/* The user has "installed" their own version of eog.desktop which
|
|
|
|
* calls it "Eye of GNOME". Do some testing based on that.
|
|
|
|
*
|
|
|
|
* We should always find "Pictures" keyword no matter where we look.
|
|
|
|
*/
|
|
|
|
assert_search ("Picture", "eog.desktop\n", TRUE, TRUE, NULL, NULL);
|
|
|
|
assert_search ("Picture", "eog.desktop\n", TRUE, FALSE, NULL, NULL);
|
|
|
|
assert_search ("Picture", "eog.desktop\n", FALSE, TRUE, NULL, NULL);
|
|
|
|
assert_search ("Picture", "", FALSE, FALSE, NULL, NULL);
|
|
|
|
|
|
|
|
/* We should only find it called "eye of gnome" when using the user's
|
|
|
|
* directory.
|
|
|
|
*/
|
|
|
|
assert_search ("eye gnome", "", TRUE, FALSE, NULL, NULL);
|
|
|
|
assert_search ("eye gnome", "eog.desktop\n", FALSE, TRUE, NULL, NULL);
|
|
|
|
assert_search ("eye gnome", "eog.desktop\n", TRUE, TRUE, NULL, NULL);
|
|
|
|
|
|
|
|
/* We should only find it called "image viewer" when _not_ using the
|
|
|
|
* user's directory.
|
|
|
|
*/
|
|
|
|
assert_search ("image viewer", "eog.desktop\n", TRUE, FALSE, NULL, NULL);
|
|
|
|
assert_search ("image viewer", "", FALSE, TRUE, NULL, NULL);
|
|
|
|
assert_search ("image viewer", "", TRUE, TRUE, NULL, NULL);
|
|
|
|
|
2018-04-24 15:21:06 +02:00
|
|
|
/* There're "flatpak" apps (clocks) installed as well - they should *not*
|
|
|
|
* match the prefix command ("/bin/sh") in the Exec= line though.
|
2018-04-23 19:50:45 +02:00
|
|
|
*/
|
2018-04-24 15:21:06 +02:00
|
|
|
assert_search ("sh", "gnome-terminal.desktop\n", TRUE, FALSE, NULL, NULL);
|
2018-04-23 19:50:45 +02:00
|
|
|
|
2018-04-24 16:01:36 +02:00
|
|
|
/* "frobnicator.desktop" is ignored by get_all() because the binary is
|
|
|
|
* missing, but search should still find it (to avoid either stale results
|
|
|
|
* from the cache or expensive stat() calls for each potential result)
|
|
|
|
*/
|
|
|
|
assert_search ("frobni", "frobnicator.desktop\n", TRUE, FALSE, NULL, NULL);
|
|
|
|
|
2013-10-10 15:28:30 +02:00
|
|
|
/* Obvious multi-word search */
|
|
|
|
assert_search ("gno hel", "yelp.desktop\n", TRUE, TRUE, NULL, NULL);
|
|
|
|
|
|
|
|
/* Repeated search terms should do nothing... */
|
|
|
|
assert_search ("files file fil fi f", "nautilus.desktop\n"
|
|
|
|
"gedit.desktop\n", TRUE, TRUE, NULL, NULL);
|
|
|
|
|
|
|
|
/* "con" will match "connect" and "contacts" on name but dconf only on
|
|
|
|
* the "config" keyword
|
|
|
|
*/
|
|
|
|
assert_search ("con", "nautilus-connect-server.desktop gnome-contacts.desktop\n"
|
|
|
|
"dconf-editor.desktop\n", TRUE, TRUE, NULL, NULL);
|
|
|
|
|
|
|
|
/* "gnome" will match "eye of gnome" from the user's directory, plus
|
|
|
|
* matching "GNOME Clocks" X-GNOME-FullName. It's only a comment on
|
|
|
|
* yelp and gnome-contacts, though.
|
|
|
|
*/
|
|
|
|
assert_search ("gnome", "eog.desktop\n"
|
2018-04-23 23:21:59 +02:00
|
|
|
"org.gnome.clocks.desktop\n"
|
2013-10-10 15:28:30 +02:00
|
|
|
"yelp.desktop gnome-contacts.desktop\n", TRUE, TRUE, NULL, NULL);
|
|
|
|
|
2014-03-02 15:38:51 +01:00
|
|
|
/* eog has exec name 'false' in usr only */
|
|
|
|
assert_search ("false", "eog.desktop\n", TRUE, FALSE, NULL, NULL);
|
|
|
|
assert_search ("false", "", FALSE, TRUE, NULL, NULL);
|
|
|
|
assert_search ("false", "", TRUE, TRUE, NULL, NULL);
|
|
|
|
assert_search ("false", "", FALSE, FALSE, NULL, NULL);
|
|
|
|
|
|
|
|
/* make sure we only search the first component */
|
|
|
|
assert_search ("nonsearchable", "", TRUE, FALSE, NULL, NULL);
|
|
|
|
|
2013-10-10 15:28:30 +02:00
|
|
|
/* "gnome con" will match only gnome contacts; via the name for
|
|
|
|
* "contacts" and the comment for "gnome"
|
|
|
|
*/
|
|
|
|
assert_search ("gnome con", "gnome-contacts.desktop\n", TRUE, TRUE, NULL, NULL);
|
|
|
|
|
|
|
|
/* make sure we get the correct kde4- prefix on the application IDs
|
|
|
|
* from subdirectories
|
|
|
|
*/
|
|
|
|
assert_search ("konq", "kde4-konqbrowser.desktop\n", TRUE, TRUE, NULL, NULL);
|
|
|
|
assert_search ("kate", "kde4-kate.desktop\n", TRUE, TRUE, NULL, NULL);
|
|
|
|
|
2019-04-26 13:12:31 +02:00
|
|
|
/* make sure we can look up apps by name properly */
|
2013-10-10 15:28:30 +02:00
|
|
|
assert_info ("kde4-kate.desktop",
|
|
|
|
"kde4-kate.desktop\n"
|
|
|
|
"Kate\n"
|
|
|
|
"Kate\n"
|
|
|
|
"nil\n", TRUE, TRUE, NULL, NULL);
|
|
|
|
|
|
|
|
assert_info ("nautilus.desktop",
|
|
|
|
"nautilus.desktop\n"
|
|
|
|
"Files\n"
|
|
|
|
"Files\n"
|
|
|
|
"Access and organize files\n", TRUE, TRUE, NULL, NULL);
|
|
|
|
|
|
|
|
/* make sure localised searching works properly */
|
2013-11-24 00:15:04 +01:00
|
|
|
assert_search ("foliumi", "nautilus.desktop\n"
|
|
|
|
"kde4-konqbrowser.desktop\n"
|
2013-10-10 15:28:30 +02:00
|
|
|
"eog.desktop\n", TRUE, FALSE, "en_US.UTF-8", "eo");
|
|
|
|
/* the user's eog.desktop has no translations... */
|
2013-11-24 00:15:04 +01:00
|
|
|
assert_search ("foliumi", "nautilus.desktop\n"
|
|
|
|
"kde4-konqbrowser.desktop\n", TRUE, TRUE, "en_US.UTF-8", "eo");
|
2013-10-10 15:28:30 +02:00
|
|
|
}
|
|
|
|
|
2013-11-15 20:44:33 +01:00
|
|
|
static void
|
|
|
|
test_implements (void)
|
|
|
|
{
|
|
|
|
/* Make sure we can find our search providers... */
|
|
|
|
assert_implementations ("org.gnome.Shell.SearchProvider2",
|
|
|
|
"gnome-music.desktop gnome-contacts.desktop eog.desktop",
|
|
|
|
TRUE, FALSE);
|
|
|
|
|
|
|
|
/* And our image acquisition possibilities... */
|
|
|
|
assert_implementations ("org.freedesktop.ImageProvider",
|
|
|
|
"cheese.desktop",
|
|
|
|
TRUE, FALSE);
|
|
|
|
|
|
|
|
/* Make sure the user's eog is properly masking the system one */
|
|
|
|
assert_implementations ("org.gnome.Shell.SearchProvider2",
|
|
|
|
"gnome-music.desktop gnome-contacts.desktop",
|
|
|
|
TRUE, TRUE);
|
|
|
|
|
|
|
|
/* Make sure we get nothing if we have nothing */
|
|
|
|
assert_implementations ("org.gnome.Shell.SearchProvider2", "", FALSE, FALSE);
|
|
|
|
}
|
|
|
|
|
2014-05-08 22:16:35 +02:00
|
|
|
static void
|
|
|
|
assert_shown (const gchar *desktop_id,
|
|
|
|
gboolean expected,
|
|
|
|
const gchar *xdg_current_desktop)
|
|
|
|
{
|
|
|
|
gchar *result;
|
|
|
|
|
|
|
|
result = run_apps ("should-show", desktop_id, TRUE, TRUE, NULL, NULL, xdg_current_desktop);
|
|
|
|
g_assert_cmpstr (result, ==, expected ? "true\n" : "false\n");
|
|
|
|
g_free (result);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
test_show_in (void)
|
|
|
|
{
|
|
|
|
assert_shown ("gcr-prompter.desktop", FALSE, NULL);
|
|
|
|
assert_shown ("gcr-prompter.desktop", FALSE, "GNOME");
|
|
|
|
assert_shown ("gcr-prompter.desktop", FALSE, "KDE");
|
|
|
|
assert_shown ("gcr-prompter.desktop", FALSE, "GNOME:GNOME-Classic");
|
|
|
|
assert_shown ("gcr-prompter.desktop", TRUE, "GNOME-Classic:GNOME");
|
|
|
|
assert_shown ("gcr-prompter.desktop", TRUE, "GNOME-Classic");
|
|
|
|
assert_shown ("gcr-prompter.desktop", TRUE, "GNOME-Classic:KDE");
|
|
|
|
assert_shown ("gcr-prompter.desktop", TRUE, "KDE:GNOME-Classic");
|
2021-01-09 15:29:03 +01:00
|
|
|
assert_shown ("invalid-desktop.desktop", TRUE, "GNOME");
|
|
|
|
assert_shown ("invalid-desktop.desktop", FALSE, "../invalid/desktop");
|
|
|
|
assert_shown ("invalid-desktop.desktop", FALSE, "../invalid/desktop:../invalid/desktop");
|
2014-05-08 22:16:35 +02:00
|
|
|
}
|
|
|
|
|
2021-09-29 08:19:09 +02:00
|
|
|
static void
|
|
|
|
on_launch_started (GAppLaunchContext *context, GAppInfo *info, GVariant *platform_data, gpointer data)
|
|
|
|
{
|
|
|
|
gboolean *invoked = data;
|
|
|
|
|
|
|
|
g_assert_true (G_IS_APP_LAUNCH_CONTEXT (context));
|
2022-10-24 13:02:40 +02:00
|
|
|
|
|
|
|
if (TEST_IS_LAUNCH_CONTEXT (context))
|
|
|
|
{
|
|
|
|
GVariantDict dict;
|
|
|
|
const char *sni;
|
|
|
|
char *expected_sni;
|
|
|
|
|
|
|
|
g_assert_nonnull (platform_data);
|
|
|
|
g_variant_dict_init (&dict, platform_data);
|
|
|
|
g_assert_true (
|
|
|
|
g_variant_dict_lookup (&dict, "startup-notification-id", "&s", &sni));
|
|
|
|
expected_sni = g_app_launch_context_get_startup_notify_id (context, info, NULL);
|
|
|
|
g_assert_cmpstr (sni, ==, expected_sni);
|
|
|
|
|
|
|
|
g_free (expected_sni);
|
|
|
|
g_variant_dict_clear (&dict);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Our default context doesn't fill in any platform data */
|
|
|
|
g_assert_null (platform_data);
|
|
|
|
}
|
2021-09-29 08:19:09 +02:00
|
|
|
|
|
|
|
g_assert_false (*invoked);
|
|
|
|
*invoked = TRUE;
|
|
|
|
}
|
|
|
|
|
2022-10-21 20:51:00 +02:00
|
|
|
static void
|
|
|
|
on_launched (GAppLaunchContext *context, GAppInfo *info, GVariant *platform_data, gpointer data)
|
|
|
|
{
|
|
|
|
gboolean *launched = data;
|
|
|
|
GVariantDict dict;
|
|
|
|
int pid;
|
|
|
|
|
|
|
|
g_assert_true (G_IS_APP_LAUNCH_CONTEXT (context));
|
|
|
|
g_assert_true (G_IS_APP_INFO (info));
|
|
|
|
g_assert_nonnull (platform_data);
|
|
|
|
g_variant_dict_init (&dict, platform_data);
|
|
|
|
g_assert_true (g_variant_dict_lookup (&dict, "pid", "i", &pid, NULL));
|
|
|
|
g_assert_cmpint (pid, >, 1);
|
|
|
|
|
|
|
|
g_assert_false (*launched);
|
|
|
|
*launched = TRUE;
|
|
|
|
|
|
|
|
g_variant_dict_clear (&dict);
|
|
|
|
}
|
|
|
|
|
2022-10-24 13:02:40 +02:00
|
|
|
static void
|
|
|
|
on_launch_failed (GAppLaunchContext *context, const char *startup_notify_id, gpointer data)
|
|
|
|
{
|
|
|
|
gboolean *invoked = data;
|
|
|
|
|
|
|
|
g_assert_true (G_IS_APP_LAUNCH_CONTEXT (context));
|
|
|
|
g_assert_nonnull (startup_notify_id);
|
|
|
|
g_test_message ("Application launch failed: %s", startup_notify_id);
|
|
|
|
|
|
|
|
g_assert_false (*invoked);
|
|
|
|
*invoked = TRUE;
|
|
|
|
}
|
|
|
|
|
2018-06-06 14:59:59 +02:00
|
|
|
/* Test g_desktop_app_info_launch_uris_as_manager() and
|
|
|
|
* g_desktop_app_info_launch_uris_as_manager_with_fds()
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
test_launch_as_manager (void)
|
|
|
|
{
|
|
|
|
GDesktopAppInfo *appinfo;
|
|
|
|
GError *error = NULL;
|
|
|
|
gboolean retval;
|
|
|
|
const gchar *path;
|
2021-09-29 08:19:09 +02:00
|
|
|
gboolean invoked = FALSE;
|
2022-10-21 20:51:00 +02:00
|
|
|
gboolean launched = FALSE;
|
2022-10-24 13:02:40 +02:00
|
|
|
gboolean failed = FALSE;
|
2021-09-29 08:19:09 +02:00
|
|
|
GAppLaunchContext *context;
|
2018-06-06 14:59:59 +02:00
|
|
|
|
2018-11-30 18:20:48 +01:00
|
|
|
path = g_test_get_filename (G_TEST_BUILT, "appinfo-test.desktop", NULL);
|
2018-06-06 14:59:59 +02:00
|
|
|
appinfo = g_desktop_app_info_new_from_filename (path);
|
2022-10-24 22:19:21 +02:00
|
|
|
g_assert_true (G_IS_APP_INFO (appinfo));
|
2018-06-06 14:59:59 +02:00
|
|
|
|
2022-10-24 13:02:40 +02:00
|
|
|
context = g_object_new (test_launch_context_get_type (), NULL);
|
2021-09-29 08:19:09 +02:00
|
|
|
g_signal_connect (context, "launch-started",
|
|
|
|
G_CALLBACK (on_launch_started),
|
|
|
|
&invoked);
|
2022-10-21 20:51:00 +02:00
|
|
|
g_signal_connect (context, "launched",
|
|
|
|
G_CALLBACK (on_launched),
|
|
|
|
&launched);
|
2022-10-24 13:02:40 +02:00
|
|
|
g_signal_connect (context, "launch-failed",
|
|
|
|
G_CALLBACK (on_launch_failed),
|
|
|
|
&failed);
|
2021-09-29 08:19:09 +02:00
|
|
|
retval = g_desktop_app_info_launch_uris_as_manager (appinfo, NULL, context, 0,
|
2018-06-06 14:59:59 +02:00
|
|
|
NULL, NULL,
|
|
|
|
NULL, NULL,
|
|
|
|
&error);
|
|
|
|
g_assert_no_error (error);
|
|
|
|
g_assert_true (retval);
|
2021-09-29 08:19:09 +02:00
|
|
|
g_assert_true (invoked);
|
2022-10-21 20:51:00 +02:00
|
|
|
g_assert_true (launched);
|
2022-10-24 13:02:40 +02:00
|
|
|
g_assert_false (failed);
|
2018-06-06 14:59:59 +02:00
|
|
|
|
2021-09-29 08:19:09 +02:00
|
|
|
invoked = FALSE;
|
2022-10-21 20:51:00 +02:00
|
|
|
launched = FALSE;
|
2022-10-24 13:02:40 +02:00
|
|
|
failed = FALSE;
|
2018-06-06 14:59:59 +02:00
|
|
|
retval = g_desktop_app_info_launch_uris_as_manager_with_fds (appinfo,
|
2021-09-29 08:19:09 +02:00
|
|
|
NULL, context, 0,
|
2018-06-06 14:59:59 +02:00
|
|
|
NULL, NULL,
|
|
|
|
NULL, NULL,
|
|
|
|
-1, -1, -1,
|
|
|
|
&error);
|
|
|
|
g_assert_no_error (error);
|
|
|
|
g_assert_true (retval);
|
2021-09-29 08:19:09 +02:00
|
|
|
g_assert_true (invoked);
|
2022-10-21 20:51:00 +02:00
|
|
|
g_assert_true (launched);
|
2022-10-24 13:02:40 +02:00
|
|
|
g_assert_false (failed);
|
2018-06-06 14:59:59 +02:00
|
|
|
|
|
|
|
g_object_unref (appinfo);
|
2021-09-29 08:19:09 +02:00
|
|
|
g_assert_finalize_object (context);
|
2018-06-06 14:59:59 +02:00
|
|
|
}
|
|
|
|
|
2022-10-23 17:09:33 +02:00
|
|
|
static void
|
|
|
|
test_launch_as_manager_fail (void)
|
|
|
|
{
|
|
|
|
GAppLaunchContext *context;
|
|
|
|
GDesktopAppInfo *appinfo;
|
|
|
|
GError *error = NULL;
|
|
|
|
gboolean retval;
|
|
|
|
const gchar *path;
|
|
|
|
gboolean launch_started = FALSE;
|
|
|
|
gboolean launched = FALSE;
|
|
|
|
gboolean failed = FALSE;
|
|
|
|
|
|
|
|
g_test_summary ("Tests that launch-errors are properly handled, we force " \
|
|
|
|
"this by using invalid FD's values when launching as manager");
|
|
|
|
|
|
|
|
path = g_test_get_filename (G_TEST_BUILT, "appinfo-test.desktop", NULL);
|
|
|
|
appinfo = g_desktop_app_info_new_from_filename (path);
|
2022-10-24 22:19:21 +02:00
|
|
|
g_assert_true (G_IS_APP_INFO (appinfo));
|
2022-10-23 17:09:33 +02:00
|
|
|
|
|
|
|
context = g_object_new (test_launch_context_get_type (), NULL);
|
|
|
|
g_signal_connect (context, "launch-started",
|
|
|
|
G_CALLBACK (on_launch_started),
|
|
|
|
&launch_started);
|
|
|
|
g_signal_connect (context, "launched",
|
|
|
|
G_CALLBACK (on_launched),
|
|
|
|
&launched);
|
|
|
|
g_signal_connect (context, "launch-failed",
|
|
|
|
G_CALLBACK (on_launch_failed),
|
|
|
|
&failed);
|
|
|
|
|
|
|
|
retval = g_desktop_app_info_launch_uris_as_manager_with_fds (appinfo,
|
|
|
|
NULL, context, 0,
|
|
|
|
NULL, NULL,
|
|
|
|
NULL, NULL,
|
|
|
|
3000, 3001, 3002,
|
|
|
|
&error);
|
|
|
|
g_assert_error (error, G_SPAWN_ERROR, G_SPAWN_ERROR_FAILED);
|
|
|
|
g_assert_false (retval);
|
|
|
|
g_assert_true (launch_started);
|
|
|
|
g_assert_false (launched);
|
|
|
|
g_assert_true (failed);
|
|
|
|
|
|
|
|
g_clear_error (&error);
|
|
|
|
g_object_unref (appinfo);
|
|
|
|
g_assert_finalize_object (context);
|
|
|
|
}
|
|
|
|
|
2022-06-14 21:47:33 +02:00
|
|
|
static GAppInfo *
|
|
|
|
create_app_info_toucher (const char *name,
|
|
|
|
const char *touched_file_name,
|
|
|
|
const char *handled_type,
|
|
|
|
char **out_file_path)
|
|
|
|
{
|
|
|
|
GError *error = NULL;
|
|
|
|
GAppInfo *info;
|
|
|
|
gchar *command_line;
|
|
|
|
gchar *file_path;
|
|
|
|
gchar *tmpdir;
|
|
|
|
|
|
|
|
g_assert_nonnull (out_file_path);
|
|
|
|
|
|
|
|
tmpdir = g_dir_make_tmp ("desktop-app-info-launch-XXXXXX", &error);
|
|
|
|
g_assert_no_error (error);
|
|
|
|
|
|
|
|
file_path = g_build_filename (tmpdir, touched_file_name, NULL);
|
|
|
|
command_line = g_strdup_printf ("touch %s", file_path);
|
|
|
|
|
|
|
|
info = create_command_line_app_info (name, command_line, handled_type);
|
|
|
|
*out_file_path = g_steal_pointer (&file_path);
|
|
|
|
|
|
|
|
g_free (tmpdir);
|
|
|
|
g_free (command_line);
|
|
|
|
|
|
|
|
return info;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
test_default_uri_handler (void)
|
|
|
|
{
|
|
|
|
GError *error = NULL;
|
|
|
|
gchar *file_path = NULL;
|
|
|
|
GAppInfo *info;
|
|
|
|
|
|
|
|
info = create_app_info_toucher ("Touch Handled", "handled",
|
|
|
|
"x-scheme-handler/glib-touch",
|
|
|
|
&file_path);
|
|
|
|
g_assert_true (G_IS_APP_INFO (info));
|
|
|
|
g_assert_nonnull (file_path);
|
|
|
|
|
|
|
|
g_assert_true (g_app_info_launch_default_for_uri ("glib-touch://touch-me",
|
|
|
|
NULL, &error));
|
|
|
|
g_assert_no_error (error);
|
|
|
|
|
|
|
|
while (!g_file_test (file_path, G_FILE_TEST_IS_REGULAR));
|
|
|
|
g_assert_true (g_file_test (file_path, G_FILE_TEST_IS_REGULAR));
|
|
|
|
|
|
|
|
g_assert_false (g_app_info_launch_default_for_uri ("glib-INVALID-touch://touch-me",
|
|
|
|
NULL, &error));
|
|
|
|
g_assert_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED);
|
|
|
|
g_clear_error (&error);
|
|
|
|
|
|
|
|
g_object_unref (info);
|
|
|
|
g_free (file_path);
|
|
|
|
}
|
|
|
|
|
2022-06-02 00:24:25 +02:00
|
|
|
static void
|
|
|
|
on_launch_default_for_uri_success_cb (GObject *object,
|
|
|
|
GAsyncResult *result,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
GError *error = NULL;
|
|
|
|
gboolean *called = user_data;
|
|
|
|
|
|
|
|
g_assert_true (g_app_info_launch_default_for_uri_finish (result, &error));
|
|
|
|
g_assert_no_error (error);
|
|
|
|
|
|
|
|
*called = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
on_launch_default_for_uri_not_found_cb (GObject *object,
|
|
|
|
GAsyncResult *result,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
GError *error = NULL;
|
|
|
|
GMainLoop *loop = user_data;
|
|
|
|
|
|
|
|
g_assert_false (g_app_info_launch_default_for_uri_finish (result, &error));
|
|
|
|
g_assert_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED);
|
|
|
|
g_clear_error (&error);
|
|
|
|
|
|
|
|
g_main_loop_quit (loop);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
on_launch_default_for_uri_cancelled_cb (GObject *object,
|
|
|
|
GAsyncResult *result,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
GError *error = NULL;
|
|
|
|
GMainLoop *loop = user_data;
|
|
|
|
|
|
|
|
g_assert_false (g_app_info_launch_default_for_uri_finish (result, &error));
|
|
|
|
g_assert_error (error, G_IO_ERROR, G_IO_ERROR_CANCELLED);
|
|
|
|
g_clear_error (&error);
|
|
|
|
|
|
|
|
g_main_loop_quit (loop);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
test_default_uri_handler_async (void)
|
|
|
|
{
|
|
|
|
GCancellable *cancellable;
|
|
|
|
gchar *file_path = NULL;
|
|
|
|
GAppInfo *info;
|
|
|
|
GMainLoop *loop;
|
|
|
|
gboolean called = FALSE;
|
|
|
|
|
|
|
|
loop = g_main_loop_new (NULL, FALSE);
|
|
|
|
info = create_app_info_toucher ("Touch Handled", "handled-async",
|
|
|
|
"x-scheme-handler/glib-async-touch",
|
|
|
|
&file_path);
|
|
|
|
g_assert_true (G_IS_APP_INFO (info));
|
|
|
|
g_assert_nonnull (file_path);
|
|
|
|
|
|
|
|
g_app_info_launch_default_for_uri_async ("glib-async-touch://touch-me", NULL,
|
|
|
|
NULL,
|
|
|
|
on_launch_default_for_uri_success_cb,
|
|
|
|
&called);
|
|
|
|
|
2022-07-12 17:18:52 +02:00
|
|
|
while (!g_file_test (file_path, G_FILE_TEST_IS_REGULAR) || !called)
|
2022-06-02 00:24:25 +02:00
|
|
|
g_main_context_iteration (NULL, FALSE);
|
|
|
|
|
|
|
|
g_assert_true (called);
|
|
|
|
g_assert_true (g_file_test (file_path, G_FILE_TEST_IS_REGULAR));
|
|
|
|
|
|
|
|
g_unlink (file_path);
|
|
|
|
g_assert_false (g_file_test (file_path, G_FILE_TEST_IS_REGULAR));
|
|
|
|
|
|
|
|
g_app_info_launch_default_for_uri_async ("glib-async-INVALID-touch://touch-me",
|
|
|
|
NULL, NULL,
|
|
|
|
on_launch_default_for_uri_not_found_cb,
|
|
|
|
loop);
|
|
|
|
g_main_loop_run (loop);
|
|
|
|
|
|
|
|
cancellable = g_cancellable_new ();
|
|
|
|
g_app_info_launch_default_for_uri_async ("glib-async-touch://touch-me", NULL,
|
|
|
|
cancellable,
|
|
|
|
on_launch_default_for_uri_cancelled_cb,
|
|
|
|
loop);
|
|
|
|
g_cancellable_cancel (cancellable);
|
|
|
|
g_main_loop_run (loop);
|
|
|
|
|
|
|
|
/* Once started our touch app may take some time before having written the
|
|
|
|
* file, so let's wait a bit here before ensuring that the file has been
|
|
|
|
* created as expected.
|
|
|
|
*/
|
|
|
|
g_usleep (G_USEC_PER_SEC / 10);
|
|
|
|
g_assert_false (g_file_test (file_path, G_FILE_TEST_IS_REGULAR));
|
|
|
|
|
|
|
|
g_object_unref (info);
|
|
|
|
g_main_loop_unref (loop);
|
|
|
|
g_free (file_path);
|
|
|
|
}
|
|
|
|
|
2021-12-13 22:43:44 +01:00
|
|
|
/* Test if Desktop-File Id is correctly formed */
|
|
|
|
static void
|
|
|
|
test_id (void)
|
|
|
|
{
|
|
|
|
gchar *result;
|
|
|
|
|
|
|
|
result = run_apps ("default-for-type", "application/vnd.kde.okular-archive",
|
|
|
|
TRUE, FALSE, NULL, NULL, NULL);
|
|
|
|
g_assert_cmpstr (result, ==, "kde4-okular.desktop\n");
|
|
|
|
g_free (result);
|
|
|
|
}
|
|
|
|
|
2022-09-13 00:22:02 +02:00
|
|
|
static const char *
|
|
|
|
get_terminal_divider (const char *terminal_name)
|
|
|
|
{
|
2022-10-26 11:05:13 +02:00
|
|
|
if (g_str_equal (terminal_name, "xdg-terminal-exec"))
|
|
|
|
return NULL;
|
2022-10-27 00:21:39 +02:00
|
|
|
if (g_str_equal (terminal_name, "kgx"))
|
|
|
|
return "-e";
|
2022-09-13 00:22:02 +02:00
|
|
|
if (g_str_equal (terminal_name, "gnome-terminal"))
|
|
|
|
return "--";
|
|
|
|
if (g_str_equal (terminal_name, "tilix"))
|
|
|
|
return "-e";
|
|
|
|
if (g_str_equal (terminal_name, "konsole"))
|
|
|
|
return "-e";
|
|
|
|
if (g_str_equal (terminal_name, "nxterm"))
|
|
|
|
return "-e";
|
|
|
|
if (g_str_equal (terminal_name, "color-xterm"))
|
|
|
|
return "-e";
|
|
|
|
if (g_str_equal (terminal_name, "rxvt"))
|
|
|
|
return "-e";
|
|
|
|
if (g_str_equal (terminal_name, "dtterm"))
|
|
|
|
return "-e";
|
|
|
|
if (g_str_equal (terminal_name, "xterm"))
|
|
|
|
return "-e";
|
|
|
|
if (g_str_equal (terminal_name, "mate-terminal"))
|
|
|
|
return "-x";
|
|
|
|
if (g_str_equal (terminal_name, "xfce4-terminal"))
|
|
|
|
return "-x";
|
|
|
|
|
|
|
|
g_return_val_if_reached (NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
test_launch_uris_with_terminal (gconstpointer data)
|
|
|
|
{
|
2022-10-17 20:44:14 +02:00
|
|
|
int fd;
|
|
|
|
int ret;
|
|
|
|
int flags;
|
2022-10-26 11:05:13 +02:00
|
|
|
int terminal_divider_arg_length;
|
2022-09-13 00:22:02 +02:00
|
|
|
const char *terminal_exec = data;
|
|
|
|
char *old_path;
|
|
|
|
char *command_line;
|
|
|
|
char *bin_path;
|
|
|
|
char *terminal_path;
|
|
|
|
char *output_fd_path;
|
|
|
|
char *script_contents;
|
2022-10-17 20:44:14 +02:00
|
|
|
char *output_contents = NULL;
|
2022-09-13 00:22:02 +02:00
|
|
|
char *sh;
|
|
|
|
GAppInfo *app_info;
|
|
|
|
GList *uris;
|
|
|
|
GList *paths;
|
|
|
|
GStrv output_args;
|
|
|
|
GError *error = NULL;
|
|
|
|
GInputStream *input_stream;
|
|
|
|
GDataInputStream *data_input_stream;
|
|
|
|
|
|
|
|
sh = g_find_program_in_path ("sh");
|
|
|
|
g_assert_nonnull (sh);
|
|
|
|
|
|
|
|
bin_path = g_dir_make_tmp ("bin-path-XXXXXX", &error);
|
|
|
|
g_assert_no_error (error);
|
|
|
|
|
|
|
|
old_path = g_strdup (g_getenv ("PATH"));
|
|
|
|
g_assert_true (g_setenv ("PATH", bin_path, TRUE));
|
|
|
|
|
|
|
|
terminal_path = g_build_filename (bin_path, terminal_exec, NULL);
|
2022-10-17 20:44:14 +02:00
|
|
|
output_fd_path = g_build_filename (bin_path, "fifo", NULL);
|
|
|
|
|
|
|
|
ret = mkfifo (output_fd_path, 0600);
|
|
|
|
|
|
|
|
g_assert_cmpint (ret, ==, 0);
|
|
|
|
|
|
|
|
fd = g_open (output_fd_path, O_RDONLY | O_CLOEXEC | O_NONBLOCK, 0);
|
|
|
|
|
|
|
|
g_assert_cmpint (fd, >=, 0);
|
2022-09-13 00:22:02 +02:00
|
|
|
|
2022-10-17 20:44:14 +02:00
|
|
|
flags = fcntl (fd, F_GETFL);
|
|
|
|
|
|
|
|
g_assert_cmpint (flags, >=, 0);
|
|
|
|
|
|
|
|
ret = fcntl (fd, F_SETFL, flags & ~O_NONBLOCK);
|
|
|
|
|
|
|
|
g_assert_cmpint (ret, ==, 0);
|
|
|
|
|
|
|
|
input_stream = g_unix_input_stream_new (fd, TRUE);
|
2022-09-13 00:22:02 +02:00
|
|
|
data_input_stream = g_data_input_stream_new (input_stream);
|
|
|
|
script_contents = g_strdup_printf ("#!%s\n" \
|
|
|
|
"out='%s'\n"
|
2022-10-17 18:40:53 +02:00
|
|
|
"printf '%%s\\n' \"$*\" > \"$out\"\n",
|
2022-09-13 00:22:02 +02:00
|
|
|
sh,
|
|
|
|
output_fd_path);
|
|
|
|
g_file_set_contents (terminal_path, script_contents, -1, &error);
|
|
|
|
g_assert_no_error (error);
|
|
|
|
g_assert_cmpint (g_chmod (terminal_path, 0500), ==, 0);
|
|
|
|
|
|
|
|
g_test_message ("Fake '%s' terminal created as: %s", terminal_exec, terminal_path);
|
|
|
|
|
|
|
|
command_line = g_strdup_printf ("true %s-argument", terminal_exec);
|
|
|
|
app_info = g_app_info_create_from_commandline (command_line,
|
|
|
|
"Test App on Terminal",
|
|
|
|
G_APP_INFO_CREATE_NEEDS_TERMINAL |
|
|
|
|
G_APP_INFO_CREATE_SUPPORTS_URIS,
|
|
|
|
&error);
|
|
|
|
g_assert_no_error (error);
|
|
|
|
|
|
|
|
paths = g_list_prepend (NULL, bin_path);
|
|
|
|
uris = g_list_prepend (NULL, g_filename_to_uri (bin_path, NULL, &error));
|
|
|
|
g_assert_no_error (error);
|
|
|
|
|
|
|
|
paths = g_list_prepend (paths, (gpointer) g_get_user_data_dir ());
|
|
|
|
uris = g_list_append (uris, g_filename_to_uri (g_get_user_data_dir (), NULL, &error));
|
|
|
|
g_assert_no_error (error);
|
|
|
|
|
|
|
|
g_assert_cmpint (g_list_length (paths), ==, 2);
|
|
|
|
g_app_info_launch_uris (app_info, uris, NULL, &error);
|
|
|
|
g_assert_no_error (error);
|
|
|
|
|
2022-10-17 20:44:14 +02:00
|
|
|
while (output_contents == NULL)
|
|
|
|
{
|
|
|
|
output_contents =
|
|
|
|
g_data_input_stream_read_upto (data_input_stream, "\n", 1, NULL, NULL, &error);
|
|
|
|
g_assert_no_error (error);
|
|
|
|
|
|
|
|
if (output_contents == NULL)
|
|
|
|
g_usleep (G_USEC_PER_SEC / 10);
|
|
|
|
}
|
2022-09-13 00:22:02 +02:00
|
|
|
g_test_message ("'%s' called with arguments: '%s'", terminal_exec, output_contents);
|
|
|
|
|
2022-10-17 20:44:14 +02:00
|
|
|
g_data_input_stream_read_byte (data_input_stream, NULL, &error);
|
|
|
|
g_assert_no_error (error);
|
|
|
|
|
2022-09-13 00:22:02 +02:00
|
|
|
output_args = g_strsplit (output_contents, " ", -1);
|
|
|
|
g_clear_pointer (&output_contents, g_free);
|
|
|
|
|
2022-10-26 11:05:13 +02:00
|
|
|
terminal_divider_arg_length = (get_terminal_divider (terminal_exec) != NULL) ? 1 : 0;
|
|
|
|
g_assert_cmpuint (g_strv_length (output_args), ==, 3 + terminal_divider_arg_length);
|
|
|
|
if (terminal_divider_arg_length == 1)
|
|
|
|
{
|
|
|
|
g_assert_cmpstr (output_args[0], ==, get_terminal_divider (terminal_exec));
|
|
|
|
g_assert_cmpstr (output_args[1], ==, "true");
|
|
|
|
g_assert_cmpstr (output_args[2], ==, command_line + 5);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_assert_cmpstr (output_args[0], ==, "true");
|
|
|
|
g_assert_cmpstr (output_args[1], ==, command_line + 5);
|
|
|
|
}
|
2022-09-13 00:22:02 +02:00
|
|
|
paths = g_list_delete_link (paths,
|
2022-10-26 11:05:13 +02:00
|
|
|
g_list_find_custom (paths, output_args[2 + terminal_divider_arg_length], g_str_equal));
|
2022-09-13 00:22:02 +02:00
|
|
|
g_assert_cmpint (g_list_length (paths), ==, 1);
|
|
|
|
g_clear_pointer (&output_args, g_strfreev);
|
|
|
|
|
2022-10-17 20:44:14 +02:00
|
|
|
while (output_contents == NULL)
|
|
|
|
{
|
|
|
|
output_contents =
|
|
|
|
g_data_input_stream_read_upto (data_input_stream, "\n", 1, NULL, NULL, &error);
|
|
|
|
g_assert_no_error (error);
|
|
|
|
|
|
|
|
if (output_contents == NULL)
|
|
|
|
g_usleep (G_USEC_PER_SEC / 10);
|
|
|
|
}
|
2022-09-13 00:22:02 +02:00
|
|
|
g_test_message ("'%s' called with arguments: '%s'", terminal_exec, output_contents);
|
|
|
|
|
2022-10-17 20:44:14 +02:00
|
|
|
g_data_input_stream_read_byte (data_input_stream, NULL, &error);
|
|
|
|
g_assert_no_error (error);
|
|
|
|
|
2022-09-13 00:22:02 +02:00
|
|
|
output_args = g_strsplit (output_contents, " ", -1);
|
|
|
|
g_clear_pointer (&output_contents, g_free);
|
2022-10-26 11:05:13 +02:00
|
|
|
g_assert_cmpuint (g_strv_length (output_args), ==, 3 + terminal_divider_arg_length);
|
|
|
|
if (terminal_divider_arg_length > 0)
|
|
|
|
{
|
|
|
|
g_assert_cmpstr (output_args[0], ==, get_terminal_divider (terminal_exec));
|
|
|
|
g_assert_cmpstr (output_args[1], ==, "true");
|
|
|
|
g_assert_cmpstr (output_args[2], ==, command_line + 5);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_assert_cmpstr (output_args[0], ==, "true");
|
|
|
|
g_assert_cmpstr (output_args[1], ==, command_line + 5);
|
|
|
|
}
|
2022-09-13 00:22:02 +02:00
|
|
|
paths = g_list_delete_link (paths,
|
2022-10-26 11:05:13 +02:00
|
|
|
g_list_find_custom (paths, output_args[2 + terminal_divider_arg_length], g_str_equal));
|
2022-09-13 00:22:02 +02:00
|
|
|
g_assert_cmpint (g_list_length (paths), ==, 0);
|
|
|
|
g_clear_pointer (&output_args, g_strfreev);
|
|
|
|
|
|
|
|
g_assert_null (paths);
|
|
|
|
g_assert_true (g_setenv ("PATH", old_path, TRUE));
|
|
|
|
|
2022-10-17 20:44:14 +02:00
|
|
|
g_close (fd, &error);
|
2022-09-13 00:22:02 +02:00
|
|
|
g_assert_no_error (error);
|
|
|
|
|
|
|
|
g_free (sh);
|
|
|
|
g_free (command_line);
|
|
|
|
g_free (bin_path);
|
|
|
|
g_free (terminal_path);
|
|
|
|
g_free (output_fd_path);
|
|
|
|
g_free (script_contents);
|
|
|
|
g_free (old_path);
|
|
|
|
g_clear_pointer (&output_args, g_strfreev);
|
|
|
|
g_clear_pointer (&output_contents, g_free);
|
|
|
|
g_clear_object (&data_input_stream);
|
|
|
|
g_clear_object (&input_stream);
|
|
|
|
g_clear_object (&app_info);
|
|
|
|
g_clear_error (&error);
|
|
|
|
g_clear_list (&paths, NULL);
|
|
|
|
g_clear_list (&uris, g_free);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
test_launch_uris_with_invalid_terminal (void)
|
|
|
|
{
|
|
|
|
char *old_path;
|
|
|
|
char *bin_path;
|
|
|
|
GAppInfo *app_info;
|
|
|
|
GError *error = NULL;
|
|
|
|
|
|
|
|
bin_path = g_dir_make_tmp ("bin-path-XXXXXX", &error);
|
|
|
|
g_assert_no_error (error);
|
|
|
|
|
|
|
|
old_path = g_strdup (g_getenv ("PATH"));
|
|
|
|
g_assert_true (g_setenv ("PATH", bin_path, TRUE));
|
|
|
|
|
|
|
|
app_info = g_app_info_create_from_commandline ("true invalid-glib-terminal",
|
|
|
|
"Test App on Invalid Terminal",
|
|
|
|
G_APP_INFO_CREATE_NEEDS_TERMINAL |
|
|
|
|
G_APP_INFO_CREATE_SUPPORTS_URIS,
|
|
|
|
&error);
|
|
|
|
g_assert_no_error (error);
|
|
|
|
|
|
|
|
g_app_info_launch_uris (app_info, NULL, NULL, &error);
|
|
|
|
g_assert_error (error, G_IO_ERROR, G_IO_ERROR_FAILED);
|
|
|
|
g_clear_error (&error);
|
|
|
|
|
|
|
|
g_assert_true (g_setenv ("PATH", old_path, TRUE));
|
|
|
|
|
|
|
|
g_clear_object (&app_info);
|
|
|
|
g_clear_error (&error);
|
|
|
|
g_free (bin_path);
|
|
|
|
g_free (old_path);
|
|
|
|
}
|
|
|
|
|
2008-09-26 21:57:36 +02:00
|
|
|
int
|
|
|
|
main (int argc,
|
|
|
|
char *argv[])
|
|
|
|
{
|
2022-09-13 00:22:02 +02:00
|
|
|
guint i;
|
|
|
|
const gchar *supported_terminals[] = {
|
2022-10-26 11:05:13 +02:00
|
|
|
"xdg-terminal-exec",
|
2022-10-27 00:21:39 +02:00
|
|
|
"kgx",
|
2022-09-13 00:22:02 +02:00
|
|
|
"gnome-terminal",
|
|
|
|
"mate-terminal",
|
|
|
|
"xfce4-terminal",
|
|
|
|
"tilix",
|
|
|
|
"konsole",
|
|
|
|
"nxterm",
|
|
|
|
"color-xterm",
|
|
|
|
"rxvt",
|
|
|
|
"dtterm",
|
|
|
|
"xterm",
|
|
|
|
};
|
|
|
|
|
2018-11-30 19:03:41 +01:00
|
|
|
/* While we use %G_TEST_OPTION_ISOLATE_DIRS to create temporary directories
|
|
|
|
* for each of the tests, we want to use the system MIME registry, assuming
|
|
|
|
* that it exists and correctly has shared-mime-info installed. */
|
|
|
|
g_content_type_set_mime_dirs (NULL);
|
2008-10-17 01:59:50 +02:00
|
|
|
|
2018-11-30 19:03:41 +01:00
|
|
|
g_test_init (&argc, &argv, G_TEST_OPTION_ISOLATE_DIRS, NULL);
|
2013-10-10 15:28:30 +02:00
|
|
|
|
2008-09-26 21:57:36 +02:00
|
|
|
g_test_add_func ("/desktop-app-info/delete", test_delete);
|
|
|
|
g_test_add_func ("/desktop-app-info/default", test_default);
|
2022-06-01 21:45:58 +02:00
|
|
|
g_test_add_func ("/desktop-app-info/default-async", test_default_async);
|
2010-11-19 11:37:44 +01:00
|
|
|
g_test_add_func ("/desktop-app-info/fallback", test_fallback);
|
2010-12-15 17:56:22 +01:00
|
|
|
g_test_add_func ("/desktop-app-info/lastused", test_last_used);
|
2012-11-21 22:15:14 +01:00
|
|
|
g_test_add_func ("/desktop-app-info/extra-getters", test_extra_getters);
|
2013-07-11 18:46:59 +02:00
|
|
|
g_test_add_func ("/desktop-app-info/actions", test_actions);
|
2013-10-10 15:28:30 +02:00
|
|
|
g_test_add_func ("/desktop-app-info/search", test_search);
|
2013-11-15 20:44:33 +01:00
|
|
|
g_test_add_func ("/desktop-app-info/implements", test_implements);
|
2014-05-08 22:16:35 +02:00
|
|
|
g_test_add_func ("/desktop-app-info/show-in", test_show_in);
|
2018-06-06 14:59:59 +02:00
|
|
|
g_test_add_func ("/desktop-app-info/launch-as-manager", test_launch_as_manager);
|
2022-10-23 17:09:33 +02:00
|
|
|
g_test_add_func ("/desktop-app-info/launch-as-manager/fail", test_launch_as_manager_fail);
|
2022-06-14 21:47:33 +02:00
|
|
|
g_test_add_func ("/desktop-app-info/launch-default-uri-handler", test_default_uri_handler);
|
2022-06-02 00:24:25 +02:00
|
|
|
g_test_add_func ("/desktop-app-info/launch-default-uri-handler-async", test_default_uri_handler_async);
|
2021-12-13 22:43:44 +01:00
|
|
|
g_test_add_func ("/desktop-app-info/id", test_id);
|
2008-09-26 21:57:36 +02:00
|
|
|
|
2022-09-13 00:22:02 +02:00
|
|
|
for (i = 0; i < G_N_ELEMENTS (supported_terminals); i++)
|
|
|
|
{
|
|
|
|
char *path;
|
|
|
|
|
|
|
|
path = g_strdup_printf ("/desktop-app-info/launch-uris-with-terminal/%s",
|
|
|
|
supported_terminals[i]);
|
|
|
|
g_test_add_data_func (path, supported_terminals[i],
|
|
|
|
test_launch_uris_with_terminal);
|
|
|
|
|
|
|
|
g_free (path);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_test_add_func ("/desktop-app-info/launch-uris-with-terminal/invalid-glib-terminal",
|
|
|
|
test_launch_uris_with_invalid_terminal);
|
|
|
|
|
2018-11-30 19:03:41 +01:00
|
|
|
return g_test_run ();
|
2008-09-26 21:57:36 +02:00
|
|
|
}
|