summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2020-03-25 22:01:16 +0100
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2020-03-25 22:13:29 +0100
commitf6cb2340701f65c08508bc5c4988caa06141865e (patch)
treeff03009a4ed5f6c6d5bcb984b35e6f4902103f5c
parent43f95ec6b3be726df4f8b834d9f3821a11096a6e (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. Depends on D11009 Differential Revision: https://phab.enlightenment.org/D11010
-rw-r--r--src/tests/elementary/efl_ui_test_spin_button.c55
1 files changed, 55 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 f723e348af..db6ddc2831 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
@@ -209,6 +210,58 @@ EFL_START_TEST (spin_double_values_hitting_max_with_step)
209} 210}
210EFL_END_TEST 211EFL_END_TEST
211 212
213static inline void
214_try_direct_text_input(const char *text, double result)
215{
216 Eo *entry;
217
218 efl_ui_focus_util_focus(efl_content_get(efl_part(spin, "efl.text_button")));
219 get_me_to_those_events(spin);
220 entry = efl_content_get(efl_part(spin, "efl.entry"));
221 elm_object_text_set(entry, "");
222 ck_assert_int_eq(efl_isa(entry, ELM_ENTRY_CLASS), 1);
223 efl_ui_focus_util_focus(entry);
224 get_me_to_those_events(spin);
225
226 write_key_sequence(spin, text);
227 get_me_to_those_events(spin);
228
229 efl_ui_focus_util_focus(efl_content_get(efl_part(spin, "efl.inc_button")));
230 ck_assert_msg(EINA_DBL_EQ(efl_ui_range_value_get(spin), result), "Values do not match %f - %f (%s)", efl_ui_range_value_get(spin), result, elm_object_text_get(entry));
231}
232
233EFL_START_TEST (spin_direct_text_input)
234{
235 efl_ui_spin_button_direct_text_input_set(spin, EINA_TRUE);
236 efl_ui_range_limits_set(spin, -30, 30);
237 efl_ui_range_value_set(spin, 20);
238 get_me_to_those_events(spin);
239 _try_direct_text_input("1asdf2", 12);
240 _try_direct_text_input("1-2", 12);
241 _try_direct_text_input("-12", -12);
242 _try_direct_text_input("-100", -30);
243 _try_direct_text_input("1.8", 18);
244 _try_direct_text_input("12342435", 30);
245}
246EFL_END_TEST
247
248EFL_START_TEST (spin_direct_text_input_comma_value)
249{
250 efl_ui_spin_button_direct_text_input_set(spin, EINA_TRUE);
251 efl_ui_range_limits_set(spin, -30, 30);
252 efl_ui_range_value_set(spin, 20);
253 efl_ui_format_string_set(spin, "%.2f", EFL_UI_FORMAT_STRING_TYPE_SIMPLE);
254 efl_ui_focus_util_focus(efl_content_get(efl_part(spin, "efl.text_button")));
255 get_me_to_those_events(spin);
256 _try_direct_text_input("1asdf2.1", 12.1);
257 _try_direct_text_input("1-2.2", 12.2);
258 _try_direct_text_input("-12.8", -12.8);
259 _try_direct_text_input("-100", -30);
260 _try_direct_text_input("10.8", 10.8);
261 _try_direct_text_input("12342435.12312341342", 30);
262}
263EFL_END_TEST
264
212void efl_ui_test_spin_button(TCase *tc) 265void efl_ui_test_spin_button(TCase *tc)
213{ 266{
214 tcase_add_checked_fixture(tc, fail_on_errors_setup, fail_on_errors_teardown); 267 tcase_add_checked_fixture(tc, fail_on_errors_setup, fail_on_errors_teardown);
@@ -220,4 +273,6 @@ void efl_ui_test_spin_button(TCase *tc)
220 tcase_add_test(tc, spin_wraparound); 273 tcase_add_test(tc, spin_wraparound);
221 tcase_add_test(tc, spin_double_values); 274 tcase_add_test(tc, spin_double_values);
222 tcase_add_test(tc, spin_double_values_hitting_max_with_step); 275 tcase_add_test(tc, spin_double_values_hitting_max_with_step);
276 tcase_add_test(tc, spin_direct_text_input);
277 tcase_add_test(tc, spin_direct_text_input_comma_value);
223} 278}