elm-test: simulate focus on the window

we cannot rely on the compositor to actaully get focus.
However, a few widgets are only doing focus operations if they can get
focus, if not they do nothing. Which effectifility turns off every focus
operation if you don't have compositor focus. In order to work arround
this, we are getting the ee, NULL out the callbacks, so the window does
not know about the the *real* compositor focus, after that we manully
say that the root object has focus, so normal operations can be
performed again.

Differential Revision: https://phab.enlightenment.org/D7311
This commit is contained in:
Marcel Hollerbach 2018-11-20 18:18:04 +01:00
parent 1524c94180
commit d79db7c8bf
4 changed files with 34 additions and 5 deletions

View File

@ -5,6 +5,7 @@
#include <Elementary.h>
#include "elm_suite.h"
#include "../efl_check.h"
#include "elm_widget.h"
static int main_pid = -1;
static Eina_Bool did_shutdown;
@ -182,6 +183,34 @@ win_add()
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)
{
@ -211,6 +240,7 @@ main(int argc, char **argv)
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 */

View File

@ -103,5 +103,6 @@ void elm_code_test_widget_selection(TCase *tc);
void elm_code_test_widget_undo(TCase *tc);
Evas_Object *win_add();
Evas_Object *win_add_focused();
#endif /* _ELM_SUITE_H */

View File

@ -477,7 +477,8 @@ EFL_START_TEST (elm_genlist_test_focus_state)
Elm_Object_Item *it;
Evas_Object *btn;
win = win_add(NULL, "genlist", ELM_WIN_BASIC);
win = win_add_focused(NULL, "genlist", ELM_WIN_BASIC);
evas_object_show(win);
btn = elm_button_add(win);

View File

@ -150,13 +150,10 @@ _eventing_test(void *data, Evas_Object *obj, void *event_info)
EFL_START_TEST (elm_test_widget_focus_simple_widget)
{
Evas_Object *win, *box, *resettor, *o;
Ecore_Evas *ee;
Eina_Hash *map;
map = eina_hash_string_small_new(NULL);
win = win_add(NULL, "focus test", ELM_WIN_BASIC);
ee = ecore_evas_ecore_evas_get(evas_object_evas_get(win));
ecore_evas_focus_set(ee, EINA_TRUE);
win = win_add_focused(NULL, "focus test", ELM_WIN_BASIC);
box = elm_box_add(win);
elm_win_resize_object_add(win, box);