From 94ade8124bcf428d5823ba784fe54888512d2fc3 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 20 Jun 2011 12:35:58 +0100 Subject: [PATCH 13/14] Flatten _dbus_gmain_test into _dbus_gvalue_test It actually only tests _dbus_gtype_from_signature and related things, and has nothing to do with main loop integration. --- dbus/dbus-gmain.c | 42 ------------------------------------------ dbus/dbus-gtest.c | 4 ---- dbus/dbus-gtest.h | 1 - dbus/dbus-gvalue.c | 27 +++++++++++++++++++++++++++ 4 files changed, 27 insertions(+), 47 deletions(-) diff --git a/dbus/dbus-gmain.c b/dbus/dbus-gmain.c index caca03b..40e2d49 100644 --- a/dbus/dbus-gmain.c +++ b/dbus/dbus-gmain.c @@ -786,45 +786,3 @@ dbus_g_bus_get_private (DBusBusType type, return DBUS_G_CONNECTION_FROM_CONNECTION (connection); } - -#ifdef DBUS_BUILD_TESTS - -/* - * Unit test for GLib main loop integration - * Returns: #TRUE on success. - */ -gboolean -_dbus_gmain_test (const char *test_data_dir) -{ - GType type; - GType rectype; - - g_type_init (); - _dbus_g_value_types_init (); - - rectype = dbus_g_type_get_collection ("GArray", G_TYPE_UINT); - g_assert (rectype != G_TYPE_INVALID); - g_assert (!strcmp (g_type_name (rectype), "GArray_guint_")); - - type = _dbus_gtype_from_signature ("au", TRUE); - g_assert (type == rectype); - - rectype = dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_STRING); - g_assert (rectype != G_TYPE_INVALID); - g_assert (!strcmp (g_type_name (rectype), "GHashTable_gchararray+gchararray_")); - - type = _dbus_gtype_from_signature ("a{ss}", TRUE); - g_assert (type == rectype); - - type = _dbus_gtype_from_signature ("o", FALSE); - g_assert (type == DBUS_TYPE_G_OBJECT_PATH); - type = _dbus_gtype_from_signature ("o", TRUE); - g_assert (type == DBUS_TYPE_G_OBJECT_PATH); - - type = _dbus_gtype_from_signature ("g", TRUE); - g_assert (type == DBUS_TYPE_G_SIGNATURE); - - return TRUE; -} - -#endif /* DBUS_BUILD_TESTS */ diff --git a/dbus/dbus-gtest.c b/dbus/dbus-gtest.c index e149277..c9572ef 100644 --- a/dbus/dbus-gtest.c +++ b/dbus/dbus-gtest.c @@ -63,10 +63,6 @@ dbus_glib_internal_do_not_use_run_tests (const char *test_data_dir) if (!_dbus_gvalue_test (test_data_dir)) die ("gvalue utils"); - printf ("%s: running mainloop integration tests\n", "dbus-glib-test"); - if (!_dbus_gmain_test (test_data_dir)) - die ("gmain"); - printf ("%s: running GObject tests\n", "dbus-glib-test"); if (!_dbus_gobject_test (test_data_dir)) die ("gobject"); diff --git a/dbus/dbus-gtest.h b/dbus/dbus-gtest.h index 940e959..8ce4b00 100644 --- a/dbus/dbus-gtest.h +++ b/dbus/dbus-gtest.h @@ -26,7 +26,6 @@ #include -gboolean _dbus_gmain_test (const char *test_data_dir); gboolean _dbus_gobject_test (const char *test_data_dir); gboolean _dbus_gutils_test (const char *test_data_dir); gboolean _dbus_gvalue_test (const char *test_data_dir); diff --git a/dbus/dbus-gvalue.c b/dbus/dbus-gvalue.c index a9cae0c..8f9180f 100644 --- a/dbus/dbus-gvalue.c +++ b/dbus/dbus-gvalue.c @@ -2032,6 +2032,10 @@ assert_bidirectional_mapping (GType gtype, const char *expected_sig) gboolean _dbus_gvalue_test (const char *test_data_dir) { + GType type; + GType rectype; + + g_type_init (); _dbus_g_value_types_init (); assert_bidirectional_mapping (G_TYPE_STRING, DBUS_TYPE_STRING_AS_STRING); @@ -2047,6 +2051,29 @@ _dbus_gvalue_test (const char *test_data_dir) assert_bidirectional_mapping (dbus_g_type_get_struct ("GValueArray", G_TYPE_INT, G_TYPE_STRING, DBUS_TYPE_G_OBJECT_PATH, G_TYPE_INVALID), DBUS_STRUCT_BEGIN_CHAR_AS_STRING DBUS_TYPE_INT32_AS_STRING DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_OBJECT_PATH_AS_STRING DBUS_STRUCT_END_CHAR_AS_STRING ); + + rectype = dbus_g_type_get_collection ("GArray", G_TYPE_UINT); + g_assert (rectype != G_TYPE_INVALID); + g_assert (!strcmp (g_type_name (rectype), "GArray_guint_")); + + type = _dbus_gtype_from_signature ("au", TRUE); + g_assert (type == rectype); + + rectype = dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_STRING); + g_assert (rectype != G_TYPE_INVALID); + g_assert (!strcmp (g_type_name (rectype), "GHashTable_gchararray+gchararray_")); + + type = _dbus_gtype_from_signature ("a{ss}", TRUE); + g_assert (type == rectype); + + type = _dbus_gtype_from_signature ("o", FALSE); + g_assert (type == DBUS_TYPE_G_OBJECT_PATH); + type = _dbus_gtype_from_signature ("o", TRUE); + g_assert (type == DBUS_TYPE_G_OBJECT_PATH); + + type = _dbus_gtype_from_signature ("g", TRUE); + g_assert (type == DBUS_TYPE_G_SIGNATURE); + return TRUE; } -- 1.7.5.4