forked from enlightenment/efl
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
This commit is contained in:
parent
d48941c783
commit
f62cee28cb
|
@ -3,6 +3,7 @@
|
|||
#endif
|
||||
|
||||
#include <Elementary.h>
|
||||
#include "elm_entry_eo.h" //needed to check that spin is in text mode
|
||||
#include <Efl_Ui.h>
|
||||
#include "efl_ui_suite.h"
|
||||
|
||||
|
@ -192,6 +193,56 @@ EFL_START_TEST (spin_double_values)
|
|||
}
|
||||
EFL_END_TEST
|
||||
|
||||
static inline void
|
||||
_try_direct_text_input(const char *text, double result)
|
||||
{
|
||||
Eo *entry = efl_content_get(efl_part(spin, "efl.entry"));
|
||||
ck_assert_int_eq(efl_isa(entry, ELM_ENTRY_CLASS), 1);
|
||||
|
||||
write_key_sequence(spin, text);
|
||||
efl_ui_focus_util_focus(efl_content_get(efl_part(spin, "efl.inc_button")));
|
||||
if (EINA_DBL_EQ(efl_ui_range_value_get(spin), result) != 1)
|
||||
ck_assert_msg("Double %g does not match %g", efl_ui_range_value_get(spin), result);
|
||||
}
|
||||
|
||||
EFL_START_TEST (spin_direct_text_input)
|
||||
{
|
||||
efl_ui_spin_button_direct_text_input_set(spin, EINA_TRUE);
|
||||
efl_ui_range_limits_set(spin, -30, 30);
|
||||
efl_ui_range_value_set(spin, 20);
|
||||
efl_ui_focus_util_focus(efl_content_get(efl_part(spin, "efl.text_button")));
|
||||
DISABLE_ABORT_ON_CRITICAL_START; //FIXME there is a bug in the cnp handling code
|
||||
get_me_to_those_events(spin);
|
||||
DISABLE_ABORT_ON_CRITICAL_END;
|
||||
|
||||
_try_direct_text_input("1asdf2", 12);
|
||||
_try_direct_text_input("1-2", 12);
|
||||
_try_direct_text_input("-12", -12);
|
||||
_try_direct_text_input("-100", -30);
|
||||
_try_direct_text_input("10.8", 10);
|
||||
_try_direct_text_input("12342435", 30);
|
||||
}
|
||||
EFL_END_TEST
|
||||
|
||||
EFL_START_TEST (spin_direct_text_input_comma_value)
|
||||
{
|
||||
efl_ui_spin_button_direct_text_input_set(spin, EINA_TRUE);
|
||||
efl_ui_range_limits_set(spin, -30, 30);
|
||||
efl_ui_range_value_set(spin, 20);
|
||||
efl_ui_format_string_set(spin, "%.2f", EFL_UI_FORMAT_STRING_TYPE_SIMPLE);
|
||||
efl_ui_focus_util_focus(efl_content_get(efl_part(spin, "efl.text_button")));
|
||||
DISABLE_ABORT_ON_CRITICAL_START; //FIXME there is a bug in the cnp handling code
|
||||
get_me_to_those_events(spin);
|
||||
DISABLE_ABORT_ON_CRITICAL_END;
|
||||
|
||||
_try_direct_text_input("1asdf2.1", 12.1);
|
||||
_try_direct_text_input("1-2.2", 12.2);
|
||||
_try_direct_text_input("-12.8", -12.8);
|
||||
_try_direct_text_input("-100", -30);
|
||||
_try_direct_text_input("10.8", 10.8);
|
||||
_try_direct_text_input("12342435.12312341342", 30);
|
||||
}
|
||||
EFL_END_TEST
|
||||
void efl_ui_test_spin_button(TCase *tc)
|
||||
{
|
||||
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)
|
|||
tcase_add_test(tc, spin_value_dec_min);
|
||||
tcase_add_test(tc, spin_wraparound);
|
||||
tcase_add_test(tc, spin_double_values);
|
||||
tcase_add_test(tc, spin_direct_text_input);
|
||||
tcase_add_test(tc, spin_direct_text_input_comma_value);
|
||||
}
|
||||
|
|
|
@ -618,3 +618,16 @@ drag_object(Eo *obj, int x, int y, int dx, int dy, Eina_Bool iterate)
|
|||
evas_event_feed_mouse_move(e, x + dx, y + dy, 0, NULL);
|
||||
evas_event_feed_mouse_up(e, 1, 0, 0, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
write_key_sequence(Eo *obj, const char *seqence)
|
||||
{
|
||||
Evas *e = evas_object_evas_get(obj);
|
||||
for (unsigned int i = 0; i < strlen(seqence); ++i)
|
||||
{
|
||||
const char part_seq[] = {seqence[i], '\0'};
|
||||
evas_event_feed_key_down(e, part_seq, part_seq, part_seq, part_seq, 0, NULL);
|
||||
evas_event_feed_key_up(e, part_seq, part_seq, part_seq, part_seq, 0, NULL);
|
||||
ecore_main_loop_iterate();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ void click_part(Eo *obj, const char *part);
|
|||
void click_part_flags(Eo *obj, const char *part, int flags);
|
||||
void click_object_at(Eo *obj, int x, int y);
|
||||
void click_object_at_flags(Eo *obj, int x, int y, int flags);
|
||||
void write_key_sequence(Eo *obj, const char *seqence);
|
||||
void drag_object(Eo *obj, int x, int y, int dx, int dy, Eina_Bool iterate);
|
||||
void wheel_object(Eo *obj, Eina_Bool horiz, Eina_Bool down);
|
||||
void wheel_part(Eo *obj, const char *part, Eina_Bool horiz, Eina_Bool down);
|
||||
|
|
Loading…
Reference in New Issue