summaryrefslogtreecommitdiff
path: root/src/tests/elementary/elm_test_win.c
blob: 90934a3a395eb7f29af5e00687e9892f8c4209cd (plain) (blame)
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
#ifdef HAVE_CONFIG_H
# include "elementary_config.h"
#endif

#define ELM_INTERFACE_ATSPI_ACCESSIBLE_PROTECTED
#define ELM_INTERFACE_ATSPI_COMPONENT_PROTECTED
#include <Elementary.h>
#include <Ecore_X.h>
#include "elm_suite.h"

static const double _timeout1 = 0.1;
static const double _timeout2 = 0.2;
static const double _timeout_fail = 2.0;

static void
_do_delete_request(Eo *win)
{
#ifdef HAVE_ELEMENTARY_X
   Ecore_X_Window xwin;
   xwin = elm_win_xwindow_get(win);
   ecore_x_window_delete_request_send(xwin);
#endif

   (void) win;
}


static Eina_Bool
_timer_delete_request_cb(void *data)
{
   Eo *win = (Eo*) data;
   _do_delete_request(win);
   return ECORE_CALLBACK_PASS_ON;
}

static Eina_Bool
_timer_hide_window_cb(void *data)
{
   Eo *win = (Eo*) data;
   efl_gfx_visible_set(win, EINA_FALSE);
   return ECORE_CALLBACK_PASS_ON;
}

static Eina_Bool
_timer_exit_cb(void *data EINA_UNUSED)
{
   elm_exit();
   return ECORE_CALLBACK_PASS_ON;
}

static Eina_Bool
_timer_fail_flag_cb(void *data)
{
   Eina_Bool *fail_flag = (Eina_Bool*) data;
   *fail_flag = EINA_TRUE;
   elm_exit();
   return ECORE_CALLBACK_PASS_ON;
}


START_TEST (elm_atspi_role_get)
{
   Evas_Object *win;
   Elm_Atspi_Role role;

   elm_init(1, NULL);
   win = elm_win_add(NULL, "win", ELM_WIN_BASIC);

   role = elm_interface_atspi_accessible_role_get(win);

   ck_assert(role == ELM_ATSPI_ROLE_WINDOW);

   elm_shutdown();
}
END_TEST

START_TEST (elm_atspi_component_position)
{
   Eina_Bool ret;
   int x, y;

   elm_init(0, NULL);

   Eo *win = elm_win_add(NULL, "win", ELM_WIN_BASIC);

   ret = elm_interface_atspi_component_position_set(win, EINA_TRUE, 45, 45);
   ck_assert(ret == EINA_TRUE);

   Ecore_Evas *ee = ecore_evas_ecore_evas_get(evas_object_evas_get(win));
   ck_assert(ee != NULL);
   ecore_evas_geometry_get(ee, &x, &y, NULL, NULL);

   ck_assert((x == 45) && (y == 45));

   elm_shutdown();
}
END_TEST

START_TEST (elm_atspi_component_size)
{
   Eina_Bool ret;
   int w, h;

   elm_init(0, NULL);

   Eo *win = elm_win_add(NULL, "win", ELM_WIN_BASIC);
   evas_object_resize(win, 50, 50);

   ret = elm_interface_atspi_component_size_set(win, 100, 100);
   ck_assert(ret == EINA_TRUE);

   evas_object_geometry_get(win, NULL, NULL, &w, &h);
   ck_assert((w == 100) && (h == 100));

   elm_shutdown();
}
END_TEST

START_TEST (elm_win_autohide)
{
   elm_init(0, NULL);

   Eo *win = elm_win_add(NULL, "win", ELM_WIN_BASIC);
   elm_obj_win_autohide_set(win, EINA_TRUE);
   efl_gfx_visible_set(win, EINA_TRUE);

   Eina_Bool fail_flag = EINA_FALSE;
   ecore_timer_add(_timeout1, _timer_delete_request_cb, win);
   ecore_timer_add(_timeout2, _timer_exit_cb, &fail_flag);

   elm_run();

   Eina_Bool visible;
   visible = efl_gfx_visible_get(win);
   ck_assert(visible == EINA_FALSE);

   elm_shutdown();
}
END_TEST

START_TEST (elm_win_policy_quit_last_window_hidden)
{
   elm_init(0, NULL);

   elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN);

   Eo *win = elm_win_add(NULL, "win", ELM_WIN_BASIC);
   efl_gfx_visible_set(win, EINA_TRUE);

   Eina_Bool fail_flag = EINA_FALSE;
   ecore_timer_add(_timeout1, _timer_hide_window_cb, win);
   ecore_timer_add(_timeout_fail, _timer_fail_flag_cb, &fail_flag);

   elm_run();

   Eina_Bool visible;
   visible = efl_gfx_visible_get(win);

   ck_assert(fail_flag == EINA_FALSE);
   ck_assert(eo_ref_get(win) >= 1);
   ck_assert(visible == EINA_FALSE);

   elm_shutdown();
}
END_TEST

START_TEST (elm_win_autohide_and_policy_quit_last_window_hidden)
{
   elm_init(0, NULL);

   elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN);

   Eo *win = elm_win_add(NULL, "win", ELM_WIN_BASIC);
   elm_obj_win_autohide_set(win, EINA_TRUE);
   efl_gfx_visible_set(win, EINA_TRUE);

   Eina_Bool fail_flag = EINA_FALSE;
   ecore_timer_add(_timeout1, _timer_delete_request_cb, win);
   ecore_timer_add(_timeout_fail, _timer_fail_flag_cb, &fail_flag);

   elm_run();

   Eina_Bool visible;
   visible = efl_gfx_visible_get(win);

   ck_assert(fail_flag == EINA_FALSE);
   ck_assert(eo_ref_get(win) >= 1);
   ck_assert(visible == EINA_FALSE);

   elm_shutdown();
}
END_TEST

void elm_test_win(TCase *tc)
{
   tcase_add_test(tc, elm_atspi_role_get);
   tcase_add_test(tc, elm_atspi_component_position);
   tcase_add_test(tc, elm_atspi_component_size);
   tcase_add_test(tc, elm_win_policy_quit_last_window_hidden);
#ifdef HAVE_ELEMENTARY_X
   tcase_add_test(tc, elm_win_autohide);
   tcase_add_test(tc, elm_win_autohide_and_policy_quit_last_window_hidden);
#endif
}