diff options
author | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2009-01-28 12:42:24 +0000 |
---|---|---|
committer | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2009-01-28 12:42:24 +0000 |
commit | ee694d522887c28ec677a1c35931113854f72f41 (patch) | |
tree | 12a707f5b3d8524c3299f710b77c2c0bcf38b521 | |
parent | c27b970f8407ffac4134544d387afdd033bbc994 (diff) |
tests/dbus/connection-error.c: exercise custom error remapping and the client side of ConnectionError
-rw-r--r-- | tests/dbus/connection-error.c | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/tests/dbus/connection-error.c b/tests/dbus/connection-error.c index 243a579d6..83f2e63c2 100644 --- a/tests/dbus/connection-error.c +++ b/tests/dbus/connection-error.c @@ -51,6 +51,54 @@ on_status_changed (TpConnection *conn, g_main_loop_quit (user_data); } +typedef enum +{ + DOMAIN_SPECIFIC_ERROR = 0, +} ExampleError; + +static GType +example_com_error_get_type (void) +{ + static gsize type = 0; + + if (g_once_init_enter (&type)) + { + static const GEnumValue values[] = { + { DOMAIN_SPECIFIC_ERROR, "DOMAIN_SPECIFIC_ERROR", + "DomainSpecificError" }, + { 0 } + }; + GType gtype; + + g_assert (sizeof (GType) <= sizeof (gsize)); + + gtype = g_enum_register_static ("ExampleError", values); + g_once_init_leave (&type, gtype); + } + + return (GType) type; +} + +static GQuark +example_com_error_quark (void) +{ + static gsize quark = 0; + + if (g_once_init_enter (&quark)) + { + GQuark domain = g_quark_from_static_string ("com.example"); + + g_assert (sizeof (GQuark) <= sizeof (gsize)); + + g_type_init (); + dbus_g_error_domain_register (domain, "com.example", + example_com_error_get_type ()); + g_once_init_leave (&quark, domain); + } + + return (GQuark) quark; +} + int main (int argc, char **argv) @@ -69,6 +117,9 @@ main (int argc, mainloop = g_main_loop_new (NULL, FALSE); dbus = tp_dbus_daemon_new (tp_get_bus ()); + tp_proxy_subclass_add_error_mapping (TP_TYPE_CONNECTION, + "com.example", example_com_error_quark (), example_com_error_get_type ()); + service_conn = SIMPLE_CONNECTION (g_object_new ( SIMPLE_TYPE_CONNECTION, "account", "me@example.com", @@ -103,6 +154,13 @@ main (int argc, MYASSERT_SAME_UINT (connection_errors, 1); + MYASSERT (!tp_connection_run_until_ready (conn, FALSE, &error, NULL), ""); + MYASSERT_SAME_STRING (g_quark_to_string (error->domain), + g_quark_to_string (example_com_error_quark ())); + MYASSERT_SAME_UINT (error->code, DOMAIN_SPECIFIC_ERROR); + g_error_free (error); + error = NULL; + service_conn_as_base = NULL; g_object_unref (service_conn); g_free (name); |