Unit tests for avatars¶WebODF already has a number of unit test files for carets and selections. These are in
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.
A selection consists of ranges which have been specified for some time:
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.
Initial tests should focus on manipulating selections with function calls. For this we can continue on the existing SelectionMover class. The tests should cover a number of start documents and then move through those and end up on a predetermined positions.Unit test categories for SelectionMover:
- check creation
- contained text and nodes
- check movement
- check ability to have multiple avatars
- check ability to color the avatar ranges (needs e.g. phantomjs)
Because it is possible to have multiple avatars in one document, the native browser selection object cannot be used. The DOM ranges can still be used.