You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by pi...@apache.org on 2014/10/05 11:05:13 UTC
[02/30] Reorganized TLF test applications for using Apache Flex Unit
4.2.0 Changed first 8 tests for Apache Flex Unit Fixed ant build - no test
automation yet
http://git-wip-us.apache.org/repos/asf/flex-tlf/blob/cad064e0/automation_tests/src/UnitTest/Tests/ParagraphTest.as
----------------------------------------------------------------------
diff --git a/automation_tests/src/UnitTest/Tests/ParagraphTest.as b/automation_tests/src/UnitTest/Tests/ParagraphTest.as
index debc433..85463a9 100644
--- a/automation_tests/src/UnitTest/Tests/ParagraphTest.as
+++ b/automation_tests/src/UnitTest/Tests/ParagraphTest.as
@@ -40,7 +40,9 @@ package UnitTest.Tests
import flashx.textLayout.property.Property;
import flashx.textLayout.tlf_internal;
- use namespace tlf_internal;
+ import org.flexunit.asserts.assertTrue;
+
+ use namespace tlf_internal;
public class ParagraphTest extends VellumTestCase
{
http://git-wip-us.apache.org/repos/asf/flex-tlf/blob/cad064e0/automation_tests/src/UnitTest/Tests/SWFTest.as
----------------------------------------------------------------------
diff --git a/automation_tests/src/UnitTest/Tests/SWFTest.as b/automation_tests/src/UnitTest/Tests/SWFTest.as
index 9afcbf0..cdaff1e 100644
--- a/automation_tests/src/UnitTest/Tests/SWFTest.as
+++ b/automation_tests/src/UnitTest/Tests/SWFTest.as
@@ -42,7 +42,9 @@ package UnitTest.Tests
import mx.containers.Canvas;
import mx.utils.LoaderUtil;
- public class SWFTest extends VellumTestCase
+ import org.flexunit.asserts.assertTrue;
+
+ public class SWFTest extends VellumTestCase
{
public function SWFTest(methodName:String, testID:String, testConfig:TestConfig, testCaseXML:XML=null)
{
@@ -63,9 +65,9 @@ package UnitTest.Tests
load_file = TestData.swf;
ldr = new Loader();
ldr.load(new URLRequest(LoaderUtil.createAbsoluteURL(baseURL,"../../asPrivateTestApps/bin/" + load_file)));
- var func:Function = addAsync(validateLoad, 10000, null);
+ /*var func:Function = addAsync(validateLoad, 10000, null);
ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, func, false, 0, true);
- ldr.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, func, false, 0, true);
+ ldr.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, func, false, 0, true); */
}
public function validateLoad(e:Event):void
@@ -79,7 +81,7 @@ package UnitTest.Tests
thing1.addChild(ldr);
var result:String = ldr.content["validateTest"]();
- assertTrue (result, result=="");
+ assertTrue(result, result=="");
}
}
@@ -92,9 +94,9 @@ package UnitTest.Tests
{
ldr = new Loader();
ldr.load(new URLRequest(LoaderUtil.createAbsoluteURL(baseURL,fileName)));
- var func:Function = addAsync(validateInspectableLoad, 10000, null);
+ /*var func:Function = addAsync(validateInspectableLoad, 10000, null);
ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, func, false, 0, true);
- ldr.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, func, false, 0, true);
+ ldr.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, func, false, 0, true); */
}
public function validateInspectableLoad(e:Event):void
@@ -119,9 +121,9 @@ package UnitTest.Tests
// load these into a separate application domain
var loaderContext:LoaderContext = new LoaderContext(false, new ApplicationDomain());
ldr.load(new URLRequest(LoaderUtil.createAbsoluteURL(baseURL,"../../asPrivateTestApps/bin/" + load_file)),loaderContext);
- var func:Function = addAsync(validateLoadDC, 10000, null);
+ /* var func:Function = addAsync(validateLoadDC, 10000, null);
ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, func, false, 0, true);
- ldr.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, func, false, 0, true);
+ ldr.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, func, false, 0, true); */
exceptionList = exceptions;
}
@@ -196,14 +198,14 @@ package UnitTest.Tests
}
}
- public override function tearDown():void
+ public override function tearDownTest():void
{
if (thing1.parent)
{
var canvas:Canvas = testApp.getDisplayObject();
canvas.rawChildren.removeChild(thing1);
}
- super.tearDown();
+ super.tearDownTest();
}
}
}
http://git-wip-us.apache.org/repos/asf/flex-tlf/blob/cad064e0/automation_tests/src/UnitTest/Tests/ScrollToRangeTest.as
----------------------------------------------------------------------
diff --git a/automation_tests/src/UnitTest/Tests/ScrollToRangeTest.as b/automation_tests/src/UnitTest/Tests/ScrollToRangeTest.as
index 71caf02..5ff8646 100644
--- a/automation_tests/src/UnitTest/Tests/ScrollToRangeTest.as
+++ b/automation_tests/src/UnitTest/Tests/ScrollToRangeTest.as
@@ -40,7 +40,10 @@ package UnitTest.Tests
import mx.containers.Canvas;
- public class ScrollToRangeTest extends VellumTestCase
+ import org.flexunit.asserts.assertTrue;
+ import org.flexunit.asserts.fail;
+
+ public class ScrollToRangeTest extends VellumTestCase
{
private var testCanvas:Canvas;
private var testCaseXML:XML;
@@ -71,7 +74,7 @@ package UnitTest.Tests
VellumTestCase.suiteFromXML(testCaseClass, testListXML, testConfig, ts);
}
- override public function setUp() : void
+ override public function setUpTest() : void
{
cleanUpTestApp();
TestDisplayObject = testApp.getDisplayObject();
@@ -81,7 +84,7 @@ package UnitTest.Tests
}
else
{
- fail ("Did not get a blank canvas to work with");
+ fail("Did not get a blank canvas to work with");
}
}
http://git-wip-us.apache.org/repos/asf/flex-tlf/blob/cad064e0/automation_tests/src/UnitTest/Tests/ScrollingTest.as
----------------------------------------------------------------------
diff --git a/automation_tests/src/UnitTest/Tests/ScrollingTest.as b/automation_tests/src/UnitTest/Tests/ScrollingTest.as
index 13c5e01..4b52fbf 100644
--- a/automation_tests/src/UnitTest/Tests/ScrollingTest.as
+++ b/automation_tests/src/UnitTest/Tests/ScrollingTest.as
@@ -18,543 +18,587 @@
////////////////////////////////////////////////////////////////////////////////
package UnitTest.Tests
{
- import UnitTest.ExtendedClasses.TestSuiteExtended;
- import UnitTest.ExtendedClasses.VellumTestCase;
- import UnitTest.Fixtures.TestConfig;
- import UnitTest.Tests.SingleContainerTest;
-
- import flash.display.Shape;
- import flash.display.Sprite;
- import flash.events.KeyboardEvent;
- import flash.ui.Keyboard;
-
- import flashx.textLayout.compose.IFlowComposer;
- import flashx.textLayout.compose.TextFlowLine;
- import flashx.textLayout.container.ContainerController;
- import flashx.textLayout.conversion.TextConverter;
- import flashx.textLayout.edit.IEditManager;
- import flashx.textLayout.edit.SelectionManager;
- import flashx.textLayout.edit.SelectionState;
- import flashx.textLayout.elements.FlowElement;
- import flashx.textLayout.elements.InlineGraphicElement;
- import flashx.textLayout.elements.ParagraphElement;
- import flashx.textLayout.elements.SpanElement;
- import flashx.textLayout.elements.TextFlow;
- import flashx.textLayout.elements.TextRange;
- import flashx.textLayout.formats.*;
- import flashx.textLayout.utils.NavigationUtil;
-
- /** Test the state of selection after each operation is done, undone, and redone.
- */
- public class ScrollingTest extends VellumTestCase
- {
- public function ScrollingTest(methodName:String, testID:String, testConfig:TestConfig, testCaseXML:XML=null)
- {
- super(methodName, testID, testConfig, testCaseXML);
- addDefaultTestSettings = false;
- if (!TestData.hasOwnProperty("testFile"))
- TestData.fileName = "aliceExcerpt.xml"; // longer file so it exceeds container - default for this suite, tests may override in XML
- else
- TestData.fileName = TestData.testFile;
-
- // Note: These must correspond to a Watson product area (case-sensitive)
- metaData.productArea = "UI";
- metaData.productSubArea = "Scrolling";
- }
-
- public static function suiteFromXML(testListXML:XML, testConfig:TestConfig, ts:TestSuiteExtended):void
- {
- var testCaseClass:Class = ScrollingTest;
- VellumTestCase.suiteFromXML(testCaseClass, testListXML, testConfig, ts);
- }
-
-
- private function findFirstAndLastVisibleLine(flowComposer:IFlowComposer, controller:ContainerController):Array
- {
- var firstLine:int = flowComposer.findLineIndexAtPosition(controller.absoluteStart);
- var lastLine:int = flowComposer.findLineIndexAtPosition(controller.absoluteStart + controller.textLength - 1);
- var lastColumn:int = 0;
- var firstVisibleLine:int = -1;
- var lastVisibleLine:int = -1;
- for (var lineIndex:int = firstLine; lineIndex <= lastLine; lineIndex++)
- {
- var curLine:TextFlowLine = flowComposer.getLineAt(lineIndex);
- if (curLine.controller != controller)
- continue;
-
- // skip until we find the lines in the last column
- if (curLine.columnIndex != lastColumn)
- continue;
-
- if (curLine.textLineExists && curLine.getTextLine().parent)
- {
- if (firstVisibleLine < 0)
- firstVisibleLine = lineIndex;
-
- lastVisibleLine = lineIndex;
- }
- }
-
- return [firstVisibleLine, lastVisibleLine];
- }
-
- /* Test Cases: (explicit & wrap, vertical & horizontal, ltr, rtl)
- - Page forward, backward
- - Forward, backward by n lines
- - Partial line visible
- - On line boundary
- - Forward, backward by n pixels
- - Scroll to position horizontal scroll forward/backward (mimic typing off form field)
- - Scroll to position when position is visible
- - Scroll to position when position is partly visible (up/down/left/right)
- - Scroll to end
- - Scroll to start
- */
-
- private function pageForwardOrBackward(forward:Boolean):Array
- {
- var textFlow:TextFlow = SelManager.textFlow;
- var flowComposer:IFlowComposer = textFlow.flowComposer;
- var controller:ContainerController = flowComposer.getControllerAt(0);
- var blockProgression:String = textFlow.computedFormat.blockProgression;
-
- var linePositionBefore:Array = findFirstAndLastVisibleLine(flowComposer, controller);
-
- var panelSize:Number = (blockProgression == BlockProgression.TB) ? controller.compositionHeight : controller.compositionWidth;
- var pageSize:Number = panelSize * .75;
-
- if (!forward)
- pageSize = -pageSize;
-
- if (blockProgression == BlockProgression.TB)
- controller.verticalScrollPosition += pageSize;
- else
- controller.horizontalScrollPosition -= pageSize;
-
- flowComposer.updateAllControllers();
-
- return linePositionBefore;
- }
-
- public function pageForward():void
- {
- var beforePosition:Array = pageForwardOrBackward(true);
- var beforeFirstVisibleLine:int = beforePosition[0];
- var beforeLastVisibleLine:int = beforePosition[1];
-
- var textFlow:TextFlow = SelManager.textFlow;
- var flowComposer:IFlowComposer = textFlow.flowComposer;
- var controller:ContainerController = flowComposer.getControllerAt(0);
- var afterPosition:Array = findFirstAndLastVisibleLine(flowComposer, controller);
- var afterFirstVisibleLine:int = afterPosition[0];
- var afterLastVisibleLine:int = afterPosition[1];
-
- // Check that we did scroll forward, and check that some text that was visible before is still visible.
- assertTrue("PageForward didn't advance scroll", afterFirstVisibleLine > beforeFirstVisibleLine);
- assertTrue("PageForward didn't overlap previous text", afterFirstVisibleLine < beforeLastVisibleLine);
- }
-
- public function pageBackward():void
- {
- var beforePosition:Array = pageForwardOrBackward(false);
- var beforeFirstVisibleLine:int = beforePosition[0];
- var beforeLastVisibleLine:int = beforePosition[1];
-
- var textFlow:TextFlow = SelManager.textFlow;
- var flowComposer:IFlowComposer = textFlow.flowComposer;
- var controller:ContainerController = flowComposer.getControllerAt(0);
- var afterPosition:Array = findFirstAndLastVisibleLine(flowComposer, controller);
- var afterFirstVisibleLine:int = afterPosition[0];
- var afterLastVisibleLine:int = afterPosition[1];
-
- // Check that we did scroll backward, and check that some text that was visible before is still visible.
- assertTrue("PageBackward didn't reverse scroll", afterFirstVisibleLine < beforeFirstVisibleLine);
- assertTrue("PageBackward didn't overlap previous text", afterLastVisibleLine > beforeFirstVisibleLine);
- }
-
- public function scrollByPageTest():void
- {
- pageForward();
- pageBackward();
- }
-
- private function pageForwardOrBackwardByLines(numberOfLines:int):void
- {
- var textFlow:TextFlow = SelManager.textFlow;
- var flowComposer:IFlowComposer = textFlow.flowComposer;
- var controller:ContainerController = flowComposer.getControllerAt(0);
- var blockProgression:String = textFlow.computedFormat.blockProgression;
-
- var beforePosition:Array = findFirstAndLastVisibleLine(flowComposer, controller);
-
- var amount:Number = controller.getScrollDelta(numberOfLines);
-
- if (blockProgression == BlockProgression.TB)
- controller.verticalScrollPosition += amount;
- else
- controller.horizontalScrollPosition -= amount;
-
- flowComposer.updateAllControllers();
-
- var beforeFirstVisibleLine:int = beforePosition[0];
- var beforeLastVisibleLine:int = beforePosition[1];
-
- var afterPosition:Array = findFirstAndLastVisibleLine(flowComposer, controller);
- var afterFirstVisibleLine:int = afterPosition[0];
- var afterLastVisibleLine:int = afterPosition[1];
-
- // Check that we did scroll forward, and check that some text that was visible before is still visible.
- assertTrue("scrollMultipleLines didn't advance scroll correctly", afterFirstVisibleLine == beforeFirstVisibleLine + numberOfLines);
- }
-
- public function scrollMultipleLinesTest():void
- {
- pageForwardOrBackwardByLines(26);
- pageForwardOrBackwardByLines(-13);
- for (var i:int = 0; i < 6; ++i)
- pageForwardOrBackwardByLines(1);
- }
-
- public function scrollAndResizeTest():void
- {
- var textFlow:TextFlow = SelManager.textFlow;
- var position:int = textFlow.textLength-1;
-
- // shrink it down
- var w:Number = TestFrame.compositionWidth;
- var h:Number = TestFrame.compositionHeight;
- TestFrame.setCompositionSize(w/2,h/2);
- textFlow.flowComposer.updateAllControllers();
-
- // select at the end
- SelManager.selectRange(position,position);
- TestFrame.scrollToRange(position,position);
-
- // restore size
- TestFrame.setCompositionSize(w,h);
- textFlow.flowComposer.updateAllControllers();
-
- // verify that the last line is in view
- var afterPosition:Array = findFirstAndLastVisibleLine(textFlow.flowComposer, TestFrame);
- var afterFirstVisibleLine:int = afterPosition[0];
- var afterLastVisibleLine:int = afterPosition[1];
- assertTrue("scrollAndResizeTest last line no longer in view", afterLastVisibleLine == textFlow.flowComposer.numLines-1);
- }
- /* ************************************************************** */
- /* nextPage() test */
- /* ************************************************************** */
-
- public function nextPageTest():void
- {
- //Create a new TextFlow, IFlowComposer, ContainerController
- var textFlow:TextFlow = SelManager.textFlow;
- var flowComposer:IFlowComposer = textFlow.flowComposer;
- var controller:ContainerController = flowComposer.getControllerAt(0);
-
- //set a textRange.
- var textRange:TextRange = new TextRange(textFlow, 0, 10);
-
- NavigationUtil.nextPage(textRange, false);
-
- //composes all the text up-to date.
- flowComposer.updateAllControllers();
-
- //find what the first line displayed in a scrolling container is
- var firstLineIndex:int = findFirstAndLastVisibleLine(flowComposer, controller)[0];
-
- //verify the position of textRange after nextPage applied
- assertTrue("first line index at first line is " + firstLineIndex + " and it should be large than 0" ,
- firstLineIndex > 0);
- }
-
- /* ************************************************************** */
- /* previousPage() test */
- /* ************************************************************** */
-
- public function previousPageTest():void
- {
- //Create a new TextFlow, IFlowComposer, ContainerController?
- var textFlow:TextFlow = SelManager.textFlow;
- var flowComposer:IFlowComposer = textFlow.flowComposer;
- var controller:ContainerController = flowComposer.getControllerAt(0);
- controller.verticalScrollPosition = 100;
-
- //set a textRange.
- var textRange:TextRange = new TextRange(textFlow, 1000, 1010);
-
- //find text index at the first line in the visible area befor change
- var firstLineIndexBefore:int = findFirstAndLastVisibleLine(flowComposer, controller)[0];
-
- NavigationUtil.previousPage(textRange, false);
-
- //composes all the text up-to date.
- flowComposer.updateAllControllers();
-
- //find text index at the first line in the visible area after change
- var firstLineIndexAfter:int = findFirstAndLastVisibleLine(flowComposer, controller)[0];
-
- //verify the position of textRange after previousPage applied
- assertTrue("last line index at last line is " + firstLineIndexAfter + " and it should be less than " + firstLineIndexBefore,
- firstLineIndexAfter < firstLineIndexBefore);
- }
-
-
- private function testScrollLimitWithString(content:String):void
- // Scrolling from a long line to a short line should not scroll horizontally if end of short line already in view
- {
- var textFlow:TextFlow = TextConverter.importToFlow(content, TextConverter.PLAIN_TEXT_FORMAT);
- textFlow.lineBreak = LineBreak.EXPLICIT;
- var flowComposer:IFlowComposer = textFlow.flowComposer;
- var s:Sprite = new Sprite();
- var controller:ContainerController = new ContainerController(s, 100, 30);
- flowComposer.addController(controller);
- var selectionManager:SelectionManager = new SelectionManager();
- textFlow.interactionManager = selectionManager;
- selectionManager.selectRange(0, 0);
- selectionManager.setFocus();
- flowComposer.updateAllControllers();
-
- // Set cursor at the end of the 1st line
- var firstLine:TextFlowLine = flowComposer.getLineAt(0);
- selectionManager.selectRange(firstLine.absoluteStart + firstLine.textLength - 1, firstLine.absoluteStart + firstLine.textLength - 1);
- controller.scrollToRange(selectionManager.absoluteStart, selectionManager.absoluteEnd);
- var secondLine:TextFlowLine = flowComposer.getLineAt(1);
- var expectScrolling:Boolean = firstLine.textLength > secondLine.textLength;
-
-
- // Scroll down and back up
- scrollByKey(textFlow, Keyboard.DOWN, expectScrolling);
- scrollByKey(textFlow, Keyboard.UP, false);
- scrollByKey(textFlow, Keyboard.DOWN, false);
- scrollByKey(textFlow, Keyboard.UP, false);
-
- textFlow.interactionManager.selectRange(secondLine.absoluteStart + secondLine.textLength - 1, secondLine.absoluteStart + secondLine.textLength - 1);
- controller.scrollToRange(selectionManager.absoluteStart, selectionManager.absoluteEnd);
- flowComposer.updateAllControllers();
-
- // Scroll up and back down
- scrollByKey(textFlow, Keyboard.UP, !expectScrolling);
- scrollByKey(textFlow, Keyboard.DOWN, false);
- scrollByKey(textFlow, Keyboard.UP, false);
- scrollByKey(textFlow, Keyboard.DOWN, false);
- }
-
- public function scrollByKey(textFlow:TextFlow, keyCode:int, expectScrolling:Boolean):void
- // Scroll one line, and check that we only scrolled in vertical direction
- {
- var controller:ContainerController = textFlow.flowComposer.getControllerAt(0);
-
- // Save off old logical horizontal scroll pos
- var blockProgression:String = textFlow.computedFormat.blockProgression;
- var logicalHorizontalScrollPosition:Number = (blockProgression == BlockProgression.TB) ? controller.horizontalScrollPosition : controller.verticalScrollPosition;
-
- var kEvent:KeyboardEvent = new KeyboardEvent( KeyboardEvent.KEY_DOWN, true, false, 0, keyCode);
- SelectionManager(textFlow.interactionManager).keyDownHandler(kEvent);
-
- if (expectScrolling)
- assertTrue("Logical horizontal scroll position should have changed",
- logicalHorizontalScrollPosition != ((blockProgression == BlockProgression.TB) ? controller.horizontalScrollPosition : controller.verticalScrollPosition));
- else
- assertTrue("Logical horizontal scroll position should not have changed",
- logicalHorizontalScrollPosition == ((blockProgression == BlockProgression.TB) ? controller.horizontalScrollPosition : controller.verticalScrollPosition));
- }
-
- // Test for Watson 2476646
- public function scrollUpDownLimitTest():void
- // Scrolling from a long line to a short line or vice versa should not scroll horizontally if end of short line already in view
- {
- testScrollLimitWithString("A B C D E F G\n" + "A B C D E F G H I J K L M N O P Q R S T U V W X Y Z");
- testScrollLimitWithString("A B C D E F G H I J K L M N O P Q R S T U V W X Y Z\n" + "A B C D E F G");
- }
-
- public function scrollToSelectionAfterParagraphInsertion():void
- {
- var textFlow:TextFlow = SelManager.textFlow;
- textFlow.flowComposer.updateAllControllers();
- SelManager.selectRange(textFlow.textLength, textFlow.textLength);
- var paragraphCount:int = textFlow.computedFormat.blockProgression == BlockProgression.RL ? 12 : 7;
- for (var i:int = 0; i < paragraphCount; ++i)
- SelManager.splitParagraph();
- var controller:ContainerController = textFlow.flowComposer.getControllerAt(0);
- var firstLineIndex:int = findFirstAndLastVisibleLine(textFlow.flowComposer, controller)[0];
- assertTrue("Expected view to scroll to keep selection in view", firstLineIndex > 0);
- }
-
- public function scrollWithAdormentsAndInlines():void
- {
- var textFlow:TextFlow = SelManager.textFlow;
- textFlow.flowComposer.updateAllControllers();
- // underline everything
- SelManager.selectAll();
- var format:TextLayoutFormat = new TextLayoutFormat();
- format.textDecoration = TextDecoration.UNDERLINE;
- (SelManager as IEditManager).applyLeafFormat(format);
- // insert a graphic
- var shape:Shape = new Shape;
- shape.graphics.beginFill(0xff0000);
- shape.graphics.drawRect(0,0,25,25);
- shape.graphics.endFill();
- SelManager.selectRange(0,0);
- (SelManager as IEditManager).insertInlineGraphic(shape,25,25);
- // now page forward and then back
- pageForward();
- pageBackward();
- // check rendering - there should be decorations
- }
-
- public function scrollWithInsideList():void
- {
- var textFlow:TextFlow = SelManager.textFlow;
- textFlow.flowComposer.updateAllControllers();
- // now page forward and then back
- pageForward();
- pageBackward();
- // check rendering - the inside list should have proper markers
- }
-
- private function createFilledSprite(width:Number, height:Number, color:int):Sprite
- {
- var sprite:Sprite = new Sprite();
- sprite.graphics.beginFill(color); // red
- sprite.graphics.drawRect(0,0,width,height);
- sprite.graphics.endFill();
- return sprite;
- }
-
- public function largeLastLine():void // 2739996
- {
- var textFlow:TextFlow = SelManager.textFlow;
- SelManager.selectRange(textFlow.textLength - 1, textFlow.textLength - 1);
- SelManager.insertInlineGraphic(createFilledSprite(200, 200, 0xff0000), 200, 200, Float.NONE);
- textFlow.flowComposer.updateAllControllers();
- SelManager.selectRange(0, 0);
- textFlow.flowComposer.getControllerAt(0).scrollToRange(0, 0);
- var insertLineCount:int = textFlow.computedFormat.blockProgression == BlockProgression.RL ? 11 : 6;
- for (var i:int = 0; i < insertLineCount; ++i) // gradually force the inline out of view
- SelManager.splitParagraph();
- var firstVisibleLine:int = findFirstAndLastVisibleLine(textFlow.flowComposer, textFlow.flowComposer.getControllerAt(0))[0];
- assertTrue("Shouldn't scroll down yet", firstVisibleLine == 0);
- }
-
- // mjzhang : Watson#2819924 Error #1009 in flashx.textLayout.container::ContainerController::updateGraphics()
- public function Bug2819924_case1():void
- {
- var textFlow:TextFlow = SelManager.textFlow;
- var controller:ContainerController = textFlow.flowComposer.getControllerAt(0);
-
- for ( var i:int = 0; i < 15; i ++ )
- {
- textFlow.addChild( TextConverter.importToFlow(
- '<TextFlow xmlns="http://ns.adobe.com/textLayout/2008">xxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx <img source="http://static.v41.skyrock.net/chat/chat20080110/images/smileys/3-blink.png"/> xxxx</TextFlow>',
- TextConverter.TEXT_LAYOUT_FORMAT
- ).getChildAt(0) );
-
- textFlow.addChild(
- TextConverter.importToFlow(
- '<TextFlow xmlns="http://ns.adobe.com/textLayout/2008">xxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx</TextFlow>',
- TextConverter.TEXT_LAYOUT_FORMAT
- ).getChildAt(0) );
-
- controller.verticalScrollPosition += 50;
- textFlow.flowComposer.updateAllControllers();
- }
- }
- private var singleCT:SingleContainerTest = new SingleContainerTest();
- // mjzhang : Watson#2819924 Error #1009 in flashx.textLayout.container::ContainerController::updateGraphics()
- public function Bug2819924_case2():void
- {
- SelManager.insertInlineGraphic(singleCT, 600, 400, Float.NONE);
- }
-
- // mjzhang : Watson#2819924 Error #1009 in flashx.textLayout.container::ContainerController::updateGraphics()
- public function Bug2819924_case3():void
- {
- var textFlow:TextFlow = SelManager.textFlow;
- var controller:ContainerController = textFlow.flowComposer.getControllerAt(0);
-
- var str:String = "";
- var i:int = 30;
- while(i>0){
- str += i+"\n"
- i--;
- }
-
- var tf:TextFlow = TextConverter.importToFlow(str, TextConverter.PLAIN_TEXT_FORMAT);
- var flowElem:FlowElement = tf.getChildAt(0);
- textFlow.addChild( flowElem );
-
- textFlow.addChild( TextConverter.importToFlow(
- '<TextFlow xmlns="http://ns.adobe.com/textLayout/2008"><img source="http://static.v41.skyrock.net/chat/chat20080110/images/smileys/3-blink.png"/> </TextFlow>',
- TextConverter.TEXT_LAYOUT_FORMAT
- ).getChildAt(0) );
-
-
- for ( var j:int = 0; j < 100; j ++ )
- {
- textFlow.addChild( TextConverter.importToFlow("aaa", TextConverter.PLAIN_TEXT_FORMAT).getChildAt(0) );
- textFlow.addChild( TextConverter.importToFlow(
- '<TextFlow xmlns="http://ns.adobe.com/textLayout/2008"><img source="http://static.v41.skyrock.net/chat/chat20080110/images/smileys/3-blink.png"/> </TextFlow>',
- TextConverter.TEXT_LAYOUT_FORMAT
- ).getChildAt(0) );
-
- controller.verticalScrollPosition += 10;
- textFlow.flowComposer.updateAllControllers();
- }
-
- textFlow.flowComposer.updateAllControllers();
- }
-
- public function bug2988852():void
- {
- var tf:TextFlow = SelManager.textFlow;
- for( var i:int = 0; i < 15; i ++ )
- {
- tf.addChild( TextConverter.importToFlow(
- '<TextFlow xmlns="http://ns.adobe.com/textLayout/2008">Alice was beginning to get very tired of sitting by her sister on the bank, and of having nothing to do: once or twice she had peeped into the book her sister was reading, but it had no pictures or conversations in it, “and what is the use of a book,” thought Alice “without pictures or conversation?<img source="http://static.v41.skyrock.net/chat/chat20080110/images/smileys/3-blink.png"/> conversation?</TextFlow>',
- TextConverter.TEXT_LAYOUT_FORMAT
- ).getChildAt(0) );
- }
- tf.flowComposer.updateAllControllers();
-
- SelManager.insertInlineGraphic(singleCT, "auto", "auto", Float.NONE, new SelectionState(tf, 500,500));
- var controller:ContainerController = tf.flowComposer.getControllerAt(0);
- controller.verticalScrollPosition += 20;
- tf.flowComposer.updateAllControllers();
-
- controller.verticalScrollPosition += 2000;
- tf.flowComposer.updateAllControllers();
-
- controller.verticalScrollPosition -= 2100;
- tf.flowComposer.updateAllControllers();
-
- for(var scrollTimes:int = 0; scrollTimes < 10; scrollTimes ++)
- {
- controller.verticalScrollPosition += (800 + 50*scrollTimes);
- tf.flowComposer.updateAllControllers();
-
- controller.verticalScrollPosition -= (800 + 20*scrollTimes);
- tf.flowComposer.updateAllControllers();
- }
- }
-
- public function twoColumnsTest():void
- {
- var tf:TextFlow = SelManager.textFlow;
- for( var i:int = 0; i < 60; i ++ )
- {
- tf.addChildAt(0, TextConverter.importToFlow(
- '<TextFlow xmlns="http://ns.adobe.com/textLayout/2008"><list paddingRight="24" paddingLeft="24" listStyleType="upperAlpha"><li>upperAlpha item</li></list></TextFlow>',
- TextConverter.TEXT_LAYOUT_FORMAT
- ).getChildAt(0));
- }
- var controller:ContainerController = tf.flowComposer.getControllerAt(0);
- controller.columnCount = 2;
- tf.flowComposer.updateAllControllers();
-
- controller.verticalScrollPosition += 100;
- tf.flowComposer.updateAllControllers();
- var tfl60:TextFlowLine = tf.flowComposer.getLineAt(59);
- assertTrue("The 60th line should be on the stage after scrolling down 100 pixels", controller.container.contains(tfl60.getTextLine()));
- }
- }
+
+ import UnitTest.ExtendedClasses.TestSuiteExtended;
+ import UnitTest.ExtendedClasses.VellumTestCase;
+ import UnitTest.Fixtures.TestConfig;
+
+ import flash.display.Shape;
+ import flash.display.Sprite;
+ import flash.events.KeyboardEvent;
+ import flash.ui.Keyboard;
+
+ import flashx.textLayout.compose.IFlowComposer;
+ import flashx.textLayout.compose.TextFlowLine;
+ import flashx.textLayout.container.ContainerController;
+ import flashx.textLayout.conversion.TextConverter;
+ import flashx.textLayout.edit.IEditManager;
+ import flashx.textLayout.edit.SelectionManager;
+ import flashx.textLayout.edit.SelectionState;
+ import flashx.textLayout.elements.FlowElement;
+ import flashx.textLayout.elements.TextFlow;
+ import flashx.textLayout.elements.TextRange;
+ import flashx.textLayout.formats.*;
+ import flashx.textLayout.utils.NavigationUtil;
+
+ import org.flexunit.asserts.assertTrue;
+
+ /** Test the state of selection after each operation is done, undone, and redone.
+ */
+ public class ScrollingTest extends VellumTestCase
+ {
+ public function ScrollingTest()
+ {
+ // super(methodName, testID, testConfig, testCaseXML);
+ super("", "OperationTest2", TestConfig.getInstance());
+
+ addDefaultTestSettings = false;
+ TestData.fileName = "aliceExcerpt.xml";
+
+ /*if (!TestData.hasOwnProperty("testFile"))
+ TestData.fileName = "aliceExcerpt.xml"; // longer file so it exceeds container - default for this suite, tests may override in XML
+ else
+ TestData.fileName = TestData.testFile; */
+
+ metaData = {};
+ // Note: These must correspond to a Watson product area (case-sensitive)
+ metaData.productArea = "UI";
+ metaData.productSubArea = "Scrolling";
+ }
+
+ public static function suiteFromXML(testListXML:XML, testConfig:TestConfig, ts:TestSuiteExtended):void
+ {
+ var testCaseClass:Class = ScrollingTest;
+ VellumTestCase.suiteFromXML(testCaseClass, testListXML, testConfig, ts);
+ }
+
+ [Before]
+ override public function setUpTest():void
+ {
+ super.setUpTest();
+ }
+
+ [After]
+ override public function tearDownTest():void
+ {
+ super.tearDownTest();
+ }
+
+ private function findFirstAndLastVisibleLine(flowComposer:IFlowComposer, controller:ContainerController):Array
+ {
+ var firstLine:int = flowComposer.findLineIndexAtPosition(controller.absoluteStart);
+ var lastLine:int = flowComposer.findLineIndexAtPosition(controller.absoluteStart + controller.textLength - 1);
+ var lastColumn:int = 0;
+ var firstVisibleLine:int = -1;
+ var lastVisibleLine:int = -1;
+ for (var lineIndex:int = firstLine; lineIndex <= lastLine; lineIndex++)
+ {
+ var curLine:TextFlowLine = flowComposer.getLineAt(lineIndex);
+ if (curLine.controller != controller)
+ continue;
+
+ // skip until we find the lines in the last column
+ if (curLine.columnIndex != lastColumn)
+ continue;
+
+ if (curLine.textLineExists && curLine.getTextLine().parent)
+ {
+ if (firstVisibleLine < 0)
+ firstVisibleLine = lineIndex;
+
+ lastVisibleLine = lineIndex;
+ }
+ }
+
+ return [firstVisibleLine, lastVisibleLine];
+ }
+
+ /* Test Cases: (explicit & wrap, vertical & horizontal, ltr, rtl)
+ - Page forward, backward
+ - Forward, backward by n lines
+ - Partial line visible
+ - On line boundary
+ - Forward, backward by n pixels
+ - Scroll to position horizontal scroll forward/backward (mimic typing off form field)
+ - Scroll to position when position is visible
+ - Scroll to position when position is partly visible (up/down/left/right)
+ - Scroll to end
+ - Scroll to start
+ */
+
+ private function pageForwardOrBackward(forward:Boolean):Array
+ {
+ var textFlow:TextFlow = SelManager.textFlow;
+ var flowComposer:IFlowComposer = textFlow.flowComposer;
+ var controller:ContainerController = flowComposer.getControllerAt(0);
+ var blockProgression:String = textFlow.computedFormat.blockProgression;
+
+ var linePositionBefore:Array = findFirstAndLastVisibleLine(flowComposer, controller);
+
+ var panelSize:Number = (blockProgression == BlockProgression.TB) ? controller.compositionHeight : controller.compositionWidth;
+ var pageSize:Number = panelSize * .75;
+
+ if (!forward)
+ pageSize = -pageSize;
+
+ if (blockProgression == BlockProgression.TB)
+ controller.verticalScrollPosition += pageSize;
+ else
+ controller.horizontalScrollPosition -= pageSize;
+
+ flowComposer.updateAllControllers();
+
+ return linePositionBefore;
+ }
+
+ private function pageForward():void
+ {
+ var beforePosition:Array = pageForwardOrBackward(true);
+ var beforeFirstVisibleLine:int = beforePosition[0];
+ var beforeLastVisibleLine:int = beforePosition[1];
+
+ var textFlow:TextFlow = SelManager.textFlow;
+ var flowComposer:IFlowComposer = textFlow.flowComposer;
+ var controller:ContainerController = flowComposer.getControllerAt(0);
+ var afterPosition:Array = findFirstAndLastVisibleLine(flowComposer, controller);
+ var afterFirstVisibleLine:int = afterPosition[0];
+ var afterLastVisibleLine:int = afterPosition[1];
+
+ // Check that we did scroll forward, and check that some text that was visible before is still visible.
+ assertTrue("PageForward didn't advance scroll", afterFirstVisibleLine > beforeFirstVisibleLine);
+ assertTrue("PageForward didn't overlap previous text", afterFirstVisibleLine < beforeLastVisibleLine);
+ }
+
+
+ private function pageBackward():void
+ {
+ var beforePosition:Array = pageForwardOrBackward(false);
+ var beforeFirstVisibleLine:int = beforePosition[0];
+ var beforeLastVisibleLine:int = beforePosition[1];
+
+ var textFlow:TextFlow = SelManager.textFlow;
+ var flowComposer:IFlowComposer = textFlow.flowComposer;
+ var controller:ContainerController = flowComposer.getControllerAt(0);
+ var afterPosition:Array = findFirstAndLastVisibleLine(flowComposer, controller);
+ var afterFirstVisibleLine:int = afterPosition[0];
+ var afterLastVisibleLine:int = afterPosition[1];
+
+ // Check that we did scroll backward, and check that some text that was visible before is still visible.
+ assertTrue("PageBackward didn't reverse scroll", afterFirstVisibleLine < beforeFirstVisibleLine);
+ assertTrue("PageBackward didn't overlap previous text", afterLastVisibleLine > beforeFirstVisibleLine);
+ }
+
+ [Test]
+ public function scrollByPageTest():void
+ {
+ pageForward();
+ pageBackward();
+ }
+
+ private function pageForwardOrBackwardByLines(numberOfLines:int):void
+ {
+ var textFlow:TextFlow = SelManager.textFlow;
+ var flowComposer:IFlowComposer = textFlow.flowComposer;
+ var controller:ContainerController = flowComposer.getControllerAt(0);
+ var blockProgression:String = textFlow.computedFormat.blockProgression;
+
+ var beforePosition:Array = findFirstAndLastVisibleLine(flowComposer, controller);
+
+ var amount:Number = controller.getScrollDelta(numberOfLines);
+
+ if (blockProgression == BlockProgression.TB)
+ controller.verticalScrollPosition += amount;
+ else
+ controller.horizontalScrollPosition -= amount;
+
+ flowComposer.updateAllControllers();
+
+ var beforeFirstVisibleLine:int = beforePosition[0];
+ var beforeLastVisibleLine:int = beforePosition[1];
+
+ var afterPosition:Array = findFirstAndLastVisibleLine(flowComposer, controller);
+ var afterFirstVisibleLine:int = afterPosition[0];
+ var afterLastVisibleLine:int = afterPosition[1];
+
+ // Check that we did scroll forward, and check that some text that was visible before is still visible.
+ assertTrue("scrollMultipleLines didn't advance scroll correctly", afterFirstVisibleLine == beforeFirstVisibleLine + numberOfLines);
+ }
+
+ [Test]
+ [Ignore]
+ public function scrollMultipleLinesTest():void
+ {
+ pageForwardOrBackwardByLines(26);
+ pageForwardOrBackwardByLines(-13);
+ for (var i:int = 0; i < 6; ++i)
+ pageForwardOrBackwardByLines(1);
+ }
+
+ [Test]
+ public function scrollAndResizeTest():void
+ {
+ var textFlow:TextFlow = SelManager.textFlow;
+ var position:int = textFlow.textLength - 1;
+
+ // shrink it down
+ var w:Number = TestFrame.compositionWidth;
+ var h:Number = TestFrame.compositionHeight;
+ TestFrame.setCompositionSize(w / 2, h / 2);
+ textFlow.flowComposer.updateAllControllers();
+
+ // select at the end
+ SelManager.selectRange(position, position);
+ TestFrame.scrollToRange(position, position);
+
+ // restore size
+ TestFrame.setCompositionSize(w, h);
+ textFlow.flowComposer.updateAllControllers();
+
+ // verify that the last line is in view
+ var afterPosition:Array = findFirstAndLastVisibleLine(textFlow.flowComposer, TestFrame);
+ var afterFirstVisibleLine:int = afterPosition[0];
+ var afterLastVisibleLine:int = afterPosition[1];
+ assertTrue("scrollAndResizeTest last line no longer in view", afterLastVisibleLine == textFlow.flowComposer.numLines - 1);
+ }
+
+ /* ************************************************************** */
+ /* nextPage() test */
+ /* ************************************************************** */
+
+ [Test]
+ public function nextPageTest():void
+ {
+ //Create a new TextFlow, IFlowComposer, ContainerController
+ var textFlow:TextFlow = SelManager.textFlow;
+ var flowComposer:IFlowComposer = textFlow.flowComposer;
+ var controller:ContainerController = flowComposer.getControllerAt(0);
+
+ //set a textRange.
+ var textRange:TextRange = new TextRange(textFlow, 0, 10);
+
+ NavigationUtil.nextPage(textRange, false);
+
+ //composes all the text up-to date.
+ flowComposer.updateAllControllers();
+
+ //find what the first line displayed in a scrolling container is
+ var firstLineIndex:int = findFirstAndLastVisibleLine(flowComposer, controller)[0];
+
+ //verify the position of textRange after nextPage applied
+ assertTrue("first line index at first line is " + firstLineIndex + " and it should be large than 0",
+ firstLineIndex > 0);
+ }
+
+ /* ************************************************************** */
+ /* previousPage() test */
+ /* ************************************************************** */
+ [Test]
+ public function previousPageTest():void
+ {
+ //Create a new TextFlow, IFlowComposer, ContainerController?
+ var textFlow:TextFlow = SelManager.textFlow;
+ var flowComposer:IFlowComposer = textFlow.flowComposer;
+ var controller:ContainerController = flowComposer.getControllerAt(0);
+ controller.verticalScrollPosition = 100;
+
+ //set a textRange.
+ var textRange:TextRange = new TextRange(textFlow, 1000, 1010);
+
+ //find text index at the first line in the visible area befor change
+ var firstLineIndexBefore:int = findFirstAndLastVisibleLine(flowComposer, controller)[0];
+
+ NavigationUtil.previousPage(textRange, false);
+
+ //composes all the text up-to date.
+ flowComposer.updateAllControllers();
+
+ //find text index at the first line in the visible area after change
+ var firstLineIndexAfter:int = findFirstAndLastVisibleLine(flowComposer, controller)[0];
+
+ //verify the position of textRange after previousPage applied
+ assertTrue("last line index at last line is " + firstLineIndexAfter + " and it should be less than " + firstLineIndexBefore,
+ firstLineIndexAfter < firstLineIndexBefore);
+ }
+
+
+ private function testScrollLimitWithString(content:String):void
+ // Scrolling from a long line to a short line should not scroll horizontally if end of short line already in view
+ {
+ var textFlow:TextFlow = TextConverter.importToFlow(content, TextConverter.PLAIN_TEXT_FORMAT);
+ textFlow.lineBreak = LineBreak.EXPLICIT;
+ var flowComposer:IFlowComposer = textFlow.flowComposer;
+ var s:Sprite = new Sprite();
+ var controller:ContainerController = new ContainerController(s, 100, 30);
+ flowComposer.addController(controller);
+ var selectionManager:SelectionManager = new SelectionManager();
+ textFlow.interactionManager = selectionManager;
+ selectionManager.selectRange(0, 0);
+ selectionManager.setFocus();
+ flowComposer.updateAllControllers();
+
+ // Set cursor at the end of the 1st line
+ var firstLine:TextFlowLine = flowComposer.getLineAt(0);
+ selectionManager.selectRange(firstLine.absoluteStart + firstLine.textLength - 1, firstLine.absoluteStart + firstLine.textLength - 1);
+ controller.scrollToRange(selectionManager.absoluteStart, selectionManager.absoluteEnd);
+ var secondLine:TextFlowLine = flowComposer.getLineAt(1);
+ var expectScrolling:Boolean = firstLine.textLength > secondLine.textLength;
+
+
+ // Scroll down and back up
+ scrollByKey(textFlow, Keyboard.DOWN, expectScrolling);
+ scrollByKey(textFlow, Keyboard.UP, false);
+ scrollByKey(textFlow, Keyboard.DOWN, false);
+ scrollByKey(textFlow, Keyboard.UP, false);
+
+ textFlow.interactionManager.selectRange(secondLine.absoluteStart + secondLine.textLength - 1, secondLine.absoluteStart + secondLine.textLength - 1);
+ controller.scrollToRange(selectionManager.absoluteStart, selectionManager.absoluteEnd);
+ flowComposer.updateAllControllers();
+
+ // Scroll up and back down
+ scrollByKey(textFlow, Keyboard.UP, !expectScrolling);
+ scrollByKey(textFlow, Keyboard.DOWN, false);
+ scrollByKey(textFlow, Keyboard.UP, false);
+ scrollByKey(textFlow, Keyboard.DOWN, false);
+ }
+
+ private function scrollByKey(textFlow:TextFlow, keyCode:int, expectScrolling:Boolean):void
+ // Scroll one line, and check that we only scrolled in vertical direction
+ {
+ var controller:ContainerController = textFlow.flowComposer.getControllerAt(0);
+
+ // Save off old logical horizontal scroll pos
+ var blockProgression:String = textFlow.computedFormat.blockProgression;
+ var logicalHorizontalScrollPosition:Number = (blockProgression == BlockProgression.TB) ? controller.horizontalScrollPosition : controller.verticalScrollPosition;
+
+ var kEvent:KeyboardEvent = new KeyboardEvent(KeyboardEvent.KEY_DOWN, true, false, 0, keyCode);
+ SelectionManager(textFlow.interactionManager).keyDownHandler(kEvent);
+
+ if (expectScrolling)
+ assertTrue("Logical horizontal scroll position should have changed",
+ logicalHorizontalScrollPosition != ((blockProgression == BlockProgression.TB) ? controller.horizontalScrollPosition : controller.verticalScrollPosition));
+ else
+ assertTrue("Logical horizontal scroll position should not have changed",
+ logicalHorizontalScrollPosition == ((blockProgression == BlockProgression.TB) ? controller.horizontalScrollPosition : controller.verticalScrollPosition));
+ }
+
+ /**
+ * Test for Watson 2476646
+ */
+ [Test]
+ public function scrollUpDownLimitTest():void
+ // Scrolling from a long line to a short line or vice versa should not scroll horizontally if end of short line already in view
+ {
+ testScrollLimitWithString("A B C D E F G\n" + "A B C D E F G H I J K L M N O P Q R S T U V W X Y Z");
+ testScrollLimitWithString("A B C D E F G H I J K L M N O P Q R S T U V W X Y Z\n" + "A B C D E F G");
+ }
+
+ [Test]
+ public function scrollToSelectionAfterParagraphInsertion():void
+ {
+ var textFlow:TextFlow = SelManager.textFlow;
+ textFlow.flowComposer.updateAllControllers();
+ SelManager.selectRange(textFlow.textLength, textFlow.textLength);
+ var paragraphCount:int = textFlow.computedFormat.blockProgression == BlockProgression.RL ? 12 : 7;
+ for (var i:int = 0; i < paragraphCount; ++i)
+ SelManager.splitParagraph();
+ var controller:ContainerController = textFlow.flowComposer.getControllerAt(0);
+ var firstLineIndex:int = findFirstAndLastVisibleLine(textFlow.flowComposer, controller)[0];
+ assertTrue("Expected view to scroll to keep selection in view", firstLineIndex > 0);
+ }
+
+ [Test]
+ public function scrollWithAdormentsAndInlines():void
+ {
+ var textFlow:TextFlow = SelManager.textFlow;
+ textFlow.flowComposer.updateAllControllers();
+ // underline everything
+ SelManager.selectAll();
+ var format:TextLayoutFormat = new TextLayoutFormat();
+ format.textDecoration = TextDecoration.UNDERLINE;
+ (SelManager as IEditManager).applyLeafFormat(format);
+ // insert a graphic
+ var shape:Shape = new Shape;
+ shape.graphics.beginFill(0xff0000);
+ shape.graphics.drawRect(0, 0, 25, 25);
+ shape.graphics.endFill();
+ SelManager.selectRange(0, 0);
+ (SelManager as IEditManager).insertInlineGraphic(shape, 25, 25);
+ // now page forward and then back
+ pageForward();
+ pageBackward();
+ // check rendering - there should be decorations
+ }
+
+ [Test]
+ public function scrollWithInsideList():void
+ {
+ var textFlow:TextFlow = SelManager.textFlow;
+ textFlow.flowComposer.updateAllControllers();
+ // now page forward and then back
+ pageForward();
+ pageBackward();
+ // check rendering - the inside list should have proper markers
+ }
+
+ private function createFilledSprite(width:Number, height:Number, color:int):Sprite
+ {
+ var sprite:Sprite = new Sprite();
+ sprite.graphics.beginFill(color); // red
+ sprite.graphics.drawRect(0, 0, width, height);
+ sprite.graphics.endFill();
+ return sprite;
+ }
+
+ [Test]
+ public function largeLastLine():void // 2739996
+ {
+ var textFlow:TextFlow = SelManager.textFlow;
+ SelManager.selectRange(textFlow.textLength - 1, textFlow.textLength - 1);
+ SelManager.insertInlineGraphic(createFilledSprite(200, 200, 0xff0000), 200, 200, Float.NONE);
+ textFlow.flowComposer.updateAllControllers();
+ SelManager.selectRange(0, 0);
+ textFlow.flowComposer.getControllerAt(0).scrollToRange(0, 0);
+ var insertLineCount:int = textFlow.computedFormat.blockProgression == BlockProgression.RL ? 11 : 6;
+ for (var i:int = 0; i < insertLineCount; ++i) // gradually force the inline out of view
+ SelManager.splitParagraph();
+ var firstVisibleLine:int = findFirstAndLastVisibleLine(textFlow.flowComposer, textFlow.flowComposer.getControllerAt(0))[0];
+ assertTrue("Shouldn't scroll down yet", firstVisibleLine == 0);
+ }
+
+ /**
+ * mjzhang : Watson#2819924 Error #1009 in flashx.textLayout.container::ContainerController::updateGraphics()
+ */
+ [Test]
+ public function Bug2819924_case1():void
+ {
+ var textFlow:TextFlow = SelManager.textFlow;
+ var controller:ContainerController = textFlow.flowComposer.getControllerAt(0);
+
+ for (var i:int = 0; i < 15; i++)
+ {
+ textFlow.addChild(TextConverter.importToFlow(
+ '<TextFlow xmlns="http://ns.adobe.com/textLayout/2008">xxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx <img source="http://static.v41.skyrock.net/chat/chat20080110/images/smileys/3-blink.png"/> xxxx</TextFlow>',
+ TextConverter.TEXT_LAYOUT_FORMAT
+ ).getChildAt(0));
+
+ textFlow.addChild(
+ TextConverter.importToFlow(
+ '<TextFlow xmlns="http://ns.adobe.com/textLayout/2008">xxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx</TextFlow>',
+ TextConverter.TEXT_LAYOUT_FORMAT
+ ).getChildAt(0));
+
+ controller.verticalScrollPosition += 50;
+ textFlow.flowComposer.updateAllControllers();
+ }
+ }
+
+ private var singleCT:SingleContainerTest = new SingleContainerTest();
+
+ /**
+ * mjzhang : Watson#2819924 Error #1009 in flashx.textLayout.container::ContainerController::updateGraphics()
+ */
+ [Test]
+ public function Bug2819924_case2():void
+ {
+ SelManager.insertInlineGraphic(singleCT, 600, 400, Float.NONE);
+ }
+
+ /**
+ * mjzhang : Watson#2819924 Error #1009 in flashx.textLayout.container::ContainerController::updateGraphics()
+ */
+ [Test]
+ public function Bug2819924_case3():void
+ {
+ var textFlow:TextFlow = SelManager.textFlow;
+ var controller:ContainerController = textFlow.flowComposer.getControllerAt(0);
+
+ var str:String = "";
+ var i:int = 30;
+ while (i > 0)
+ {
+ str += i + "\n"
+ i--;
+ }
+
+ var tf:TextFlow = TextConverter.importToFlow(str, TextConverter.PLAIN_TEXT_FORMAT);
+ var flowElem:FlowElement = tf.getChildAt(0);
+ textFlow.addChild(flowElem);
+
+ textFlow.addChild(TextConverter.importToFlow(
+ '<TextFlow xmlns="http://ns.adobe.com/textLayout/2008"><img source="http://static.v41.skyrock.net/chat/chat20080110/images/smileys/3-blink.png"/> </TextFlow>',
+ TextConverter.TEXT_LAYOUT_FORMAT
+ ).getChildAt(0));
+
+
+ for (var j:int = 0; j < 100; j++)
+ {
+ textFlow.addChild(TextConverter.importToFlow("aaa", TextConverter.PLAIN_TEXT_FORMAT).getChildAt(0));
+ textFlow.addChild(TextConverter.importToFlow(
+ '<TextFlow xmlns="http://ns.adobe.com/textLayout/2008"><img source="http://static.v41.skyrock.net/chat/chat20080110/images/smileys/3-blink.png"/> </TextFlow>',
+ TextConverter.TEXT_LAYOUT_FORMAT
+ ).getChildAt(0));
+
+ controller.verticalScrollPosition += 10;
+ textFlow.flowComposer.updateAllControllers();
+ }
+
+ textFlow.flowComposer.updateAllControllers();
+ }
+
+ [Test]
+ public function bug2988852():void
+ {
+ var tf:TextFlow = SelManager.textFlow;
+ for (var i:int = 0; i < 15; i++)
+ {
+ tf.addChild(TextConverter.importToFlow(
+ '<TextFlow xmlns="http://ns.adobe.com/textLayout/2008">Alice was beginning to get very tired of sitting by her sister on the bank, and of having nothing to do: once or twice she had peeped into the book her sister was reading, but it had no pictures or conversations in it, “and what is the use of a book,” thought Alice “without pictures or conversation?<img source="http://static.v41.skyrock.net/chat/chat20080110/images/smileys/3-blink.png"/> conversation?</TextFlow>',
+ TextConverter.TEXT_LAYOUT_FORMAT
+ ).getChildAt(0));
+ }
+ tf.flowComposer.updateAllControllers();
+
+ SelManager.insertInlineGraphic(singleCT, "auto", "auto", Float.NONE, new SelectionState(tf, 500, 500));
+ var controller:ContainerController = tf.flowComposer.getControllerAt(0);
+ controller.verticalScrollPosition += 20;
+ tf.flowComposer.updateAllControllers();
+
+ controller.verticalScrollPosition += 2000;
+ tf.flowComposer.updateAllControllers();
+
+ controller.verticalScrollPosition -= 2100;
+ tf.flowComposer.updateAllControllers();
+
+ for (var scrollTimes:int = 0; scrollTimes < 10; scrollTimes++)
+ {
+ controller.verticalScrollPosition += (800 + 50 * scrollTimes);
+ tf.flowComposer.updateAllControllers();
+
+ controller.verticalScrollPosition -= (800 + 20 * scrollTimes);
+ tf.flowComposer.updateAllControllers();
+ }
+ }
+
+ [Test]
+ [Ignore]
+ public function twoColumnsTest():void
+ {
+ var tf:TextFlow = SelManager.textFlow;
+ for (var i:int = 0; i < 60; i++)
+ {
+ tf.addChildAt(0, TextConverter.importToFlow(
+ '<TextFlow xmlns="http://ns.adobe.com/textLayout/2008"><list paddingRight="24" paddingLeft="24" listStyleType="upperAlpha"><li>upperAlpha item</li></list></TextFlow>',
+ TextConverter.TEXT_LAYOUT_FORMAT
+ ).getChildAt(0));
+ }
+ var controller:ContainerController = tf.flowComposer.getControllerAt(0);
+ controller.columnCount = 2;
+ tf.flowComposer.updateAllControllers();
+
+ controller.verticalScrollPosition += 100;
+ tf.flowComposer.updateAllControllers();
+ var tfl60:TextFlowLine = tf.flowComposer.getLineAt(59);
+ assertTrue("The 60th line should be on the stage after scrolling down 100 pixels", controller.container.contains(tfl60.getTextLine()));
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/flex-tlf/blob/cad064e0/automation_tests/src/UnitTest/Tests/SelectionTest.as
----------------------------------------------------------------------
diff --git a/automation_tests/src/UnitTest/Tests/SelectionTest.as b/automation_tests/src/UnitTest/Tests/SelectionTest.as
index b2138d7..2e72cfd 100644
--- a/automation_tests/src/UnitTest/Tests/SelectionTest.as
+++ b/automation_tests/src/UnitTest/Tests/SelectionTest.as
@@ -51,7 +51,10 @@ package UnitTest.Tests
import mx.utils.LoaderUtil;
- public class SelectionTest extends VellumTestCase
+ import org.flexunit.asserts.assertTrue;
+ import org.flexunit.asserts.fail;
+
+ public class SelectionTest extends VellumTestCase
{
public function SelectionTest(methodName:String, testID:String, testConfig:TestConfig, testCaseXML:XML=null)
{
@@ -72,14 +75,14 @@ package UnitTest.Tests
VellumTestCase.suiteFromXML(testCaseClass, testListXML, testConfig, ts);
}
- public override function setUp():void
+ public override function setUpTest():void
{
- super.setUp();
+ super.setUpTest();
}
- public override function tearDown():void
+ public override function tearDownTest():void
{
- super.tearDown();
+ super.tearDownTest();
}
// Tests the default SelectionFormat
http://git-wip-us.apache.org/repos/asf/flex-tlf/blob/cad064e0/automation_tests/src/UnitTest/Tests/SimpleTest.as
----------------------------------------------------------------------
diff --git a/automation_tests/src/UnitTest/Tests/SimpleTest.as b/automation_tests/src/UnitTest/Tests/SimpleTest.as
new file mode 100644
index 0000000..319fc5a
--- /dev/null
+++ b/automation_tests/src/UnitTest/Tests/SimpleTest.as
@@ -0,0 +1,37 @@
+/**
+ * Created with IntelliJ IDEA.
+ * User: piotr.zarzycki
+ * Date: 05.04.14
+ * Time: 11:55
+ * To change this template use File | Settings | File Templates.
+ */
+package UnitTest.Tests
+{
+
+ import org.flexunit.asserts.assertTrue;
+
+ public class SimpleTest
+ {
+ public function SimpleTest()
+ {
+ }
+
+ [Before]
+ public function setUp() : void
+ {
+ var ddd:Object = null;
+ }
+
+ [After]
+ public function tearDown():void
+ {
+ var ddd:Object = null;
+ }
+
+ [Test]
+ public function myTest():void
+ {
+ assertTrue(true);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-tlf/blob/cad064e0/automation_tests/src/UnitTest/Tests/SpacingTest.as
----------------------------------------------------------------------
diff --git a/automation_tests/src/UnitTest/Tests/SpacingTest.as b/automation_tests/src/UnitTest/Tests/SpacingTest.as
index 1047133..a689a28 100644
--- a/automation_tests/src/UnitTest/Tests/SpacingTest.as
+++ b/automation_tests/src/UnitTest/Tests/SpacingTest.as
@@ -35,7 +35,11 @@ package UnitTest.Tests
import flashx.textLayout.formats.TextLayoutFormat;
import flashx.textLayout.tlf_internal;
- use namespace tlf_internal;
+ import org.flexunit.asserts.assertTrue;
+
+ import org.flexunit.asserts.fail;
+
+ use namespace tlf_internal;
public class SpacingTest extends VellumTestCase
{
@@ -55,9 +59,9 @@ package UnitTest.Tests
ts.addTestDescriptor(new TestDescriptor(SpacingTest, "spaceLeadingMarginTest", testConfig));
}
- public override function setUp():void
+ public override function setUpTest():void
{
- super.setUp();
+ super.setUpTest();
var ca:TextLayoutFormat = new TextLayoutFormat(TestFrame.format);
ca.columnCount = 1;
http://git-wip-us.apache.org/repos/asf/flex-tlf/blob/cad064e0/automation_tests/src/UnitTest/Tests/StyleTest.as
----------------------------------------------------------------------
diff --git a/automation_tests/src/UnitTest/Tests/StyleTest.as b/automation_tests/src/UnitTest/Tests/StyleTest.as
index 6dd2efb..2aecda9 100644
--- a/automation_tests/src/UnitTest/Tests/StyleTest.as
+++ b/automation_tests/src/UnitTest/Tests/StyleTest.as
@@ -29,7 +29,9 @@ package UnitTest.Tests
import flashx.textLayout.formats.TextAlign;
import flashx.textLayout.formats.TextLayoutFormat;
- public class StyleTest extends VellumTestCase
+ import org.flexunit.asserts.assertTrue;
+
+ public class StyleTest extends VellumTestCase
{
private var formatResolver:TestFormatResolver;
@@ -48,19 +50,19 @@ package UnitTest.Tests
VellumTestCase.suiteFromXML(testCaseClass, testListXML, testConfig, ts);
}
- public override function setUp():void
+ public override function setUpTest():void
{
- super.setUp();
+ super.setUpTest();
formatResolver = new TestFormatResolver();
TestFrame.textFlow.formatResolver = formatResolver;
}
- public override function tearDown():void
+ public override function tearDownTest():void
{
TestFrame.textFlow.formatResolver = null;
- super.tearDown();
+ super.tearDownTest();
}
public function basicStyleTest():void
http://git-wip-us.apache.org/repos/asf/flex-tlf/blob/cad064e0/automation_tests/src/UnitTest/Tests/TCYTests.as
----------------------------------------------------------------------
diff --git a/automation_tests/src/UnitTest/Tests/TCYTests.as b/automation_tests/src/UnitTest/Tests/TCYTests.as
index 13b11b5..f78776e 100644
--- a/automation_tests/src/UnitTest/Tests/TCYTests.as
+++ b/automation_tests/src/UnitTest/Tests/TCYTests.as
@@ -51,7 +51,14 @@ package UnitTest.Tests
import flashx.textLayout.conversion.TextConverter;
import mx.containers.Canvas;
- use namespace tlf_internal;
+
+ import org.flexunit.asserts.assertFalse;
+
+ import org.flexunit.asserts.assertTrue;
+ import org.flexunit.asserts.fail;
+ import org.flexunit.async.Async;
+
+ use namespace tlf_internal;
public class TCYTests extends VellumTestCase
{
@@ -447,7 +454,10 @@ package UnitTest.Tests
tf.interactionManager = editmanager;
editmanager.selectRange(4,7);
var tcy:TCYElement = editmanager.applyTCY(true);
- tcy.getEventMirror().addEventListener(FlowElementMouseEvent.MOUSE_DOWN, addAsync(checkMouseDownEvent,2500,null),false,0,true);
+
+ var checkMouseDownHandler = Async.asyncHandler(this, checkMouseDownEvent, 2500, {timeOut: "Timeout reached checkMouseDownEvent"}, tcyTestsTimeout);
+
+ tcy.getEventMirror().addEventListener(FlowElementMouseEvent.MOUSE_DOWN, checkMouseDownHandler,false,0,true);
var container:Sprite = new Sprite();
var TestCanvas:Canvas = testApp.getDisplayObject();
@@ -466,7 +476,7 @@ package UnitTest.Tests
tf.interactionManager = editmanager;
editmanager.selectRange(0, 0);
}
-
+
public function tcyMouseClickEventMirrorTest():void
{
SelManager.selectAll();
@@ -487,7 +497,10 @@ package UnitTest.Tests
tf.interactionManager = editmanager;
editmanager.selectRange(4,7);
var tcy:TCYElement = editmanager.applyTCY(true);
- tcy.getEventMirror().addEventListener(FlowElementMouseEvent.CLICK, addAsync(checkMouseClickEvent,2500,null),false,0,true);
+
+ var checkMouseClickHandler = Async.asyncHandler(this, checkMouseClickEvent, 2500, {timeOut: "Timeout reached checkMouseClickEvent"}, tcyTestsTimeout);
+
+ tcy.getEventMirror().addEventListener(FlowElementMouseEvent.CLICK, checkMouseClickHandler,false,0,true);
var container:Sprite = new Sprite();
var TestCanvas:Canvas = testApp.getDisplayObject();
@@ -511,7 +524,12 @@ package UnitTest.Tests
tf.interactionManager = editmanager;
editmanager.selectRange(0, 0);
}
-
+
+ private function checkMouseClickTimeout(passThroughData:Object = null):void
+ {
+ fail("Timeout reached TCYTests.checkMouseClick");
+ }
+
public function tcyMouseMoveEventMirrorTest():void
{
SelManager.selectAll();
@@ -532,7 +550,10 @@ package UnitTest.Tests
tf.interactionManager = editmanager;
editmanager.selectRange(4,7);
var tcy:TCYElement = editmanager.applyTCY(true);
- tcy.getEventMirror().addEventListener(FlowElementMouseEvent.MOUSE_MOVE, addAsync(checkMouseMoveEvent,2500,null),false,0,true);
+
+ var checkMouseMoveHandler = Async.asyncHandler(this, checkMouseMoveEvent, 2500, {timeOut: "Timeout reached checkMouseMoveEvent"}, tcyTestsTimeout);
+
+ tcy.getEventMirror().addEventListener(FlowElementMouseEvent.MOUSE_MOVE, checkMouseMoveHandler,false,0,true);
var container:Sprite = new Sprite();
var TestCanvas:Canvas = testApp.getDisplayObject();
@@ -575,7 +596,10 @@ package UnitTest.Tests
tf.interactionManager = editmanager;
editmanager.selectRange(4,7);
var tcy:TCYElement = editmanager.applyTCY(true);
- tcy.getEventMirror().addEventListener(FlowElementMouseEvent.MOUSE_UP, addAsync(checkMouseUpEvent,2500,null),false,0,true);
+
+ var checkMouseUpHandler = Async.asyncHandler(this, checkMouseUpEvent, 2500, {timeOut: "Timeout reached checkMouseUpEvent"}, tcyTestsTimeout);
+
+ tcy.getEventMirror().addEventListener(FlowElementMouseEvent.MOUSE_UP, checkMouseUpHandler,false,0,true);
var container:Sprite = new Sprite();
var TestCanvas:Canvas = testApp.getDisplayObject();
@@ -616,7 +640,10 @@ package UnitTest.Tests
tf.interactionManager = editmanager;
editmanager.selectRange(4,7);
var tcy:TCYElement = editmanager.applyTCY(true);
- tcy.getEventMirror().addEventListener(FlowElementMouseEvent.ROLL_OVER, addAsync(checkMouseRollOverEvent,2500,null),false,0,true);
+
+ var checkMouseRollOverHandler = Async.asyncHandler(this, checkMouseRollOverEvent, 2500, {timeOut: "Timeout reached checkMouseRollOverEvent"}, tcyTestsTimeout);
+
+ tcy.getEventMirror().addEventListener(FlowElementMouseEvent.ROLL_OVER, checkMouseRollOverHandler,false,0,true);
var container:Sprite = new Sprite();
var TestCanvas:Canvas = testApp.getDisplayObject();
@@ -660,7 +687,10 @@ package UnitTest.Tests
tf.interactionManager = editmanager;
editmanager.selectRange(4,7);
var tcy:TCYElement = editmanager.applyTCY(true);
- tcy.getEventMirror().addEventListener(FlowElementMouseEvent.ROLL_OUT, addAsync(checkMouseRollOutEvent,2500,null),false,0,true);
+
+ var checkMouseRollOutHandler = Async.asyncHandler(this, checkMouseRollOutEvent, 2500, {timeOut: "Timeout reached checkMouseRollOutEvent"}, tcyTestsTimeout);
+
+ tcy.getEventMirror().addEventListener(FlowElementMouseEvent.ROLL_OUT, checkMouseRollOutHandler,false,0,true);
var container:Sprite = new Sprite();
var TestCanvas:Canvas = testApp.getDisplayObject();
@@ -736,38 +766,43 @@ package UnitTest.Tests
}
- private function checkMouseDownEvent(e:FlowElementMouseEvent):void
+ private function checkMouseDownEvent(e:FlowElementMouseEvent, passThroughData:Object):void
{
assertTrue("mouseDown event is not fired", !(e is ErrorEvent));
tf.removeEventListener(FlowElementMouseEvent.MOUSE_DOWN, checkMouseDownEvent);
}
- private function checkMouseUpEvent(e:FlowElementMouseEvent):void
+ private function checkMouseUpEvent(e:FlowElementMouseEvent, passThroughData:Object):void
{
assertTrue("mouseUp event is not fired", !(e is ErrorEvent));
tf.removeEventListener(FlowElementMouseEvent.MOUSE_UP, checkMouseUpEvent);
}
- private function checkMouseClickEvent(e:FlowElementMouseEvent):void
+ private function checkMouseClickEvent(e:FlowElementMouseEvent, passThroughData:Object):void
{
assertTrue("mouseClick event is not fired", !(e is ErrorEvent));
tf.removeEventListener(FlowElementMouseEvent.CLICK, checkMouseClickEvent);
}
- private function checkMouseMoveEvent(e:FlowElementMouseEvent):void
+ private function checkMouseMoveEvent(e:FlowElementMouseEvent, passThroughData:Object):void
{
assertTrue("mouseMove event is not fired", !(e is ErrorEvent));
tf.removeEventListener(FlowElementMouseEvent.MOUSE_MOVE, checkMouseMoveEvent);
}
- private function checkMouseRollOverEvent(e:FlowElementMouseEvent):void
+ private function checkMouseRollOverEvent(e:FlowElementMouseEvent, passThroughData:Object):void
{
assertTrue("mouseRollOver event is not fired", !(e is ErrorEvent));
tf.removeEventListener(FlowElementMouseEvent.ROLL_OVER, checkMouseRollOverEvent);
}
- private function checkMouseRollOutEvent(e:FlowElementMouseEvent):void
+ private function checkMouseRollOutEvent(e:FlowElementMouseEvent, passThroughData:Object):void
{
assertTrue("mouseRollOut event is not fired", !(e is ErrorEvent));
tf.removeEventListener(FlowElementMouseEvent.ROLL_OUT, checkMouseRollOutEvent);
}
-
- public function addDivInTcyTest():void
+
+ private function tcyTestsTimeout(passThroughData:Object = null):void
+ {
+ fail(passThroughData.timeOut);
+ }
+
+ public function addDivInTcyTest():void
{
SelManager.selectAll();
SelManager.deleteText();
http://git-wip-us.apache.org/repos/asf/flex-tlf/blob/cad064e0/automation_tests/src/UnitTest/Tests/TabTest.as
----------------------------------------------------------------------
diff --git a/automation_tests/src/UnitTest/Tests/TabTest.as b/automation_tests/src/UnitTest/Tests/TabTest.as
index 7e46fc4..2195826 100644
--- a/automation_tests/src/UnitTest/Tests/TabTest.as
+++ b/automation_tests/src/UnitTest/Tests/TabTest.as
@@ -30,8 +30,10 @@ package UnitTest.Tests
import flashx.textLayout.formats.TabStopFormat;
import flashx.textLayout.formats.TextLayoutFormat;
+ import org.flexunit.asserts.assertTrue;
- public class TabTest extends VellumTestCase
+
+ public class TabTest extends VellumTestCase
{
public function TabTest(methodName:String, testID:String, testConfig:TestConfig, testCaseXML:XML=null)
{
http://git-wip-us.apache.org/repos/asf/flex-tlf/blob/cad064e0/automation_tests/src/UnitTest/Tests/TableBackgroundTest.as
----------------------------------------------------------------------
diff --git a/automation_tests/src/UnitTest/Tests/TableBackgroundTest.as b/automation_tests/src/UnitTest/Tests/TableBackgroundTest.as
index 3c98628..37a5b32 100644
--- a/automation_tests/src/UnitTest/Tests/TableBackgroundTest.as
+++ b/automation_tests/src/UnitTest/Tests/TableBackgroundTest.as
@@ -44,8 +44,10 @@ package UnitTest.Tests
import flashx.textLayout.tlf_internal;
import mx.containers.Canvas;
-
- use namespace tlf_internal;
+
+ import org.flexunit.asserts.assertTrue;
+
+ use namespace tlf_internal;
public class TableBackgroundTest extends VellumTestCase
{
@@ -64,17 +66,17 @@ package UnitTest.Tests
super(methodName, testID, testConfig, testCaseXML);
}
- override public function setUp():void
+ override public function setUpTest():void
{
// TODO Auto Generated method stub
- super.setUp();
+ super.setUpTest();
_canvas = VellumTestCase.testApp.getDisplayObject() as Canvas;
}
- override public function tearDown():void
+ override public function tearDownTest():void
{
- super.tearDown();
+ super.tearDownTest();
}
public static function suite(testConfig:TestConfig, ts:TestSuiteExtended):void
http://git-wip-us.apache.org/repos/asf/flex-tlf/blob/cad064e0/automation_tests/src/UnitTest/Tests/TableTests.as
----------------------------------------------------------------------
diff --git a/automation_tests/src/UnitTest/Tests/TableTests.as b/automation_tests/src/UnitTest/Tests/TableTests.as
index c775658..bc8ed99 100644
--- a/automation_tests/src/UnitTest/Tests/TableTests.as
+++ b/automation_tests/src/UnitTest/Tests/TableTests.as
@@ -48,6 +48,8 @@ package UnitTest.Tests
import mx.containers.Canvas;
+ import org.flexunit.asserts.assertTrue;
+
use namespace tlf_internal;
public class TableTests extends VellumTestCase
@@ -152,16 +154,16 @@ package UnitTest.Tests
ts.addTestDescriptor (new TestDescriptor (TableTests,"callTestMethod", testConfig, testXML) );
}
- override public function setUp() : void
+ override public function setUpTest() : void
{
- super.setUp();
+ super.setUpTest();
initializeSourceTextFlow();
initializeFlow();
}
- override public function tearDown(): void
+ override public function tearDownTest(): void
{
- super.tearDown();
+ super.tearDownTest();
}
public function callTestMethod():void
http://git-wip-us.apache.org/repos/asf/flex-tlf/blob/cad064e0/automation_tests/src/UnitTest/Tests/TextContainerManagerTest.as
----------------------------------------------------------------------
diff --git a/automation_tests/src/UnitTest/Tests/TextContainerManagerTest.as b/automation_tests/src/UnitTest/Tests/TextContainerManagerTest.as
index 7c22fde..2380592 100644
--- a/automation_tests/src/UnitTest/Tests/TextContainerManagerTest.as
+++ b/automation_tests/src/UnitTest/Tests/TextContainerManagerTest.as
@@ -59,7 +59,11 @@ package UnitTest.Tests
import flashx.textLayout.formats.TextLayoutFormat;
import flashx.textLayout.tlf_internal;
- use namespace tlf_internal;
+ import org.flexunit.asserts.assertTrue;
+
+ import org.flexunit.asserts.fail;
+
+ use namespace tlf_internal;
import mx.containers.Canvas;
import mx.core.ByteArrayAsset;
@@ -97,7 +101,7 @@ package UnitTest.Tests
VellumTestCase.suiteFromXML(testCaseClass, testListXML, testConfig, ts);
}
- override public function setUp() : void
+ override public function setUpTest() : void
{
cleanUpTestApp();
TestDisplayObject = testApp.getDisplayObject();
@@ -107,7 +111,7 @@ package UnitTest.Tests
}
else
{
- fail ("Did not get a blank canvas to work with");
+ fail("Did not get a blank canvas to work with");
}
}
@@ -500,7 +504,7 @@ package UnitTest.Tests
testTCM.compositionHeight = 50;
testTCM.updateContainer();
}
- var selectionChanged:Boolean = false;
+ private var selectionChanged:Boolean = false;
public function tcmSelectionTest():void
{
var sprite:Sprite = new Sprite();
@@ -1009,7 +1013,7 @@ package UnitTest.Tests
public function setTextDamageTest():void
{
tempTCM = addTCM();
- tempTCM.addEventListener(DamageEvent.DAMAGE, addAsync(damageHandler, 1000, null));
+ //tempTCM.addEventListener(DamageEvent.DAMAGE, addAsync(damageHandler, 1000, null));
tempTCM.setText("test");
}
http://git-wip-us.apache.org/repos/asf/flex-tlf/blob/cad064e0/automation_tests/src/UnitTest/Tests/TextFlowEditTest.as
----------------------------------------------------------------------
diff --git a/automation_tests/src/UnitTest/Tests/TextFlowEditTest.as b/automation_tests/src/UnitTest/Tests/TextFlowEditTest.as
index c9f199c..53f508c 100644
--- a/automation_tests/src/UnitTest/Tests/TextFlowEditTest.as
+++ b/automation_tests/src/UnitTest/Tests/TextFlowEditTest.as
@@ -34,7 +34,9 @@ package UnitTest.Tests
import mx.utils.LoaderUtil;
- public class TextFlowEditTest extends VellumTestCase
+ import org.flexunit.asserts.assertTrue;
+
+ public class TextFlowEditTest extends VellumTestCase
{
public function TextFlowEditTest(methodName:String, testID:String, testConfig:TestConfig, testXML:XML = null)
{
http://git-wip-us.apache.org/repos/asf/flex-tlf/blob/cad064e0/automation_tests/src/UnitTest/Tests/TextFlowTextLineFactoryTest.as
----------------------------------------------------------------------
diff --git a/automation_tests/src/UnitTest/Tests/TextFlowTextLineFactoryTest.as b/automation_tests/src/UnitTest/Tests/TextFlowTextLineFactoryTest.as
index 9806b38..8ecaf22 100644
--- a/automation_tests/src/UnitTest/Tests/TextFlowTextLineFactoryTest.as
+++ b/automation_tests/src/UnitTest/Tests/TextFlowTextLineFactoryTest.as
@@ -39,7 +39,11 @@ package UnitTest.Tests
import flashx.textLayout.formats.LineBreak;
import flashx.textLayout.formats.TextLayoutFormat;
import flashx.textLayout.formats.VerticalAlign;
- use namespace tlf_internal;
+
+ import org.flexunit.asserts.assertTrue;
+ import org.flexunit.asserts.fail;
+
+ use namespace tlf_internal;
import mx.utils.UIDUtil;
import flashx.textLayout.edit.EditManager;
http://git-wip-us.apache.org/repos/asf/flex-tlf/blob/cad064e0/automation_tests/src/UnitTest/Tests/TextLineFilterTest.as
----------------------------------------------------------------------
diff --git a/automation_tests/src/UnitTest/Tests/TextLineFilterTest.as b/automation_tests/src/UnitTest/Tests/TextLineFilterTest.as
index 559f70f..0fcd831 100644
--- a/automation_tests/src/UnitTest/Tests/TextLineFilterTest.as
+++ b/automation_tests/src/UnitTest/Tests/TextLineFilterTest.as
@@ -59,7 +59,10 @@ package UnitTest.Tests
import mx.core.ByteArrayAsset;
import mx.utils.LoaderUtil;
- use namespace tlf_internal;
+ import org.flexunit.asserts.assertTrue;
+ import org.flexunit.asserts.fail;
+
+ use namespace tlf_internal;
public class TextLineFilterTest extends VellumTestCase
{
@@ -129,7 +132,7 @@ package UnitTest.Tests
VellumTestCase.suiteFromXML(testCaseClass, testListXML, testConfig, ts);
}
- override public function setUp() : void
+ override public function setUpTest() : void
{
cleanUpTestApp();
TestDisplayObject = testApp.getDisplayObject();
@@ -139,7 +142,7 @@ package UnitTest.Tests
}
else
{
- fail ("Did not get a blank canvas to work with");
+ fail("Did not get a blank canvas to work with");
}
}
@@ -577,7 +580,7 @@ package UnitTest.Tests
if(!callback)
{
callback = true;
- tf.addEventListener(StatusChangeEvent.INLINE_GRAPHIC_STATUS_CHANGE,addAsync(embeddedInlineGraphics,2500,null),false,0,true);
+ //tf.addEventListener(StatusChangeEvent.INLINE_GRAPHIC_STATUS_CHANGE,addAsync(embeddedInlineGraphics,2500,null),false,0,true);
var TestCanvas:Canvas;
TestDisplayObject = testApp.getDisplayObject();
if (TestDisplayObject)
@@ -621,7 +624,7 @@ package UnitTest.Tests
var img:InlineGraphicElement = tf.findLeaf(3) as InlineGraphicElement;
if(img.status != InlineGraphicElementStatus.READY)
{
- tf.addEventListener(StatusChangeEvent.INLINE_GRAPHIC_STATUS_CHANGE,addAsync(embeddedInlineGraphics,2500,null),false,0,true);
+ //tf.addEventListener(StatusChangeEvent.INLINE_GRAPHIC_STATUS_CHANGE,addAsync(embeddedInlineGraphics,2500,null),false,0,true);
}
}
http://git-wip-us.apache.org/repos/asf/flex-tlf/blob/cad064e0/automation_tests/src/UnitTest/Tests/UndoRedoTest.as
----------------------------------------------------------------------
diff --git a/automation_tests/src/UnitTest/Tests/UndoRedoTest.as b/automation_tests/src/UnitTest/Tests/UndoRedoTest.as
index ecf5a2c..b0bfcee 100644
--- a/automation_tests/src/UnitTest/Tests/UndoRedoTest.as
+++ b/automation_tests/src/UnitTest/Tests/UndoRedoTest.as
@@ -35,7 +35,10 @@ package UnitTest.Tests
import flashx.textLayout.operations.ApplyLinkOperation;
import flashx.textLayout.tlf_internal;
- use namespace tlf_internal;
+
+ import org.flexunit.asserts.assertTrue;
+
+ use namespace tlf_internal;
/** Test the state of selection after each operation is done, undone, and redone.
*/
public class UndoRedoTest extends VellumTestCase
@@ -94,7 +97,7 @@ package UnitTest.Tests
editManager.selectRange(1,posOfSelection);
editManager.doOperation(new ApplyLinkOperation(editManager.getSelectionState(), "http://www.yahoo.com", "_self", true));
var resultString:String = editManager.errors;
- assertTrue ("Undo and Redo not successfully. " + resultString, resultString == "");
+ assertTrue("Undo and Redo not successfully. " + resultString, resultString == "");
}
http://git-wip-us.apache.org/repos/asf/flex-tlf/blob/cad064e0/automation_tests/src/UnitTest/Tests/VerticalScrollingTest.as
----------------------------------------------------------------------
diff --git a/automation_tests/src/UnitTest/Tests/VerticalScrollingTest.as b/automation_tests/src/UnitTest/Tests/VerticalScrollingTest.as
index 77a2230..86ec159 100644
--- a/automation_tests/src/UnitTest/Tests/VerticalScrollingTest.as
+++ b/automation_tests/src/UnitTest/Tests/VerticalScrollingTest.as
@@ -31,9 +31,10 @@ package UnitTest.Tests
import flashx.textLayout.formats.BlockProgression;
import flashx.textLayout.elements.TextFlow;
+ import org.flexunit.asserts.assertTrue;
- public class VerticalScrollingTest extends VellumTestCase
+ public class VerticalScrollingTest extends VellumTestCase
{
// List of available keyboard gestures
// Note that on Mac: CTRL == COMMAND
@@ -103,17 +104,17 @@ package UnitTest.Tests
VellumTestCase.suiteFromXML(testCaseClass, testListXML, testConfig, ts);
}
- public override function setUp():void
+ public override function setUpTest():void
{
// Booga - Need to load up the test file here.
- super.setUp();
+ super.setUpTest();
}
- public override function tearDown():void
+ public override function tearDownTest():void
{
// Restore default configurations
- super.tearDown();
+ super.tearDownTest();
}
http://git-wip-us.apache.org/repos/asf/flex-tlf/blob/cad064e0/automation_tests/src/UnitTest/Tests/WritingModeTest.as
----------------------------------------------------------------------
diff --git a/automation_tests/src/UnitTest/Tests/WritingModeTest.as b/automation_tests/src/UnitTest/Tests/WritingModeTest.as
index 74d3bfb..7b35e35 100644
--- a/automation_tests/src/UnitTest/Tests/WritingModeTest.as
+++ b/automation_tests/src/UnitTest/Tests/WritingModeTest.as
@@ -29,7 +29,9 @@ package UnitTest.Tests
import flashx.textLayout.formats.BlockProgression;
import flashx.textLayout.formats.Direction;
- public class WritingModeTest extends VellumTestCase
+ import org.flexunit.asserts.assertTrue;
+
+ public class WritingModeTest extends VellumTestCase
{
public function WritingModeTest(methodName:String, testID:String, testConfig:TestConfig, testCaseXML:XML=null)
{
http://git-wip-us.apache.org/repos/asf/flex-tlf/blob/cad064e0/automation_tests/src/perfAppTests/VellumAliceTestCanvas.mxml
----------------------------------------------------------------------
diff --git a/automation_tests/src/perfAppTests/VellumAliceTestCanvas.mxml b/automation_tests/src/perfAppTests/VellumAliceTestCanvas.mxml
index 290501a..2f19d0c 100644
--- a/automation_tests/src/perfAppTests/VellumAliceTestCanvas.mxml
+++ b/automation_tests/src/perfAppTests/VellumAliceTestCanvas.mxml
@@ -47,8 +47,10 @@
import mx.controls.Text;
import mx.core.ByteArrayAsset;
-
- use namespace tlf_internal;
+ import org.flexunit.asserts.assertTrue;
+
+
+ use namespace tlf_internal;
private static var factory:TextFlowTextLineFactory = new TextFlowTextLineFactory();
@@ -161,8 +163,9 @@
{
lineHolder.rawChildren.removeChildAt(0);
}
-
- CONFIG::debug { assert(lineHolder.rawChildren.numChildren == 0,"bad test"); }
+
+ assertTrue(lineHolder.rawChildren.numChildren == 0,"bad test");
+ //CONFIG::debug { assert(lineHolder.rawChildren.numChildren == 0,"bad test"); }
var begTime:int = getTimer();
var example:DisplayObject = buildVellumFactory(currWidthVal);
http://git-wip-us.apache.org/repos/asf/flex-tlf/blob/cad064e0/automation_tests/src/perfAppTests/VellumTweenTestCanvas.mxml
----------------------------------------------------------------------
diff --git a/automation_tests/src/perfAppTests/VellumTweenTestCanvas.mxml b/automation_tests/src/perfAppTests/VellumTweenTestCanvas.mxml
index bcc046d..08fde2a 100644
--- a/automation_tests/src/perfAppTests/VellumTweenTestCanvas.mxml
+++ b/automation_tests/src/perfAppTests/VellumTweenTestCanvas.mxml
@@ -48,7 +48,9 @@
import mx.collections.ArrayCollection;
import mx.controls.Text;
- use namespace tlf_internal;
+ import org.flexunit.asserts.assertTrue;
+
+ use namespace tlf_internal;
private static var factory:StringTextLineFactory = new StringTextLineFactory();
@@ -171,8 +173,10 @@
{
lineHolder.rawChildren.removeChildAt(0);
}
-
- CONFIG::debug { assert(lineHolder.rawChildren.numChildren == 0,"bad test"); }
+
+ assertTrue(lineHolder.rawChildren.numChildren == 0,"bad test");
+
+ // CONFIG::debug { assert(lineHolder.rawChildren.numChildren == 0,"bad test"); }
//lineHolder.visible = false;
http://git-wip-us.apache.org/repos/asf/flex-tlf/blob/cad064e0/build.xml
----------------------------------------------------------------------
diff --git a/build.xml b/build.xml
index 4fffecb..531710c 100644
--- a/build.xml
+++ b/build.xml
@@ -22,7 +22,7 @@
<property file="${basedir}/build.properties"/>
<!-- Specify a FLEX_HOME in local.properties or
Override on cmd line with -D=FLEX_HOME=path. -->
- <property file="${basedir}/local.properties"/>
+ <!--<property file="${basedir}/local.properties"/>-->
<!-- Default Flex SDK is the trunk. Override on cmd line with -D=FLEX_HOME=path. -->
<property name="FLEX_HOME" value="${basedir}/../flex-sdk"/>
<echo>FLEX_HOME is ${FLEX_HOME}</echo>
@@ -190,7 +190,7 @@
<target name="testApps" description="Builds TLF test application">
<mxmlc fork="${forkValue}" file="${testApps.dir}/src/flowCss.css"
keep-generated-actionscript="false"
- output="${output.dir}/apps/testApps/bin/Flow.swf">
+ output="${output.dir}/apps/automation_apps/bin/Flow.swf">
<jvmarg line="${jvm.args}"/>
<library-path/>
<library-path dir="${output.dir}" includes="textLayout.swc" append="true"/>
@@ -214,7 +214,7 @@
<mxmlc fork="${forkValue}" file="${testApps.dir}/src/Flow.mxml"
keep-generated-actionscript="false"
- output="${output.dir}/apps/testApps/bin/Flow.swf">
+ output="${output.dir}/apps/automation_apps/bin/Flow.swf">
<default-size width="1100" height="550" />
<jvmarg line="${jvm.args}"/>
@@ -341,10 +341,12 @@
output="${output.dir}/apps/automation_apps/bin/VellumUnit.swf">
<jvmarg line="${jvm.args}"/>
<library-path/>
+
<library-path dir="${output.dir}" includes="textLayout.swc" append="true"/>
<library-path dir="${output.dir}/apps/automation_apps/bin" includes="automation_core.swc" append="true"/>
<library-path dir="${output.dir}/apps/automation_apps/bin" includes="automation_tests.swc" append="true"/>
- <library-path dir="${automation_core.dir}/libs" includes="flexunit.swc" append="true"/>
+ <library-path dir="${automation_apps.dir}/libs" includes="flexunit.swc" append="true"/>
+ <library-path dir="${automation_apps.dir}/libs" includes="flexunit-uilistener.swc" append="true"/>
<!-- External swcs -->
<library-path dir="${flex.sdk.frameworks}/libs/mx/" includes="mx.swc" append="true"/><!-- for Flex SDK 4.5 -->
@@ -357,10 +359,10 @@
<library-path dir="${flex.sdk.frameworks}/libs/" includes="utilities.swc" append="true"/>
<library-path dir="${flex.sdk.frameworks}/locale/${flex.locale}/" includes="framework_rb.swc" append="true"/>
<library-path dir="${flex.sdk.frameworks}/locale/${flex.locale}/" includes="rpc_rb.swc" append="true"/>
- <library-path dir="${flex.sdk.frameworks}/locale/${flex.locale}/" includes="spark_rb.swc" append="true"/>
+ <library-path dir="${flex.sdk.frameworks}/locale/${flex.locale}/" includes="spark_rb.swc" append="true"/>
+ <library-path dir="${flex.sdk.frameworks}/locale/${flex.locale}/" includes="textLayout_rb.swc" append="true"/>
-
- <static-link-runtime-shared-libraries/>
+ <static-link-runtime-shared-libraries/>
<define name="CONFIG::debug" value="${dbg}"/>
<define name="CONFIG::release" value="${rel}"/>