Skip to content

Commit

Permalink
Report one test per cursor position document fragment
Browse files Browse the repository at this point in the history
  • Loading branch information
peitschie committed Aug 21, 2014
1 parent d68c26b commit f6a7602
Showing 1 changed file with 84 additions and 81 deletions.
165 changes: 84 additions & 81 deletions webodf/tests/ops/OdtDocumentTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -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., <a>|</a> has two segments, but only one cursor position
r.shouldBe(t, "t.segmentCount > 1", "true");
Expand Down Expand Up @@ -366,76 +365,6 @@ ops.OdtDocumentTests = function OdtDocumentTests(runner) {
r.shouldBe(t, "t.rootToFocus", "1");
}

function testAvailablePositions_EmptyParagraph() {
// Examples from README_cursorpositions.txt
testCursorPositions("<text:p>|</text:p>");
// TODO behaviour is different from README_cursorpositions
// cursorPositionsTest("<text:p><text:span>|</text:span></text:p>");
// TODO behaviour is different from README_cursorpositions
// cursorPositionsTest("<text:p><text:span>|</text:span><text:span></text:span></text:p>");
// TODO behaviour is different from README_cursorpositions
// cursorPositionsTest("<text:p><text:span>|<text:span></text:span></text:span></text:p>");
testCursorPositions("<text:p>| </text:p>");
// TODO behaviour is different from README_cursorpositions
// cursorPositionsTest("<text:p> <text:span>| </text:span> </text:p>");
// TODO behaviour is different from README_cursorpositions
// cursorPositionsTest("<text:p> <text:span>| </text:span> <text:span> <text:span> </text:span> </text:span> </text:p>");
}
function testAvailablePositions_SimpleTextNodes() {
// Examples from README_cursorpositions.txt
testCursorPositions("<text:p>|A|B|C|</text:p>");
}
function testAvailablePositions_MixedSpans() {
// Examples from README_cursorpositions.txt
testCursorPositions("<text:p><text:span>|A|B|</text:span>C|</text:p>");
testCursorPositions("<text:p>|A|<text:span>B|</text:span>C|</text:p>");
testCursorPositions("<text:p>|A|<text:span>B|C|</text:span></text:p>");
testCursorPositions("<text:p><text:span>|A|<text:span>B|</text:span></text:span>C|</text:p>");
testCursorPositions("<text:p>|A|<text:span><text:span>B|</text:span>C|</text:span></text:p>");
}
function testAvailablePositions_Whitespace() {
// Examples from README_cursorpositions.txt
testCursorPositions("<text:p>|A| |B|C|</text:p>");
testCursorPositions("<text:p> |A| </text:p>");
testCursorPositions("<text:p>|A| |B|</text:p>");
testCursorPositions("<text:p> |A| | B| </text:p>");
testCursorPositions("<text:p> <text:span> |a| </text:span> </text:p>");
testCursorPositions("<text:p> <text:span>|a| | </text:span> <text:span> b|</text:span> </text:p>");
// TODO behaviour is different from README_cursorpositions
// cursorPositionsTest("<text:p> <text:span> |a<text:span>|</text:span> </text:span> </text:p>");
testCursorPositions("<text:p> <text:span> |a|<text:span></text:span> </text:span> </text:p>");
testCursorPositions("<text:p><text:span></text:span> |a|</text:p>");
}
function testAvailablePositions_SpaceElements() {
// Examples from README_cursorpositions.txt
testCursorPositions("<text:p>|A|<text:s> </text:s>|B|C|</text:p>");
// Unexpanded spaces - Not really supported, but interesting to test
testCursorPositions("<text:p>|A|<text:s></text:s>|B|C|</text:p>");
// Slight span nesting and positioning
testCursorPositions("<text:p><text:span>|<text:s> </text:s>|</text:span></text:p>");
// TODO behaviour is different from README_cursorpositions
// cursorPositionsTest("<text:p> <text:span>|A| |</text:span> <text:s></text:s>| <text:span><text:s> </text:s>|B|</text:span> </text:p>");
testCursorPositions("<text:p>|<text:tab> </text:tab>|<text:s> </text:s>|<text:s> </text:s>|</text:p>");
testCursorPositions("<text:p>|<text:tab> </text:tab>| |<text:s> </text:s>|</text:p>");
testCursorPositions("<text:p>|a| | <text:s> </text:s>| </text:p>");
testCursorPositions("<text:p><e:editinfo></e:editinfo><text:span></text:span>|a|<text:s> </text:s>|<text:s> </text:s>|<text:span></text:span><text:span></text:span></text:p>");
}
function testAvailablePositions_DrawElements() {
testCursorPositions("<text:p>|<draw:frame text:anchor-type=\"as-char\"><draw:image><office:binary-data>data</office:binary-data></draw:image></draw:frame>|</text:p>");
testCursorPositions("<text:p><text:span>|<draw:frame text:anchor-type=\"as-char\"><draw:image><office:binary-data>data</office:binary-data></draw:image></draw:frame>|</text:span></text:p>");
}
function testAvailablePositions_Annotations() {
testCursorPositions('<text:p>|a|b|<office:annotation><text:list><text:list-item><text:p>|</text:p></text:list-item></text:list></office:annotation>|c|d|<office:annotation-end></office:annotation-end>1|2|</text:p>');
testCursorPositions('<text:p>|a|<office:annotation><text:list><text:list-item><text:p>|b|</text:p></text:list-item></text:list></office:annotation>|c|<office:annotation-end></office:annotation-end>1|2|</text:p>');
testCursorPositions('<text:p>|a|<office:annotation><text:list><text:list-item><text:p>|b|</text:p></text:list-item></text:list></office:annotation>|<office:annotation-end></office:annotation-end>1|2|</text:p>');
}
function testAvailablePositions_BetweenAnnotationAndSpan() {
testCursorPositions('<text:p>|a|b|<office:annotation><text:list><text:list-item><text:p>|</text:p></text:list-item></text:list></office:annotation><text:span>|c|d|</text:span><office:annotation-end></office:annotation-end>1|2|</text:p>');
testCursorPositions('<text:p>|a|<html:div class="annotationWrapper"><office:annotation><text:list><text:list-item><text:p>|b|</text:p></text:list-item></text:list></office:annotation></html:div><html:span class="webodf-annotationHighlight">|c|</html:span><office:annotation-end></office:annotation-end>1|2|</text:p>');
testCursorPositions('<text:p>|a|<html:div class="annotationWrapper"><office:annotation><text:list><text:list-item><text:p>|b|</text:p></text:list-item></text:list></office:annotation></html:div><html:span class="webodf-annotationHighlight">|</html:span><office:annotation-end></office:annotation-end>1|2|</text:p>');
}


