summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2020-01-03 18:40:26 +0100
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2020-01-13 15:57:23 +0100
commitf62cee28cbb634731d7c39378dd29530d767b505 (patch)
treef04551d407bcdffc9bdf64fb2c9186b51ca2bcc2
parentd48941c783a697c8a075a8703da4e92e08c4ae4c (diff)
efl_ui_spin_button: add tests for direct input feature
this simply passes in some key sequences and checks if the validation is working. Additionally the output value is checked. Differential Revision: https://phab.enlightenment.org/D11010
-rw-r--r--src/tests/elementary/efl_ui_test_spin_button.c53
-rw-r--r--src/tests/elementary/suite_helpers.c13
-rw-r--r--src/tests/elementary/suite_helpers.h1
3 files changed, 67 insertions, 0 deletions
diff --git a/src/tests/elementary/efl_ui_test_spin_button.c b/src/tests/elementary/efl_ui_test_spin_button.c
index 9903e8312d..0d73e44271 100644
--- a/src/tests/elementary/efl_ui_test_spin_button.c
+++ b/src/tests/elementary/efl_ui_test_spin_button.c
@@ -3,6 +3,7 @@
3#endif 3#endif
4 4
5#include <Elementary.h> 5#include <Elementary.h>
6#include "elm_entry_eo.h" //needed to check that spin is in text mode
6#include <Efl_Ui.h> 7#include <Efl_Ui.h>
7#include "efl_ui_suite.h" 8#include "efl_ui_suite.h"
8 9
@@ -192,6 +193,56 @@ EFL_START_TEST (spin_double_values)
192} 193}
193EFL_END_TEST 194EFL_END_TEST
194 195
196static inline void
197_try_direct_text_input(const char *text, double result)
198{
199 Eo *entry = efl_content_get(efl_part(spin, "efl.entry"));
200 ck_assert_int_eq(efl_isa(entry, ELM_ENTRY_CLASS), 1);
201
202 write_key_sequence(spin, text);
203 efl_ui_focus_util_focus(efl_content_get(efl_part(spin, "efl.inc_button")));
204 if (EINA_DBL_EQ(efl_ui_range_value_get(spin), result) != 1)
205 ck_assert_msg("Double %g does not match %g", efl_ui_range_value_get(spin), result);
206}
207
208EFL_START_TEST (spin_direct_text_input)
209{
210 efl_ui_spin_button_direct_text_input_set(spin, EINA_TRUE);
211 efl_ui_range_limits_set(spin, -30, 30);
212 efl_ui_range_value_set(spin, 20);
213 efl_ui_focus_util_focus(efl_content_get(efl_part(spin, "efl.text_button")));
214 DISABLE_ABORT_ON_CRITICAL_START; //FIXME there is a bug in the cnp handling code
215 get_me_to_those_events(spin);
216 DISABLE_ABORT_ON_CRITICAL_END;
217
218 _try_direct_text_input("1asdf2", 12);
219 _try_direct_text_input("1-2", 12);
220 _try_direct_text_input("-12", -12);
221 _try_direct_text_input("-100", -30);
222 _try_direct_text_input("10.8", 10);
223 _try_direct_text_input("12342435", 30);
224}
225EFL_END_TEST
226
227EFL_START_TEST (spin_direct_text_input_comma_value)
228{
229 efl_ui_spin_button_direct_text_input_set(spin, EINA_TRUE);
230 efl_ui_range_limits_set(spin, -30, 30);
231 efl_ui_range_value_set(spin, 20);
232 efl_ui_format_string_set(spin, "%.2f", EFL_UI_FORMAT_STRING_TYPE_SIMPLE);
233 efl_ui_focus_util_focus(efl_content_get(efl_part(spin, "efl.text_button")));
234 DISABLE_ABORT_ON_CRITICAL_START; //FIXME there is a bug in the cnp handling code
235 get_me_to_those_events(spin);
236 DISABLE_ABORT_ON_CRITICAL_END;
237
238 _try_direct_text_input("1asdf2.1", 12.1);
239 _try_direct_text_input("1-2.2", 12.2);
240 _try_direct_text_input("-12.8", -12.8);
241 _try_direct_text_input("-100", -30);
242 _try_direct_text_input("10.8", 10.8);
243 _try_direct_text_input("12342435.12312341342", 30);
244}
245EFL_END_TEST
195void efl_ui_test_spin_button(TCase *tc) 246void efl_ui_test_spin_button(TCase *tc)
196{ 247{
197 tcase_add_checked_fixture(tc, fail_on_errors_setup, fail_on_errors_teardown); 248 tcase_add_checked_fixture(tc, fail_on_errors_setup, fail_on_errors_teardown);
@@ -202,4 +253,6 @@ void efl_ui_test_spin_button(TCase *tc)
202 tcase_add_test(tc, spin_value_dec_min); 253 tcase_add_test(tc, spin_value_dec_min);
203 tcase_add_test(tc, spin_wraparound); 254 tcase_add_test(tc, spin_wraparound);
204 tcase_add_test(tc, spin_double_values); 255 tcase_add_test(tc, spin_double_values);
256 tcase_add_test(tc, spin_direct_text_input);
257 tcase_add_test(tc, spin_direct_text_input_comma_value);
205} 258}
diff --git a/src/tests/elementary/suite_helpers.c b/src/tests/elementary/suite_helpers.c
index 53c473a9fa..c637ff7f77 100644
--- a/src/tests/elementary/suite_helpers.c
+++ b/src/tests/elementary/suite_helpers.c
@@ -618,3 +618,16 @@ drag_object(Eo *obj, int x, int y, int dx, int dy, Eina_Bool iterate)
618 evas_event_feed_mouse_move(e, x + dx, y + dy, 0, NULL); 618 evas_event_feed_mouse_move(e, x + dx, y + dy, 0, NULL);
619 evas_event_feed_mouse_up(e, 1, 0, 0, NULL); 619 evas_event_feed_mouse_up(e, 1, 0, 0, NULL);
620} 620}
621
622void
623write_key_sequence(Eo *obj, const char *seqence)
624{
625 Evas *e = evas_object_evas_get(obj);
626 for (unsigned int i = 0; i < strlen(seqence); ++i)
627 {
628 const char part_seq[] = {seqence[i], '\0'};
629 evas_event_feed_key_down(e, part_seq, part_seq, part_seq, part_seq, 0, NULL);
630 evas_event_feed_key_up(e, part_seq, part_seq, part_seq, part_seq, 0, NULL);
631 ecore_main_loop_iterate();
632 }
633}
diff --git a/src/tests/elementary/suite_helpers.h b/src/tests/elementary/suite_helpers.h
index 40c8dec12b..b9535a8826 100644
--- a/src/tests/elementary/suite_helpers.h
+++ b/src/tests/elementary/suite_helpers.h
@@ -22,6 +22,7 @@ void click_part(Eo *obj, const char *part);
22void click_part_flags(Eo *obj, const char *part, int flags); 22void click_part_flags(Eo *obj, const char *part, int flags);
23void click_object_at(Eo *obj, int x, int y); 23void click_object_at(Eo *obj, int x, int y);
24void click_object_at_flags(Eo *obj, int x, int y, int flags); 24void click_object_at_flags(Eo *obj, int x, int y, int flags);
25void write_key_sequence(Eo *obj, const char *seqence);
25void drag_object(Eo *obj, int x, int y, int dx, int dy, Eina_Bool iterate); 26void drag_object(Eo *obj, int x, int y, int dx, int dy, Eina_Bool iterate);
26void wheel_object(Eo *obj, Eina_Bool horiz, Eina_Bool down); 27void wheel_object(Eo *obj, Eina_Bool horiz, Eina_Bool down);
27void wheel_part(Eo *obj, const char *part, Eina_Bool horiz, Eina_Bool down); 28void wheel_part(Eo *obj, const char *part, Eina_Bool horiz, Eina_Bool down);