[evolution/wip/webkit2] Add --cmd-delay=ms argument to test-html-editor-units



commit 9ad039d412a891c6876acba71cf5173396a2a15f
Author: Milan Crha <mcrha redhat com>
Date:   Wed Jun 22 10:18:00 2016 +0200

    Add --cmd-delay=ms argument to test-html-editor-units

 e-util/test-html-editor-units-utils.c |   26 ++++++++++++++++++++------
 e-util/test-html-editor-units-utils.h |    5 ++++-
 e-util/test-html-editor-units.c       |   24 ++++++++++++++++++++++++
 3 files changed, 48 insertions(+), 7 deletions(-)
---
diff --git a/e-util/test-html-editor-units-utils.c b/e-util/test-html-editor-units-utils.c
index aa9a247..0cf021a 100644
--- a/e-util/test-html-editor-units-utils.c
+++ b/e-util/test-html-editor-units-utils.c
@@ -25,6 +25,20 @@
 
 #include "test-html-editor-units-utils.h"
 
+static guint event_processing_delay_ms = 5;
+
+void
+test_utils_set_event_processing_delay_ms (guint value)
+{
+       event_processing_delay_ms = value;
+}
+
+guint
+test_utils_get_event_processing_delay_ms (void)
+{
+       return event_processing_delay_ms;
+}
+
 typedef struct _UndoContent {
        gchar *html;
        gchar *plain;
@@ -309,7 +323,7 @@ test_utils_send_key_event (GtkWidget *widget,
 
        gtk_main_do_event (event);
 
-       test_utils_wait_milliseconds (5);
+       test_utils_wait_milliseconds (event_processing_delay_ms);
 
        gdk_event_free (event);
 }
@@ -342,7 +356,7 @@ test_utils_type_text (TestFixture *fixture,
                test_utils_send_key_event (widget, GDK_KEY_RELEASE, keyval, 0);
        }
 
-       test_utils_wait_milliseconds (5);
+       test_utils_wait_milliseconds (event_processing_delay_ms);
 
        return TRUE;
 }
@@ -510,7 +524,7 @@ test_utils_process_sequence (TestFixture *fixture,
                state = change_state;
        }
 
-       test_utils_wait_milliseconds (5);
+       test_utils_wait_milliseconds (event_processing_delay_ms);
 
        return success;
 }
@@ -700,20 +714,20 @@ test_utils_process_commands (TestFixture *fixture,
                                success = FALSE;
                        }
 
-                       test_utils_wait_milliseconds (500);
+                       test_utils_wait_milliseconds (event_processing_delay_ms);
                } else if (*command) {
                        g_warning ("%s: Unknown command '%s'", G_STRFUNC, command);
                        success = FALSE;
                }
 
-               test_utils_wait_milliseconds (5);
+               test_utils_wait_milliseconds (event_processing_delay_ms);
        }
 
        g_strfreev (cmds);
 
        if (success) {
                /* Give the editor some time to finish any ongoing async operations */
-               test_utils_wait_milliseconds (100);
+               test_utils_wait_milliseconds (MAX (event_processing_delay_ms, 100));
        }
 
        return success;
diff --git a/e-util/test-html-editor-units-utils.h b/e-util/test-html-editor-units-utils.h
index dc1083d..3baaeb1 100644
--- a/e-util/test-html-editor-units-utils.h
+++ b/e-util/test-html-editor-units-utils.h
@@ -28,6 +28,10 @@ typedef struct _TestFixture {
        GSList *undo_stack; /* UndoContent * */
 } TestFixture;
 
+void           test_utils_set_event_processing_delay_ms
+                                               (guint value);
+guint          test_utils_get_event_processing_delay_ms
+                                               (void);
 void           test_utils_fixture_set_up       (TestFixture *fixture,
                                                 gconstpointer user_data);
 void           test_utils_fixture_tear_down    (TestFixture *fixture,
@@ -37,7 +41,6 @@ gboolean      test_utils_async_call_wait      (gpointer async_data,
                                                 guint timeout_seconds);
 gboolean       test_utils_async_call_finish    (gpointer async_data);
 gboolean       test_utils_wait_milliseconds    (guint milliseconds);
-
 gboolean       test_utils_type_text            (TestFixture *fixture,
                                                 const gchar *text);
 gboolean       test_utils_html_equal           (TestFixture *fixture,
diff --git a/e-util/test-html-editor-units.c b/e-util/test-html-editor-units.c
index 070c63d..dc2829e 100644
--- a/e-util/test-html-editor-units.c
+++ b/e-util/test-html-editor-units.c
@@ -188,6 +188,16 @@ gint
 main (gint argc,
       gchar *argv[])
 {
+       gint cmd_delay = -1;
+       GOptionEntry entries[] = {
+               { "cmd-delay", '\0', 0,
+                 G_OPTION_ARG_INT, &cmd_delay,
+                 "Specify delay, in milliseconds, to use during processing commands. Default is 5 ms.",
+                 NULL },
+               { NULL }
+       };
+       GOptionContext *context;
+       GError *error = NULL;
        GList *modules;
        gint res;
 
@@ -198,6 +208,20 @@ main (gint argc,
 
        gtk_init (&argc, &argv);
 
+       context = g_option_context_new (NULL);
+       g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
+       if (!g_option_context_parse (context, &argc, &argv, &error)) {
+               g_warning ("Failed to parse arguments: %s\n", error ? error->message : "Unknown error");
+               g_option_context_free (context);
+               g_clear_error (&error);
+               return -1;
+       }
+
+       g_option_context_free (context);
+
+       if (cmd_delay > 0)
+               test_utils_set_event_processing_delay_ms ((guint) cmd_delay);
+
        e_util_init_main_thread (NULL);
        e_passwords_init ();
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]