From 468414442f0c4a785fcf784752cae8a1e44323c9 Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Wed, 2 Nov 2011 14:10:43 +0100 Subject: gck: Chaining of enumerators * Add functions gck_enumerator_get_chained() and gck_enumerator_set_chained() * Chaining enumerator returns results from the chained enumerator after all results have been retrieved from the former. --- gck/tests/test-gck-enumerator.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'gck/tests') diff --git a/gck/tests/test-gck-enumerator.c b/gck/tests/test-gck-enumerator.c index d46d437..b248b4e 100644 --- a/gck/tests/test-gck-enumerator.c +++ b/gck/tests/test-gck-enumerator.c @@ -499,6 +499,45 @@ test_attribute_get (Test *test, g_object_unref (en); } +static void +test_chained (Test *test, + gconstpointer unused) +{ + GckEnumerator *one; + GckEnumerator *two; + GckEnumerator *three; + GckUriData *uri_data; + GError *error = NULL; + GList *objects; + + uri_data = gck_uri_data_new (); + uri_data->attributes = gck_attributes_new (); + gck_attributes_add_ulong (uri_data->attributes, CKA_CLASS, CKO_PUBLIC_KEY); + one = _gck_enumerator_new_for_modules (test->modules, 0, uri_data); + + uri_data = gck_uri_data_new (); + uri_data->attributes = gck_attributes_new (); + gck_attributes_add_ulong (uri_data->attributes, CKA_CLASS, CKO_PRIVATE_KEY); + two = _gck_enumerator_new_for_modules (test->modules, 0, uri_data); + gck_enumerator_set_chained (one, two); + + uri_data = gck_uri_data_new (); + uri_data->attributes = gck_attributes_new (); + gck_attributes_add_ulong (uri_data->attributes, CKA_CLASS, CKO_DATA); + three = _gck_enumerator_new_for_modules (test->modules, 0, uri_data); + gck_enumerator_set_chained (two, three); + + g_object_unref (two); + g_object_unref (three); + + objects = gck_enumerator_next_n (one, -1, NULL, &error); + g_assert_no_error (error); + g_assert_cmpint (g_list_length (objects), ==, 5); + + gck_list_unref_free (objects); + g_object_unref (one); +} + int main (int argc, char **argv) { @@ -520,6 +559,7 @@ main (int argc, char **argv) g_test_add ("/gck/enumerator/attribute_match", Test, NULL, setup, test_attribute_match, teardown); g_test_add ("/gck/enumerator/token_match", Test, NULL, setup, test_token_match, teardown); g_test_add ("/gck/enumerator/attribute_get", Test, NULL, setup, test_attribute_get, teardown); + g_test_add ("/gck/enumerator/chained", Test, NULL, setup, test_chained, teardown); return egg_tests_run_in_thread_with_loop (); } -- cgit v1.2.1