summaryrefslogtreecommitdiff
path: root/src/tests/elementary/efl_ui_test_config.c
blob: a9f31ea988411a093652bdf2db1f7a51817c04fc (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
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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
#ifdef HAVE_CONFIG_H
# include "elementary_config.h"
#endif

#define EFL_ACCESS_OBJECT_PROTECTED
#include <Efl_Ui.h>
#include <Elementary.h>
#include "elm_suite.h"

#include <stdbool.h>
typedef unsigned int uint;

EFL_START_TEST(efl_config_eoapi)
{
   Eo *cfg = efl_provider_find(efl_main_loop_get(), EFL_CONFIG_INTERFACE);
   fail_if(!cfg);

#define CONFIG_CHK(opt, typ, val) do { \
   typ old = elm_config_ ## opt ## _get(); \
   fail_if(old != efl_config_ ## typ ## _get(cfg, #opt)); \
   fail_if(!efl_config_ ## typ ## _set(cfg, #opt, val)); \
   fail_if(elm_config_ ## opt ## _get() != val); \
   fail_if(efl_config_ ## typ ## _get(cfg, #opt) != val); \
   } while (0)

#define CONFIG_CHKB(opt, val) CONFIG_CHK(opt, bool, val)
#define CONFIG_CHKI(opt, val) CONFIG_CHK(opt, int, val)
#define CONFIG_CHKD(opt, val) CONFIG_CHK(opt, double, val)

   // note: leaks badly
#define CONFIG_CHKS(opt, val) do { \
   const char *old = elm_config_ ## opt ## _get(); \
   fail_if(!eina_streq(old, efl_config_string_get(cfg, #opt))); \
   fail_if(!efl_config_string_set(cfg, #opt, val)); \
   fail_if(!eina_streq(elm_config_ ## opt ## _get(), val)); \
   fail_if(!eina_streq(efl_config_string_get(cfg, #opt), val)); \
   } while (0)

#define CONFIG_CHKE(opt, ival, sval) do { \
   elm_config_ ## opt ## _set(ival); \
   fail_if(!eina_streq(efl_config_string_get(cfg, #opt), sval)); \
   fail_if(!efl_config_string_set(cfg, #opt, sval)); \
   fail_if(!eina_streq(efl_config_string_get(cfg, #opt), sval)); \
   } while (0)

   CONFIG_CHKB(scroll_bounce_enabled, !old);
   CONFIG_CHKD(scroll_bounce_friction, 0);
   CONFIG_CHKD(scroll_page_scroll_friction, 0);
   CONFIG_CHKB(context_menu_disabled, !old);
   CONFIG_CHKD(scroll_bring_in_scroll_friction, 0);
   CONFIG_CHKD(scroll_zoom_friction, 0);
   CONFIG_CHKB(scroll_thumbscroll_enabled, !old);
   CONFIG_CHKI(scroll_thumbscroll_threshold, 0);
   CONFIG_CHKI(scroll_thumbscroll_hold_threshold, 0);
   CONFIG_CHKD(scroll_thumbscroll_momentum_threshold, 0);
   CONFIG_CHKI(scroll_thumbscroll_flick_distance_tolerance, 0);
   CONFIG_CHKD(scroll_thumbscroll_friction, 0);
   CONFIG_CHKD(scroll_thumbscroll_min_friction, 0);
   CONFIG_CHKD(scroll_thumbscroll_friction_standard, 0);
   CONFIG_CHKD(scroll_thumbscroll_border_friction, 0);
   CONFIG_CHKD(scroll_thumbscroll_sensitivity_friction, 1.0);
   CONFIG_CHKB(scroll_thumbscroll_smooth_start, 0);
   CONFIG_CHKB(scroll_animation_disabled, 0);
   CONFIG_CHKD(scroll_accel_factor, 0);
   CONFIG_CHKD(scroll_thumbscroll_smooth_amount, 0);
   CONFIG_CHKD(scroll_thumbscroll_smooth_time_window, 0);
   CONFIG_CHKD(scroll_thumbscroll_acceleration_threshold, 0);
   CONFIG_CHKD(scroll_thumbscroll_acceleration_time_limit, 0);
   CONFIG_CHKD(scroll_thumbscroll_acceleration_weight, 0);
   CONFIG_CHKE(focus_autoscroll_mode, EFL_UI_FOCUS_AUTOSCROLL_MODE_NONE, "none");
   CONFIG_CHKD(longpress_timeout, 0);
   CONFIG_CHKE(softcursor_mode, EFL_UI_SOFTCURSOR_MODE_ON, "on");
   CONFIG_CHKD(tooltip_delay, 0);
   CONFIG_CHKB(cursor_engine_only, 0);
   CONFIG_CHKD(scale, 0);
   CONFIG_CHKS(icon_theme, ELM_CONFIG_ICON_THEME_ELEMENTARY);
   CONFIG_CHKB(password_show_last, 0);
   CONFIG_CHKD(password_show_last_timeout, 0);
   CONFIG_CHKS(preferred_engine, 0);
   CONFIG_CHKS(accel_preference, 0);
   //font_overlay
   CONFIG_CHKB(access, 0);
   CONFIG_CHKB(selection_unfocused_clear, 0);
   //elm_config_font_overlay_unset
   //CONFIG_CHKI(font_hint_type, 0); // this has no get!
   CONFIG_CHKI(finger_size, 0);
   CONFIG_CHKI(cache_flush_interval, 10);
   CONFIG_CHKB(cache_flush_enabled, !old);
   CONFIG_CHKI(cache_font_cache_size, 0);
   CONFIG_CHKI(cache_image_cache_size, 0);
   CONFIG_CHKI(cache_edje_file_cache_size, 0);
   CONFIG_CHKI(cache_edje_collection_cache_size, 0);
   CONFIG_CHKB(vsync, 0);
   CONFIG_CHKB(accel_preference_override, 0);
   CONFIG_CHKB(focus_highlight_enabled, !old);
   CONFIG_CHKB(focus_highlight_animate, 0);
   CONFIG_CHKB(focus_highlight_clip_disabled, !old);
   CONFIG_CHKE(focus_move_policy, EFL_UI_FOCUS_MOVE_POLICY_MOVE_IN, "in");
   CONFIG_CHKB(item_select_on_focus_disabled, !old);
   CONFIG_CHKB(first_item_focus_on_first_focusin, 0);
   CONFIG_CHKB(mirrored, 0);
   //see clouseau tests
   //CONFIG_CHKB(clouseau_enabled, !old);
   CONFIG_CHKD(glayer_long_tap_start_timeout, 0);
   CONFIG_CHKD(glayer_double_tap_timeout, 0);
   //color_overlay
   //color_overlay_unset
   CONFIG_CHKB(magnifier_enable, 0);
   CONFIG_CHKD(magnifier_scale, 0);
   CONFIG_CHKB(window_auto_focus_enable, 0);
   CONFIG_CHKB(window_auto_focus_animate, 0);
   CONFIG_CHKB(popup_scrollable, 0);
   CONFIG_CHKB(atspi_mode, 0);
   CONFIG_CHKD(transition_duration_factor, 0);
   CONFIG_CHKS(web_backend, old); // no value change (requires web support)

   static const struct {
      Edje_Channel chan;
      const char  *name;
   } channels[] = {
   { EDJE_CHANNEL_EFFECT, "audio_mute_effect" },
   { EDJE_CHANNEL_BACKGROUND, "audio_mute_background" },
   { EDJE_CHANNEL_MUSIC, "audio_mute_music" },
   { EDJE_CHANNEL_FOREGROUND, "audio_mute_foreground" },
   { EDJE_CHANNEL_INTERFACE, "audio_mute_interface" },
   { EDJE_CHANNEL_INPUT, "audio_mute_input" },
   { EDJE_CHANNEL_ALERT, "audio_mute_alert" },
   { EDJE_CHANNEL_ALL, "audio_mute_all" },
   { EDJE_CHANNEL_ALL, "audio_mute" },
   };

   for (unsigned i = 0; i < (sizeof(channels) / sizeof(channels[0])); i++)
     {
        Eina_Bool b = elm_config_audio_mute_get(channels[i].chan);
        if (b != efl_config_bool_get(cfg, channels[i].name))
          fail(channels[i].name);
        efl_config_bool_set(cfg, channels[i].name, !b);
        if(efl_config_bool_get(cfg, channels[i].name) != !b)
          fail(channels[i].name);
        if(elm_config_audio_mute_get(channels[i].chan) != !b)
          fail(channels[i].name);
     }

}
EFL_END_TEST

EFL_START_TEST(efl_config_win)
{
   Eo *cfg = efl_provider_find(efl_main_loop_get(), EFL_CONFIG_INTERFACE);
   fail_if(!cfg);

   Eo *win = efl_add_ref(EFL_UI_WIN_CLASS, NULL);
   Eo *cfg2 = efl_provider_find(win, EFL_CONFIG_INTERFACE);
   fail_if(cfg != cfg2);

   elm_config_cache_flush_interval_set(42);
   fail_if(efl_config_int_get(win, "cache_flush_interval") != 42);

   efl_unref(win);
}
EFL_END_TEST

static inline Eina_Bool
_eina_list_string_has(const Eina_List *list, const char *str)
{
   const char *s;
   const Eina_List *l;

   EINA_LIST_FOREACH(list, l, s)
     if (eina_streq(str, s))
       return EINA_TRUE;

   return EINA_FALSE;
}

EFL_START_TEST(efl_config_profiles)
{
   // this only tests some of the profile APIs. we're not going to mess with
   // the global config during make check :)

   Eo *cfg = efl_provider_find(efl_main_loop_get(), EFL_CONFIG_INTERFACE);
   fail_if(!cfg);

   for (int hidden = 0; hidden <= 1; hidden++)
     {
        Eina_List *list;
        Eina_Iterator *it;
        const char *prof;
        unsigned int cnt = 0;

        list = (!hidden) ? elm_config_profile_list_get()
                         : elm_config_profile_list_full_get();
        it = efl_config_profile_iterate(cfg, hidden);
        EINA_ITERATOR_FOREACH(it, prof)
          {
             fail_if(!_eina_list_string_has(list, prof));
             cnt++;
          }
        fail_if(cnt != eina_list_count(list));
        elm_config_profile_list_free(list);
        eina_iterator_free(it);
     }

   const char *dir, *profile;
   Eina_Stringshare *str;

   profile = elm_config_profile_get();
   fail_if(!profile);
   dir = elm_config_profile_dir_get(profile, EINA_TRUE);
   str = efl_config_profile_dir_get(cfg, profile, EINA_TRUE);
   fail_if(!eina_streq(dir, str));
   elm_config_profile_dir_free(dir);
   eina_stringshare_del(str);

   dir = elm_config_profile_dir_get(profile, EINA_FALSE);
   str = efl_config_profile_dir_get(cfg, profile, EINA_FALSE);
   fail_if(!eina_streq(dir, str));
   elm_config_profile_dir_free(dir);
   eina_stringshare_del(str);

}
EFL_END_TEST

void efl_ui_test_config(TCase *tc)
{
   tcase_add_test(tc, efl_config_eoapi);
   tcase_add_test(tc, efl_config_win);
   tcase_add_test(tc, efl_config_profiles);
}