Skip to content

Commit

Permalink
Make OdtDocument.getMemberIds return ALL memberIds
Browse files Browse the repository at this point in the history
and not just those of cursors.
  • Loading branch information
Aditya Bhatt authored and adityab committed Jul 17, 2015
1 parent 5d5102b commit 526f4c0
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 15 deletions.
14 changes: 3 additions & 11 deletions webodf/lib/ops/OdtDocument.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
* of the given memberid, or a given node
* @constructor
* @implements {core.PositionFilter}
* @param {!string|!Node} anchor
* @param {!string|!Node} anchor
* @param {Object.<!ops.OdtCursor>} cursors
* @param {function(!Node):!Node} getRoot
*/
Expand Down Expand Up @@ -186,7 +186,7 @@ ops.OdtDocument = function OdtDocument(odfCanvas) {
return /**@type{!Document}*/(self.getDocumentElement().ownerDocument);
}
this.getDOMDocument = getDOMDocument;

/**
* @param {!Node} node
* @return {!boolean}
Expand Down Expand Up @@ -818,15 +818,7 @@ ops.OdtDocument = function OdtDocument(odfCanvas) {
* @return {!Array.<string>}
*/
this.getMemberIds = function () {
var list = [],
/**@type{string}*/
i;
for (i in cursors) {
if (cursors.hasOwnProperty(i)) {
list.push(cursors[i].getMemberId());
}
}
return list;
return Object.keys(members);
};

/**
Expand Down
1 change: 1 addition & 0 deletions webodf/tests/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@
"odf.Namespaces",
"odf.OdfCanvas",
"odf.OdfNodeFilter",
"ops.Member",
"ops.OdtCursor",
"ops.OdtDocument",
"xmldom.LSSerializer",
Expand Down
20 changes: 16 additions & 4 deletions webodf/tests/ops/OdtDocumentTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ ops.OdtDocumentTests = function OdtDocumentTests(runner) {

function cursorPositionTests() {
// Examples from README_cursorpositions.txt

return [
// *************** Empty Paragraph *************** //
// Examples from README_cursorpositions.txt
Expand All @@ -575,7 +575,7 @@ ops.OdtDocumentTests = function OdtDocumentTests(runner) {
// 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>",

Expand Down Expand Up @@ -632,7 +632,7 @@ ops.OdtDocumentTests = function OdtDocumentTests(runner) {
'<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,
Expand All @@ -641,6 +641,16 @@ ops.OdtDocumentTests = function OdtDocumentTests(runner) {
});
}

function testMemberIds() {
createOdtDocument('<text:p></text:p>');

t.odtDocument.addMember(new ops.Member('alice', /**@type{!ops.MemberProperties}*/({ fullName: 'Alice' })));
t.odtDocument.addMember(new ops.Member('bob', /**@type{!ops.MemberProperties}*/({ fullName: 'Bob' })));
t.odtDocument.addMember(new ops.Member('eve', /**@type{!ops.MemberProperties}*/({ fullName: 'Eve' })));

r.shouldBe(t, 't.odtDocument.getMemberIds().join()', '"alice,bob,eve"');
}

this.setUp = function () {
var doc, stylesElement;
testarea = core.UnitTest.provideTestAreaDiv();
Expand Down Expand Up @@ -687,7 +697,9 @@ ops.OdtDocumentTests = function OdtDocumentTests(runner) {
getTextNodeAtStep_At1_PutsTargetMemberCursor_BeforeTextNode,
getTextNodeAtStep_At4_PutsTargetMemberCursor_BeforeTextNode,
getTextNodeAtStep_AfterNonText_PutsTargetMemberCursor_BeforeTextNode,
getTextNodeAtStep_EmptyP_MovesAllCursors_BeforeTextNode
getTextNodeAtStep_EmptyP_MovesAllCursors_BeforeTextNode,

testMemberIds
]).concat(cursorPositionTests());
};
this.asyncTests = function () {
Expand Down

0 comments on commit 526f4c0

Please sign in to comment.