elm_test: add keybinds to rapidly flip between tests
authorMike Blumenkrantz <zmike@samsung.com>
Wed, 24 Jul 2019 17:16:58 +0000 (13:16 -0400)
committerWooHyun Jung <wh0705.jung@samsung.com>
Mon, 5 Aug 2019 01:48:32 +0000 (10:48 +0900)
when not using --test-win-only, allow opening new tests forward and
backward with alt+. and alt+,

Reviewed-by: Marcel Hollerbach <mail@marcel-hollerbach.de>
Differential Revision: https://phab.enlightenment.org/D9406

src/bin/elementary/test.c

index 3222fad..8856c7c 100644 (file)
@@ -405,7 +405,7 @@ static void _list_udpate(void);
 
 static Evas_Object *win, *tbx, *entry; // TODO: refactoring
 static void *tt;
-static Eina_List *tests;
+static Eina_List *tests, *cur_test;;
 static Eina_Bool hide_legacy = EINA_FALSE;
 static Eina_Bool hide_beta = EINA_FALSE;
 
@@ -643,6 +643,32 @@ _space_removed_string_get(const char *name)
    return ret;
 }
 
+static Eina_Bool
+_my_win_key_up(void *d EINA_UNUSED, int type EINA_UNUSED, Ecore_Event_Key *ev)
+{
+   struct elm_test *t;
+
+   if (eina_streq(ev->key, "comma") && (ev->modifiers & ECORE_EVENT_MODIFIER_ALT))
+     {
+        if (cur_test)
+          cur_test = eina_list_prev(cur_test);
+        if (!cur_test)
+          cur_test = eina_list_last(tests);
+        t = eina_list_data_get(cur_test);
+        t->cb(NULL, NULL, NULL);
+     }
+   else if (eina_streq(ev->key, "period") && (ev->modifiers & ECORE_EVENT_MODIFIER_ALT))
+     {
+        if (cur_test)
+          cur_test = eina_list_next(cur_test);
+        if (!cur_test)
+          cur_test = tests;
+        t = eina_list_data_get(cur_test);
+        t->cb(NULL, NULL, NULL);
+     }
+   return ECORE_CALLBACK_RENEW;
+}
+
 static void
 my_win_main(const char *autorun, Eina_Bool test_win_only)
 {
@@ -1300,7 +1326,10 @@ add_tests:
      }
 
    if (tests)
-     _menu_create(NULL);
+     {
+        _menu_create(NULL);
+        ecore_event_handler_add(ECORE_EVENT_KEY_UP, (Ecore_Event_Handler_Cb)_my_win_key_up, NULL);
+     }
 
    /* bring in autorun frame */
    if (autorun)