summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Zeuthen <davidz@x61.localdomain>2008-12-20 09:50:37 -0500
committerDavid Zeuthen <davidz@x61.localdomain>2008-12-20 09:50:37 -0500
commitd174aef51e55d5fdb8cd29d99e5911609c8b33b9 (patch)
tree317962ed39b095ec8d647c40b0686c62575a4a2a
parentfccb491c88d5372f326cbd419c7ff80740d5f913 (diff)
bring back test_hash_table_of_structures()
-rw-r--r--src/tests/testclient.c31
-rw-r--r--src/tests/testfrobimpl.c39
2 files changed, 54 insertions, 16 deletions
diff --git a/src/tests/testclient.c b/src/tests/testclient.c
index bd9a096..e58d6f4 100644
--- a/src/tests/testclient.c
+++ b/src/tests/testclient.c
@@ -981,7 +981,6 @@ test_hash_tables_of_arrays (void)
EggDBusArraySeq *array_double;
gchar *array_string[] = {"foo", "foo2", NULL};
gchar *array_objpath[] = {"/foo", "/foo2", NULL};
- gchar *array_sig[] = {"(ii)", "s", NULL};
gchar *array_string_other[] = {"bar", "bar2", NULL};
gchar *array_objpath_other[] = {"/bar", "/bar2", NULL};
EggDBusArraySeq *site1_points;
@@ -1249,63 +1248,63 @@ test_hash_tables_of_arrays (void)
g_object_unref (ret_hsat);
g_object_unref (ret_hsad);
g_object_unref (ret_hash_of_point_arrays);
-
}
/* ---------------------------------------------------------------------------------------------------- */
-#if 0
static void
test_hash_table_of_structures (void)
{
GError *error;
- GHashTable *hash_of_points;
- GHashTable *hash_of_described_points;
+ EggDBusHashMap *hash_of_points;
+ EggDBusHashMap *hash_of_described_points;
TestPoint *point;
TestDescribedPoint *dpoint;
const char *s;
error = NULL;
- hash_of_points = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_object_unref);
- g_hash_table_insert (hash_of_points, "alpha", test_point_new (10, 10));
- g_hash_table_insert (hash_of_points, "beta", test_point_new (12, 12));
- g_hash_table_insert (hash_of_points, "gamma", test_point_new (14, 14));
+ hash_of_points = egg_dbus_hash_map_new (G_TYPE_STRING, NULL, TEST_TYPE_POINT, g_object_unref);
+ egg_dbus_hash_map_insert (hash_of_points, "alpha", test_point_new (10, 10));
+ egg_dbus_hash_map_insert (hash_of_points, "beta", test_point_new (12, 12));
+ egg_dbus_hash_map_insert (hash_of_points, "gamma", test_point_new (14, 14));
- g_assert (test_frob_invoke_test_hash_table_of_structures_sync (TEST_QUERY_INTERFACE_FROB (object_proxy), 0, /* flags */
+ g_assert (test_frob_invoke_test_hash_table_of_structures_sync (TEST_QUERY_INTERFACE_FROB (object_proxy),
+ 0, /* flags */
hash_of_points,
&hash_of_described_points,
NULL,
&error));
g_assert_no_error (error);
- dpoint = g_hash_table_lookup (hash_of_described_points, "alpha_new");
+ dpoint = egg_dbus_hash_map_lookup (hash_of_described_points, "alpha_new");
s = test_described_point_get_desc (dpoint);
point = test_described_point_get_point (dpoint);
g_assert_cmpstr (s, ==, "alpha");
g_assert_cmpint (test_point_get_x (point), ==, 10 + 100);
g_assert_cmpint (test_point_get_y (point), ==, 10 + 200);
- dpoint = g_hash_table_lookup (hash_of_described_points, "beta_new");
+ dpoint = egg_dbus_hash_map_lookup (hash_of_described_points, "beta_new");
s = test_described_point_get_desc (dpoint);
point = test_described_point_get_point (dpoint);
g_assert_cmpstr (s, ==, "beta");
g_assert_cmpint (test_point_get_x (point), ==, 12 + 100);
g_assert_cmpint (test_point_get_y (point), ==, 12 + 200);
- dpoint = g_hash_table_lookup (hash_of_described_points, "gamma_new");
+ dpoint = egg_dbus_hash_map_lookup (hash_of_described_points, "gamma_new");
s = test_described_point_get_desc (dpoint);
point = test_described_point_get_point (dpoint);
g_assert_cmpstr (s, ==, "gamma");
g_assert_cmpint (test_point_get_x (point), ==, 14 + 100);
g_assert_cmpint (test_point_get_y (point), ==, 14 + 200);
- g_hash_table_unref (hash_of_points);
- egg_dbus_hash_table_unref (hash_of_described_points);
+ g_object_unref (hash_of_points);
+ g_object_unref (hash_of_described_points);
}
/* ---------------------------------------------------------------------------------------------------- */
+#if 0
static void
test_hash_table_of_hash_table_of_structures (void)
{
@@ -4386,7 +4385,7 @@ main (int argc, char *argv[])
test_array_of_structure_types ();
test_hash_tables ();
test_hash_tables_of_arrays ();
- /*test_hash_table_of_structures ();*/
+ test_hash_table_of_structures ();
/*test_hash_table_of_hash_table_of_structures ();*/
/*test_array_of_hash_table_of_structures ();*/
/*test_array_of_arrays ();*/
diff --git a/src/tests/testfrobimpl.c b/src/tests/testfrobimpl.c
index da65f35..71424f0 100644
--- a/src/tests/testfrobimpl.c
+++ b/src/tests/testfrobimpl.c
@@ -838,6 +838,44 @@ frob_iface_handle_test_hash_tables_of_arrays (TestFrob *instance,
}
+static gboolean
+thos_cb (EggDBusHashMap *hash_map,
+ const gchar *key,
+ TestPoint *point,
+ EggDBusHashMap *new_hash_map)
+{
+ TestPoint *new_point;
+
+ new_point = test_point_new (test_point_get_x (point) + 100,
+ test_point_get_y (point) + 200);
+
+ egg_dbus_hash_map_insert (new_hash_map,
+ g_strdup_printf ("%s_new", key),
+ test_described_point_new (key,
+ new_point));
+
+ g_object_unref (new_point);
+
+ return FALSE;
+}
+
+static void
+frob_iface_handle_test_hash_table_of_structures (TestFrob *instance,
+ EggDBusHashMap *hash_of_points,
+ EggDBusMethodInvocation *method_invocation)
+{
+ EggDBusHashMap *hash_of_dpoints;
+
+ hash_of_dpoints = egg_dbus_hash_map_new (G_TYPE_STRING, g_free, TEST_TYPE_DESCRIBED_POINT, g_object_unref);
+ egg_dbus_hash_map_foreach (hash_of_points, (EggDBusHashMapForeachFunc) thos_cb, hash_of_dpoints);
+
+ test_frob_handle_test_hash_table_of_structures_finish (method_invocation,
+ hash_of_dpoints);
+
+ g_object_unref (hash_of_dpoints);
+}
+
+
static void
test_frob_impl_frob_iface_init (TestFrobIface *iface)
{
@@ -849,4 +887,5 @@ test_frob_impl_frob_iface_init (TestFrobIface *iface)
iface->handle_test_array_of_structure_types = frob_iface_handle_test_array_of_structure_types;
iface->handle_test_hash_tables = frob_iface_handle_test_hash_tables;
iface->handle_test_hash_tables_of_arrays = frob_iface_handle_test_hash_tables_of_arrays;
+ iface->handle_test_hash_table_of_structures = frob_iface_handle_test_hash_table_of_structures;
}