undoManager.maybeCheckpoint(1, 1);
insert(1, 7);
undoManager.maybeCheckpoint(2, 2);
insert(2, 8);
FocusedRange oldSelection = selectionHelper.getSelectionRange();
undoManager.undo();
assertEquals(new FocusedRange(2, 2), selectionHelper.getSelectionRange());
assertEquals("<doc>ahello</doc>", XmlStringBuilder.innerXml(doc).toString());
undoManager.redo();
assertEquals(oldSelection, selectionHelper.getSelectionRange());
assertEquals("<doc>aahello</doc>", XmlStringBuilder.innerXml(doc).toString());
selectionHelper.setSelectionRange(new FocusedRange(5));
undoManager.undo();
assertEquals(new FocusedRange(2, 2), selectionHelper.getSelectionRange());
assertEquals("<doc>ahello</doc>", XmlStringBuilder.innerXml(doc).toString());
responsibility.endDirectSequence();
insert(1, 8);
undoManager.redo();
assertEquals(new FocusedRange(6), selectionHelper.getSelectionRange());
assertEquals("<doc>aaahello</doc>", XmlStringBuilder.innerXml(doc).toString());
undoManager.redo();
assertEquals(new FocusedRange(6), selectionHelper.getSelectionRange());
assertEquals("<doc>aaahello</doc>", XmlStringBuilder.innerXml(doc).toString());
}