Compare commits

...

6 Commits

Author SHA1 Message Date
WooHyun Jung 5866323022 tests: making infra to cover all focus tests 2017-08-04 17:31:19 +09:00
WooHyun Jung fe18465267 Merge branch 'devs/woohyun/focus_tests' of ssh://git.enlightenment.org/core/efl into devs/woohyun/focus_tests 2017-08-01 13:41:58 +09:00
WooHyun Jung ac59000ab1 tests: add elm_test_focus_legacy
In this test, you can add any test case which is based on legacy
focus APIs with elementary widgets.
2017-08-01 13:41:19 +09:00
WooHyun Jung 3aae7371f0 elm_test_focus: add a test case for focus moving 2017-08-01 13:41:19 +09:00
WooHyun Jung 3502c3658e tests: add elm_test_focus_legacy
In this test, you can add any test case which is based on legacy
focus APIs with elementary widgets.
2017-07-31 20:26:18 +09:00
WooHyun Jung 46c7350276 elm_test_focus: add a test case for focus moving 2017-07-31 19:50:19 +09:00
4 changed files with 116 additions and 1 deletions

View File

@ -1353,7 +1353,8 @@ tests_elementary_elm_suite_SOURCES = \
tests/elementary/elm_test_focus_common.c \
tests/elementary/elm_test_focus_common.h \
tests/elementary/elm_test_focus.c \
tests/elementary/elm_test_focus_sub.c
tests/elementary/elm_test_focus_sub.c \
tests/elementary/elm_test_focus_legacy.c
tests_elementary_elm_suite_CPPFLAGS = \
-DTESTS_BUILD_DIR=\"${top_builddir}/src/tests/elementary\" \

View File

@ -85,6 +85,7 @@ static const Efl_Test_Case etc[] = {
{ "elm_code_widget_undo", elm_code_test_widget_undo },
{ "elm_focus", elm_test_focus},
{ "elm_focus_sub", elm_test_focus_sub},
{ "elm_focus_legacy", elm_test_focus_legacy},
{ NULL, NULL }
};

View File

@ -71,6 +71,7 @@ void elm_test_spinner(TCase *tc);
void elm_test_plug(TCase *tc);
void elm_test_focus(TCase *tc);
void elm_test_focus_sub(TCase *tc);
void elm_test_focus_legacy(TCase *tc);
void elm_code_file_test_load(TCase *tc);
void elm_code_file_test_memory(TCase *tc);

View File

@ -0,0 +1,112 @@
#include "elm_test_focus_common.h"
// printf("[%s:%d] %p %p --- %p --- %p ----- JWH : %d\n", __func__, __LINE__,
// btn[0], btn[1], obj, elm_object_focused_object_get(obj),
// elm_object_focus_get(btn[0]));
// fflush(stdout);
// Create a window
static Evas_Object *_win_create(Evas_Object *parent, int w, int h, Eina_Bool visible);
// Window focused callback function. This should be the start point of the focus tests
static void _win_focused_cb(void *data, Evas_Object *obj, void *event_info);
// Focus Test functions
static void focus_test_next(Evas_Object *top, Evas_Object *next, Elm_Object_Item *next_item, Elm_Focus_Direction dir);
static void focus_test_next(Evas_Object *top, Evas_Object *next, Elm_Object_Item *next_item, Elm_Focus_Direction dir)
{
elm_object_focus_next(top, dir);
ck_assert(elm_object_focused_object_get(top) == next);
if (next_item)
ck_assert(elm_object_item_focus_get(next_item) == EINA_TRUE);
}
static void _win_focused_cb(void *data, Evas_Object *obj, void *event_info)
{
Evas_Object **btn = (Evas_Object **)data;
elm_object_focus_set(btn[0], EINA_TRUE);
ck_assert_int_eq(elm_object_focus_get(btn[0]), 1);
// Focus Set test
// Focus Next with API test
focus_test_next(obj, btn[1], NULL, ELM_FOCUS_RIGHT);
focus_test_next(obj, btn[2], NULL, ELM_FOCUS_DOWN);
focus_test_next(obj, btn[4], NULL, ELM_FOCUS_DOWN);
focus_test_next(obj, btn[3], NULL, ELM_FOCUS_RIGHT);
focus_test_next(obj, btn[1], NULL, ELM_FOCUS_UP);
focus_test_next(obj, btn[0], NULL, ELM_FOCUS_LEFT);
// Focus Next with Key event test
// Focus Revert test with new win show/hide
// Focus Revert test with focused object delete
elm_exit();
}
static Evas_Object *_win_create(Evas_Object *parent, int w, int h, Eina_Bool visible)
{
Evas_Object *win;
win = efl_add(EFL_UI_WIN_CLASS, NULL,
efl_text_set(efl_added, "Focus Test1"),
efl_ui_win_autodel_set(efl_added, EINA_TRUE));
efl_gfx_size_set(win, w, h);
efl_gfx_visible_set(win, visible);
return win;
}
START_TEST(focus_next_test1)
{
Evas_Object *win, *btn[2];
int i;
elm_init(1, NULL);
// creating window
win = _win_create(NULL, 500, 500, EINA_TRUE);
evas_object_smart_callback_add(win, "focused", _win_focused_cb, btn);
// creating buttons
//////////////////////////////////////////
// //
// btn1 btn2 //
// //
// //
// btn3 //
// //
// btn4 //
// //
// btn5 //
//////////////////////////////////////////
{
char *btn_str[5] = {"Button1", "Button2", "Button3", "Button4", "Button5"};
int btn_loc[5][2] = {{50, 50}, {300, 50}, {100, 250}, {350, 350}, {150, 450}};
int btn_w = 100, btn_h = 50;
for (i = 0; i < 5; i++)
{
btn[i] = efl_add(EFL_UI_BUTTON_CLASS, win,
efl_text_set(efl_added, btn_str[i]),
efl_gfx_geometry_set(efl_added,
btn_loc[i][0], btn_loc[i][1],
btn_w, btn_h),
efl_gfx_visible_set(efl_added, 1));
}
}
elm_run();
elm_shutdown();
}
END_TEST
void elm_test_focus_legacy(TCase *tc)
{
tcase_add_test(tc, focus_next_test1);
}