function getTextNodeAtStep_BeginningOfTextNode() {
var doc = createOdtDocument("<text:p>ABCD</text:p>");
t.paragraph = doc.getElementsByTagNameNS(odf.Namespaces.textns, "p")[0];
Expand Down Expand Up @@ -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
"<text:p>|</text:p>",
// TODO behaviour is different from README_cursorpositions
// "<text:p><text:span>|</text:span></text:p>",
// TODO behaviour is different from README_cursorpositions
// "<text:p><text:span>|</text:span><text:span></text:span></text:p>",
// TODO behaviour is different from README_cursorpositions
// "<text:p><text:span>|<text:span></text:span></text:span></text:p>",
"<text:p>| </text:p>",
// TODO behaviour is different from README_cursorpositions
// "<text:p> <text:span>| </text:span> </text:p>",
// TODO behaviour is different from README_cursorpositions
// "<text:p> <text:span>| </text:span> <text:span> <text:span> </text:span> </text:span> </text:p>",


// *************** Simple Text Nodes *************** //
"<text:p>|A|B|C|</text:p>",


// *************** Mixed spans *************** //
"<text:p><text:span>|A|B|</text:span>C|</text:p>",
"<text:p>|A|<text:span>B|</text:span>C|</text:p>",
"<text:p>|A|<text:span>B|C|</text:span></text:p>",
"<text:p><text:span>|A|<text:span>B|</text:span></text:span>C|</text:p>",
"<text:p>|A|<text:span><text:span>B|</text:span>C|</text:span></text:p>",


// *************** Whitespace *************** //
"<text:p>|A| |B|C|</text:p>",
"<text:p> |A| </text:p>",
"<text:p>|A| |B|</text:p>",
"<text:p> |A| | B| </text:p>",
"<text:p> <text:span> |a| </text:span> </text:p>",
"<text:p> <text:span>|a| | </text:span> <text:span> b|</text:span> </text:p>",
// TODO behaviour is different from README_cursorpositions
// cursorPositionsTest("<text:p> <text:span> |a<text:span>|</text:span> </text:span> </text:p>",
"<text:p> <text:span> |a|<text:span></text:span> </text:span> </text:p>",
"<text:p><text:span></text:span> |a|</text:p>",


// *************** Space elements *************** //
"<text:p>|A|<text:s> </text:s>|B|C|</text:p>",
// Unexpanded spaces - Not really supported, but interesting to test
"<text:p>|A|<text:s></text:s>|B|C|</text:p>",
// Slight span nesting and positioning
"<text:p><text:span>|<text:s> </text:s>|</text:span></text:p>",
// TODO behaviour is different from README_cursorpositions
// cursorPositionsTest("<text:p> <text:span>|A| |</text:span> <text:s></text:s>| <text:span><text:s> </text:s>|B|</text:span> </text:p>",
"<text:p>|<text:tab> </text:tab>|<text:s> </text:s>|<text:s> </text:s>|</text:p>",
"<text:p>|<text:tab> </text:tab>| |<text:s> </text:s>|</text:p>",
"<text:p>|a| | <text:s> </text:s>| </text:p>",
"<text:p><e:editinfo></e:editinfo><text:span></text:span>|a|<text:s> </text:s>|<text:s> </text:s>|<text:span></text:span><text:span></text:span></text:p>",


// *************** Draw elements *************** //
"<text:p>|<draw:frame text:anchor-type=\"as-char\"><draw:image><office:binary-data>data</office:binary-data></draw:image></draw:frame>|</text:p>",
"<text:p><text:span>|<draw:frame text:anchor-type=\"as-char\"><draw:image><office:binary-data>data</office:binary-data></draw:image></draw:frame>|</text:span></text:p>",


// *************** Annotations *************** //
'<text:p>|a|b|<office:annotation><text:list><text:list-item><text:p>|</text:p></text:list-item></text:list></office:annotation>|c|d|<office:annotation-end></office:annotation-end>1|2|</text:p>',
'<text:p>|a|<office:annotation><text:list><text:list-item><text:p>|b|</text:p></text:list-item></text:list></office:annotation>|c|<office:annotation-end></office:annotation-end>1|2|</text:p>',
'<text:p>|a|<office:annotation><text:list><text:list-item><text:p>|b|</text:p></text:list-item></text:list></office:annotation>|<office:annotation-end></office:annotation-end>1|2|</text:p>',


// *************** Annotations with highlighting *************** //
'<text:p>|a|b|<office:annotation><text:list><text:list-item><text:p>|</text:p></text:list-item></text:list></office:annotation><text:span>|c|d|</text:span><office:annotation-end></office:annotation-end>1|2|</text:p>',
'<text:p>|a|<html:div class="annotationWrapper"><office:annotation><text:list><text:list-item><text:p>|b|</text:p></text:list-item></text:list></office:annotation></html:div><html:span class="webodf-annotationHighlight">|c|</html:span><office:annotation-end></office:annotation-end>1|2|</text:p>',
'<text:p>|a|<html:div class="annotationWrapper"><office:annotation><text:list><text:list-item><text:p>|b|</text:p></text:list-item></text:list></office:annotation></html:div><html:span class="webodf-annotationHighlight">|</html:span><office:annotation-end></office:annotation-end>1|2|</text:p>'

].map(function(testInput) {
return {
name: "cursorPositions " + testInput,
f: testCursorPositions.bind(undefined, testInput)
};
});
}

this.setUp = function () {
var doc, stylesElement;
testarea = core.UnitTest.provideTestAreaDiv();
Expand Down Expand Up @@ -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,
Expand All @@ -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 [
Expand Down

0 comments on commit f6a7602

Please sign in to comment.