Version 1/4
-
Next » -
Current version
Jos van den Oever, 07/30/2012 10:23 am
Avatars¶
Unit tests for avatars¶
WebODF already has a number of unit test files for carets and selections. These are in
webodf/tests/gui/CaretTests.js
webodf/tests/gui/SelectionMoverTests.js
Only the CaretTests file is currently run. It has no tests. The tests in that file would be intended for testing gui.Caret.
To test the avatars, first the task of the avatars should be clear. Avatars represent position of a user in a text. This position can be one point, a range (selection) or a number of ranges (multiple selection one can often do by dragging some areas while holding ctrl button). In addition, an avatar has a graphical representation. This can depend on the state. Each range has a start and an end which could be represented differently. E.g. the end could have a pulsating caret.
In the DOM this interface is defined by the Selection interface for most browsers.
http://www.w3.org/TR/2009/WD-html5-20090423/editing.html#selection
https://developer-new.mozilla.org/en-US/docs/DOM/Selection
A selection consists of ranges which have been specified for some time:
http://www.w3.org/TR/DOM-Level-2-Traversal-Range/ranges.html
Ranges are already used in
lib/odf/OdfCanvas.js
lib/gui/SelectionMover.js
lib/gui/XMLEdit.js
The SelectionMover class is close to what an Avatar should be.
The ranges are not represented when the document is serialized. The positions should not be part of the main document but be part of the surrounding session information of which the document is a part. This has not yet been defined. If we want to keep that updated, we need to define that too, so there can be documents for it.