" +
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec quis metus mi. Morbi augue neque, vestibulum sit amet rhoncus at, interdum quis lectus. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Suspendisse potenti. Praesent rutrum erat eget nulla malesuada tristique. Nulla sit amet tempus magna. Duis turpis tellus, imperdiet at dignissim nec, vehicula non eros. Vestibulum vel tincidunt arcu. Cras auctor elit vitae lacus tincidunt ut tincidunt turpis gravida. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.
" +
"Vivamus id tristique nisl. Proin consectetur laoreet nunc at cursus. Cras pulvinar lorem ut neque adipiscing nec dapibus purus rutrum. Cras sit amet mauris sit amet nisi aliquam dapibus. Proin ipsum dui, semper eu ornare sed, aliquet vitae est. Suspendisse elementum placerat nibh, eget malesuada erat facilisis id. Etiam pretium lorem ac eros rhoncus in fringilla nisl commodo. Sed vel ligula nulla. Donec quis nulla arcu. Mauris et nulla felis, eu aliquet arcu. Vivamus laoreet diam vitae orci pellentesque sed dapibus nibh laoreet.
" +
"Etiam sollicitudin, libero a sagittis egestas, odio ligula euismod odio, nec euismod risus dui id justo. Duis a augue feugiat est luctus porttitor. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Fusce sapien nulla, porta ut facilisis nec, malesuada nec eros. Maecenas eget mauris odio. Aliquam condimentum, magna sit amet bibendum ultricies, augue ipsum egestas metus, eu consequat felis tortor sit amet turpis. Aenean commodo venenatis diam in mollis. Donec et elementum nunc. Integer dignissim adipiscing nunc, eu tincidunt felis suscipit sed. In hac habitasse platea dictumst. Donec vitae sapien vel mi ornare condimentum. Aliquam ornare metus eget nisi viverra ut accumsan lacus varius. Nulla facilisi. Morbi molestie eros sed tellus rhoncus non feugiat neque lacinia. Mauris quis mauris sit amet lorem iaculis posuere. Fusce quis ornare eros. Donec aliquam magna nec metus scelerisque ac luctus sem ultrices.
" +
"";
public function scrollToRangeTest():void
{
var tConverter:TextConverter = new TextConverter();
var textFlow:TextFlow = TextConverter.importToFlow(scrollToRangeMarkup, TextConverter.TEXT_LAYOUT_FORMAT);
var testTCM:TextContainerManager = addTCM();
testTCM.setTextFlow(textFlow);
var format:TextLayoutFormat = new TextLayoutFormat(TextLayoutFormat.defaultFormat);
format.fontFamily = "Arial";
format.fontSize = 12;
format.paddingLeft = 3;
format.paddingTop = 5;
format.paddingRight = 3;
format.paddingBottom = 3;
testTCM.hostFormat = format;
testTCM.compositionWidth = 186;
testTCM.compositionHeight = 144;
testTCM.setTextFlow(textFlow);
// ma**lesua**da tristique
testTCM.scrollToRange(testTCM.getText().length, testTCM.getText().length);
testTCM.scrollToRange(300, 305);
testTCM.scrollToRange(0, 0);
// text not/barely visible after scroll
testTCM.scrollToRange(300, 305);
testTCM.updateContainer();
assertTrue( "Doesn't get the red text",Math.round(testTCM.verticalScrollPosition) == 16);
}
public function scrollToRangeExplicitMeasureTest():void
{
var tConverter:TextConverter = new TextConverter();
var textFlow:TextFlow = TextConverter.importToFlow(scrollToRangeMarkup, TextConverter.TEXT_LAYOUT_FORMAT);
var testTCM:TextContainerManager = addTCM();
testTCM.setTextFlow(textFlow);
var format:TextLayoutFormat = new TextLayoutFormat(testTCM.hostFormat);
format.fontFamily = "Arial";
format.fontSize = 12;
format.paddingLeft = 3;
format.paddingTop = 5;
format.paddingRight = 3;
format.paddingBottom = 3;
format.lineBreak = LineBreak.EXPLICIT;
testTCM.hostFormat = format;
testTCM.compositionWidth = format.blockProgression == BlockProgression.RL ? NaN : 186;
testTCM.compositionHeight = format.blockProgression == BlockProgression.TB ? NaN : 144;
testTCM.setTextFlow(textFlow);
// ma**lesua**da tristique
testTCM.scrollToRange(testTCM.getText().length, testTCM.getText().length);
testTCM.scrollToRange(300, 305);
testTCM.scrollToRange(0, 0);
// text not/barely visible after scroll
testTCM.scrollToRange(300, 305);
testTCM.updateContainer();
}
public function scrollMaxValueTest():void
{
var markup:String =
"" +
"1 The quick brown fox jumps over the lazy dog.
" +
"2 The quick brown fox jumps over the lazy dog.
" +
"3 The quick brown fox jumps over the lazy dog.
" +
"4 The quick brown fox jumps over the lazy dog.
" +
"5 The quick brown fox jumps over the lazy dog.
" +
"6 The quick brown fox jumps over the lazy dog.
" +
"7 The quick brown fox jumps over the lazy dog.
" +
"8 The quick brown fox jumps over the lazy dog.
" +
"9 The quick brown fox jumps over the lazy dog.
" +
"10 The quick brown fox jumps over the lazy dog.
" +
"11 The quick brown fox jumps over the lazy dog.
" +
"12 The quick brown fox jumps over the lazy dog.
" +
"13 The quick brown fox jumps over the lazy dog.
" +
"14 The quick brown fox jumps over the lazy dog.
" +
"15 The quick brown fox jumps over the lazy dog.
" +
"16The quick brown fox jumps over the lazy dog.
" +
"";
var tConverter:TextConverter = new TextConverter();
var textFlow:TextFlow = TextConverter.importToFlow(markup, TextConverter.TEXT_LAYOUT_FORMAT);
var testTCM:TextContainerManager = addTCM();
testTCM.setTextFlow(textFlow);
var format:TextLayoutFormat = new TextLayoutFormat(TextLayoutFormat.defaultFormat);
format.fontFamily = "Arial";
testTCM.hostFormat = format;
testTCM.compositionWidth = 172;
testTCM.compositionHeight = 149;
testTCM.setTextFlow(textFlow);
var max:uint = uint.MAX_VALUE;
/*if (max > int.MAX_VALUE)
trace("bigger");
else if (max < int.MAX_VALUE)
trace("less than");*/
testTCM.scrollToRange(testTCM.getText().length, int.MAX_VALUE);
testTCM.updateContainer();
assertTrue( "Doesn't get the bottom of text", Math.round(testTCM.verticalScrollPosition) == 309);
}
public function aliceTCMTest():void
{
var alice:ByteArrayAsset = new AliceClass();
var aliceData:String = alice.readMultiByte(alice.length,"utf-8");
var aliceFlow:TextFlow = TextConverter.importToFlow( aliceData, TextConverter.TEXT_LAYOUT_FORMAT );
var testTCM:TextContainerManager = addTCM();
testTCM.setTextFlow(aliceFlow);
testTCM.updateContainer();
testTCM.compositionHeight = 200;
testTCM.updateContainer();
testTCM.compositionHeight = 50;
testTCM.updateContainer();
}
public function tcmSelectionTest():void
{
var testTCM:CustomTCM = addCustomTCM();
testTCM.setText("Selection test");
testTCM.updateContainer();
var selManager:SelectionManager = testTCM.beginInteraction() as SelectionManager;
selManager.selectRange(1,5);
testTCM.endInteraction();
testTCM.setText( "Setting text again to break selection" );
testTCM.updateContainer();
//assertTrue("Selection was maintained after new text was set", selManager.hasSelection() == false);
var secondTCM:CustomTCM = addCustomTCM( 100, 100 );
}
public function customEventTCMTest():void
{
var testTCM:CustomTCM = addCustomTCM();
testTCM.customBehaviorEnabled = true;
testTCM.setText("Testing the CustomTCM with Selection on focusIn");
testTCM.updateContainer();
testTCM.container.dispatchEvent(new FocusEvent( FocusEvent.FOCUS_IN ) );
testTCM.updateContainer();
var selManager:SelectionManager = testTCM.beginInteraction() as SelectionManager;
assertTrue( "focusInHandler not called on FocusEvent.FOCUS_IN event",
selManager.anchorPosition == 0 && selManager.activePosition == 5);
testTCM.endInteraction();
}
public function activationTCMTest():void
{
// Verify that createContextMenu get*SelectionFormat, getUndoManager are called on activation
var testTCM:CustomTCM = addCustomTCM();
testTCM.setText("Testing the CustomTCM");
testTCM.updateContainer();
testTCM.container.dispatchEvent(new FocusEvent( FocusEvent.FOCUS_IN ) );
testTCM.container.dispatchEvent(new MouseEvent( MouseEvent.MOUSE_DOWN ) );
testTCM.updateContainer();
assertTrue( "createContextMenu not called on activate", testTCM.createContextMenuCallCount > 0 );
assertTrue( "getFocusedSelectionFormat not called on activate", testTCM.getFocusedSelectionFormatCallCount > 0 );
assertTrue( "getInactiveSelectionFormat not called on activate", testTCM.getInactiveSelectionFormatCallCount > 0 );
assertTrue( "getUnfocusedSelectionFormat not called on activate", testTCM.getUnfocusedSelectionFormatCallCount > 0 );
assertTrue( "getUndoManager not called on activate", testTCM.getUndoManagerCallCount > 0 );
}
public function focusInHandlerTest():void
{
var testTCM:CustomTCM = addCustomTCM();
testTCM.setText("Testing the CustomTCM Event Handler Tests");
testTCM.updateContainer();
testTCM.container.dispatchEvent(new FocusEvent( FocusEvent.FOCUS_IN ) );
testTCM.updateContainer();
assertTrue( "focusInHandler not called on FocusEvent.FOCUS_IN event", testTCM.focusInHandlerCallCount > 0 );
}
public function mouseOverHandlerTest():void
{
var testTCM:CustomTCM = addCustomTCM();
testTCM.setText("Testing the CustomTCM Event Handler Tests");
testTCM.updateContainer();
testTCM.container.dispatchEvent(new MouseEvent( MouseEvent.MOUSE_OVER ) );
testTCM.updateContainer();
assertTrue( "mouseOverHandler not called on MouseEvent.MOUSE_OVER", testTCM.mouseOverHandlerCallCount > 0 );
}
public function activateHandlerTest():void
{
var testTCM:CustomTCM = addCustomTCM();
testTCM.setText("Testing the CustomTCM Event Handler Tests");
testTCM.updateContainer();
testTCM.container.dispatchEvent(new FocusEvent( FocusEvent.FOCUS_IN ) );
testTCM.container.dispatchEvent(new MouseEvent( MouseEvent.MOUSE_DOWN ) );
testTCM.container.dispatchEvent(new Event( Event.DEACTIVATE ) );
testTCM.container.dispatchEvent(new Event( Event.ACTIVATE ) );
testTCM.updateContainer();
assertTrue( "activateHandlerTest not called on Event.ACTIVATE", testTCM.activateHandlerCallCount > 0 );
}
public function deactivateHandlerTest():void
{
var testTCM:CustomTCM = addCustomTCM();
testTCM.setText("Testing the CustomTCM Event Handler Tests");
testTCM.updateContainer();
testTCM.container.dispatchEvent(new FocusEvent( FocusEvent.FOCUS_IN ) );
testTCM.container.dispatchEvent(new MouseEvent( MouseEvent.MOUSE_DOWN ) );
testTCM.container.dispatchEvent(new Event( Event.DEACTIVATE ) );
testTCM.updateContainer();
assertTrue( "deactivateHandlerTest not called on Event.DEACTIVATE", testTCM.deactivateHandlerCallCount > 0 );
}
public function editHandlerTest():void
{
var testTCM:CustomTCM = addCustomTCM();
testTCM.setText("Testing the CustomTCM Event Handler Tests");
testTCM.updateContainer();
//testTCM.container.dispatchEvent(new Event( Event. ) );
testTCM.updateContainer();
assertTrue( "deactivateHandlerTest not called on activate event", testTCM.deactivateHandlerCallCount > 0 );
}
public function focusChangeHandlerTest():void
{
var testTCM:CustomTCM = addCustomTCM();
testTCM.setText("Testing the CustomTCM Event Handler Tests");
testTCM.updateContainer();
testTCM.container.dispatchEvent(new FocusEvent( FocusEvent.FOCUS_IN ) );
testTCM.container.dispatchEvent(new MouseEvent( MouseEvent.MOUSE_DOWN ) );
testTCM.container.dispatchEvent(new FocusEvent( FocusEvent.KEY_FOCUS_CHANGE ) );
testTCM.updateContainer();
assertTrue( "focusChangeHandler not called on FocusEvent.KEY_FOCUS_CHANGE", testTCM.focusChangeHandlerCallCount > 0 );
}
public function focusOutHandlerTest():void
{
var testTCM:CustomTCM = addCustomTCM();
testTCM.setText("Testing the CustomTCM Event Handler Tests");
testTCM.updateContainer();
testTCM.container.dispatchEvent(new FocusEvent( FocusEvent.FOCUS_IN ) );
testTCM.container.dispatchEvent(new MouseEvent( MouseEvent.MOUSE_DOWN ) );
testTCM.container.dispatchEvent(new FocusEvent( Event.DEACTIVATE ) );
testTCM.container.dispatchEvent(new FocusEvent( FocusEvent.FOCUS_OUT ) );
testTCM.updateContainer();
assertTrue( "focusOutHandler not called on FocusEvent.FOCUS_OUT", testTCM.focusOutHandlerCallCount > 0 );
}
public function keyDownHandlerTest():void
{
var testTCM:CustomTCM = addCustomTCM();
testTCM.setText("Testing the CustomTCM Event Handler Tests");
testTCM.updateContainer();
testTCM.container.dispatchEvent(new FocusEvent( FocusEvent.FOCUS_IN ) );
testTCM.container.dispatchEvent(new MouseEvent( MouseEvent.MOUSE_DOWN ) );
testTCM.container.dispatchEvent(new KeyboardEvent( KeyboardEvent.KEY_DOWN ) );
testTCM.updateContainer();
assertTrue( "keyDownHandler not called on KeyboardEvent.KEY_DOWN", testTCM.keyDownHandlerCallCount > 0 );
}
public function keyUpHandlerTest():void
{
var testTCM:CustomTCM = addCustomTCM();
testTCM.setText("Testing the CustomTCM Event Handler Tests");
testTCM.updateContainer();
testTCM.container.dispatchEvent(new FocusEvent( FocusEvent.FOCUS_IN ) );
testTCM.container.dispatchEvent(new MouseEvent( MouseEvent.MOUSE_DOWN ) );
testTCM.container.dispatchEvent(new KeyboardEvent( KeyboardEvent.KEY_DOWN ) );
testTCM.container.dispatchEvent(new KeyboardEvent( KeyboardEvent.KEY_UP ) );
testTCM.updateContainer();
assertTrue( "keyUpHandler not called on KeyboardEvent.KEY_UP", testTCM.keyUpHandlerCallCount > 0 );
}
public function menuSelectHandlerTest():void
{
var testTCM:CustomTCM = addCustomTCM();
testTCM.setText("Testing the CustomTCM Event Handler Tests");
testTCM.updateContainer();
testTCM.container.dispatchEvent(new FocusEvent( FocusEvent.FOCUS_IN ) );
testTCM.container.dispatchEvent(new MouseEvent( MouseEvent.MOUSE_DOWN ) );
testTCM.container.dispatchEvent(new ContextMenuEvent(ContextMenuEvent.MENU_SELECT ) );
testTCM.updateContainer();
assertTrue( "menuSelectHandler not called on ContextMenuEvent.MENU_SELECT", testTCM.menuSelectHandlerCallCount > 0 );
}
public function mouseDoubleClickHandlerTest():void
{
var testTCM:CustomTCM = addCustomTCM();
testTCM.setText("Testing the CustomTCM Event Handler Tests");
testTCM.updateContainer();
testTCM.container.dispatchEvent(new FocusEvent( FocusEvent.FOCUS_IN ) );
testTCM.container.dispatchEvent(new MouseEvent( MouseEvent.MOUSE_DOWN ) );
testTCM.container.dispatchEvent(new MouseEvent( MouseEvent.DOUBLE_CLICK ) );
testTCM.updateContainer();
assertTrue( "mouseDoubleClickHandler not called on MouseEvent.DOUBLE_CLICK", testTCM.mouseDoubleClickHandlerCallCount > 0 );
}
public function mouseDownHandlerTest():void
{
var testTCM:CustomTCM = addCustomTCM();
testTCM.setText("Testing the CustomTCM Event Handler Tests");
testTCM.updateContainer();
testTCM.container.dispatchEvent(new FocusEvent( FocusEvent.FOCUS_IN ) );
testTCM.container.dispatchEvent(new MouseEvent( MouseEvent.MOUSE_DOWN ) );
testTCM.container.dispatchEvent(new MouseEvent( MouseEvent.MOUSE_DOWN ) );
testTCM.updateContainer();
assertTrue( "mouseDownHandler not called on MouseEvent.MOUSE_DOWN", testTCM.mouseDownHandlerCallCount > 0 );
}
public function mouseMoveHandlerTest():void
{
var testTCM:CustomTCM = addCustomTCM();
testTCM.setText("Testing the CustomTCM Event Handler Tests");
testTCM.updateContainer();
testTCM.container.dispatchEvent(new FocusEvent( FocusEvent.FOCUS_IN ) );
testTCM.container.dispatchEvent(new MouseEvent( MouseEvent.MOUSE_DOWN ) );
testTCM.container.dispatchEvent(new MouseEvent( MouseEvent.ROLL_OVER ) );
testTCM.container.dispatchEvent(new MouseEvent( MouseEvent.MOUSE_MOVE ) );
testTCM.updateContainer();
assertTrue( "mouseMoveHandler not called on MouseEvent.MOUSE_MOVE", testTCM.mouseMoveHandlerCallCount > 0 );
}
public function mouseOutHandlerTest():void
{
var testTCM:CustomTCM = addCustomTCM();
testTCM.setText("Testing the CustomTCM Event Handler Tests");
testTCM.updateContainer();
testTCM.container.dispatchEvent(new FocusEvent( FocusEvent.FOCUS_IN ) );
testTCM.container.dispatchEvent(new MouseEvent( MouseEvent.MOUSE_DOWN ) );
testTCM.container.dispatchEvent(new MouseEvent( MouseEvent.MOUSE_OUT ) );
testTCM.updateContainer();
assertTrue( "mouseOutHandler not called on MouseEvent.MOUSE_OUT", testTCM.mouseOutHandlerCallCount > 0 );
}
public function mouseUpHandlerTest():void
{
var testTCM:CustomTCM = addCustomTCM();
testTCM.setText("Testing the CustomTCM Event Handler Tests");
testTCM.updateContainer();
testTCM.container.dispatchEvent(new FocusEvent( FocusEvent.FOCUS_IN ) );
testTCM.container.dispatchEvent(new MouseEvent( MouseEvent.MOUSE_DOWN ) );
testTCM.container.dispatchEvent(new MouseEvent( MouseEvent.MOUSE_UP ) );
testTCM.updateContainer();
assertTrue( "mouseUpHandler not called on MouseEvent.MOUSE_UP", testTCM.mouseUpHandlerCallCount > 0 );
}
public function mouseWheelHandlerTest():void
{
var testTCM:CustomTCM = addCustomTCM();
testTCM.setText("Testing the CustomTCM Event Handler Tests");
testTCM.updateContainer();
testTCM.container.dispatchEvent(new FocusEvent( FocusEvent.FOCUS_IN ) );
testTCM.container.dispatchEvent(new MouseEvent( MouseEvent.MOUSE_DOWN ) );
testTCM.container.dispatchEvent(new MouseEvent( MouseEvent.MOUSE_WHEEL, true, false, 27, 48 ) );
testTCM.updateContainer();
assertTrue( "mouseWheelHandler not called on MouseEvent.MOUSE_WHEEL", testTCM.mouseWheelHandlerCallCount > 0 );
}
public function textInputHandlerTest():void
{
var testTCM:CustomTCM = addCustomTCM();
testTCM.setText("Testing the CustomTCM Event Handler Tests");
testTCM.updateContainer();
testTCM.container.dispatchEvent(new FocusEvent( FocusEvent.FOCUS_IN ) );
testTCM.container.dispatchEvent(new MouseEvent( MouseEvent.MOUSE_DOWN ) );
testTCM.container.dispatchEvent(new TextEvent( TextEvent.TEXT_INPUT ) );
testTCM.updateContainer();
assertTrue( "textInputHandler not called on TextEvent.TEXT_INPUT", testTCM.textInputHandlerCallCount > 0 );
}
private static const basicBackgroundColorTestMarkup:String = '