forked from enlightenment/efl
tests/actionslider: add more actionslider unit tests
verify actionslider callbacks and various basic functionalities Reviewed-by: Marcel Hollerbach <mail@marcel-hollerbach.de> Differential Revision: https://phab.enlightenment.org/D9322
This commit is contained in:
parent
62059763c6
commit
1d90b113e0
|
@ -41,8 +41,107 @@ EFL_START_TEST(elm_atspi_role_get)
|
|||
}
|
||||
EFL_END_TEST
|
||||
|
||||
static const char *test_val;
|
||||
|
||||
static void
|
||||
test_pos_changed_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
{
|
||||
int *called = data;
|
||||
|
||||
(*called)++;
|
||||
}
|
||||
|
||||
static void
|
||||
test_selected_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info)
|
||||
{
|
||||
/* if the test crashes with a crazy stack trace, this assert failed */
|
||||
ck_assert_str_eq(event_info, test_val);
|
||||
ecore_main_loop_quit();
|
||||
}
|
||||
|
||||
EFL_START_TEST(elm_actionslider_test_callbacks)
|
||||
{
|
||||
Evas_Object *win, *as;
|
||||
int called = 0;
|
||||
|
||||
win = win_add(NULL, "as", ELM_WIN_BASIC);
|
||||
|
||||
as = elm_actionslider_add(win);
|
||||
evas_object_resize(as, 200, 200);
|
||||
evas_object_resize(win, 200, 200);
|
||||
|
||||
evas_object_show(win);
|
||||
evas_object_show(as);
|
||||
elm_actionslider_indicator_pos_set(as, ELM_ACTIONSLIDER_RIGHT);
|
||||
elm_actionslider_magnet_pos_set(as, ELM_ACTIONSLIDER_RIGHT);
|
||||
elm_object_part_text_set(as, "left", "test1");
|
||||
elm_object_part_text_set(as, "center", "test2");
|
||||
elm_object_part_text_set(as, "right", "test3");
|
||||
elm_actionslider_enabled_pos_set(as, ELM_ACTIONSLIDER_LEFT |
|
||||
ELM_ACTIONSLIDER_CENTER | ELM_ACTIONSLIDER_RIGHT);
|
||||
evas_object_smart_callback_add(as, "pos_changed",
|
||||
test_pos_changed_cb, &called);
|
||||
evas_object_smart_callback_add(as, "selected", test_selected_cb, &called);
|
||||
|
||||
get_me_to_those_events(as);
|
||||
|
||||
test_val = "test2";
|
||||
called = 0;
|
||||
click_part(as, "elm.text.left");
|
||||
edje_object_message_signal_process(as);
|
||||
ecore_main_loop_begin();
|
||||
ck_assert_int_eq(called, 1);
|
||||
|
||||
test_val = "test1";
|
||||
called = 0;
|
||||
click_part(as, "elm.text.left");
|
||||
edje_object_message_signal_process(as);
|
||||
ecore_main_loop_begin();
|
||||
ck_assert_int_eq(called, 1);
|
||||
|
||||
test_val = "test2";
|
||||
called = 0;
|
||||
click_part(as, "elm.text.center");
|
||||
edje_object_message_signal_process(as);
|
||||
ecore_main_loop_begin();
|
||||
ck_assert_int_eq(called, 1);
|
||||
|
||||
test_val = "test3";
|
||||
called = 0;
|
||||
click_part(as, "elm.text.right");
|
||||
edje_object_message_signal_process(as);
|
||||
ecore_main_loop_begin();
|
||||
ck_assert_int_eq(called, 1);
|
||||
}
|
||||
EFL_END_TEST
|
||||
|
||||
EFL_START_TEST(elm_actionslider_test_parts)
|
||||
{
|
||||
Evas_Object *win, *as;
|
||||
|
||||
win = win_add(NULL, "as", ELM_WIN_BASIC);
|
||||
|
||||
as = elm_actionslider_add(win);
|
||||
|
||||
elm_actionslider_indicator_pos_set(as, ELM_ACTIONSLIDER_RIGHT);
|
||||
ck_assert_int_eq(elm_actionslider_indicator_pos_get(as), ELM_ACTIONSLIDER_RIGHT);
|
||||
elm_actionslider_magnet_pos_set(as, ELM_ACTIONSLIDER_RIGHT);
|
||||
ck_assert_int_eq(elm_actionslider_magnet_pos_get(as), ELM_ACTIONSLIDER_RIGHT);
|
||||
elm_object_part_text_set(as, "left", "Snooze");
|
||||
ck_assert_str_eq(elm_object_part_text_get(as, "left"), "Snooze");
|
||||
elm_object_part_text_set(as, "center", NULL);
|
||||
ck_assert_ptr_eq(elm_object_part_text_get(as, "center"), NULL);
|
||||
elm_object_part_text_set(as, "right", "Stop");
|
||||
ck_assert_str_eq(elm_object_part_text_get(as, "right"), "Stop");
|
||||
elm_actionslider_enabled_pos_set(as, ELM_ACTIONSLIDER_LEFT | ELM_ACTIONSLIDER_RIGHT);
|
||||
ck_assert_int_eq(elm_actionslider_enabled_pos_get(as), ELM_ACTIONSLIDER_LEFT | ELM_ACTIONSLIDER_RIGHT);
|
||||
}
|
||||
EFL_END_TEST
|
||||
|
||||
void elm_test_actionslider(TCase *tc)
|
||||
{
|
||||
tcase_add_test(tc, elm_actionslider_legacy_type_check);
|
||||
tcase_add_test(tc, elm_atspi_role_get);
|
||||
tcase_add_test(tc, elm_actionslider_test_callbacks);
|
||||
tcase_add_test(tc, elm_actionslider_test_parts);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue