summaryrefslogtreecommitdiff
path: root/gck/tests
diff options
context:
space:
mode:
authorStef Walter <stefw@collabora.co.uk>2011-11-02 14:10:43 +0100
committerStef Walter <stefw@collabora.co.uk>2011-11-02 14:10:43 +0100
commit468414442f0c4a785fcf784752cae8a1e44323c9 (patch)
tree17a19b29060f1a0b22d55020583ded479a56bda7 /gck/tests
parent83c859210e66ffa5e0d7814cb822066c23c1e7bb (diff)
downloadgcr-468414442f0c4a785fcf784752cae8a1e44323c9.tar.gz
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.
Diffstat (limited to 'gck/tests')
-rw-r--r--gck/tests/test-gck-enumerator.c40
1 files changed, 40 insertions, 0 deletions
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 ();
}