From: Mike Blumenkrantz Date: Mon, 28 Jan 2019 18:38:24 +0000 (-0500) Subject: tests: modify efl_ui_suite to use same test infrastructure as elm_suite X-Git-Tag: accepted/tizen/unified/20190201.061426~31 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2461910418926b706bafa506eb0c0c69aa0c864a;p=platform%2Fupstream%2Fefl.git tests: modify efl_ui_suite to use same test infrastructure as elm_suite this should enable us to begin moving efl_ui tests into the proper suite instead of sticking them all into elm_suite also move grid tests to efl_ui_suite Reviewed-by: Cedric BAIL Reviewed-by: Stefan Schmidt Differential Revision: https://phab.enlightenment.org/D7765 --- diff --git a/src/Makefile_Elementary.am b/src/Makefile_Elementary.am index 4f968d9..b2fdd7b 100644 --- a/src/Makefile_Elementary.am +++ b/src/Makefile_Elementary.am @@ -1564,6 +1564,7 @@ check_PROGRAMS += tests/elementary/elm_suite tests/elementary/efl_ui_suite TESTS += tests/elementary/elm_suite tests/elementary/efl_ui_suite tests_elementary_elm_suite_SOURCES = \ + tests/elementary/suite_helpers.c \ tests/elementary/elm_suite.c \ tests/elementary/elm_test_atspi.c \ tests/elementary/elm_test_check.c \ @@ -1646,7 +1647,6 @@ tests_elementary_elm_suite_SOURCES = \ tests/elementary/elm_test_focus_common.h \ tests/elementary/elm_test_focus.c \ tests/elementary/elm_test_focus_sub.c \ - tests/elementary/efl_ui_test_grid.c \ tests/elementary/elm_test_widget_focus.c tests_elementary_elm_suite_CPPFLAGS = \ @@ -1667,9 +1667,13 @@ tests_elementary_elm_suite_LDADD = @CHECK_LIBS@ @USE_ELEMENTARY_LIBS@ tests_elementary_elm_suite_DEPENDENCIES = @USE_ELEMENTARY_INTERNAL_LIBS@ tests_elementary_efl_ui_suite_SOURCES = \ - tests/elementary/efl_ui_suite.c + tests/elementary/suite_helpers.c \ + tests/elementary/efl_ui_suite.c \ + tests/elementary/elm_test_init.c \ + tests/elementary/efl_ui_test_grid.c tests_elementary_efl_ui_suite_CPPFLAGS = \ +-DELM_INTERNAL_API_ARGESFSDFEFC=1 \ -DPACKAGE_BUILD_DIR=\"$(abs_top_builddir)\" \ -DTESTS_BUILD_DIR=\"${top_builddir}/src/tests/elementary\" \ -DTESTS_SRC_DIR=\"${top_srcdir}/src/tests/elementary\" \ diff --git a/src/tests/elementary/efl_ui_suite.c b/src/tests/elementary/efl_ui_suite.c index c5c39bd..d257f2d 100644 --- a/src/tests/elementary/efl_ui_suite.c +++ b/src/tests/elementary/efl_ui_suite.c @@ -5,65 +5,17 @@ #define EFL_NOLEGACY_API_SUPPORT #include #include "../efl_check.h" - -EAPI_MAIN void -efl_main(void *data EINA_UNUSED, - const Efl_Event *ev) -{ - Efl_Loop_Arguments *arge = ev->info; - - fail_if(!arge->initialization); - fprintf(stderr, "ARGC %d\n", eina_array_count(arge->argv)); - fail_if(eina_array_count(arge->argv) != 2); - fail_if(!eina_streq(eina_array_data_get(arge->argv, 1), "test")); - - efl_loop_quit(ev->object, eina_value_string_init("success")); -} - -EFL_START_TEST(efl_ui_test_init) -{ - /* EFL_MAIN */ - Eina_Value *ret__; - int real__; - - int argc = 2; - char *argv[] = { "efl_ui_suite", "test" }; - _efl_startup_time = ecore_time_unix_get(); - _EFL_APP_VERSION_SET(); - fail_if(!ecore_init()); - efl_event_callback_add(efl_app_main_get(EFL_APP_CLASS), EFL_LOOP_EVENT_ARGUMENTS, efl_main, NULL); - fail_if(!ecore_init_ex(argc, argv)); - __EFL_MAIN_CONSTRUCTOR; - ret__ = efl_loop_begin(efl_app_main_get(EFL_APP_CLASS)); - real__ = efl_loop_exit_code_process(ret__); - fail_if(real__ != 0); - __EFL_MAIN_DESTRUCTOR; - ecore_shutdown_ex(); - ecore_shutdown(); -} -EFL_END_TEST - -void efl_ui_test(TCase *tc) -{ - tcase_add_test(tc, efl_ui_test_init); -} - +#include "efl_ui_suite.h" +#include "suite_helpers.h" static const Efl_Test_Case etc[] = { - { "Efl_Ui", efl_ui_test }, + //{ "elm_focus", elm_test_focus}, + //{ "elm_focus_sub", elm_test_focus_sub}, + //{ "elm_widget_focus", elm_test_widget_focus}, + { "efl_ui_grid", efl_ui_test_grid}, { NULL, NULL } }; -SUITE_INIT(efl_ui) -{ - //??? -} - -SUITE_SHUTDOWN(efl_ui) -{ - -} - int main(int argc, char **argv) { @@ -72,12 +24,10 @@ main(int argc, char **argv) if (!_efl_test_option_disp(argc, argv, etc)) return 0; -#ifdef NEED_RUN_IN_TREE - putenv("EFL_RUN_IN_TREE=1"); -#endif + failed_count = suite_setup(EINA_FALSE); - failed_count = _efl_suite_build_and_run(argc - 1, (const char **)argv + 1, - "Efl_Ui", etc, SUITE_INIT_FN(efl_ui), SUITE_SHUTDOWN_FN(efl_ui)); + failed_count += _efl_suite_build_and_run(argc - 1, (const char **)argv + 1, + "Efl_Ui", etc, SUITE_INIT_FN(elm2), SUITE_SHUTDOWN_FN(elm)); return (failed_count == 0) ? 0 : 255; } diff --git a/src/tests/elementary/efl_ui_suite.h b/src/tests/elementary/efl_ui_suite.h new file mode 100644 index 0000000..a077bc3 --- /dev/null +++ b/src/tests/elementary/efl_ui_suite.h @@ -0,0 +1,23 @@ +#ifndef EFL_UI_SUITE_H +#define EFL_UI_SUITE_H + +#include +#include "../efl_check.h" +#define ck_assert_strn_eq(s1, s2, len) \ + { \ + char expected[len+1], actual[len+1]; \ + \ + strncpy(expected, s1, len); \ + expected[len] = '\0'; \ + strncpy(actual, s2, len); \ + actual[len] = '\0'; \ + \ + ck_assert_str_eq(expected, actual); \ + } + +#include +void efl_ui_test_grid(TCase *tc); + +Eo *win_add(); +Eo *win_add_focused(); +#endif diff --git a/src/tests/elementary/efl_ui_test_grid.c b/src/tests/elementary/efl_ui_test_grid.c index 5fbadf9..55e21e4 100644 --- a/src/tests/elementary/efl_ui_test_grid.c +++ b/src/tests/elementary/efl_ui_test_grid.c @@ -4,33 +4,22 @@ #define EFL_ACCESS_OBJECT_BETA #include -#include "elm_suite.h" +#include "efl_ui_suite.h" -static Eo *win, *box; +static Eo *win; static Efl_Ui_Grid *grid; static void grid_setup() { - //win = win_add(); - win = efl_add(EFL_UI_WIN_CLASS, efl_main_loop_get(), - efl_ui_win_type_set(efl_added, EFL_UI_WIN_BASIC), - efl_text_set(efl_added, "Efl.Ui.Grid"), - efl_ui_win_autodel_set(efl_added, EINA_TRUE)); - box = efl_add(EFL_UI_BOX_CLASS, win, - efl_ui_direction_set(efl_added, EFL_UI_DIR_VERTICAL)); - efl_gfx_size_hint_weight_set(box, EFL_GFX_SIZE_HINT_EXPAND, EFL_GFX_SIZE_HINT_EXPAND); - efl_gfx_size_hint_fill_set(box, EINA_TRUE, EINA_TRUE); - elm_win_resize_object_add(win, box); - - grid = efl_add(EFL_UI_GRID_CLASS, box); + win = win_add(); - efl_ui_grid_item_size_set(grid, EINA_SIZE2D(100, 100)); - efl_pack_padding_set(grid, 5.0, 5.0, EINA_TRUE); - efl_pack_align_set(grid, 0.5, 0.5); - efl_pack_end(box, grid); + grid = efl_add(EFL_UI_GRID_CLASS, win); - efl_gfx_entity_size_set(win, EINA_SIZE2D(500, 500)); + efl_ui_grid_item_size_set(grid, EINA_SIZE2D(100, 100)); + efl_gfx_entity_size_set(grid, EINA_SIZE2D(500, 50)); + efl_gfx_entity_size_set(win, EINA_SIZE2D(500, 50)); + efl_gfx_entity_visible_set(win, EINA_TRUE); } static void diff --git a/src/tests/elementary/elm_suite.c b/src/tests/elementary/elm_suite.c index a046e6c..17bfeae 100644 --- a/src/tests/elementary/elm_suite.c +++ b/src/tests/elementary/elm_suite.c @@ -5,12 +5,7 @@ #include #include "elm_suite.h" #include "../efl_check.h" -#include "elm_widget.h" - -static int main_pid = -1; -static Eina_Bool did_shutdown; -static Evas_Object *global_win; -static Eina_Bool buffer = EINA_FALSE; +#include "suite_helpers.h" static const Efl_Test_Case etc[] = { { "elm_config", elm_test_config }, @@ -91,126 +86,9 @@ static const Efl_Test_Case etc[] = { { "elm_focus", elm_test_focus}, { "elm_focus_sub", elm_test_focus_sub}, { "elm_widget_focus", elm_test_widget_focus}, -/* FIXME : This test must move efl_ui_suite when it ready * - * EFL_UI_TEST BEGIN */ - { "efl_ui_grid", efl_ui_test_grid}, -/* EFL_UI_TEST END */ { NULL, NULL } }; -SUITE_INIT(elm) -{ - char *args[] = { "exe" }; - ck_assert_int_eq(elm_init(1, args), 1); -} - -SUITE_INIT(elm2) -{ - char *args[] = { "exe" }; - - if (getpid() != main_pid) - { - ecore_fork_reset(); - return; - } - if (!did_shutdown) - { - /* if running un-forked then remove cached init */ - ck_assert_int_eq(elm_shutdown(), 0); - did_shutdown = 1; - } - ck_assert_int_eq(elm_init(1, args), 1); -} - -SUITE_SHUTDOWN(elm) -{ - ck_assert_int_eq(elm_shutdown(), 0); - /* verify that ecore was de-initialized completely */ - ck_assert_int_eq(ecore_init(), 1); - /* avoid slowdowns in fork mode */ - if (getpid() != main_pid) return; - ck_assert_int_eq(ecore_shutdown(), 0); -} - - -static const Efl_Test_Case etc_init[] = { - { "init", elm_test_init }, - { NULL, NULL } -}; - -#define BUFFER_RENDER_INTERVAL 0.002 - -static Eina_Bool -_win_manual_render(void *data) -{ - ecore_animator_custom_tick(); - evas_norender(evas_object_evas_get(data)); - return EINA_TRUE; -} - -static void -_win_show(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED) -{ - evas_object_data_set(obj, "timer", ecore_timer_add(BUFFER_RENDER_INTERVAL, _win_manual_render, obj)); -} - -static void -_win_hide(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED) -{ - ecore_timer_del(evas_object_data_del(obj, "timer")); -} - -static Evas_Object * -_elm_suite_win_create() -{ - Evas_Object *win = elm_win_add(NULL, "elm_suite", ELM_WIN_BASIC); - if (!buffer) return win; - ecore_evas_manual_render_set(ecore_evas_ecore_evas_get(evas_object_evas_get(win)), EINA_TRUE); - edje_frametime_set(BUFFER_RENDER_INTERVAL); - ecore_animator_source_set(ECORE_ANIMATOR_SOURCE_CUSTOM); - evas_object_event_callback_add(win, EVAS_CALLBACK_SHOW, _win_show, NULL); - evas_object_event_callback_add(win, EVAS_CALLBACK_HIDE, _win_hide, NULL); - return win; -} - -Evas_Object * -win_add() -{ - if (getpid() != main_pid) - { - if (global_win) return global_win; - } - return _elm_suite_win_create(); -} - -static void -force_focus_win(Evas_Object *win) -{ - Ecore_Evas *ee; - - ee = ecore_evas_ecore_evas_get(evas_object_evas_get(win)); - ecore_evas_focus_set(ee, EINA_TRUE); - ecore_evas_callback_focus_in_set(ee, NULL); - ecore_evas_callback_focus_out_set(ee, NULL); - Elm_Widget_Smart_Data *pd = efl_data_scope_safe_get(win, EFL_UI_WIDGET_CLASS); - pd->top_win_focused = EINA_TRUE; -} - -Evas_Object * -win_add_focused() -{ - Evas_Object *win; - - if (getpid() != main_pid) - { - if (global_win) return global_win; - } - - win = _elm_suite_win_create(); - force_focus_win(win); - return win; -} - int main(int argc, char **argv) { @@ -219,51 +97,7 @@ main(int argc, char **argv) if (!_efl_test_option_disp(argc, argv, etc)) return 0; -#ifdef NEED_RUN_IN_TREE - putenv("EFL_RUN_IN_TREE=1"); -#endif - if (!getenv("ELM_ENGINE")) - putenv("ELM_ENGINE=buffer"); - if (eina_streq(getenv("ELM_ENGINE"), "buffer")) - { - putenv("TESTS_GL_DISABLED=1"); - buffer = EINA_TRUE; - } - - main_pid = getpid(); - ecore_app_no_system_modules(); - efreet_cache_disable(); - - failed_count = _efl_suite_build_and_run(argc - 1, (const char **)argv + 1, - "Elementary_Init", etc_init, SUITE_INIT_FN(elm), SUITE_SHUTDOWN_FN(elm)); - failed_count += !elm_init(1, (char*[]){"exe"}); - if (buffer) - { - global_win = _elm_suite_win_create(); - force_focus_win(global_win); - } - EINA_SAFETY_ON_TRUE_RETURN_VAL(failed_count, 255); - /* preload default theme */ - failed_count += !elm_theme_group_path_find(NULL, "elm/button/base/default"); - EINA_SAFETY_ON_TRUE_RETURN_VAL(failed_count, 255); - failed_count += !elm_theme_group_path_find(NULL, "elm/border/base/default"); - EINA_SAFETY_ON_TRUE_RETURN_VAL(failed_count, 255); - failed_count += !elm_theme_group_path_find(NULL, "elm/win/base/default"); - EINA_SAFETY_ON_TRUE_RETURN_VAL(failed_count, 255); - - /* none of these will be found in the default theme, - * but all are "fetched" hundreds of times - * T6865 - */ - elm_theme_group_path_find(NULL, "elm/cursor/top_side/default"); - elm_theme_group_path_find(NULL, "elm/cursor/bottom_side/default"); - elm_theme_group_path_find(NULL, "elm/cursor/top_left_corner/default"); - elm_theme_group_path_find(NULL, "elm/cursor/bottom_left_corner/default"); - elm_theme_group_path_find(NULL, "elm/cursor/top_right_corner/default"); - elm_theme_group_path_find(NULL, "elm/cursor/bottom_right_corner/default"); - - - elm_theme_group_path_find(NULL, "elm/colorselector/item/color/default"); + failed_count = suite_setup(EINA_TRUE); failed_count += _efl_suite_build_and_run(argc - 1, (const char **)argv + 1, "Elementary", etc, SUITE_INIT_FN(elm2), SUITE_SHUTDOWN_FN(elm)); diff --git a/src/tests/elementary/elm_suite.h b/src/tests/elementary/elm_suite.h index b12dc5e..34257ac 100644 --- a/src/tests/elementary/elm_suite.h +++ b/src/tests/elementary/elm_suite.h @@ -16,7 +16,7 @@ } #include -void elm_test_init(TCase *tc); + void elm_test_config(TCase *tc); void elm_test_check(TCase *tc); void elm_test_colorselector(TCase *tc); @@ -84,10 +84,6 @@ void elm_test_plug(TCase *tc); void elm_test_focus(TCase *tc); void elm_test_focus_sub(TCase *tc); void elm_test_widget_focus(TCase *tc); -/* FIXME : This test must move efl_ui_suite when it ready * - * EFL_UI_TEST BEGIN */ -void efl_ui_test_grid(TCase *tc); -/* EFL_UI_TEST END */ void elm_code_file_test_load(TCase *tc); void elm_code_file_test_memory(TCase *tc); diff --git a/src/tests/elementary/meson.build b/src/tests/elementary/meson.build index b8c030b..36db763 100644 --- a/src/tests/elementary/meson.build +++ b/src/tests/elementary/meson.build @@ -19,6 +19,7 @@ endforeach elementary_suite_src = [ 'elm_suite.c', + 'suite_helpers.c', 'elm_test_atspi.c', 'elm_test_check.c', 'elm_test_colorselector.c', @@ -100,7 +101,6 @@ elementary_suite_src = [ 'elm_test_focus_common.h', 'elm_test_focus.c', 'elm_test_focus_sub.c', - 'efl_ui_test_grid.c', 'elm_test_widget_focus.c' ] @@ -118,6 +118,9 @@ elementary_suite = executable('elementary_suite', efl_ui_suite_src = [ 'efl_ui_suite.c', + 'suite_helpers.c', + 'elm_test_init.c', + 'efl_ui_test_grid.c', ] efl_ui_suite = executable('efl_ui_suite', diff --git a/src/tests/elementary/suite_helpers.c b/src/tests/elementary/suite_helpers.c new file mode 100644 index 0000000..e6a8cfe --- /dev/null +++ b/src/tests/elementary/suite_helpers.c @@ -0,0 +1,305 @@ +#ifdef HAVE_CONFIG_H +# include "elementary_config.h" +#endif +#include +#include +#include +#include "../efl_check.h" +#include "elm_widget.h" + +static int main_pid = -1; +static Eina_Bool did_shutdown; +static Evas_Object *global_win; +static Eina_Bool buffer = EINA_FALSE; +static Eina_Bool legacy_mode = EINA_FALSE; + +void elm_test_init(TCase *tc); + +SUITE_INIT(elm) +{ + char *args[] = { "exe" }; + ck_assert_int_eq(elm_init(1, args), 1); +} + +void +_elm2_suite_init(void) +{ + char *args[] = { "exe" }; + + if (getpid() != main_pid) + { + ecore_fork_reset(); + return; + } + if (!did_shutdown) + { + /* if running un-forked then remove cached init */ + ck_assert_int_eq(elm_shutdown(), 0); + did_shutdown = 1; + } + ck_assert_int_eq(elm_init(1, args), 1); +} + +void +_elm_suite_shutdown(void) +{ + ck_assert_int_eq(elm_shutdown(), 0); + /* verify that ecore was de-initialized completely */ + ck_assert_int_eq(ecore_init(), 1); + /* avoid slowdowns in fork mode */ + if (getpid() != main_pid) return; + ck_assert_int_eq(ecore_shutdown(), 0); +} + + +static const Efl_Test_Case etc_init[] = { + { "init", elm_test_init }, + { NULL, NULL } +}; + + +EAPI_MAIN void +efl_main(void *data EINA_UNUSED, + const Efl_Event *ev) +{ + Efl_Loop_Arguments *arge = ev->info; + + + fail_if(!arge->initialization); + fprintf(stderr, "ARGC %d\n", eina_array_count(arge->argv)); + fail_if(eina_array_count(arge->argv) != 2); + fail_if(!eina_streq(eina_array_data_get(arge->argv, 1), "test")); + + efl_loop_quit(ev->object, eina_value_string_init("success")); +} + +EFL_START_TEST(efl_ui_test_init) +{ + /* EFL_MAIN */ + Eina_Value *ret__; + int real__; + + int argc = 2; + char *argv[] = { "efl_ui_suite", "test" }; + _efl_startup_time = ecore_time_unix_get(); + _EFL_APP_VERSION_SET(); + fail_if(!ecore_init()); + efl_event_callback_add(efl_app_main_get(EFL_APP_CLASS), EFL_LOOP_EVENT_ARGUMENTS, efl_main, NULL); + fail_if(!ecore_init_ex(argc, argv)); + __EFL_MAIN_CONSTRUCTOR; + ret__ = efl_loop_begin(efl_app_main_get(EFL_APP_CLASS)); + real__ = efl_loop_exit_code_process(ret__); + fail_if(real__ != 0); + __EFL_MAIN_DESTRUCTOR; + ecore_shutdown_ex(); + ecore_shutdown(); +} +EFL_END_TEST + +void efl_ui_init(TCase *tc) +{ + tcase_add_test(tc, efl_ui_test_init); +} + + +static const Efl_Test_Case ui_init[] = { + { "init", efl_ui_init }, + { NULL, NULL } +}; + +#define BUFFER_RENDER_INTERVAL 0.002 + +static void +_ui_win_manual_render(void *data, const Efl_Event *ev EINA_UNUSED) +{ + ecore_animator_custom_tick(); + evas_norender(evas_object_evas_get(data)); +} + +static Eina_Bool +_win_manual_render(void *data) +{ + ecore_animator_custom_tick(); + evas_norender(evas_object_evas_get(data)); + return EINA_TRUE; +} + +static void +_ui_win_show(void *data EINA_UNUSED, const Efl_Event *ev) +{ + Eo *timer = efl_add(EFL_LOOP_TIMER_CLASS, ev->object, + efl_event_callback_add(efl_added, EFL_LOOP_TIMER_EVENT_TICK, _ui_win_manual_render, ev->object), + efl_loop_timer_interval_set(efl_added, BUFFER_RENDER_INTERVAL) + ); + efl_key_data_set(ev->object, "timer", timer); +} + +static void +_ui_win_hide(void *data EINA_UNUSED, const Efl_Event *ev) +{ + efl_del(efl_key_data_get(ev->object, "timer")); + efl_key_data_set(ev->object, "timer", NULL); +} + +static void +_win_show(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED) +{ + evas_object_data_set(obj, "timer", ecore_timer_add(BUFFER_RENDER_INTERVAL, _win_manual_render, obj)); +} + +static void +_win_hide(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED) +{ + ecore_timer_del(evas_object_data_del(obj, "timer")); +} + +static Evas_Object * +_elm_suite_win_create() +{ + Evas_Object *win; + + if (legacy_mode) + win = elm_win_add(NULL, "elm_suite", ELM_WIN_BASIC); + else + win = efl_add(EFL_UI_WIN_CLASS, efl_main_loop_get(), efl_ui_win_type_set(efl_added, EFL_UI_WIN_BASIC)); + if (!buffer) return win; + ecore_evas_manual_render_set(ecore_evas_ecore_evas_get(evas_object_evas_get(win)), EINA_TRUE); + edje_frametime_set(BUFFER_RENDER_INTERVAL); + ecore_animator_source_set(ECORE_ANIMATOR_SOURCE_CUSTOM); + if (legacy_mode) + { + evas_object_event_callback_add(win, EVAS_CALLBACK_SHOW, _win_show, NULL); + evas_object_event_callback_add(win, EVAS_CALLBACK_HIDE, _win_hide, NULL); + } + else + { + efl_event_callback_add(win, EFL_GFX_ENTITY_EVENT_SHOW, _ui_win_show, NULL); + efl_event_callback_add(win, EFL_GFX_ENTITY_EVENT_HIDE, _ui_win_hide, NULL); + } + return win; +} + +Evas_Object * +win_add() +{ + if (getpid() != main_pid) + { + if (global_win) return global_win; + } + return _elm_suite_win_create(); +} + +static void +force_focus_win(Evas_Object *win) +{ + Ecore_Evas *ee; + + ee = ecore_evas_ecore_evas_get(evas_object_evas_get(win)); + ecore_evas_focus_set(ee, EINA_TRUE); + ecore_evas_callback_focus_in_set(ee, NULL); + ecore_evas_callback_focus_out_set(ee, NULL); + Elm_Widget_Smart_Data *pd = efl_data_scope_safe_get(win, EFL_UI_WIDGET_CLASS); + pd->top_win_focused = EINA_TRUE; +} + +Evas_Object * +win_add_focused() +{ + Evas_Object *win; + + if (getpid() != main_pid) + { + if (global_win) return global_win; + } + + win = _elm_suite_win_create(); + force_focus_win(win); + return win; +} + +int +suite_setup(Eina_Bool legacy) +{ + int failed_count; + + legacy_mode = legacy; + +#ifdef NEED_RUN_IN_TREE + putenv("EFL_RUN_IN_TREE=1"); +#endif + if (!getenv("ELM_ENGINE")) + putenv("ELM_ENGINE=buffer"); + if (eina_streq(getenv("ELM_ENGINE"), "buffer")) + { + putenv("TESTS_GL_DISABLED=1"); + buffer = EINA_TRUE; + } + + main_pid = getpid(); + ecore_app_no_system_modules(); + efreet_cache_disable(); + + if (legacy) + failed_count = _efl_suite_build_and_run(0, NULL, + "Elementary_Init", etc_init, SUITE_INIT_FN(elm), SUITE_SHUTDOWN_FN(elm)); + else + failed_count = _efl_suite_build_and_run(0, NULL, + "Efl_Ui_Init", ui_init, NULL, NULL); + + failed_count += !elm_init(1, (char*[]){"exe"}); + if (buffer) + { + global_win = _elm_suite_win_create(); + force_focus_win(global_win); + } + EINA_SAFETY_ON_TRUE_RETURN_VAL(failed_count, 255); + /* preload default theme */ + if (legacy) + { + failed_count += !elm_theme_group_path_find(NULL, "elm/button/base/default"); + EINA_SAFETY_ON_TRUE_RETURN_VAL(failed_count, 255); + failed_count += !elm_theme_group_path_find(NULL, "elm/border/base/default"); + EINA_SAFETY_ON_TRUE_RETURN_VAL(failed_count, 255); + failed_count += !elm_theme_group_path_find(NULL, "elm/win/base/default"); + EINA_SAFETY_ON_TRUE_RETURN_VAL(failed_count, 255); + } + else + { + failed_count += !elm_theme_group_path_find(NULL, "efl/button"); + EINA_SAFETY_ON_TRUE_RETURN_VAL(failed_count, 255); + failed_count += !elm_theme_group_path_find(NULL, "efl/border"); + EINA_SAFETY_ON_TRUE_RETURN_VAL(failed_count, 255); + failed_count += !elm_theme_group_path_find(NULL, "efl/win"); + EINA_SAFETY_ON_TRUE_RETURN_VAL(failed_count, 255); + } + + /* none of these will be found in the default theme, + * but all are "fetched" hundreds of times + * T6865 + */ + if (legacy) + { + elm_theme_group_path_find(NULL, "elm/cursor/top_side/default"); + elm_theme_group_path_find(NULL, "elm/cursor/bottom_side/default"); + elm_theme_group_path_find(NULL, "elm/cursor/top_left_corner/default"); + elm_theme_group_path_find(NULL, "elm/cursor/bottom_left_corner/default"); + elm_theme_group_path_find(NULL, "elm/cursor/top_right_corner/default"); + elm_theme_group_path_find(NULL, "elm/cursor/bottom_right_corner/default"); + + + elm_theme_group_path_find(NULL, "elm/colorselector/item/color/default"); + } + else + { + elm_theme_group_path_find(NULL, "efl/cursor/top_side"); + elm_theme_group_path_find(NULL, "efl/cursor/bottom_side"); + elm_theme_group_path_find(NULL, "efl/cursor/top_left_corner"); + elm_theme_group_path_find(NULL, "efl/cursor/bottom_left_corner"); + elm_theme_group_path_find(NULL, "efl/cursor/top_right_corner"); + elm_theme_group_path_find(NULL, "efl/cursor/bottom_right_corner"); + + + elm_theme_group_path_find(NULL, "efl/colorselector/item/color"); + } + return 0; +} diff --git a/src/tests/elementary/suite_helpers.h b/src/tests/elementary/suite_helpers.h new file mode 100644 index 0000000..ae49265 --- /dev/null +++ b/src/tests/elementary/suite_helpers.h @@ -0,0 +1,10 @@ +#ifndef SUITE_HELPERS_H +#define SUITE_HELPERS_H + +#include + +int suite_setup(Eina_Bool legacy); +void _elm2_suite_init(void); +void _elm_suite_shutdown(void); + +#endif