summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@samsung.com>2019-07-01 12:09:08 -0400
committerMike Blumenkrantz <michael.blumenkrantz@gmail.com>2019-07-03 12:22:17 -0400
commitf619ad88a402f5cc3ad77931ff715fd08bc6b65e (patch)
tree98c9171934e7b2f4f117ca5c69c43cbcd5fdce94
parentebf39e9fd7ba054f49031f7f4162ced8c63b1d22 (diff)
tests: add functional unit tests for radio widgets
this adds some basic testing to verify that callbacks occur and values are set as expected Differential Revision: https://phab.enlightenment.org/D9091
-rw-r--r--src/tests/elementary/elm_test_radio.c57
1 files changed, 57 insertions, 0 deletions
diff --git a/src/tests/elementary/elm_test_radio.c b/src/tests/elementary/elm_test_radio.c
index e619d29a4c..c196850015 100644
--- a/src/tests/elementary/elm_test_radio.c
+++ b/src/tests/elementary/elm_test_radio.c
@@ -41,8 +41,65 @@ EFL_START_TEST(elm_atspi_role_get)
41} 41}
42EFL_END_TEST 42EFL_END_TEST
43 43
44static unsigned int radio_change_count = 0;
45
46static void
47_rdg_changed_cb()
48{
49 radio_change_count++;
50 ecore_main_loop_quit();
51}
52
53EFL_START_TEST(elm_test_radio_selection)
54{
55 radio_change_count = 0;
56 Evas_Object *rd, *rdg;
57 Evas_Object *win = win_add(NULL, "radio", ELM_WIN_BASIC);
58 evas_object_resize(win, 100, 100);
59
60 // radio 1
61 rd = elm_radio_add(win);
62 evas_object_resize(rd, 100, 100);
63
64 // rdg radio group
65 rdg = rd;
66 evas_object_smart_callback_add(rdg, "changed", _rdg_changed_cb, NULL);
67
68 elm_radio_state_value_set(rd, 1);
69 elm_object_text_set(rd, "Radio Group Test #1");
70 evas_object_show(rd);
71
72
73 // radio 2
74 rd = elm_radio_add(win);
75 evas_object_smart_callback_add(rd, "changed", _rdg_changed_cb, NULL);
76 evas_object_resize(rd, 100, 100);
77 elm_radio_state_value_set(rd, 2);
78 elm_object_text_set(rd, "Radio Group Test #2");
79 elm_radio_group_add(rd, rdg);
80 evas_object_show(rd);
81 evas_object_show(win);
82
83 elm_layout_signal_emit(rdg, "elm,action,radio,toggle", "elm");
84 ecore_main_loop_begin();
85 ck_assert_int_eq(elm_radio_value_get(rdg), 1);
86 ck_assert_int_eq(radio_change_count, 1);
87
88 elm_layout_signal_emit(rd, "elm,action,radio,toggle", "elm");
89 ecore_main_loop_begin();
90 ck_assert_int_eq(elm_radio_value_get(rdg), 2);
91 ck_assert_int_eq(radio_change_count, 2);
92
93 elm_layout_signal_emit(rdg, "elm,action,radio,toggle", "elm");
94 ecore_main_loop_begin();
95 ck_assert_int_eq(elm_radio_value_get(rdg), 1);
96 ck_assert_int_eq(radio_change_count, 3);
97}
98EFL_END_TEST
99
44void elm_test_radio(TCase *tc) 100void elm_test_radio(TCase *tc)
45{ 101{
46 tcase_add_test(tc, elm_radio_legacy_type_check); 102 tcase_add_test(tc, elm_radio_legacy_type_check);
47 tcase_add_test(tc, elm_atspi_role_get); 103 tcase_add_test(tc, elm_atspi_role_get);
104 tcase_add_test(tc, elm_test_radio_selection);
48} 105}