From f6a76020361bbecce6684a2b76fdcecaf3746513 Mon Sep 17 00:00:00 2001 From: Philip Peitsch Date: Wed, 13 Aug 2014 17:34:51 +1000 Subject: [PATCH] Report one test per cursor position document fragment --- webodf/tests/ops/OdtDocumentTests.js | 165 ++++++++++++++------------- 1 file changed, 84 insertions(+), 81 deletions(-) diff --git a/webodf/tests/ops/OdtDocumentTests.js b/webodf/tests/ops/OdtDocumentTests.js index 2fbefd160..4f6f4a37d 100644 --- a/webodf/tests/ops/OdtDocumentTests.js +++ b/webodf/tests/ops/OdtDocumentTests.js @@ -158,7 +158,6 @@ ops.OdtDocumentTests = function OdtDocumentTests(runner) { documentRoot; serializer.filter = new OdfOrCursorNodeFilter(); - runtime.log("Scenario: " + documentString); t.segmentCount = segments.length; t.expectedCursorPositionsCount = segments.length - 1; // e.g., | has two segments, but only one cursor position r.shouldBe(t, "t.segmentCount > 1", "true"); @@ -366,76 +365,6 @@ ops.OdtDocumentTests = function OdtDocumentTests(runner) { r.shouldBe(t, "t.rootToFocus", "1"); } - function testAvailablePositions_EmptyParagraph() { - // Examples from README_cursorpositions.txt - testCursorPositions("|"); - // TODO behaviour is different from README_cursorpositions - // cursorPositionsTest("|"); - // TODO behaviour is different from README_cursorpositions - // cursorPositionsTest("|"); - // TODO behaviour is different from README_cursorpositions - // cursorPositionsTest("|"); - testCursorPositions("| "); - // TODO behaviour is different from README_cursorpositions - // cursorPositionsTest(" | "); - // TODO behaviour is different from README_cursorpositions - // cursorPositionsTest(" | "); - } - function testAvailablePositions_SimpleTextNodes() { - // Examples from README_cursorpositions.txt - testCursorPositions("|A|B|C|"); - } - function testAvailablePositions_MixedSpans() { - // Examples from README_cursorpositions.txt - testCursorPositions("|A|B|C|"); - testCursorPositions("|A|B|C|"); - testCursorPositions("|A|B|C|"); - testCursorPositions("|A|B|C|"); - testCursorPositions("|A|B|C|"); - } - function testAvailablePositions_Whitespace() { - // Examples from README_cursorpositions.txt - testCursorPositions("|A| |B|C|"); - testCursorPositions(" |A| "); - testCursorPositions("|A| |B|"); - testCursorPositions(" |A| | B| "); - testCursorPositions(" |a| "); - testCursorPositions(" |a| | b| "); - // TODO behaviour is different from README_cursorpositions - // cursorPositionsTest(" |a| "); - testCursorPositions(" |a| "); - testCursorPositions(" |a|"); - } - function testAvailablePositions_SpaceElements() { - // Examples from README_cursorpositions.txt - testCursorPositions("|A| |B|C|"); - // Unexpanded spaces - Not really supported, but interesting to test - testCursorPositions("|A||B|C|"); - // Slight span nesting and positioning - testCursorPositions("| |"); - // TODO behaviour is different from README_cursorpositions - // cursorPositionsTest(" |A| | | |B| "); - testCursorPositions("| | | |"); - testCursorPositions("| | | |"); - testCursorPositions("|a| | | "); - testCursorPositions("|a| | |"); - } - function testAvailablePositions_DrawElements() { - testCursorPositions("|data|"); - testCursorPositions("|data|"); - } - function testAvailablePositions_Annotations() { - testCursorPositions('|a|b|||c|d|1|2|'); - testCursorPositions('|a||b||c|1|2|'); - testCursorPositions('|a||b||1|2|'); - } - function testAvailablePositions_BetweenAnnotationAndSpan() { - testCursorPositions('|a|b|||c|d|1|2|'); - testCursorPositions('|a||b||c|1|2|'); - testCursorPositions('|a||b||1|2|'); - } - - function getTextNodeAtStep_BeginningOfTextNode() { var doc = createOdtDocument("ABCD"); t.paragraph = doc.getElementsByTagNameNS(odf.Namespaces.textns, "p")[0]; @@ -627,6 +556,89 @@ ops.OdtDocumentTests = function OdtDocumentTests(runner) { r.shouldBe(t, "t.domPosition.textNode.previousSibling.localName", "'cursor'"); } + function cursorPositionTests() { + // Examples from README_cursorpositions.txt + + return [ + // *************** Empty Paragraph *************** // + // Examples from README_cursorpositions.txt + "|", + // TODO behaviour is different from README_cursorpositions + // "|", + // TODO behaviour is different from README_cursorpositions + // "|", + // TODO behaviour is different from README_cursorpositions + // "|", + "| ", + // TODO behaviour is different from README_cursorpositions + // " | ", + // TODO behaviour is different from README_cursorpositions + // " | ", + + + // *************** Simple Text Nodes *************** // + "|A|B|C|", + + + // *************** Mixed spans *************** // + "|A|B|C|", + "|A|B|C|", + "|A|B|C|", + "|A|B|C|", + "|A|B|C|", + + + // *************** Whitespace *************** // + "|A| |B|C|", + " |A| ", + "|A| |B|", + " |A| | B| ", + " |a| ", + " |a| | b| ", + // TODO behaviour is different from README_cursorpositions + // cursorPositionsTest(" |a| ", + " |a| ", + " |a|", + + + // *************** Space elements *************** // + "|A| |B|C|", + // Unexpanded spaces - Not really supported, but interesting to test + "|A||B|C|", + // Slight span nesting and positioning + "| |", + // TODO behaviour is different from README_cursorpositions + // cursorPositionsTest(" |A| | | |B| ", + "| | | |", + "| | | |", + "|a| | | ", + "|a| | |", + + + // *************** Draw elements *************** // + "|data|", + "|data|", + + + // *************** Annotations *************** // + '|a|b|||c|d|1|2|', + '|a||b||c|1|2|', + '|a||b||1|2|', + + + // *************** Annotations with highlighting *************** // + '|a|b|||c|d|1|2|', + '|a||b||c|1|2|', + '|a||b||1|2|' + + ].map(function(testInput) { + return { + name: "cursorPositions " + testInput, + f: testCursorPositions.bind(undefined, testInput) + }; + }); + } + this.setUp = function () { var doc, stylesElement; testarea = core.UnitTest.provideTestAreaDiv(); @@ -659,15 +671,6 @@ ops.OdtDocumentTests = function OdtDocumentTests(runner) { testFixCursorPositions_CursorNearParagraphStart_ForwardSelection, testFixCursorPositions_CursorNearParagraphStart_ReverseSelection, - testAvailablePositions_EmptyParagraph, - testAvailablePositions_SimpleTextNodes, - testAvailablePositions_MixedSpans, - testAvailablePositions_Whitespace, - testAvailablePositions_SpaceElements, - testAvailablePositions_DrawElements, - testAvailablePositions_Annotations, - testAvailablePositions_BetweenAnnotationAndSpan, - getTextNodeAtStep_BeginningOfTextNode, getTextNodeAtStep_EndOfTextNode, getTextNodeAtStep_PositionWithNoTextNode_AddsNewNode_Front, @@ -683,7 +686,7 @@ ops.OdtDocumentTests = function OdtDocumentTests(runner) { getTextNodeAtStep_At4_PutsTargetMemberCursor_BeforeTextNode, getTextNodeAtStep_AfterNonText_PutsTargetMemberCursor_BeforeTextNode, getTextNodeAtStep_EmptyP_MovesAllCursors_BeforeTextNode - ]); + ]).concat(cursorPositionTests()); }; this.asyncTests = function () { return [