[evolution/wip/webkit2] html-editor-test-units: Simplify the /undo/text-type test



commit 22a006daf30ee9bb0597989c7ccd6f935ce4842f
Author: Milan Crha <mcrha redhat com>
Date:   Wed Jun 29 15:07:25 2016 +0200

    html-editor-test-units: Simplify the /undo/text-type test

 e-util/test-html-editor-units-utils.c |   10 ++++++----
 e-util/test-html-editor-units.c       |   30 +++++++++++-------------------
 2 files changed, 17 insertions(+), 23 deletions(-)
---
diff --git a/e-util/test-html-editor-units-utils.c b/e-util/test-html-editor-units-utils.c
index 0cf021a..0dc9d18 100644
--- a/e-util/test-html-editor-units-utils.c
+++ b/e-util/test-html-editor-units-utils.c
@@ -79,7 +79,8 @@ undo_content_free (gpointer ptr)
 
 static gboolean
 undo_content_test (TestFixture *fixture,
-                  const UndoContent *uc)
+                  const UndoContent *uc,
+                  gint cmd_index)
 {
        EContentEditor *cnt_editor;
        gchar *text;
@@ -94,7 +95,7 @@ undo_content_test (TestFixture *fixture,
        g_return_val_if_fail (text != NULL, FALSE);
 
        if (!test_utils_html_equal (fixture, text, uc->html)) {
-               g_warning ("%s: returned HTML\n---%s---\n and expected HTML\n---%s---\n do not match", 
G_STRFUNC, text, uc->html);
+               g_warning ("%s: returned HTML\n---%s---\n and expected HTML\n---%s---\n do not match at 
command %d", G_STRFUNC, text, uc->html, cmd_index);
                g_free (text);
                return FALSE;
        }
@@ -105,7 +106,7 @@ undo_content_test (TestFixture *fixture,
        g_return_val_if_fail (text != NULL, FALSE);
 
        if (!test_utils_html_equal (fixture, text, uc->plain)) {
-               g_warning ("%s: returned Plain\n---%s---\n and expected Plain\n---%s---\n do not match", 
G_STRFUNC, text, uc->plain);
+               g_warning ("%s: returned Plain\n---%s---\n and expected Plain\n---%s---\n do not match at 
command %d", G_STRFUNC, text, uc->plain, cmd_index);
                g_free (text);
                return FALSE;
        }
@@ -577,6 +578,7 @@ test_utils_pick_undo_content (const GSList *undo_stack,
 
        g_return_val_if_fail (undo_stack != NULL, NULL);
 
+       number--;
        for (link = undo_stack; link && number > 0; link = g_slist_next (link)) {
                number--;
        }
@@ -708,7 +710,7 @@ test_utils_process_commands (TestFixture *fixture,
 
                                number = test_utils_maybe_extract_undo_number (command);
                                uc = test_utils_pick_undo_content (fixture->undo_stack, number);
-                               success = uc && undo_content_test (fixture, uc);
+                               success = uc && undo_content_test (fixture, uc, cc);
                        } else {
                                g_warning ("%s: Unknown command 'undo:%s'", G_STRFUNC, command);
                                success = FALSE;
diff --git a/e-util/test-html-editor-units.c b/e-util/test-html-editor-units.c
index dc2829e..011d4be 100644
--- a/e-util/test-html-editor-units.c
+++ b/e-util/test-html-editor-units.c
@@ -158,29 +158,21 @@ test_undo_text_type (TestFixture *fixture)
 {
        if (!test_utils_run_simple_test (fixture,
                "mode:html\n"
+               "type:some te\n"
                "undo:save\n"   /* 1 */
-               "type:some text corretC\n"
+               "type:tz\n"
                "undo:save\n"   /* 2 */
-               "seq:CSlcsD\n"  /* delete the last word */
-               "undo:save\n"   /* 3 */
-               "type:broken\n" /* and write 'broken' there */
-               "undo:save\n"   /* 4 */
-               "undo:undo:2\n" /* undo the 'broken' word write */
+               "undo:undo\n"
+               "undo:undo\n"
                "undo:test:2\n"
-               "undo:redo\n" /* redo 'broken' word write */
+               "undo:redo\n"
+               "undo:redo\n"
                "undo:test\n"
-               "undo:undo\n" /* undo 'broken' word write */
-               "undo:test:2\n"
-               "undo:redo\n" /* redo 'broken' word write */
-               "undo:test\n"
-               "undo:drop:2\n" /* 2 */
-               "undo:undo:2\n" /* undo 'broken' word write and word delete*/
-               "undo:test\n"
-               "undo:undo:3\n" /* undo text typing */
-               "undo:test\n"
-               "undo:drop\n",  /* 1 */
-               HTML_PREFIX "" HTML_SUFFIX,
-               ""))
+               "undo:undo:2\n"
+               "undo:drop\n"
+               "type:xt\n"
+               , HTML_PREFIX "some text" HTML_SUFFIX,
+               "some text"))
                g_test_fail ();
 }
 


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