[evolution/wip/webkit2] Add some paste clipboard tests and a "wait" command
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/wip/webkit2] Add some paste clipboard tests and a "wait" command
- Date: Mon, 8 Aug 2016 18:02:19 +0000 (UTC)
commit a6d4937a404faa8e4537339437bc0148aba1b136
Author: Milan Crha <mcrha redhat com>
Date: Mon Aug 8 20:02:57 2016 +0200
Add some paste clipboard tests and a "wait" command
e-util/test-html-editor-units-utils.c | 24 ++++++++
e-util/test-html-editor-units-utils.h | 2 +
e-util/test-html-editor-units.c | 96 +++++++++++++++++++++++++++++++++
3 files changed, 122 insertions(+), 0 deletions(-)
---
diff --git a/e-util/test-html-editor-units-utils.c b/e-util/test-html-editor-units-utils.c
index 36cb08e..cd71d14 100644
--- a/e-util/test-html-editor-units-utils.c
+++ b/e-util/test-html-editor-units-utils.c
@@ -794,6 +794,7 @@ test_utils_pick_undo_content (const GSList *undo_stack,
/ seqcmd ; Sequence of special key strokes
/ typecmd ; Type a text
/ undocmd ; Undo/redo commands
+ / waitcmd ; Wait command
actioncmd = "action:" name
@@ -830,6 +831,8 @@ test_utils_pick_undo_content (const GSList *undo_stack,
/ "drop" [ ":" number ] ; Forgets saved content, if 'number' is provided, then top number saves
are forgotten
/ "test" [ ":" number ] ; Tests current editor content against any previously saved state; the
optional
; 'number' argument can be used to specify which exact previous state
to use
+
+ waitcmd = "wait:" milliseconds ; waits for 'milliseconds'
*/
gboolean
test_utils_process_commands (TestFixture *fixture,
@@ -915,6 +918,8 @@ test_utils_process_commands (TestFixture *fixture,
}
test_utils_wait_milliseconds (event_processing_delay_ms);
+ } else if (g_str_has_prefix (command, "wait:")) {
+ test_utils_wait_milliseconds (atoi (command + 5));
} else if (*command) {
g_warning ("%s: Unknown command '%s'", G_STRFUNC, command);
success = FALSE;
@@ -994,3 +999,22 @@ test_utils_insert_content (TestFixture *fixture,
cnt_editor = e_html_editor_get_content_editor (fixture->editor);
e_content_editor_insert_content (cnt_editor, content, flags);
}
+
+void
+test_utils_set_clipboard_text (const gchar *text,
+ gboolean is_html)
+{
+ GtkClipboard *clipboard;
+
+ g_return_if_fail (text != NULL);
+
+ clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD);
+
+ gtk_clipboard_clear (clipboard);
+
+ if (is_html) {
+ e_clipboard_set_html (clipboard, text, -1);
+ } else {
+ gtk_clipboard_set_text (clipboard, text, -1);
+ }
+}
diff --git a/e-util/test-html-editor-units-utils.h b/e-util/test-html-editor-units-utils.h
index 78f470c..15bf7bf 100644
--- a/e-util/test-html-editor-units-utils.h
+++ b/e-util/test-html-editor-units-utils.h
@@ -82,5 +82,7 @@ gboolean test_utils_run_simple_test (TestFixture *fixture,
void test_utils_insert_content (TestFixture *fixture,
const gchar *content,
EContentEditorInsertContentFlags flags);
+void test_utils_set_clipboard_text (const gchar *text,
+ gboolean is_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 97f2511..981ef3b 100644
--- a/e-util/test-html-editor-units.c
+++ b/e-util/test-html-editor-units.c
@@ -1213,6 +1213,96 @@ test_paragraph_wrap_lines (TestFixture *fixture)
g_test_fail ();
}
+static void
+test_paste_html2html (TestFixture *fixture)
+{
+ test_utils_set_clipboard_text ("<html><body>some <b>bold</b> text</body></html>", TRUE);
+
+ if (!test_utils_run_simple_test (fixture,
+ "mode:html\n"
+ "type:text before \n"
+ "action:paste\n"
+ "type: text after\n",
+ HTML_PREFIX "<p>text before some <b>bold</b> text text after</p>" HTML_SUFFIX,
+ "text before some bold text text after\n"))
+ g_test_fail ();
+}
+
+static void
+test_paste_html2plain (TestFixture *fixture)
+{
+ test_utils_set_clipboard_text ("<html><body>some <b>bold</b> text</body></html>", TRUE);
+
+ if (!test_utils_run_simple_test (fixture,
+ "mode:plain\n"
+ "type:text before \n"
+ "action:paste\n"
+ "type: text after\n",
+ HTML_PREFIX_PLAIN "<p style=\"width: 71ch;\">text before some bold text text after</p>"
HTML_SUFFIX,
+ "text before some bold text text after\n"))
+ g_test_fail ();
+}
+
+static void
+test_paste_plain2html (TestFixture *fixture)
+{
+ test_utils_set_clipboard_text ("some plain text", FALSE);
+
+ if (!test_utils_run_simple_test (fixture,
+ "mode:html\n"
+ "type:text before \n"
+ "action:paste\n"
+ "type: text after\n",
+ HTML_PREFIX "<p>text before some plain text text after</p>" HTML_SUFFIX,
+ "text before some plain text text after\n"))
+ g_test_fail ();
+}
+
+static void
+test_paste_plain2plain (TestFixture *fixture)
+{
+ test_utils_set_clipboard_text ("some plain text", FALSE);
+
+ if (!test_utils_run_simple_test (fixture,
+ "mode:plain\n"
+ "type:text before \n"
+ "action:paste\n"
+ "type: text after\n",
+ HTML_PREFIX_PLAIN "<p style=\"width: 71ch;\">text before some plain text text after</p>"
HTML_SUFFIX,
+ "text before some plain text text after\n"))
+ g_test_fail ();
+}
+
+static void
+test_paste_quoted_html (TestFixture *fixture)
+{
+ test_utils_set_clipboard_text ("<html><body>some <b>bold</b> text</body></html>", TRUE);
+
+ if (!test_utils_run_simple_test (fixture,
+ "mode:html\n"
+ "type:text before \n"
+ "action:paste-quote\n"
+ "type: text after\n",
+ HTML_PREFIX "<p>text before some <b>bold</b> text text after</p>" HTML_SUFFIX,
+ "text before some bold text text after\n"))
+ g_test_fail ();
+}
+
+static void
+test_paste_quoted_plain (TestFixture *fixture)
+{
+ test_utils_set_clipboard_text ("some plain text", FALSE);
+
+ if (!test_utils_run_simple_test (fixture,
+ "mode:plain\n"
+ "type:text before \n"
+ "action:paste-quote\n"
+ "type: text after\n",
+ HTML_PREFIX_PLAIN "<p style=\"width: 71ch;\">text before some plain text text after</p>"
HTML_SUFFIX,
+ "text before some plain text text after\n"))
+ g_test_fail ();
+}
+
gint
main (gint argc,
gchar *argv[])
@@ -1322,6 +1412,12 @@ main (gint argc,
add_test ("/paragraph/header6/selection", test_paragraph_header6_selection);
add_test ("/paragraph/header6/typed", test_paragraph_header6_typed);
add_test ("/paragraph/wrap-lines", test_paragraph_wrap_lines);
+ add_test ("/paste/html2html", test_paste_html2html);
+ add_test ("/paste/html2plain", test_paste_html2plain);
+ add_test ("/paste/plain2html", test_paste_plain2html);
+ add_test ("/paste/plain2plain", test_paste_plain2plain);
+ add_test ("/paste/quoted/html", test_paste_quoted_html);
+ add_test ("/paste/quoted/plain", test_paste_quoted_plain);
#undef add_test
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]