bu5hm4n pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=d79db7c8bf7d925db9f2e1a78ad8082674b9b71d

commit d79db7c8bf7d925db9f2e1a78ad8082674b9b71d
Author: Marcel Hollerbach <[email protected]>
Date:   Tue Nov 20 18:18:04 2018 +0100

    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
---
 src/tests/elementary/elm_suite.c             | 30 ++++++++++++++++++++++++++++
 src/tests/elementary/elm_suite.h             |  1 +
 src/tests/elementary/elm_test_genlist.c      |  3 ++-
 src/tests/elementary/elm_test_widget_focus.c |  5 +----
 4 files changed, 34 insertions(+), 5 deletions(-)

diff --git a/src/tests/elementary/elm_suite.c b/src/tests/elementary/elm_suite.c
index 627bb3a105..a046e6c1b1 100644
--- a/src/tests/elementary/elm_suite.c
+++ b/src/tests/elementary/elm_suite.c
@@ -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 */
diff --git a/src/tests/elementary/elm_suite.h b/src/tests/elementary/elm_suite.h
index 651c308c3c..b12dc5eb46 100644
--- a/src/tests/elementary/elm_suite.h
+++ b/src/tests/elementary/elm_suite.h
@@ -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 */
diff --git a/src/tests/elementary/elm_test_genlist.c 
b/src/tests/elementary/elm_test_genlist.c
index af4016b023..60c9d0028a 100644
--- a/src/tests/elementary/elm_test_genlist.c
+++ b/src/tests/elementary/elm_test_genlist.c
@@ -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);
diff --git a/src/tests/elementary/elm_test_widget_focus.c 
b/src/tests/elementary/elm_test_widget_focus.c
index be5b0c79fc..ec4be8f2d3 100644
--- a/src/tests/elementary/elm_test_widget_focus.c
+++ b/src/tests/elementary/elm_test_widget_focus.c
@@ -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);

-- 


Reply via email to