summaryrefslogtreecommitdiff
path: root/src/tests/elementary/efl_ui_test_check.c
blob: bd38aa1e8e4ebf9fae9496b82953f47b49ce6fb5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#ifdef HAVE_CONFIG_H
# include "elementary_config.h"
#endif

#include <Efl_Ui.h>
#include "efl_ui_suite.h"

static Eo *win, *check;

static void
check_setup()
{
   win = win_add();

   check = efl_add(EFL_UI_CHECK_CLASS, win);
}

EFL_START_TEST(check_content)
{
   Eo *t = efl_add(EFL_UI_BUTTON_CLASS, win,
    efl_text_set(efl_added, "asdf")
   );
   efl_content_set(check, t);
   ck_assert_ptr_eq(efl_content_get(check), t);
   //TODO verify that signals can be emitted
}
EFL_END_TEST

EFL_START_TEST(check_text)
{
   efl_text_set(check, "Test the Rest");
   ck_assert_str_eq(efl_text_get(check), "Test the Rest");
   //TODO verify that signals can be emitted
}
EFL_END_TEST

EFL_START_TEST(check_selection_state)
{
   efl_ui_check_selected_set(check, EINA_TRUE);
   ck_assert_int_eq(efl_ui_check_selected_get(check), EINA_TRUE);
   efl_ui_check_selected_set(check, EINA_TRUE);
   ck_assert_int_eq(efl_ui_check_selected_get(check), EINA_TRUE);
   //TODO verify that signals can be emitted

   efl_ui_check_selected_set(check, EINA_FALSE);
   ck_assert_int_eq(efl_ui_check_selected_get(check), EINA_FALSE);
   efl_ui_check_selected_set(check, EINA_FALSE);
   ck_assert_int_eq(efl_ui_check_selected_get(check), EINA_FALSE);
   //TODO verify that signals can be emitted
}
EFL_END_TEST

static void
_check(void *data, const Efl_Event *ev)
{
   Eina_Bool *flag = data;

   *flag = *((Eina_Bool*)ev->info);
}

EFL_START_TEST(check_selection_events)
{
   Eina_Bool bool_event_info = EINA_FALSE;

   efl_event_callback_add(check, EFL_UI_CHECK_EVENT_SELECTED_CHANGED, _check, &bool_event_info);
   efl_ui_check_selected_set(check, EINA_TRUE);
   ck_assert_int_eq(bool_event_info, EINA_TRUE);
   efl_ui_check_selected_set(check, EINA_FALSE);
   ck_assert_int_eq(bool_event_info, EINA_FALSE);
}
EFL_END_TEST

void efl_ui_test_check(TCase *tc)
{
   tcase_add_checked_fixture(tc, check_setup, NULL);
   tcase_add_test(tc, check_selection_state);
   tcase_add_test(tc, check_text);
   tcase_add_test(tc, check_content);
   tcase_add_test(tc, check_selection_events);
}