telepathy-glib: Test TP_TLS_CERTIFICATE_FEATURE_CORE and props

Guillaume Desmottes gdesmott at kemper.freedesktop.org
Wed May 9 03:15:57 PDT 2012


Module: telepathy-glib
Branch: master
Commit: 16c054d58c2748435c45e44924a44063ad57d439
URL:    http://cgit.freedesktop.org/telepathy/telepathy-glib/commit/?id=16c054d58c2748435c45e44924a44063ad57d439

Author: Guillaume Desmottes <guillaume.desmottes at collabora.co.uk>
Date:   Wed Apr 18 12:55:53 2012 +0200

Test TP_TLS_CERTIFICATE_FEATURE_CORE and props

---

 tests/dbus/tls-certificate.c |   48 ++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 48 insertions(+), 0 deletions(-)

diff --git a/tests/dbus/tls-certificate.c b/tests/dbus/tls-certificate.c
index e3b003b..5725393 100644
--- a/tests/dbus/tls-certificate.c
+++ b/tests/dbus/tls-certificate.c
@@ -101,6 +101,52 @@ test_creation (Test *test,
   g_assert (TP_IS_TLS_CERTIFICATE (test->cert));
 }
 
+static void
+proxy_prepare_cb (GObject *source,
+    GAsyncResult *result,
+    gpointer user_data)
+{
+  Test *test = user_data;
+
+  tp_proxy_prepare_finish (source, result, &test->error);
+
+  test->wait--;
+  if (test->wait <= 0)
+    g_main_loop_quit (test->mainloop);
+}
+
+static void
+test_core (Test *test,
+    gconstpointer data G_GNUC_UNUSED)
+{
+  GQuark features[] = { TP_TLS_CERTIFICATE_FEATURE_CORE, 0 };
+  GPtrArray *cert_data;
+  GArray *d;
+
+  /* Properties are not valid yet */
+  g_assert_cmpstr (tp_tls_certificate_get_cert_type (test->cert), ==, NULL);
+  g_assert (tp_tls_certificate_get_cert_data (test->cert) == NULL);
+  g_assert_cmpuint (tp_tls_certificate_get_state (test->cert), ==,
+      TP_TLS_CERTIFICATE_STATE_PENDING);
+
+  tp_proxy_prepare_async (test->cert, features,
+      proxy_prepare_cb, test);
+
+  test->wait = 1;
+  g_main_loop_run (test->mainloop);
+  g_assert_no_error (test->error);
+
+  g_assert_cmpstr (tp_tls_certificate_get_cert_type (test->cert), ==, "x509");
+  g_assert_cmpuint (tp_tls_certificate_get_state (test->cert), ==,
+      TP_TLS_CERTIFICATE_STATE_PENDING);
+
+  cert_data = tp_tls_certificate_get_cert_data (test->cert);
+  g_assert (cert_data != NULL);
+  g_assert_cmpuint (cert_data->len, ==, 1);
+  d = g_ptr_array_index (cert_data, 0);
+  g_assert_cmpstr (d->data, ==, "BADGER");
+}
+
 int
 main (int argc,
       char **argv)
@@ -110,6 +156,8 @@ main (int argc,
 
   g_test_add ("/tls-certificate/creation", Test, NULL, setup,
       test_creation, teardown);
+  g_test_add ("/tls-certificate/core", Test, NULL, setup,
+      test_core, teardown);
 
   return g_test_run ();
 }



More information about the telepathy-commits mailing list