[telepathy-glib/master] Test _borrow_interface_by_id after invalidation.

Will Thompson will.thompson at collabora.co.uk
Mon May 18 08:00:53 PDT 2009


I thought this test would fail, but it passed. But it's written now, so
let's have it in telepathy-glib.
---
 tests/dbus/Makefile.am                      |    4 ++
 tests/dbus/get-interface-after-invalidate.c |   42 +++++++++++++++++++++++++++
 2 files changed, 46 insertions(+), 0 deletions(-)
 create mode 100644 tests/dbus/get-interface-after-invalidate.c

diff --git a/tests/dbus/Makefile.am b/tests/dbus/Makefile.am
index 773c45c..049d550 100644
--- a/tests/dbus/Makefile.am
+++ b/tests/dbus/Makefile.am
@@ -20,6 +20,7 @@ noinst_PROGRAMS = \
     test-error-enum \
     test-example-no-protocols \
     test-finalized-in-invalidated-handler \
+    test-get-interface-after-invalidate \
     test-group-mixin \
     test-handle-set \
     test-invalidated-while-invoking-signals \
@@ -85,6 +86,9 @@ test_example_no_protocols_SOURCES = example-no-protocols.c
 test_finalized_in_invalidated_handler_SOURCES = \
     finalized-in-invalidated-handler.c
 
+test_get_interface_after_invalidate_SOURCES = \
+    get-interface-after-invalidate.c
+
 test_group_mixin_SOURCES = group-mixin.c
 
 test_handle_set_SOURCES = handle-set.c
diff --git a/tests/dbus/get-interface-after-invalidate.c b/tests/dbus/get-interface-after-invalidate.c
new file mode 100644
index 0000000..f1deece
--- /dev/null
+++ b/tests/dbus/get-interface-after-invalidate.c
@@ -0,0 +1,42 @@
+#include <telepathy-glib/dbus.h>
+#include <telepathy-glib/errors.h>
+#include <telepathy-glib/interfaces.h>
+#include <telepathy-glib/proxy-subclass.h>
+
+static void
+test_get_interface_after_invalidate (void)
+{
+  TpDBusDaemon *bus_daemon;
+  DBusGProxy *props;
+  GError invalidation_reason = { TP_ERRORS, TP_ERROR_NOT_YOURS, "bees!" };
+  GError *error = NULL;
+
+  bus_daemon = tp_dbus_daemon_dup (NULL);
+  g_assert (bus_daemon != NULL);
+  tp_proxy_invalidate ((TpProxy *) bus_daemon, &invalidation_reason);
+
+  props = tp_proxy_borrow_interface_by_id ((TpProxy *) bus_daemon,
+      TP_IFACE_QUARK_DBUS_DAEMON, &error);
+
+  /* Borrowing the interface should fail because the proxy is invalidated. */
+  g_assert (props == NULL);
+  g_assert (error != NULL);
+  g_assert_cmpuint (error->domain, ==, invalidation_reason.domain);
+  g_assert_cmpint (error->code, ==, invalidation_reason.code);
+  g_assert_cmpstr (error->message, ==, invalidation_reason.message);
+
+  g_error_free (error);
+  g_object_unref (bus_daemon);
+}
+
+int
+main (int argc,
+    char **argv)
+{
+  g_test_init (&argc, &argv, NULL);
+
+  g_test_add_func ("/test-get-interface-after-invalidate",
+      test_get_interface_after_invalidate);
+
+  return g_test_run ();
+}
-- 
1.5.6.5




More information about the telepathy-commits mailing list