diff options
Diffstat (limited to 'tests/check-qom-proplist.c')
-rw-r--r-- | tests/check-qom-proplist.c | 58 |
1 files changed, 37 insertions, 21 deletions
diff --git a/tests/check-qom-proplist.c b/tests/check-qom-proplist.c index 92898e1..a8b2958 100644 --- a/tests/check-qom-proplist.c +++ b/tests/check-qom-proplist.c @@ -125,10 +125,13 @@ static char *dummy_get_sv(Object *obj, static void dummy_init(Object *obj) { + Error *err = NULL; + object_property_add_bool(obj, "bv", dummy_get_bv, dummy_set_bv, - NULL); + &err); + error_free_or_abort(&err); } @@ -517,32 +520,19 @@ static void test_dummy_getenum(void) } -static void test_dummy_iterator(void) +static void test_dummy_prop_iterator(ObjectPropertyIterator *iter) { - Object *parent = object_get_objects_root(); - DummyObject *dobj = DUMMY_OBJECT( - object_new_with_props(TYPE_DUMMY, - parent, - "dummy0", - &error_abort, - "bv", "yes", - "sv", "Hiss hiss hiss", - "av", "platypus", - NULL)); - + bool seenbv = false, seensv = false, seenav = false, seentype = false; ObjectProperty *prop; - ObjectPropertyIterator iter; - bool seenbv = false, seensv = false, seenav = false, seentype; - object_property_iter_init(&iter, OBJECT(dobj)); - while ((prop = object_property_iter_next(&iter))) { - if (g_str_equal(prop->name, "bv")) { + while ((prop = object_property_iter_next(iter))) { + if (!seenbv && g_str_equal(prop->name, "bv")) { seenbv = true; - } else if (g_str_equal(prop->name, "sv")) { + } else if (!seensv && g_str_equal(prop->name, "sv")) { seensv = true; - } else if (g_str_equal(prop->name, "av")) { + } else if (!seenav && g_str_equal(prop->name, "av")) { seenav = true; - } else if (g_str_equal(prop->name, "type")) { + } else if (!seentype && g_str_equal(prop->name, "type")) { /* This prop comes from the base Object class */ seentype = true; } else { @@ -554,10 +544,35 @@ static void test_dummy_iterator(void) g_assert(seenav); g_assert(seensv); g_assert(seentype); +} + +static void test_dummy_iterator(void) +{ + Object *parent = object_get_objects_root(); + DummyObject *dobj = DUMMY_OBJECT( + object_new_with_props(TYPE_DUMMY, + parent, + "dummy0", + &error_abort, + "bv", "yes", + "sv", "Hiss hiss hiss", + "av", "platypus", + NULL)); + ObjectPropertyIterator iter; + object_property_iter_init(&iter, OBJECT(dobj)); + test_dummy_prop_iterator(&iter); object_unparent(OBJECT(dobj)); } +static void test_dummy_class_iterator(void) +{ + ObjectPropertyIterator iter; + ObjectClass *klass = object_class_by_name(TYPE_DUMMY); + + object_class_property_iter_init(&iter, klass); + test_dummy_prop_iterator(&iter); +} static void test_dummy_delchild(void) { @@ -629,6 +644,7 @@ int main(int argc, char **argv) g_test_add_func("/qom/proplist/badenum", test_dummy_badenum); g_test_add_func("/qom/proplist/getenum", test_dummy_getenum); g_test_add_func("/qom/proplist/iterator", test_dummy_iterator); + g_test_add_func("/qom/proplist/class_iterator", test_dummy_class_iterator); g_test_add_func("/qom/proplist/delchild", test_dummy_delchild); g_test_add_func("/qom/resolve/partial", test_qom_partial_path); |