[glib/tls-database] Add test and docs for g_tls_backend_get_default_database()



commit 7ab634232190693b9681cf40ec713e581150979b
Author: Stef Walter <stefw collabora co uk>
Date:   Mon Jan 17 21:17:45 2011 -0800

    Add test and docs for g_tls_backend_get_default_database()

 gio/gtlsbackend.c |   10 ++++++++++
 gio/tests/tls.c   |   27 +++++++++++++++++++++++++++
 2 files changed, 37 insertions(+), 0 deletions(-)
---
diff --git a/gio/gtlsbackend.c b/gio/gtlsbackend.c
index 61341bc..d3edd0b 100644
--- a/gio/gtlsbackend.c
+++ b/gio/gtlsbackend.c
@@ -149,6 +149,16 @@ g_tls_backend_supports_tls (GTlsBackend *backend)
     return TRUE;
 }
 
+/**
+ * g_tls_backend_get_default_database:
+ * @backend: the #GTlsBackend
+ *
+ * Gets the default #GTlsDatabase used to verify TLS connections.
+ *
+ * Return value: the default database, which should be unreffed when done.
+ *
+ * Since: 2.30
+ */
 GTlsDatabase *
 g_tls_backend_get_default_database (GTlsBackend *backend)
 {
diff --git a/gio/tests/tls.c b/gio/tests/tls.c
index 3f0fbc1..492ca97 100644
--- a/gio/tests/tls.c
+++ b/gio/tests/tls.c
@@ -331,6 +331,30 @@ test_create_destroy_certificate_der (TestCertificate *test, gconstpointer data)
   g_assert (!G_IS_TLS_CERTIFICATE (cert));
 }
 
+/* -----------------------------------------------------------------------------
+ * BACKEND
+ */
+
+static void
+test_default_database_is_singleton (void)
+{
+  GTlsBackend *backend;
+  GTlsDatabase *database;
+  GTlsDatabase *check;
+
+  backend = g_tls_backend_get_default ();
+  g_assert (G_IS_TLS_BACKEND (backend));
+
+  database = g_tls_backend_get_default_database (backend);
+  g_assert (G_IS_TLS_DATABASE (database));
+
+  check = g_tls_backend_get_default_database (backend);
+  g_assert (database == check);
+
+  g_object_unref (database);
+  g_object_unref (check);
+}
+
 int
 main (int   argc,
       char *argv[])
@@ -343,6 +367,9 @@ main (int   argc,
   g_test_add ("/tls/connection/verified", TestConnection, NULL,
               setup_connection, test_verified_connection, teardown_connection);
 
+  g_test_add_func ("/tls/backend/default-database-is-singleton",
+                   test_default_database_is_singleton);
+
   g_test_add ("/tls/certificate/create-destroy-pem", TestCertificate, NULL,
               setup_certificate, test_create_destroy_certificate_pem, teardown_certificate);
   g_test_add ("/tls/certificate/create-destroy-der", TestCertificate, NULL,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]