credentials \
$(NULL)
-TEST_PROGS += $(test_progs)
-
if HAVE_DBUS_DAEMON
-TEST_PROGS += \
+test_progs += \
actions \
gdbus-connection \
gdbus-connection-loss \
$(NULL)
endif
-
if OS_UNIX
-TEST_PROGS += \
+test_progs += \
gdbus-close-pending \
gdbus-connection-flush \
gdbus-peer \
gdbus-example-subtree \
gdbus-example-peer \
gdbus-example-proxy-subclass \
- gdbus-connection-flush-helper \
proxy \
gapplication-example-open \
gapplication-example-cmdline \
gapplication-example-actions \
gapplication-example-dbushooks \
gdbus-daemon \
+ $(NULL)
+
+other_progs = \
gdbus-testserver \
+ gdbus-connection-flush-helper \
$(NULL)
if OS_UNIX
-TEST_PROGS += \
+test_progs += \
live-g-file \
desktop-app-info \
unix-fd \
gdbus-test-codegen \
socket-address \
$(NULL)
+
+other_progs += \
+ appinfo-test \
+ $(NULL)
+
SAMPLE_PROGS += \
gdbus-example-unix-fd-client \
gdbus-example-objectmanager-server \
gdbus-example-objectmanager-client \
gdbus-test-fixture \
- appinfo-test \
$(NULL)
endif
gdbus_testserver_SOURCES = gdbus-testserver.c
if HAVE_DBUS1
-TEST_PROGS += gdbus-serialization
+test_progs += gdbus-serialization
gdbus_serialization_SOURCES = gdbus-serialization.c gdbus-tests.h gdbus-tests.c
gdbus_serialization_CFLAGS = $(AM_CFLAGS) $(DBUS1_CFLAGS)
gdbus_serialization_LDADD = $(LDADD) $(DBUS1_LIBS)
endif
-TEST_PROGS += gdbus-auth
+test_progs += gdbus-auth
gdbus_auth_SOURCES = gdbus-auth.c gdbus-sessionbus.c gdbus-sessionbus.h gdbus-tests.h gdbus-tests.c
gdbus_auth_LDADD = $(LDADD)
gmenumodel_SOURCES = gmenumodel.c gdbus-sessionbus.h gdbus-sessionbus.c
+TEST_PROGS += $(test_progs)
+
TESTS_ENVIRONMENT = \
GLIB_MKENUMS=../../gobject/glib-mkenums \
GLIB_COMPILE_SCHEMAS=../glib-compile-schemas
org.gtk.test.gschema.xml \
org.gtk.schemasourcecheck.gschema.xml \
test.gresource \
+ appinfo-test.desktop \
+ appinfo-test2.desktop \
+ appinfo-test-gnome.desktop \
+ appinfo-test-notgnome.desktop \
$(NULL)
if BUILDOPT_INSTALL_TESTS
-insttest_PROGRAMS = $(test_progs)
+insttest_PROGRAMS = $(test_progs) $(other_progs)
schematestdir = $(insttestdir)/schema-tests
schematest_DATA = $(schema_test_files)
#include <gio/gio.h>
#include <gio/gdesktopappinfo.h>
+static const gchar *datapath;
+
static void
test_launch (void)
{
GError *error;
GFile *file;
GList *l;
+ gchar *path;
- appinfo = (GAppInfo*)g_desktop_app_info_new_from_filename (SRCDIR "/appinfo-test.desktop");
+ path = g_build_filename (datapath, "appinfo-test.desktop", NULL);
+ appinfo = (GAppInfo*)g_desktop_app_info_new_from_filename (path);
g_assert (appinfo != NULL);
+ g_free (path);
error = NULL;
g_assert (g_app_info_launch (appinfo, NULL, NULL, &error));
g_assert (g_app_info_launch_uris (appinfo, NULL, NULL, &error));
g_assert_no_error (error);
- file = g_file_new_for_path (SRCDIR "/appinfo-test.desktop");
+ path = g_build_filename (datapath, "appinfo-test.desktop", NULL);
+ file = g_file_new_for_path (path);
+ g_free (path);
l = NULL;
l = g_list_append (l, file);
g_object_unref (file);
l = NULL;
- l = g_list_append (l, "file://" SRCDIR "/appinfo-test.desktop");
+ path = g_strconcat ("file://", datapath, "/appinfo-test.desktop", NULL);
+ l = g_list_append (l, path);
l = g_list_append (l, "file:///etc/group#adm");
g_assert (g_app_info_launch_uris (appinfo, l, NULL, &error));
g_assert_no_error (error);
g_list_free (l);
+ g_free (path);
g_object_unref (appinfo);
}
{
GAppInfo *appinfo;
const gchar *orig;
+ gchar *path;
orig = setlocale (LC_ALL, NULL);
g_setenv ("LANGUAGE", locale, TRUE);
setlocale (LC_ALL, "");
- appinfo = (GAppInfo*)g_desktop_app_info_new_from_filename (SRCDIR "/appinfo-test.desktop");
+ path = g_build_filename (datapath, "appinfo-test.desktop", NULL);
+ appinfo = (GAppInfo*)g_desktop_app_info_new_from_filename (path);
+ g_free (path);
if (g_strcmp0 (locale, "C") == 0)
{
GAppInfo *appinfo;
GAppInfo *appinfo2;
GIcon *icon, *icon2;
+ gchar *path;
- appinfo = (GAppInfo*)g_desktop_app_info_new_from_filename (SRCDIR "/appinfo-test.desktop");
+ path = g_build_filename (datapath, "appinfo-test.desktop", NULL);
+ appinfo = (GAppInfo*)g_desktop_app_info_new_from_filename (path);
+ g_free (path);
g_assert_cmpstr (g_app_info_get_id (appinfo), ==, "appinfo-test.desktop");
g_assert_cmpstr (g_app_info_get_executable (appinfo), ==, "./appinfo-test");
test_show_in (void)
{
GAppInfo *appinfo;
+ gchar *path;
g_desktop_app_info_set_desktop_env ("GNOME");
- appinfo = (GAppInfo*)g_desktop_app_info_new_from_filename (SRCDIR "/appinfo-test.desktop");
+ path = g_build_filename (datapath, "appinfo-test.desktop", NULL);
+ appinfo = (GAppInfo*)g_desktop_app_info_new_from_filename (path);
g_assert (g_app_info_should_show (appinfo));
g_object_unref (appinfo);
+ g_free (path);
- appinfo = (GAppInfo*)g_desktop_app_info_new_from_filename (SRCDIR "/appinfo-test-gnome.desktop");
+ path = g_build_filename (datapath, "appinfo-test-gnome.desktop", NULL);
+ appinfo = (GAppInfo*)g_desktop_app_info_new_from_filename (path);
g_assert (g_app_info_should_show (appinfo));
g_object_unref (appinfo);
+ g_free (path);
- appinfo = (GAppInfo*)g_desktop_app_info_new_from_filename (SRCDIR "/appinfo-test-notgnome.desktop");
+ path = g_build_filename (datapath, "appinfo-test-notgnome.desktop", NULL);
+ appinfo = (GAppInfo*)g_desktop_app_info_new_from_filename (path);
g_assert (!g_app_info_should_show (appinfo));
g_object_unref (appinfo);
+ g_free (path);
}
static void
{
GAppInfo *appinfo;
GError *error;
+ gchar *cmdline;
+ gchar *cmdline_out;
+
+ cmdline = g_strconcat (datapath, "/appinfo-test --option", NULL);
+ cmdline_out = g_strconcat (cmdline, " %u", NULL);
error = NULL;
- appinfo = g_app_info_create_from_commandline ("./appinfo-test --option",
+ appinfo = g_app_info_create_from_commandline (cmdline,
"cmdline-app-test",
G_APP_INFO_CREATE_SUPPORTS_URIS,
&error);
g_assert (appinfo != NULL);
g_assert_no_error (error);
g_assert_cmpstr (g_app_info_get_name (appinfo), ==, "cmdline-app-test");
- g_assert_cmpstr (g_app_info_get_commandline (appinfo), ==, "./appinfo-test --option %u");
+ 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_object_unref (appinfo);
+ g_free (cmdline_out);
+ cmdline_out = g_strconcat (cmdline, " %f", NULL);
+
error = NULL;
- appinfo = g_app_info_create_from_commandline ("./appinfo-test --option",
+ appinfo = g_app_info_create_from_commandline (cmdline,
"cmdline-app-test",
G_APP_INFO_CREATE_NONE,
&error);
g_assert (appinfo != NULL);
g_assert_no_error (error);
g_assert_cmpstr (g_app_info_get_name (appinfo), ==, "cmdline-app-test");
- g_assert_cmpstr (g_app_info_get_commandline (appinfo), ==, "./appinfo-test --option %f");
+ 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_object_unref (appinfo);
+
+ g_free (cmdline);
+ g_free (cmdline_out);
}
static void
GAppLaunchContext *context;
GAppInfo *appinfo;
gchar *str;
+ gchar *cmdline;
+
+ cmdline = g_strconcat (datapath, "/appinfo-test --option", NULL);
context = g_app_launch_context_new ();
- appinfo = g_app_info_create_from_commandline ("./appinfo-test --option",
+ appinfo = g_app_info_create_from_commandline (cmdline,
"cmdline-app-test",
G_APP_INFO_CREATE_SUPPORTS_URIS,
NULL);
g_object_unref (appinfo);
g_object_unref (context);
+
+ g_free (cmdline);
}
static gboolean launched_reached;
GAppLaunchContext *context;
GAppInfo *appinfo;
GError *error = NULL;
+ gchar *cmdline;
+
+ cmdline = g_strconcat (datapath, "/appinfo-test --option", NULL);
context = g_app_launch_context_new ();
g_signal_connect (context, "launched", G_CALLBACK (launched), NULL);
g_signal_connect (context, "launch_failed", G_CALLBACK (launch_failed), NULL);
- appinfo = g_app_info_create_from_commandline ("./appinfo-test --option",
+ appinfo = g_app_info_create_from_commandline (cmdline,
"cmdline-app-test",
G_APP_INFO_CREATE_SUPPORTS_URIS,
NULL);
g_object_unref (appinfo);
g_object_unref (context);
+
+ g_free (cmdline);
}
static void
test_tryexec (void)
{
GAppInfo *appinfo;
+ gchar *path;
- appinfo = (GAppInfo*)g_desktop_app_info_new_from_filename (SRCDIR "/appinfo-test2.desktop");
+ path = g_build_filename (datapath, "appinfo-test2.desktop", NULL);
+ appinfo = (GAppInfo*)g_desktop_app_info_new_from_filename (path);
g_assert (appinfo == NULL);
+
+ g_free (path);
}
/* Test that we can set an appinfo as default for a mime type or
GError *error;
gboolean result;
GList *list;
+ gchar *cmdline;
- appinfo = g_app_info_create_from_commandline ("./appinfo-test --option",
+ cmdline = g_strconcat (datapath, "/appinfo-test --option", NULL);
+ appinfo = g_app_info_create_from_commandline (cmdline,
"cmdline-app-test",
G_APP_INFO_CREATE_SUPPORTS_URIS,
NULL);
{
GDesktopAppInfo *appinfo;
const char *wm_class;
+ gchar *path;
- appinfo = g_desktop_app_info_new_from_filename (SRCDIR "/appinfo-test.desktop");
+ path = g_build_filename (datapath, "appinfo-test.desktop", NULL);
+ appinfo = g_desktop_app_info_new_from_filename (path);
wm_class = g_desktop_app_info_get_startup_wm_class (appinfo);
g_assert_cmpstr (wm_class, ==, "appinfo-class");
g_object_unref (appinfo);
+ g_free (path);
}
static void
{
GAppInfo *appinfo;
const char * const *content_types;
+ gchar *path;
- appinfo = G_APP_INFO (g_desktop_app_info_new_from_filename (SRCDIR "/appinfo-test.desktop"));
+ path = g_build_filename (datapath, "appinfo-test.desktop", NULL);
+ appinfo = G_APP_INFO (g_desktop_app_info_new_from_filename (path));
content_types = g_app_info_get_supported_types (appinfo);
g_assert_cmpint (g_strv_length ((char**)content_types), ==, 2);
g_assert_cmpstr (content_types[0], ==, "image/png");
g_object_unref (appinfo);
+ g_free (path);
}
static void
gchar **keywords;
const gchar *file;
const gchar *name;
+ gchar *path;
+ path = g_build_filename (datapath, "appinfo-test.desktop", NULL);
kf = g_key_file_new ();
- g_key_file_load_from_file (kf,
- SRCDIR "/appinfo-test.desktop",
- G_KEY_FILE_NONE,
- &error);
+ g_key_file_load_from_file (kf, path, G_KEY_FILE_NONE, &error);
g_assert_no_error (error);
info = g_desktop_app_info_new_from_keyfile (kf);
g_key_file_free (kf);
g_assert (info != NULL);
+ g_free (path);
g_object_get (info, "filename", &file, NULL);
g_assert (file == NULL);
int
main (int argc, char *argv[])
{
+ if (g_getenv ("G_TEST_DATA"))
+ datapath = g_getenv ("G_TEST_DATA");
+ else
+ datapath = SRCDIR;
+
g_test_init (&argc, &argv, NULL);
g_test_add_func ("/appinfo/basic", test_basic);
#include "gdbus-tests.h"
+static const gchar *datapath;
+
/* all tests rely on a global connection */
static GDBusConnection *c = NULL;
{
GError *error;
gint ret;
+ gchar *path;
+
+ if (g_getenv ("G_TEST_DATA"))
+ datapath = g_getenv ("G_TEST_DATA");
+ else
+ datapath = SRCDIR;
g_test_init (&argc, &argv, NULL);
session_bus_up ();
/* this is safe; testserver will exit once the bus goes away */
- g_assert (g_spawn_command_line_async ("./gdbus-testserver", NULL));
+ path = g_build_filename (datapath, "gdbus-testserver", NULL);
+ g_assert (g_spawn_command_line_async (path, NULL));
+ g_free (path);
/* wait for the service to come up */
usleep (500 * 1000);
#include "gdbus-tests.h"
+static const gchar *datapath;
+
/* all tests rely on a shared mainloop */
static GMainLoop *loop = NULL;
gboolean ret;
gint exit_status;
guint timeout_mainloop_id;
+ gchar *path;
error = NULL;
- ret = g_spawn_command_line_sync ("./gdbus-connection-flush-helper",
+ path = g_build_filename (datapath, "gdbus-connection-flush-helper", NULL);
+ ret = g_spawn_command_line_sync (path,
NULL, /* stdout */
NULL, /* stderr */
&exit_status,
g_spawn_check_exit_status (exit_status, &error);
g_assert_no_error (error);
g_assert (ret);
+ g_free (path);
timeout_mainloop_id = g_timeout_add (1000, test_connection_flush_on_timeout, GUINT_TO_POINTER (n));
g_main_loop_run (loop);
test_connection_large_message (void)
{
guint watcher_id;
+ gchar *path;
session_bus_up ();
/* this is safe; testserver will exit once the bus goes away */
- g_assert (g_spawn_command_line_async ("./gdbus-testserver", NULL));
+ path = g_build_filename (datapath, "gdbus-testserver", NULL);
+ g_assert (g_spawn_command_line_async (path, NULL));
+ g_free (path);
watcher_id = g_bus_watch_name (G_BUS_TYPE_SESSION,
"com.example.TestService",
main (int argc,
char *argv[])
{
+ if (g_getenv ("G_TEST_DATA"))
+ datapath = g_getenv ("G_TEST_DATA");
+ else
+ datapath = SRCDIR;
+
g_test_init (&argc, &argv, NULL);
/* all the tests rely on a shared main loop */
#include "gdbus-tests.h"
+const gchar *datapath;
+
/* all tests rely on a shared mainloop */
static GMainLoop *loop = NULL;
FilterEffects effects;
GVariant *result;
const gchar *s;
+ gchar *path;
memset (&data, '\0', sizeof (FilterData));
g_assert_cmpint (data.num_outgoing, ==, 4);
/* this is safe; testserver will exit once the bus goes away */
- g_assert (g_spawn_command_line_async ("./gdbus-testserver", NULL));
+ path = g_build_filename (datapath, "gdbus-testserver", NULL);
+ g_assert (g_spawn_command_line_async (path, NULL));
+ g_free (path);
+
/* wait for service to be available */
signal_handler_id = g_dbus_connection_signal_subscribe (c,
"org.freedesktop.DBus", /* sender */
{
g_test_init (&argc, &argv, NULL);
+ if (g_getenv ("G_TEST_DATA"))
+ datapath = g_getenv ("G_TEST_DATA");
+ else
+ datapath = SRCDIR;
+
/* all the tests rely on a shared main loop */
loop = g_main_loop_new (NULL, FALSE);
#include "gdbus-tests.h"
+static const gchar *datapath;
+
/* all tests rely on a shared mainloop */
static GMainLoop *loop = NULL;
GDBusProxy *proxy;
GDBusConnection *connection;
GError *error;
+ gchar *path;
error = NULL;
connection = g_bus_get_sync (G_BUS_TYPE_SESSION,
g_assert_no_error (error);
/* this is safe; testserver will exit once the bus goes away */
- g_assert (g_spawn_command_line_async ("./gdbus-testserver", NULL));
+ path = g_build_filename (datapath, "gdbus-testserver", NULL);
+ g_assert (g_spawn_command_line_async (path, NULL));
+ g_free (path);
_g_assert_property_notify (proxy, "g-name-owner");
{
gint ret;
+ if (g_getenv ("G_TEST_DATA"))
+ datapath = g_getenv ("G_TEST_DATA");
+ else
+ datapath = SRCDIR;
+
g_test_init (&argc, &argv, NULL);
/* all the tests rely on a shared main loop */
#include "gdbus-tests.h"
+static const gchar *datapath;
+
/* all tests rely on a shared mainloop */
static GMainLoop *loop = NULL;
gchar **property_names;
GVariant *variant;
GVariant *result;
+ gchar *path;
session_bus_up ();
g_assert (g_dbus_proxy_get_cached_property_names (ap) == NULL);
/* this is safe; testserver will exit once the bus goes away */
- g_assert (g_spawn_command_line_async ("./gdbus-testserver", NULL));
+ path = g_build_filename (datapath, "gdbus-testserver", NULL);
+ g_assert (g_spawn_command_line_async (path, NULL));
+ g_free (path);
/* check that we get the notify::g-name-owner signal */
_g_assert_property_notify (p, "g-name-owner");
* the 'y' property should be back at 1...
*/
/* this is safe; testserver will exit once the bus goes away */
- g_assert (g_spawn_command_line_async ("./gdbus-testserver", NULL));
+ path = g_build_filename (datapath, "gdbus-testserver", NULL);
+ g_assert (g_spawn_command_line_async (path, NULL));
+ g_free (path);
+
/* check that we get the notify::g-name-owner signal */
_g_assert_property_notify (p, "g-name-owner");
/* Now we should have a name owner as well as properties */
{
gint ret;
+ if (g_getenv ("G_TEST_DATA"))
+ datapath = g_getenv ("G_TEST_DATA");
+ else
+ datapath = SRCDIR;
+
g_test_init (&argc, &argv, NULL);
/* all the tests rely on a shared main loop */
#include "gdbus-tests.h"
+static const gchar *datapath;
+
/* all tests rely on a shared mainloop */
static GMainLoop *loop = NULL;
GDBusProxy *proxy;
GDBusConnection *connection;
GError *error;
+ gchar *path;
error = NULL;
connection = g_bus_get_sync (G_BUS_TYPE_SESSION,
g_assert_no_error (error);
/* this is safe; testserver will exit once the bus goes away */
- g_assert (g_spawn_command_line_async ("./gdbus-testserver", NULL));
+ path = g_build_filename (datapath, "gdbus-testserver", NULL);
+ g_assert (g_spawn_command_line_async (path, NULL));
+ g_free (path);
_g_assert_property_notify (proxy, "g-name-owner");
static void
test_async (void)
{
+ gchar *path;
+
g_dbus_proxy_new_for_bus (G_BUS_TYPE_SESSION,
G_DBUS_PROXY_FLAGS_NONE,
NULL, /* GDBusInterfaceInfo */
NULL);
/* this is safe; testserver will exit once the bus goes away */
- g_assert (g_spawn_command_line_async ("./gdbus-testserver", NULL));
+ path = g_build_filename (datapath, "gdbus-testserver", NULL);
+ g_assert (g_spawn_command_line_async (path, NULL));
+ g_free (path);
g_timeout_add (10000, fail_test, NULL);
g_main_loop_run (loop);
gint ret;
GDBusNodeInfo *introspection_data = NULL;
+ if (g_getenv ("G_TEST_DATA"))
+ datapath = g_getenv ("G_TEST_DATA");
+ else
+ datapath = SRCDIR;
+
g_test_init (&argc, &argv, NULL);
introspection_data = g_dbus_node_info_new_for_xml (frob_dbus_interface_xml, NULL);
#include "gdbus-tests.h"
+static const gchar *datapath;
+
/* all tests rely on a global connection */
static GDBusConnection *c = NULL;
{
GError *error;
gint ret;
+ gchar *path;
+
+ if (g_getenv ("G_TEST_DATA"))
+ datapath = g_getenv ("G_TEST_DATA");
+ else
+ datapath = SRCDIR;
g_test_init (&argc, &argv, NULL);
session_bus_up ();
/* this is safe; testserver will exit once the bus goes away */
- g_assert (g_spawn_command_line_async ("./gdbus-testserver", NULL));
+ path = g_build_filename (datapath, "gdbus-testserver", NULL);
+ g_assert (g_spawn_command_line_async (path, NULL));
+ g_free (path);
/* wait for the service to come up */
usleep (500 * 1000);