Unit testing with TLF
While unit testing complex formating, I hit several problems. Below are simple tests that fail with an error. Does anybody know what is wrong with these tests?
Thanks for any hints,
Marc
public function test_apply_Link():void
{
var init:XML = <TextFlow xmlns="http://ns.adobe.com/textLayout/2008"><p><span>aaa</span></p></TextFlow>
var textFlow:TextFlow = TextConverter.importToFlow(init, TextConverter.TEXT_LAYOUT_FORMAT)
var editManager:IEditManager = new EditManager()
textFlow.interactionManager = editManager
editManager.selectRange(1,2)
editManager.applyLink("http://livedocs.adobe.com/", "_self", true) // throws error:
/*
RangeError: Error #2006: The supplied index is out of bounds.
at flash.text.engine::GroupElement/replaceElements()
at flashx.textLayout.elements::ParagraphElement/http://ns.adobe.com/textLayout/internal/2008::insertBlockElement()
at flashx.textLayout.elements::FlowLeafElement/http://ns.adobe.com/textLayout/internal/2008::createContentElement()
at flashx.textLayout.elements::SpanElement/http://ns.adobe.com/textLayout/internal/2008::createContentElement()
at flashx.textLayout.elements::ParagraphElement/http://ns.adobe.com/textLayout/internal/2008::createTextBlock()
at flashx.textLayout.elements::ParagraphElement/http://ns.adobe.com/textLayout/internal/2008::createContentElement()
at flashx.textLayout.elements::SubParagraphGroupElement/http://ns.adobe.com/textLayout/internal/2008::setParentAndRelativeStart()
at flashx.textLayout.elements::LinkElement/http://ns.adobe.com/textLayout/internal/2008::setParentAndRelativeStart()
at flashx.textLayout.elements::FlowGroupElement/replaceChildren()
at Function/http://adobe.com/AS3/2006/builtin::apply()
at flashx.textLayout.elements::ParagraphElement/replaceChildren()
at flashx.textLayout.edit::TextFlowEdit$/insertNewSPBlock()
at flashx.textLayout.edit::TextFlowEdit$/makeLink()
at flashx.textLayout.operations::ApplyLinkOperation/doOperation()
at flashx.textLayout.edit::EditManager/doInternal()
at flashx.textLayout.edit::EditManager/doOperation()
at flashx.textLayout.edit::EditManager/applyLink()
*/
}
public function test_undo():void
{
var init:XML = <TextFlow xmlns="http://ns.adobe.com/textLayout/2008"><p><span>aaa</span></p></TextFlow>
var textFlow:TextFlow = TextConverter.importToFlow(init, TextConverter.TEXT_LAYOUT_FORMAT)
var undoManager:IUndoManager = new UndoManager()
var editManager:IEditManager = new EditManager(undoManager)
textFlow.interactionManager = editManager
editManager.selectRange(1,2)
var format:TextLayoutFormat = new TextLayoutFormat()
format.fontWeight = FontWeight.BOLD
editManager.applyLeafFormat(format)
undoManager.undo() // throws error:
/*
TypeError: Error #1009: Cannot access a property or method of a null object reference
at flashx.textLayout.edit::EditManager/performUndo()
at flashx.textLayout.operations::FlowOperation/performUndo()
at flashx.undo::UndoManager/undo()
*/
}
