![]() |
![]() |
![]() |
GIO Reference Manual | ![]() |
---|---|---|---|---|
Top | Description | Object Hierarchy | Properties |
#include <gio/gio.h> GTestDBus; enum GTestDBusFlags; GTestDBus * g_test_dbus_new (GTestDBusFlags flags
); GTestDBusFlags g_test_dbus_get_flags (GTestDBus *self
); const gchar * g_test_dbus_get_bus_address (GTestDBus *self
); void g_test_dbus_add_service_dir (GTestDBus *self
,const gchar *path
); void g_test_dbus_up (GTestDBus *self
); void g_test_dbus_stop (GTestDBus *self
); void g_test_dbus_down (GTestDBus *self
); void g_test_dbus_unset (void
);
A helper class for testing code which uses D-Bus without touching the user's session bus.
typedef struct _GTestDBus GTestDBus;
The GTestDBus structure contains only private data and should only be accessed using the provided API.
Since 2.34
typedef enum { G_TEST_DBUS_NONE = 0 } GTestDBusFlags;
Flags to define future GTestDBus behaviour.
Since 2.34
GTestDBus * g_test_dbus_new (GTestDBusFlags flags
);
Create a new GTestDBus object.
|
a GTestDBusFlags |
Returns : |
a new GTestDBus. [transfer full] |
GTestDBusFlags g_test_dbus_get_flags (GTestDBus *self
);
Gets the flags of the GTestDBus object.
const gchar * g_test_dbus_get_bus_address (GTestDBus *self
);
Get the address on which dbus-daemon is running. if g_test_dbus_up()
has not
been called yet, NULL
is returned. This can be used with
g_dbus_connection_new_for_address()
void g_test_dbus_add_service_dir (GTestDBus *self
,const gchar *path
);
Add a path where dbus-daemon will lookup for .services files. This can't be
called after g_test_dbus_up()
.
|
a GTestDBus |
|
path to a directory containing .service files |
void g_test_dbus_up (GTestDBus *self
);
Start a dbus-daemon instance and set DBUS_SESSION_BUS_ADDRESS. After this call, it is safe for unit tests to start sending messages on the session bus.
If this function is called from setup callback of g_test_add()
,
g_test_dbus_down()
must be called in its teardown callback.
If this function is called from unit test's main()
, then g_test_dbus_down()
must be called after g_test_run()
.
|
a GTestDBus |
void g_test_dbus_stop (GTestDBus *self
);
Stop the session bus started by g_test_dbus_up()
.
Unlike g_test_dbus_down()
, this won't verify the GDBusConnection
singleton returned by g_bus_get()
or g_bus_get_sync()
is destroyed. Unit
tests wanting to verify behaviour after the session bus has been stopped
can use this function but should still call g_test_dbus_down()
when done.
|
a GTestDBus |
void g_test_dbus_down (GTestDBus *self
);
Stop the session bus started by g_test_dbus_up()
.
This will wait for the singleton returned by g_bus_get()
or g_bus_get_sync()
is destroyed. This is done to ensure that the next unit test won't get a
leaked singleton from this test.
|
a GTestDBus |
void g_test_dbus_unset (void
);
Unset DISPLAY and DBUS_SESSION_BUS_ADDRESS env variables to ensure the test won't use user's session bus.
This is useful for unit tests that want to verify behaviour when no session
bus is running. It is not necessary to call this if unit test already calls
g_test_dbus_up()
before acquiring the session bus.
"flags"
property"flags" GTestDBusFlags : Read / Write / Construct Only
GTestDBusFlags specifying the behaviour of the dbus session
Since 2.34