[evolution/wip/webkit2] Add a test case for bug 726548
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/wip/webkit2] Add a test case for bug 726548
- Date: Tue, 9 Aug 2016 17:23:49 +0000 (UTC)
commit 601490fb92a5d63fe083bc1a0f86d4e50122661f
Author: Milan Crha <mcrha redhat com>
Date: Tue Aug 9 19:24:18 2016 +0200
Add a test case for bug 726548
e-util/test-html-editor-units-utils.c | 27 ++++++++++++++++++++-
e-util/test-html-editor-units-utils.h | 1 +
e-util/test-html-editor-units.c | 42 +++++++++++++++++++++++++++++++++
3 files changed, 69 insertions(+), 1 deletions(-)
---
diff --git a/e-util/test-html-editor-units-utils.c b/e-util/test-html-editor-units-utils.c
index cd71d14..911cc98 100644
--- a/e-util/test-html-editor-units-utils.c
+++ b/e-util/test-html-editor-units-utils.c
@@ -925,7 +925,9 @@ test_utils_process_commands (TestFixture *fixture,
success = FALSE;
}
- test_utils_wait_milliseconds (event_processing_delay_ms);
+ /* Wait at least 100 ms, to give a chance to move the cursor and
+ other things for WebKit, for example before executing actions. */
+ test_utils_wait_milliseconds (MAX (event_processing_delay_ms, 100));
}
g_strfreev (cmds);
@@ -1009,6 +1011,7 @@ test_utils_set_clipboard_text (const gchar *text,
g_return_if_fail (text != NULL);
clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD);
+ g_return_if_fail (clipboard != NULL);
gtk_clipboard_clear (clipboard);
@@ -1018,3 +1021,25 @@ test_utils_set_clipboard_text (const gchar *text,
gtk_clipboard_set_text (clipboard, text, -1);
}
}
+
+gchar *
+test_utils_get_clipboard_text (gboolean request_html)
+{
+ GtkClipboard *clipboard;
+ gchar *text;
+
+ clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD);
+ g_return_val_if_fail (clipboard != NULL, NULL);
+
+ if (request_html) {
+ g_return_val_if_fail (e_clipboard_wait_is_html_available (clipboard), NULL);
+ text = e_clipboard_wait_for_html (clipboard);
+ } else {
+ g_return_val_if_fail (gtk_clipboard_wait_is_text_available (clipboard), NULL);
+ text = gtk_clipboard_wait_for_text (clipboard);
+ }
+
+ g_return_val_if_fail (text != NULL, NULL);
+
+ return text;
+}
diff --git a/e-util/test-html-editor-units-utils.h b/e-util/test-html-editor-units-utils.h
index 15bf7bf..f9d045f 100644
--- a/e-util/test-html-editor-units-utils.h
+++ b/e-util/test-html-editor-units-utils.h
@@ -84,5 +84,6 @@ void test_utils_insert_content (TestFixture *fixture,
EContentEditorInsertContentFlags flags);
void test_utils_set_clipboard_text (const gchar *text,
gboolean is_html);
+gchar * test_utils_get_clipboard_text (gboolean request_html);
#endif /* TEST_HTML_EDITOR_UNITS_UTILS_H */
diff --git a/e-util/test-html-editor-units.c b/e-util/test-html-editor-units.c
index 51416b1..9de5bf4 100644
--- a/e-util/test-html-editor-units.c
+++ b/e-util/test-html-editor-units.c
@@ -2158,6 +2158,47 @@ test_undo_indent (TestFixture *fixture)
g_test_fail ();
}
+static void
+test_bug_726548 (TestFixture *fixture)
+{
+ gboolean success;
+ gchar *text;
+ const gchar *expected_plain =
+ "aaa\n"
+ " 1. a\n"
+ " 2. b\n"
+ " 3. c\n";
+
+ if (!test_utils_run_simple_test (fixture,
+ "mode:plain\n"
+ "type:aaa\\n\n"
+ "action:style-list-number\n"
+ "type:a\\nb\\nc\\n\\n\n"
+ "seq:C\n"
+ "type:ac\n"
+ "seq:c\n",
+ HTML_PREFIX_PLAIN "<p style=\"width: 71ch;\">aaa</p>"
+ "<ol data-evo-paragraph=\"\" style=\"width: 65ch;\">"
+ "<li>a</li><li>b</li><li>c</li></ol>"
+ "<p style=\"width: 71ch;\"><br></p>" HTML_SUFFIX,
+ expected_plain)) {
+ g_test_fail ();
+ return;
+ }
+
+ text = test_utils_get_clipboard_text (FALSE);
+ success = test_utils_html_equal (fixture, text, expected_plain);
+
+ if (!success) {
+ g_warning ("%s: clipboard Plain text \n---%s---\n does not match expected Plain\n---%s---",
+ G_STRFUNC, text, expected_plain);
+ g_free (text);
+ g_test_fail ();
+ } else {
+ g_free (text);
+ }
+}
+
gint
main (gint argc,
gchar *argv[])
@@ -2298,6 +2339,7 @@ main (gint argc,
add_test ("/undo/style", test_undo_style);
add_test ("/undo/justify", test_undo_justify);
add_test ("/undo/indent", test_undo_indent);
+ add_test ("/bug/726548", test_bug_726548);
#undef add_test
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]