int main(int argc, char *argv[]) { int ret = 0; (void) argc; (void) argv; eo_init(); Eo *obj = eo_add(SIMPLE_CLASS, NULL); fail_if(my_init_count != 2); eo_do(obj, simple_a_set(1), simple_b_set(2)); int a, b; eo_do(obj, simple_a_get(&a), simple_b_get(&b), mixin_add_and_print(5)); eo_unref(obj); fail_if(my_init_count != 0); obj = eo_add(SIMPLE2_CLASS, NULL); fail_if(obj); obj = eo_add(SIMPLE3_CLASS, NULL); fail_if(obj); my_init_count = 0; obj = eo_add(SIMPLE4_CLASS, NULL); fail_if(my_init_count != 2); eo_unref(obj); fail_if(my_init_count != 0); obj = eo_add(SIMPLE5_CLASS, NULL); fail_if(!obj); eo_unref(obj); obj = eo_add(SIMPLE6_CLASS, NULL); fail_if(!obj); eo_unref(obj); obj = eo_add(SIMPLE7_CLASS, NULL); fail_if(obj); my_init_count = 0; obj = eo_add_custom(SIMPLE_CLASS, NULL, simple_constructor(7)); fail_if(!obj); fail_if(my_init_count != 2); eo_do(obj, simple_a_get(&a)); fail_if(a != 7); eo_unref(obj); eo_shutdown(); return ret; }
int main(int argc, char *argv[]) { (void) argc; (void) argv; eo_init(); Eo *obj = eo_add(SIMPLE_CLASS, NULL); eo_do(obj, simple_a_set(1), simple_b_set(2)); int a, b, sum = 0; eo_do(obj, simple_a_get(&a), simple_b_get(&b), interface_ab_sum_get(&sum)); fail_if(sum != a + b); sum = 0; eo_do(obj, interface_ab_sum_get(&sum), interface_ab_sum_get(&sum)); fail_if(sum != a + b); eo_do(obj, interface2_ab_sum_get2(&sum), interface2_ab_sum_get2(&sum)); fail_if(sum != a + b + 1); eo_unref(obj); eo_shutdown(); return 0; }
int main(int argc, char *argv[]) { (void) argc; (void) argv; eo_init(); Eo *obj = eo_add(SIMPLE_CLASS, NULL); eo_do(obj, simple_a_set(1), simple_b_set(2)); int a, b, sum = 0; eo_do(obj, simple_a_get(&a), simple_b_get(&b), mixin_ab_sum_get(&sum)); fail_if(sum != a + b + 2); /* 2 for the two mixins... */ eo_do(obj, mixin_ab_sum_get(&sum), mixin_ab_sum_get(&sum)); Mixin2_Public_Data *pd2 = eo_data_get(obj, MIXIN2_CLASS); fail_if(pd2->count != 6); Mixin3_Public_Data *pd3 = eo_data_get(obj, MIXIN3_CLASS); fail_if(pd3->count != 9); eo_unref(obj); obj = eo_add(INHERIT_CLASS, NULL); eo_do(obj, simple_a_set(5), simple_a_get(&a)); fail_if(a != 5); eo_unref(obj); eo_shutdown(); return 0; }
END_TEST START_TEST(eo_stack) { eo_init(); Eo *obj = eo_add(SIMPLE_CLASS, NULL); fail_if(!obj); eo_do(obj, simple_recursive(123)); eo_unref(obj); eo_shutdown(); }
int main(int argc, char *argv[]) { (void) argc; (void) argv; eo_init(); Eo *obj = eo_add(INHERIT2_CLASS, NULL); eo_do(obj, simple_a_set(1)); Simple_Public_Data *pd = eo_data_get(obj, SIMPLE_CLASS); fail_if(pd->a != 2); eo_unref(obj); obj = eo_add(INHERIT3_CLASS, NULL); eo_do(obj, simple_a_set(1)); pd = eo_data_get(obj, SIMPLE_CLASS); fail_if(pd->a != 3); eo_unref(obj); obj = eo_add(INHERIT2_CLASS, NULL); eo_do(obj, inherit2_print()); eo_unref(obj); obj = eo_add(SIMPLE_CLASS, NULL); fail_if(eo_do(obj, inherit2_print2())); fail_if(eo_do_super(obj, simple_a_print())); fail_if(eo_do(obj, simple_class_print())); fail_if(!eo_class_do(SIMPLE_CLASS, simple_class_print())); fail_if(!eo_class_do(INHERIT_CLASS, simple_class_print())); fail_if(!eo_class_do(INHERIT2_CLASS, simple_class_print())); fail_if(!eo_class_do(INHERIT3_CLASS, simple_class_print())); fail_if(eo_class_do(SIMPLE_CLASS, simple_a_print())); eo_constructor_super(obj); eo_destructor_super(obj); eo_unref(obj); eo_shutdown(); return 0; }
int main(int argc, char *argv[]) { (void) argc; (void) argv; eo_init(); Eo *obj = eo_add(INHERIT_CLASS, NULL); eo_do(obj, simple_a_set(1), inherit_prot_print()); Simple_Public_Data *pd = eo_data_scope_get(obj, SIMPLE_CLASS); printf("Pub: %d\n", pd->public_x2); eo_unref(obj); eo_shutdown(); return 0; }
END_TEST START_TEST(eo_op_not_found_in_super) { eo_init(); eina_log_print_cb_set(eo_test_print_cb, &ctx); Eo *obj = eo_add(SIMPLE_CLASS, NULL); fail_if(!obj); TEST_EO_ERROR("_eo_call_resolve", "in %s:%d: func '%s' (%d) could not be resolved for class '%s' for super of '%s'."); eo_do_super(obj, SIMPLE_CLASS, simple_a_set(10)); fail_unless(ctx.did); eo_unref(obj); eina_log_print_cb_set(eina_log_print_cb_stderr, NULL); eo_shutdown(); }
END_TEST START_TEST(eo_api_not_implemented_call) { eo_init(); eina_log_print_cb_set(eo_test_print_cb, &ctx); Eo *obj = eo_add(SIMPLE_CLASS, NULL); fail_if(!obj); TEST_EO_ERROR("_eo_api_op_id_get", "in %s:%d: unable to resolve %s api func '%s' %p in class '%s'."); eo_do(obj, simple_no_implementation()); fail_unless(ctx.did); eo_unref(obj); eina_log_print_cb_set(eina_log_print_cb_stderr, NULL); eo_shutdown(); }
int main(int argc, char *argv[]) { Evas_Coord winw, winh; { winw = 400; winh = 400; } elm_init(argc, argv); eo_init(); Eo *win = eo_add(ELW_WIN_CLASS, NULL); eo_do(win, evas_obj_size_set(winw, winh), evas_obj_visibility_set(EINA_TRUE)); Eo *bt = eo_add(ELW_BUTTON_CLASS, win); eo_do(bt, evas_obj_position_set(25, 25), evas_obj_size_set(50, 50), evas_obj_color_set(255, 0, 0, 255), elw_button_text_set("Click"), evas_obj_visibility_set(EINA_TRUE)); eo_do(bt, eo_event_callback_add(EV_CLICKED, _btn_clicked_cb, "btn")); int r, g, b, a; eo_do(bt, evas_obj_color_get(&r, &g, &b, &a)); printf("RGBa(%d, %d, %d, %d)\n", r, g, b, a); Eo *bx = eo_add(ELW_BOXEDBUTTON_CLASS, win); eo_do(bx, evas_obj_position_set(100, 100), evas_obj_size_set(70, 70), evas_obj_color_set(0, 0, 255, 255), elw_button_text_set("Click2"), evas_obj_visibility_set(EINA_TRUE)); eo_do(bx, eo_event_callback_add(EV_CLICKED, _btn_clicked_cb, "bxedbtn")); elm_run(); eo_unref(bx); eo_unref(bt); eo_unref(win); eo_shutdown(); elm_shutdown(); return 0; }
int main(int argc, char **argv) { Suite *s; SRunner *sr; int i, failed_count; eo_init(); setenv("CK_FORK", "no", 0); for (i = 1; i < argc; i++) if ((strcmp(argv[i], "-h") == 0) || (strcmp(argv[i], "--help") == 0)) { fprintf(stderr, "Usage:\n\t%s [test_case1 .. [test_caseN]]\n", argv[0]); _list_tests(); return 0; } else if ((strcmp(argv[i], "-l") == 0) || (strcmp(argv[i], "--list") == 0)) { _list_tests(); return 0; } putenv("EFL_RUN_IN_TREE=1"); s = eo_suite_build(argc - 1, (const char **)argv + 1); sr = srunner_create(s); srunner_set_xml(sr, TESTS_BUILD_DIR "/check-results.xml"); srunner_run_all(sr, CK_ENV); failed_count = srunner_ntests_failed(sr); srunner_free(sr); eo_shutdown(); return (failed_count == 0) ? 0 : 255; }
int main(int argc, char *argv[]) { (void) argc; (void) argv; eo_init(); Eo *obj = eo_add(SIMPLE_CLASS, NULL); eo_do(obj, simple_a_set(4)); int a = 0, a2 = 0, a3 = 0; eo_do(obj, a = simple_a_get(), a3 = interface_a_power_3_get(), a2 = mixin_a_square_get()); printf("Got %d %d %d\n", a, a2, a3); eo_unref(obj); eo_shutdown(); return 0; }
int main(int argc, char *argv[]) { (void) argc; (void) argv; eo_init(); Eo *obj = eo_add(SIMPLE_CLASS, NULL); Simple_Public_Data *pd = eo_data_get(obj, SIMPLE_CLASS); /* The order of these two is undetermined. */ eo_do(obj, eo_event_callback_priority_add(EV_A_CHANGED, EO_CALLBACK_PRIORITY_BEFORE, _a_changed_cb, (void *) 2)); eo_do(obj, eo_event_callback_priority_add(EV_A_CHANGED, EO_CALLBACK_PRIORITY_BEFORE, _a_changed_cb, (void *) 1)); /* This will be called afterwards. */ eo_do(obj, eo_event_callback_priority_add(EV_A_CHANGED, EO_CALLBACK_PRIORITY_DEFAULT, _a_changed_cb, (void *) 3)); /* This will never be called because the previous callback returns NULL. */ eo_do(obj, eo_event_callback_priority_add(EV_A_CHANGED, EO_CALLBACK_PRIORITY_AFTER, _a_changed_cb, (void *) 4)); eo_do(obj, simple_a_set(1)); fail_if(cb_count != 3); eo_do(obj, eo_event_callback_del(EV_A_CHANGED, _a_changed_cb, (void *) 3)); fail_if(pd->cb_count != 3); eo_do(obj, eo_event_callback_del(EV_A_CHANGED, _a_changed_cb, (void *) 12)); fail_if(pd->cb_count != 3); eo_do(obj, eo_event_callback_del(EV_A_CHANGED, _a_changed_cb, (void *) 4)); fail_if(pd->cb_count != 2); void *ret; eo_do(obj, eo_event_callback_del_lazy(EV_A_CHANGED, _a_changed_cb, &ret)); fail_if(pd->cb_count != 1); eo_do(obj, eo_event_callback_del_lazy(EV_A_CHANGED, NULL, &ret)); fail_if(ret); fail_if(pd->cb_count != 1); eo_do(obj, eo_event_callback_del(EV_A_CHANGED, NULL, 0)); fail_if(pd->cb_count != 1); eo_do(obj, eo_event_callback_del_lazy(EV_A_CHANGED, _a_changed_cb, &ret)); fail_if(pd->cb_count != 0); eo_do(obj, eo_event_callback_del_lazy(EV_A_CHANGED, _a_changed_cb, &ret)); fail_if(ret); fail_if(pd->cb_count != 0); /* Freeze/thaw. */ int fcount = 0; cb_count = 0; eo_do(obj, eo_event_callback_priority_add(EV_A_CHANGED, EO_CALLBACK_PRIORITY_BEFORE, _a_changed_cb, (void *) 1)); fail_if(pd->cb_count != 1); eo_do(obj, eo_event_freeze_get(&fcount)); fail_if(fcount != 0); eo_do(obj, eo_event_freeze()); eo_do(obj, eo_event_freeze_get(&fcount)); fail_if(fcount != 1); eo_do(obj, eo_event_freeze()); eo_do(obj, eo_event_freeze_get(&fcount)); fail_if(fcount != 2); eo_do(obj, eo_event_callback_priority_add(EV_A_CHANGED, EO_CALLBACK_PRIORITY_BEFORE, _a_changed_cb, (void *) 2)); fail_if(pd->cb_count != 1); eo_do(obj, simple_a_set(2)); fail_if(cb_count != 0); eo_do(obj, eo_event_thaw()); eo_do(obj, eo_event_freeze_get(&fcount)); fail_if(fcount != 1); eo_do(obj, eo_event_thaw()); eo_do(obj, eo_event_freeze_get(&fcount)); fail_if(fcount != 0); eo_do(obj, simple_a_set(3)); fail_if(cb_count != 2); cb_count = 0; eo_do(obj, eo_event_thaw()); eo_do(obj, eo_event_freeze_get(&fcount)); fail_if(fcount != 0); eo_do(obj, eo_event_freeze()); eo_do(obj, eo_event_freeze_get(&fcount)); fail_if(fcount != 1); eo_do(obj, simple_a_set(2)); fail_if(cb_count != 0); eo_do(obj, eo_event_thaw()); eo_do(obj, eo_event_freeze_get(&fcount)); fail_if(fcount != 0); eo_do(obj, eo_event_callback_del_lazy(EV_A_CHANGED, _a_changed_cb, &ret)); fail_if(!ret); eo_do(obj, eo_event_callback_del_lazy(EV_A_CHANGED, _a_changed_cb, &ret)); fail_if(!ret); eo_do(obj, eo_event_callback_del_lazy(EV_A_CHANGED, _a_changed_cb, &ret)); fail_if(ret); /* Global Freeze/thaw. */ fcount = 0; cb_count = 0; pd->cb_count = 0; eo_do(obj, eo_event_callback_priority_add(EV_A_CHANGED, EO_CALLBACK_PRIORITY_BEFORE, _a_changed_cb, (void *) 1)); fail_if(pd->cb_count != 1); eo_class_do(EO_BASE_CLASS, eo_event_global_freeze_get(&fcount)); fail_if(fcount != 0); eo_class_do(EO_BASE_CLASS, eo_event_global_freeze()); eo_class_do(EO_BASE_CLASS, eo_event_global_freeze_get(&fcount)); fail_if(fcount != 1); eo_class_do(EO_BASE_CLASS, eo_event_global_freeze()); eo_class_do(EO_BASE_CLASS, eo_event_global_freeze_get(&fcount)); fail_if(fcount != 2); eo_do(obj, eo_event_callback_priority_add(EV_A_CHANGED, EO_CALLBACK_PRIORITY_BEFORE, _a_changed_cb, (void *) 2)); fail_if(pd->cb_count != 1); eo_do(obj, simple_a_set(2)); fail_if(cb_count != 0); eo_class_do(EO_BASE_CLASS, eo_event_global_thaw()); eo_class_do(EO_BASE_CLASS, eo_event_global_freeze_get(&fcount)); fail_if(fcount != 1); eo_class_do(EO_BASE_CLASS, eo_event_global_thaw()); eo_class_do(EO_BASE_CLASS, eo_event_global_freeze_get(&fcount)); fail_if(fcount != 0); eo_do(obj, simple_a_set(3)); fail_if(cb_count != 2); cb_count = 0; eo_class_do(EO_BASE_CLASS, eo_event_global_thaw()); eo_class_do(EO_BASE_CLASS, eo_event_global_freeze_get(&fcount)); fail_if(fcount != 0); eo_class_do(EO_BASE_CLASS, eo_event_global_freeze()); eo_class_do(EO_BASE_CLASS, eo_event_global_freeze_get(&fcount)); fail_if(fcount != 1); eo_do(obj, simple_a_set(2)); fail_if(cb_count != 0); eo_class_do(EO_BASE_CLASS, eo_event_global_thaw()); eo_class_do(EO_BASE_CLASS, eo_event_global_freeze_get(&fcount)); fail_if(fcount != 0); eo_unref(obj); eo_shutdown(); return 0; }
END_TEST START_TEST(eo_inherit_errors) { eo_init(); const Eo_Class *klass; const Eo_Class *klass_mixin; const Eo_Class *klass_simple; static const Eo_Class_Description class_desc_simple = { "Simple", EO_CLASS_TYPE_REGULAR, EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0), NULL, 0, NULL, NULL, NULL, NULL }; static const Eo_Class_Description class_desc_mixin = { "Mixin", EO_CLASS_TYPE_MIXIN, EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0), NULL, 0, NULL, NULL, NULL, NULL }; static Eo_Class_Description class_desc = { "General", EO_CLASS_TYPE_MIXIN, EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0), NULL, 0, NULL, NULL, NULL, NULL }; klass_mixin = eo_class_new(&class_desc_mixin, NULL, NULL); fail_if(!klass_mixin); klass_simple = eo_class_new(&class_desc_simple, NULL, NULL); fail_if(!klass_simple); klass = eo_class_new(&class_desc, klass_simple, NULL); fail_if(klass); class_desc.type = EO_CLASS_TYPE_REGULAR; klass = eo_class_new(&class_desc, klass_mixin, NULL); fail_if(klass); (void) klass; eo_shutdown(); }
END_TEST START_TEST(eo_inconsistent_mro) { eo_init(); const Eo_Class *klass; const Eo_Class *klass_mixin; const Eo_Class *klass_mixin2; const Eo_Class *klass_mixin3; static const Eo_Class_Description class_desc_simple = { "Simple", EO_CLASS_TYPE_REGULAR, EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0), NULL, 0, NULL, NULL, NULL, NULL }; static const Eo_Class_Description class_desc_mixin = { "Mixin", EO_CLASS_TYPE_MIXIN, EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0), NULL, 0, NULL, NULL, NULL, NULL }; static const Eo_Class_Description class_desc_mixin2 = { "Mixin2", EO_CLASS_TYPE_MIXIN, EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0), NULL, 0, NULL, NULL, NULL, NULL }; static const Eo_Class_Description class_desc_mixin3 = { "Mixin3", EO_CLASS_TYPE_MIXIN, EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0), NULL, 0, NULL, NULL, NULL, NULL }; klass_mixin = eo_class_new(&class_desc_mixin, NULL, NULL); fail_if(!klass_mixin); klass_mixin2 = eo_class_new(&class_desc_mixin2, klass_mixin, NULL); fail_if(!klass_mixin2); klass_mixin3 = eo_class_new(&class_desc_mixin3, klass_mixin, NULL); fail_if(!klass_mixin3); klass = eo_class_new(&class_desc_simple, EO_BASE_CLASS, klass_mixin, klass_mixin2, NULL); fail_if(klass); klass = eo_class_new(&class_desc_simple, EO_BASE_CLASS, klass_mixin2, klass_mixin, NULL); fail_if(!klass); klass = eo_class_new(&class_desc_simple, EO_BASE_CLASS, klass_mixin2, klass_mixin3, NULL); fail_if(!klass); eo_shutdown(); }