summaryrefslogtreecommitdiff
path: root/src/tests/elementary/efl_ui_test_config.c
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@samsung.com>2019-07-22 13:00:45 -0400
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2019-07-29 16:06:18 +0200
commitb1986363dbe46202cd46216af7e013c2f26ff098 (patch)
treef34304b4979fb6aea0ea3bd813b0759262e58c0f /src/tests/elementary/efl_ui_test_config.c
parentb9648605e8f6623283ec960deac302685909f3c5 (diff)
tests/elm: move efl_config tests to efl_ui_suite
these invoke non-legacy codepaths which should never be triggered during legacy unit tests Reviewed-by: Marcel Hollerbach <mail@marcel-hollerbach.de> Differential Revision: https://phab.enlightenment.org/D9403
Diffstat (limited to 'src/tests/elementary/efl_ui_test_config.c')
-rw-r--r--src/tests/elementary/efl_ui_test_config.c230
1 files changed, 230 insertions, 0 deletions
diff --git a/src/tests/elementary/efl_ui_test_config.c b/src/tests/elementary/efl_ui_test_config.c
new file mode 100644
index 0000000..40d0415
--- /dev/null
+++ b/src/tests/elementary/efl_ui_test_config.c
@@ -0,0 +1,230 @@
1#ifdef HAVE_CONFIG_H
2# include "elementary_config.h"
3#endif
4
5#define EFL_ACCESS_OBJECT_PROTECTED
6#include <Efl_Ui.h>
7#include <Elementary.h>
8#include "elm_suite.h"
9
10#include <stdbool.h>
11typedef unsigned int uint;
12
13EFL_START_TEST(efl_config_eoapi)
14{
15 Eo *cfg = efl_provider_find(efl_main_loop_get(), EFL_CONFIG_INTERFACE);
16 fail_if(!cfg);
17
18#define CONFIG_CHK(opt, typ, val) do { \
19 typ old = elm_config_ ## opt ## _get(); \
20 fail_if(old != efl_config_ ## typ ## _get(cfg, #opt)); \
21 fail_if(!efl_config_ ## typ ## _set(cfg, #opt, val)); \
22 fail_if(elm_config_ ## opt ## _get() != val); \
23 fail_if(efl_config_ ## typ ## _get(cfg, #opt) != val); \
24 } while (0)
25
26#define CONFIG_CHKB(opt, val) CONFIG_CHK(opt, bool, val)
27#define CONFIG_CHKI(opt, val) CONFIG_CHK(opt, int, val)
28#define CONFIG_CHKD(opt, val) CONFIG_CHK(opt, double, val)
29
30 // note: leaks badly
31#define CONFIG_CHKS(opt, val) do { \
32 const char *old = elm_config_ ## opt ## _get(); \
33 fail_if(!eina_streq(old, efl_config_string_get(cfg, #opt))); \
34 fail_if(!efl_config_string_set(cfg, #opt, val)); \
35 fail_if(!eina_streq(elm_config_ ## opt ## _get(), val)); \
36 fail_if(!eina_streq(efl_config_string_get(cfg, #opt), val)); \
37 } while (0)
38
39#define CONFIG_CHKE(opt, ival, sval) do { \
40 elm_config_ ## opt ## _set(ival); \
41 fail_if(!eina_streq(efl_config_string_get(cfg, #opt), sval)); \
42 fail_if(!efl_config_string_set(cfg, #opt, sval)); \
43 fail_if(!eina_streq(efl_config_string_get(cfg, #opt), sval)); \
44 } while (0)
45
46 CONFIG_CHKB(scroll_bounce_enabled, !old);
47 CONFIG_CHKD(scroll_bounce_friction, 0);
48 CONFIG_CHKD(scroll_page_scroll_friction, 0);
49 CONFIG_CHKB(context_menu_disabled, !old);
50 CONFIG_CHKD(scroll_bring_in_scroll_friction, 0);
51 CONFIG_CHKD(scroll_zoom_friction, 0);
52 CONFIG_CHKB(scroll_thumbscroll_enabled, !old);
53 CONFIG_CHKI(scroll_thumbscroll_threshold, 0);
54 CONFIG_CHKI(scroll_thumbscroll_hold_threshold, 0);
55 CONFIG_CHKD(scroll_thumbscroll_momentum_threshold, 0);
56 CONFIG_CHKI(scroll_thumbscroll_flick_distance_tolerance, 0);
57 CONFIG_CHKD(scroll_thumbscroll_friction, 0);
58 CONFIG_CHKD(scroll_thumbscroll_min_friction, 0);
59 CONFIG_CHKD(scroll_thumbscroll_friction_standard, 0);
60 CONFIG_CHKD(scroll_thumbscroll_border_friction, 0);
61 CONFIG_CHKD(scroll_thumbscroll_sensitivity_friction, 1.0);
62 CONFIG_CHKB(scroll_thumbscroll_smooth_start, 0);
63 CONFIG_CHKB(scroll_animation_disabled, 0);
64 CONFIG_CHKD(scroll_accel_factor, 0);
65 CONFIG_CHKD(scroll_thumbscroll_smooth_amount, 0);
66 CONFIG_CHKD(scroll_thumbscroll_smooth_time_window, 0);
67 CONFIG_CHKD(scroll_thumbscroll_acceleration_threshold, 0);
68 CONFIG_CHKD(scroll_thumbscroll_acceleration_time_limit, 0);
69 CONFIG_CHKD(scroll_thumbscroll_acceleration_weight, 0);
70 CONFIG_CHKE(focus_autoscroll_mode, EFL_UI_FOCUS_AUTOSCROLL_MODE_NONE, "none");
71 CONFIG_CHKE(slider_indicator_visible_mode, EFL_UI_SLIDER_INDICATOR_VISIBLE_MODE_ALWAYS, "always");
72 CONFIG_CHKD(longpress_timeout, 0);
73 CONFIG_CHKE(softcursor_mode, EFL_UI_SOFTCURSOR_MODE_ON, "on");
74 CONFIG_CHKD(tooltip_delay, 0);
75 CONFIG_CHKB(cursor_engine_only, 0);
76 CONFIG_CHKD(scale, 0);
77 CONFIG_CHKS(icon_theme, ELM_CONFIG_ICON_THEME_ELEMENTARY);
78 CONFIG_CHKB(password_show_last, 0);
79 CONFIG_CHKD(password_show_last_timeout, 0);
80 CONFIG_CHKS(preferred_engine, 0);
81 CONFIG_CHKS(accel_preference, 0);
82 //font_overlay
83 CONFIG_CHKB(access, 0);
84 CONFIG_CHKB(selection_unfocused_clear, 0);
85 //elm_config_font_overlay_unset
86 //CONFIG_CHKI(font_hint_type, 0); // this has no get!
87 CONFIG_CHKI(finger_size, 0);
88 CONFIG_CHKI(cache_flush_interval, 10);
89 CONFIG_CHKB(cache_flush_enabled, !old);
90 CONFIG_CHKI(cache_font_cache_size, 0);
91 CONFIG_CHKI(cache_image_cache_size, 0);
92 CONFIG_CHKI(cache_edje_file_cache_size, 0);
93 CONFIG_CHKI(cache_edje_collection_cache_size, 0);
94 CONFIG_CHKB(vsync, 0);
95 CONFIG_CHKB(accel_preference_override, 0);
96 CONFIG_CHKB(focus_highlight_enabled, !old);
97 CONFIG_CHKB(focus_highlight_animate, 0);
98 CONFIG_CHKB(focus_highlight_clip_disabled, !old);
99 CONFIG_CHKE(focus_move_policy, EFL_UI_FOCUS_MOVE_POLICY_MOVE_IN, "in");
100 CONFIG_CHKB(item_select_on_focus_disabled, !old);
101 CONFIG_CHKB(first_item_focus_on_first_focusin, 0);
102 CONFIG_CHKB(mirrored, 0);
103 //see clouseau tests
104 //CONFIG_CHKB(clouseau_enabled, !old);
105 CONFIG_CHKD(glayer_long_tap_start_timeout, 0);
106 CONFIG_CHKD(glayer_double_tap_timeout, 0);
107 //color_overlay
108 //color_overlay_unset
109 CONFIG_CHKB(magnifier_enable, 0);
110 CONFIG_CHKD(magnifier_scale, 0);
111 CONFIG_CHKB(window_auto_focus_enable, 0);
112 CONFIG_CHKB(window_auto_focus_animate, 0);
113 CONFIG_CHKB(popup_scrollable, 0);
114 CONFIG_CHKB(atspi_mode, 0);
115 CONFIG_CHKD(transition_duration_factor, 0);
116 CONFIG_CHKS(web_backend, old); // no value change (requires web support)
117
118 static const struct {
119 Edje_Channel chan;
120 const char *name;
121 } channels[] = {
122 { EDJE_CHANNEL_EFFECT, "audio_mute_effect" },
123 { EDJE_CHANNEL_BACKGROUND, "audio_mute_background" },
124 { EDJE_CHANNEL_MUSIC, "audio_mute_music" },
125 { EDJE_CHANNEL_FOREGROUND, "audio_mute_foreground" },
126 { EDJE_CHANNEL_INTERFACE, "audio_mute_interface" },
127 { EDJE_CHANNEL_INPUT, "audio_mute_input" },
128 { EDJE_CHANNEL_ALERT, "audio_mute_alert" },
129 { EDJE_CHANNEL_ALL, "audio_mute_all" },
130 { EDJE_CHANNEL_ALL, "audio_mute" },
131 };
132
133 for (unsigned i = 0; i < (sizeof(channels) / sizeof(channels[0])); i++)
134 {
135 Eina_Bool b = elm_config_audio_mute_get(channels[i].chan);
136 if (b != efl_config_bool_get(cfg, channels[i].name))
137 fail(channels[i].name);
138 efl_config_bool_set(cfg, channels[i].name, !b);
139 if(efl_config_bool_get(cfg, channels[i].name) != !b)
140 fail(channels[i].name);
141 if(elm_config_audio_mute_get(channels[i].chan) != !b)
142 fail(channels[i].name);
143 }
144
145}
146EFL_END_TEST
147
148EFL_START_TEST(efl_config_win)
149{
150 Eo *cfg = efl_provider_find(efl_main_loop_get(), EFL_CONFIG_INTERFACE);
151 fail_if(!cfg);
152
153 Eo *win = efl_add_ref(EFL_UI_WIN_CLASS, NULL);
154 Eo *cfg2 = efl_provider_find(win, EFL_CONFIG_INTERFACE);
155 fail_if(cfg != cfg2);
156
157 elm_config_cache_flush_interval_set(42);
158 fail_if(efl_config_int_get(win, "cache_flush_interval") != 42);
159
160 efl_unref(win);
161}
162EFL_END_TEST
163
164static inline Eina_Bool
165_eina_list_string_has(const Eina_List *list, const char *str)
166{
167 const char *s;
168 const Eina_List *l;
169
170 EINA_LIST_FOREACH(list, l, s)
171 if (eina_streq(str, s))
172 return EINA_TRUE;
173
174 return EINA_FALSE;
175}
176
177EFL_START_TEST(efl_config_profiles)
178{
179 // this only tests some of the profile APIs. we're not going to mess with
180 // the global config during make check :)
181
182 Eo *cfg = efl_provider_find(efl_main_loop_get(), EFL_CONFIG_INTERFACE);
183 fail_if(!cfg);
184
185 for (int hidden = 0; hidden <= 1; hidden++)
186 {
187 Eina_List *list;
188 Eina_Iterator *it;
189 const char *prof;
190 unsigned int cnt = 0;
191
192 list = (!hidden) ? elm_config_profile_list_get()
193 : elm_config_profile_list_full_get();
194 it = efl_config_profile_iterate(cfg, hidden);
195 EINA_ITERATOR_FOREACH(it, prof)
196 {
197 fail_if(!_eina_list_string_has(list, prof));
198 cnt++;
199 }
200 fail_if(cnt != eina_list_count(list));
201 elm_config_profile_list_free(list);
202 eina_iterator_free(it);
203 }
204
205 const char *dir, *profile;
206 Eina_Stringshare *str;
207
208 profile = elm_config_profile_get();
209 fail_if(!profile);
210 dir = elm_config_profile_dir_get(profile, EINA_TRUE);
211 str = efl_config_profile_dir_get(cfg, profile, EINA_TRUE);
212 fail_if(!eina_streq(dir, str));
213 elm_config_profile_dir_free(dir);
214 eina_stringshare_del(str);
215
216 dir = elm_config_profile_dir_get(profile, EINA_FALSE);
217 str = efl_config_profile_dir_get(cfg, profile, EINA_FALSE);
218 fail_if(!eina_streq(dir, str));
219 elm_config_profile_dir_free(dir);
220 eina_stringshare_del(str);
221
222}
223EFL_END_TEST
224
225void efl_ui_test_config(TCase *tc)
226{
227 tcase_add_test(tc, efl_config_eoapi);
228 tcase_add_test(tc, efl_config_win);
229 tcase_add_test(tc, efl_config_profiles);
230}