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:30 UTC
[19/30] git commit: [flex-tlf] [refs/heads/develop] - Migrate
AllContAttributeTest to FU 4
Migrate AllContAttributeTest to FU 4
Project: http://git-wip-us.apache.org/repos/asf/flex-tlf/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-tlf/commit/b73314f6
Tree: http://git-wip-us.apache.org/repos/asf/flex-tlf/tree/b73314f6
Diff: http://git-wip-us.apache.org/repos/asf/flex-tlf/diff/b73314f6
Branch: refs/heads/develop
Commit: b73314f6fa9f63ab1c0b0f5c7884af15fad1f4e7
Parents: 2b0067b
Author: piotrz <pi...@gmail.com>
Authored: Tue May 27 08:10:00 2014 +0200
Committer: piotrz <pi...@gmail.com>
Committed: Tue May 27 08:23:10 2014 +0200
----------------------------------------------------------------------
.../ExtendedClasses/TestSuiteExtended.as | 2 -
automation_tests/src/AllTestsSuite.as | 7 +-
.../src/UnitTest/Tests/AllAttributeTest.as | 229 +---------
.../src/UnitTest/Tests/AllCharAttributeTest.as | 320 ++++++++++++-
.../src/UnitTest/Tests/AllContAttributeTest.as | 449 ++++++++++++++-----
.../src/UnitTest/Tests/AllParaAttributeTest.as | 409 +++++++++++++----
6 files changed, 987 insertions(+), 429 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-tlf/blob/b73314f6/automation_core/src/UnitTest/ExtendedClasses/TestSuiteExtended.as
----------------------------------------------------------------------
diff --git a/automation_core/src/UnitTest/ExtendedClasses/TestSuiteExtended.as b/automation_core/src/UnitTest/ExtendedClasses/TestSuiteExtended.as
index 81137a3..91ce0cf 100644
--- a/automation_core/src/UnitTest/ExtendedClasses/TestSuiteExtended.as
+++ b/automation_core/src/UnitTest/ExtendedClasses/TestSuiteExtended.as
@@ -18,8 +18,6 @@
////////////////////////////////////////////////////////////////////////////////
package UnitTest.ExtendedClasses {
- import UnitTest.ExtendedClasses.*;
-
import flash.events.Event;
import flexunit.framework.*;
http://git-wip-us.apache.org/repos/asf/flex-tlf/blob/b73314f6/automation_tests/src/AllTestsSuite.as
----------------------------------------------------------------------
diff --git a/automation_tests/src/AllTestsSuite.as b/automation_tests/src/AllTestsSuite.as
index 2134fcd..eae5aa2 100644
--- a/automation_tests/src/AllTestsSuite.as
+++ b/automation_tests/src/AllTestsSuite.as
@@ -21,7 +21,9 @@ package
import UnitTest.Tests.AccessibilityMethodsTest;
import UnitTest.Tests.AllCharAttributeTest;
+ import UnitTest.Tests.AllContAttributeTest;
import UnitTest.Tests.AllEventTest;
+ import UnitTest.Tests.AllParaAttributeTest;
import UnitTest.Tests.AttributeTest;
import UnitTest.Tests.BoxTest;
import UnitTest.Tests.ContainerTypeTest;
@@ -41,8 +43,9 @@ package
public var floatTest:FloatTest;
public var operationTest:OperationTest;
public var scrollingTest:ScrollingTest;
- public var allAttributeTest:AllCharAttributeTest;
- // public var allParagraphTest:AllParaAttributeTest;
+ public var allChartAttributeTest:AllCharAttributeTest;
+ public var allParagraphAttributeTest:AllParaAttributeTest;
+ public var allContAttirbuteTest:AllContAttributeTest;
}
}
http://git-wip-us.apache.org/repos/asf/flex-tlf/blob/b73314f6/automation_tests/src/UnitTest/Tests/AllAttributeTest.as
----------------------------------------------------------------------
diff --git a/automation_tests/src/UnitTest/Tests/AllAttributeTest.as b/automation_tests/src/UnitTest/Tests/AllAttributeTest.as
index 4402025..0c19626 100644
--- a/automation_tests/src/UnitTest/Tests/AllAttributeTest.as
+++ b/automation_tests/src/UnitTest/Tests/AllAttributeTest.as
@@ -21,8 +21,6 @@ package UnitTest.Tests
import UnitTest.ExtendedClasses.VellumTestCase;
import UnitTest.Fixtures.TestConfig;
- import flash.display.Sprite;
-
import flashx.textLayout.elements.FlowLeafElement;
import flashx.textLayout.elements.TextFlow;
import flashx.textLayout.formats.Category;
@@ -39,241 +37,16 @@ package UnitTest.Tests
protected var testProp:Property;
protected var testValue:*;
protected var expectedValue:*;
- protected var description:Object;
- protected var category:String;
- public function AllAttributeTest(methodName:String, testID:String, testConfig:TestConfig, prop:Property, testValue:*, expectedValue:*)
+ public function AllAttributeTest(methodName:String, testID:String, testConfig:TestConfig)
{
super(methodName, testID, testConfig);
- // assert(testValue != null,"null?");
- testProp = prop;
- this.testValue = testValue;
- this.expectedValue = expectedValue;
metaData = {};
// Note: These must correspond to a Watson product area (case-sensitive)
metaData.productArea = "Text Attributes";
}
- /**
- * This builds testcases for properties in description that are Number types. For each number property
- * testcases are built to set the value to the below the minimum value, step from the minimum value to the maximum value
- * and then above the maximum value.
- */
- protected function testAllNumberPropsFromMinToMax(testConfig:TestConfig, description:Object, category:String):void
- {
- for each (testProp in description)
- {
- var handler:NumberPropertyHandler = testProp.findHandler(NumberPropertyHandler) as NumberPropertyHandler;
-
- if (handler && testProp.category == category)
- {
- var minVal:Number = handler.minValue;
- var maxVal:Number = handler.maxValue;
- assertTrue(true, minVal < maxVal);
- var delta:Number = (maxVal - minVal) / 10;
- var includeInMinimalTestSuite:Boolean;
-
- for (var value:Number = minVal - delta; ;)
- {
- expectedValue = value < minVal ? undefined : (value > maxVal ? undefined : value);
- testValue = value;
- // include in the minmalTest values below the range, min value, max value and values above the range
- includeInMinimalTestSuite = (value <= minVal || value >= maxVal)
-
- runOneCharacterAttributeTest();
-
- if (value > maxVal)
- break;
- value += delta;
- }
- }
- }
- }
-
- /**
- * This builds testcases for properties in attributes in description that are Int types. For each number property
- * testcases are built to set the value to the below the minimum value, step from the minimum value to the maximum value
- * and then above the maximum value.
- */
- protected function testAllIntPropsFromMinToMax(testConfig:TestConfig, description:Object, category:String):void
- {
- for each (testProp in description)
- {
- if (testProp.category == category)
- {
- var handler:IntPropertyHandler = testProp.findHandler(IntPropertyHandler) as IntPropertyHandler;
- if (handler)
- {
- var minVal:int = handler.minValue;
- var maxVal:int = handler.maxValue;
- assertTrue(true, minVal < maxVal);
- var delta:int = (maxVal - minVal) / 10;
- var includeInMinimalTestSuite:Boolean;
-
- for (var value:Number = minVal - delta; ;)
- {
- expectedValue = value < minVal ? undefined : (value > maxVal ? undefined : value);
- testValue = value;
- // include in the minmalTest values below the range, min value, max value and values above the range
- includeInMinimalTestSuite = (value <= minVal || value >= maxVal)
-
- runOneCharacterAttributeTest();
-
- if (value > maxVal)
- break;
- value += delta;
- }
- }
- }
- }
- }
-
- /**
- * This builds testcases for properties in description that are NumberOrPercent types. For each number property
- * testcases are built to set the value to the below the minimum value, step from the minimum value to the maximum value
- * and then above the maximum value. This is done first using the min/max number values and then the min/max percent values.
- */
- protected function testAllNumberOrPercentPropsFromMinToMax(testConfig:TestConfig, description:Object, category:String):void
- {
- for each (testProp in description)
- {
- if (testProp.category == category)
- {
- var numberHandler:NumberPropertyHandler = testProp.findHandler(NumberPropertyHandler) as NumberPropertyHandler;
- var percentHandler:PercentPropertyHandler = testProp.findHandler(PercentPropertyHandler) as PercentPropertyHandler;
- if (numberHandler && percentHandler)
- {
- var minVal:Number = numberHandler.minValue;
- var maxVal:Number = numberHandler.maxValue;
- assertTrue(true, minVal < maxVal);
- var delta:Number = (maxVal - minVal) / 10;
- var includeInMinimalTestSuite:Boolean;
-
- for (var value:Number = minVal - delta; ;)
- {
- expectedValue = value < minVal ? undefined : (value > maxVal ? undefined : value);
- testValue = value;
-
- // include in the minmalTest values below the range, min value, max value and values above the range
- includeInMinimalTestSuite = (value <= minVal || value >= maxVal)
-
- runOneCharacterAttributeTest();
- //ts.addTestDescriptor( new TestDescriptor (testClass, methodName, testConfig, null, prop, value, expectedValue, includeInMinimalTestSuite) );
-
- if (value > maxVal)
- break;
- value += delta;
- }
-
- // repeat with percent values
- minVal = percentHandler.minValue;
- maxVal = percentHandler.maxValue;
- assertTrue(true, minVal < maxVal);
- delta = (maxVal - minVal) / 10;
-
- for (value = minVal - delta; ;)
- {
- expectedValue = value < minVal ? undefined : (value > maxVal ? undefined : value.toString() + "%");
- //ts.addTestDescriptor( new TestDescriptor (testClass, methodName, testConfig, null, prop, value.toString()+"%", expectedValue, true) );
-
- testValue = value.toString() + "%";
-
- runOneCharacterAttributeTest();
-
- if (value > maxVal)
- break;
- value += delta;
- }
- }
- }
- }
- }
-
- /**
- * This builds testcases for properties in attributes in description that are Boolean types. A testcase is generated
- * for true and false for the value.
- */
- protected function testAllBooleanProps(testConfig:TestConfig, description:Object, category:String):void
- {
- for each (testProp in description)
- {
- if (testProp.category == category && testProp.findHandler(BooleanPropertyHandler) != null)
- {
- expectedValue = testValue = true;
- runOneCharacterAttributeTest();
-
- expectedValue = testValue = false;
- runOneCharacterAttributeTest();
- }
- }
- }
-
- /**
- * This builds testcases for properties in attributes in description that are Enumerated types types. A testcase is generated
- * for each possible enumerated value
- */
- protected function testAllEnumProps(testConfig:TestConfig, description:Object, category:String):void
- {
- var range:Object = null;
- var value:Object = null;
-
- for each (testProp in description)
- {
- // new code
- if (testProp.category == category)
- {
- var handler:EnumPropertyHandler = testProp.findHandler(EnumPropertyHandler) as EnumPropertyHandler;
- if (handler)
- {
- range = handler.range;
- for (value in range)
- {
- if (value != FormatValue.INHERIT)
- {
- expectedValue = testValue = value;
- runOneCharacterAttributeTest();
- }
- }
- expectedValue = undefined;
- testValue = "foo";
- runOneCharacterAttributeTest();
- }
-
- }
- }
- }
-
- /**
- * This builds testcases for setting all properties in description to inherit, null, undefined and an object.
- */
- protected function testAllSharedValues(testConfig:TestConfig, description:Object, category:String):void
- {
- for each (testProp in description)
- {
- if (testProp.category == category)
- {
-
- testValue = expectedValue = FormatValue.INHERIT;
- runOneCharacterAttributeTest();
-
- testValue = new Sprite();
- expectedValue = undefined;
- runOneCharacterAttributeTest();
-
- testValue = null;
- expectedValue = undefined;
- runOneCharacterAttributeTest();
-
- testValue = expectedValue = undefined;
- runOneCharacterAttributeTest();
-
- testValue = expectedValue = undefined;
- clearFormatTest();
- }
- }
- }
-
public function clearFormatTest():void
{
SelManager.selectAll();
http://git-wip-us.apache.org/repos/asf/flex-tlf/blob/b73314f6/automation_tests/src/UnitTest/Tests/AllCharAttributeTest.as
----------------------------------------------------------------------
diff --git a/automation_tests/src/UnitTest/Tests/AllCharAttributeTest.as b/automation_tests/src/UnitTest/Tests/AllCharAttributeTest.as
index a9e1561..9824a98 100644
--- a/automation_tests/src/UnitTest/Tests/AllCharAttributeTest.as
+++ b/automation_tests/src/UnitTest/Tests/AllCharAttributeTest.as
@@ -20,18 +20,32 @@ package UnitTest.Tests
{
import UnitTest.Fixtures.TestConfig;
+ import flash.display.Sprite;
+
+ import flashx.textLayout.elements.FlowLeafElement;
+ import flashx.textLayout.elements.TextFlow;
+
import flashx.textLayout.formats.Category;
+ import flashx.textLayout.formats.FormatValue;
import flashx.textLayout.formats.TextLayoutFormat;
+ import flashx.textLayout.property.BooleanPropertyHandler;
+ import flashx.textLayout.property.EnumPropertyHandler;
+ import flashx.textLayout.property.IntPropertyHandler;
+ import flashx.textLayout.property.NumberPropertyHandler;
+ import flashx.textLayout.property.PercentPropertyHandler;
import flashx.textLayout.tlf_internal;
+ import org.flexunit.asserts.assertTrue;
+ import flashx.textLayout.property.Property;
+
use namespace tlf_internal;
public class AllCharAttributeTest extends AllAttributeTest
{
public function AllCharAttributeTest()
{
- super("", "AllCharAttributeTest", TestConfig.getInstance(), null, null, null);
+ super("", "AllCharAttributeTest", TestConfig.getInstance());
// Note: These must correspond to a Watson product area (case-sensitive)
metaData.productArea = "Text Attributes";
metaData.productSubArea = "Character Attributes";
@@ -42,27 +56,311 @@ package UnitTest.Tests
override public function setUpTest():void
{
super.setUpTest();
+ }
+
+ [After]
+ override public function tearDownTest():void
+ {
+ super.tearDownTest();
testProp = null;
expectedValue = null;
testValue = null;
}
- [After]
- override public function tearDownTest():void
+ /**
+ * This builds testcases for properties in description that are Number types. For each number property
+ * testcases are built to set the value to the below the minimum value, step from the minimum value to the maximum value
+ * and then above the maximum value.
+ */
+ [Test]
+ public function testAllNumberPropsFromMinToMax():void
{
- super.tearDownTest();
+ for each (testProp in TextLayoutFormat.description)
+ {
+ var handler:NumberPropertyHandler = testProp.findHandler(NumberPropertyHandler) as NumberPropertyHandler;
+
+ if (handler && testProp.category == Category.CHARACTER)
+ {
+ var minVal:Number = handler.minValue;
+ var maxVal:Number = handler.maxValue;
+ assertTrue(true, minVal < maxVal);
+ var delta:Number = (maxVal - minVal) / 10;
+ var includeInMinimalTestSuite:Boolean;
+
+ for (var value:Number = minVal - delta; ;)
+ {
+ expectedValue = value < minVal ? undefined : (value > maxVal ? undefined : value);
+ testValue = value;
+ // include in the minmalTest values below the range, min value, max value and values above the range
+ includeInMinimalTestSuite = (value <= minVal || value >= maxVal)
+
+ runOneCharacterAttributeTest();
+
+ if (value > maxVal)
+ break;
+ value += delta;
+ }
+ }
+ }
}
+
+ /**
+ * This builds testcases for properties in attributes in description that are Int types. For each number property
+ * testcases are built to set the value to the below the minimum value, step from the minimum value to the maximum value
+ * and then above the maximum value.
+ */
[Test]
- public function propertiesCharacterTests():void
+ public function testAllIntPropsFromMinToMax():void
{
- testAllNumberPropsFromMinToMax(TestConfig.getInstance(), TextLayoutFormat.description, Category.CHARACTER);
- testAllIntPropsFromMinToMax(TestConfig.getInstance(), TextLayoutFormat.description, Category.CHARACTER);
- testAllNumberOrPercentPropsFromMinToMax(TestConfig.getInstance(), TextLayoutFormat.description, Category.CHARACTER);
- testAllBooleanProps(TestConfig.getInstance(), TextLayoutFormat.description, Category.CHARACTER);
- testAllEnumProps(TestConfig.getInstance(), TextLayoutFormat.description, Category.CHARACTER);
- testAllSharedValues(TestConfig.getInstance(), TextLayoutFormat.description, Category.CHARACTER);
+ for each (testProp in TextLayoutFormat.description)
+ {
+ if (testProp.category == Category.CHARACTER)
+ {
+ var handler:IntPropertyHandler = testProp.findHandler(IntPropertyHandler) as IntPropertyHandler;
+ if (handler)
+ {
+ var minVal:int = handler.minValue;
+ var maxVal:int = handler.maxValue;
+ assertTrue(true, minVal < maxVal);
+ var delta:int = (maxVal - minVal) / 10;
+ var includeInMinimalTestSuite:Boolean;
+
+ for (var value:Number = minVal - delta; ;)
+ {
+ expectedValue = value < minVal ? undefined : (value > maxVal ? undefined : value);
+ testValue = value;
+ // include in the minmalTest values below the range, min value, max value and values above the range
+ includeInMinimalTestSuite = (value <= minVal || value >= maxVal)
+
+ runOneCharacterAttributeTest();
+
+ if (value > maxVal)
+ break;
+ value += delta;
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * This builds testcases for properties in description that are NumberOrPercent types. For each number property
+ * testcases are built to set the value to the below the minimum value, step from the minimum value to the maximum value
+ * and then above the maximum value. This is done first using the min/max number values and then the min/max percent values.
+ */
+ [Test]
+ public function testAllNumberOrPercentPropsFromMinToMax():void
+ {
+ for each (testProp in TextLayoutFormat.description)
+ {
+ if (testProp.category == Category.CHARACTER)
+ {
+ var numberHandler:NumberPropertyHandler = testProp.findHandler(NumberPropertyHandler) as NumberPropertyHandler;
+ var percentHandler:PercentPropertyHandler = testProp.findHandler(PercentPropertyHandler) as PercentPropertyHandler;
+ if (numberHandler && percentHandler)
+ {
+ var minVal:Number = numberHandler.minValue;
+ var maxVal:Number = numberHandler.maxValue;
+ assertTrue(true, minVal < maxVal);
+ var delta:Number = (maxVal - minVal) / 10;
+ var includeInMinimalTestSuite:Boolean;
+
+ for (var value:Number = minVal - delta; ;)
+ {
+ expectedValue = value < minVal ? undefined : (value > maxVal ? undefined : value);
+ testValue = value;
+
+ // include in the minmalTest values below the range, min value, max value and values above the range
+ includeInMinimalTestSuite = (value <= minVal || value >= maxVal)
+
+ runOneCharacterAttributeTest();
+ //ts.addTestDescriptor( new TestDescriptor (testClass, methodName, testConfig, null, prop, value, expectedValue, includeInMinimalTestSuite) );
+
+ if (value > maxVal)
+ break;
+ value += delta;
+ }
+
+ // repeat with percent values
+ minVal = percentHandler.minValue;
+ maxVal = percentHandler.maxValue;
+ assertTrue(true, minVal < maxVal);
+ delta = (maxVal - minVal) / 10;
+
+ for (value = minVal - delta; ;)
+ {
+ expectedValue = value < minVal ? undefined : (value > maxVal ? undefined : value.toString() + "%");
+ //ts.addTestDescriptor( new TestDescriptor (testClass, methodName, testConfig, null, prop, value.toString()+"%", expectedValue, true) );
+
+ testValue = value.toString() + "%";
+
+ runOneCharacterAttributeTest();
+
+ if (value > maxVal)
+ break;
+ value += delta;
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * This builds testcases for properties in attributes in description that are Boolean types. A testcase is generated
+ * for true and false for the value.
+ */
+ [Test]
+ public function testAllBooleanProps():void
+ {
+ for each (testProp in TextLayoutFormat.description)
+ {
+ if (testProp.category == Category.CHARACTER && testProp.findHandler(BooleanPropertyHandler) != null)
+ {
+ expectedValue = testValue = true;
+ runOneCharacterAttributeTest();
+
+ expectedValue = testValue = false;
+ runOneCharacterAttributeTest();
+ }
+ }
+ }
+
+
+ /**
+ * This builds testcases for properties in attributes in description that are Enumerated types types. A testcase is generated
+ * for each possible enumerated value
+ */
+ [Test]
+ public function testAllEnumProps():void
+ {
+ var range:Object = null;
+ var value:Object = null;
+
+ for each (testProp in TextLayoutFormat.description)
+ {
+ // new code
+ if (testProp.category == Category.CHARACTER)
+ {
+ var handler:EnumPropertyHandler = testProp.findHandler(EnumPropertyHandler) as EnumPropertyHandler;
+ if (handler)
+ {
+ range = handler.range;
+ for (value in range)
+ {
+ if (value != FormatValue.INHERIT)
+ {
+ expectedValue = testValue = value;
+ runOneCharacterAttributeTest();
+ }
+ }
+ expectedValue = undefined;
+ testValue = "foo";
+ runOneCharacterAttributeTest();
+ }
+
+ }
+ }
+ }
+
+ /**
+ * This builds testcases for setting all properties in description to inherit, null, undefined and an object.
+ */
+ [Test]
+ public function testAllSharedValues():void
+ {
+ for each (testProp in TextLayoutFormat.description)
+ {
+ if (testProp.category == Category.CHARACTER)
+ {
+
+ testValue = expectedValue = FormatValue.INHERIT;
+ runOneCharacterAttributeTest();
+
+ testValue = new Sprite();
+ expectedValue = undefined;
+ runOneCharacterAttributeTest();
+
+ testValue = null;
+ expectedValue = undefined;
+ runOneCharacterAttributeTest();
+
+ testValue = expectedValue = undefined;
+ runOneCharacterAttributeTest();
+
+ testValue = expectedValue = undefined;
+ clearFormatTest();
+ }
+ }
+ }
+
+ /**
+ * Generic function to run one character attribute test. Uses the selection manager to set the attributes on the entire flow at the span level
+ * to value and then validates that the value is expectedValue.
+ */
+ private function runOneCharacterAttributeTest():void
+ {
+ if (testProp == null)
+ return; // must be set
+
+ SelManager.selectAll();
+
+ // Test direct change on single leaf
+ var leaf:FlowLeafElement = SelManager.textFlow.findLeaf(SelManager.absoluteStart);
+ var originalValue:* = leaf[testProp.name];
+
+ assignmentHelper(leaf);
+
+ var expectedResult:*;
+ if (expectedValue === undefined)
+ expectedResult = testValue === undefined || testValue === null ? undefined : originalValue;
+ else
+ expectedResult = expectedValue;
+
+ assertTrue("FlowLeafElement does not have the expected value after direct change", leaf[testProp.name] == expectedResult);
+ leaf[testProp.name] = originalValue;
+
+ var ca:TextLayoutFormat = new TextLayoutFormat();
+ assignmentHelper(ca);
+ SelManager.applyLeafFormat(ca);
+
+ // expect that all FlowLeafElements have expectedValue as the properties value
+ if (expectedValue !== undefined)
+ assertTrue("not all FlowLeafElements have the expected value", validateCharacterPropertyOnEntireFlow(SelManager.textFlow, testProp, expectedValue));
+ }
+
+
+ // support function to walk all FlowLeafElements and verify that prop is val
+ private function validateCharacterPropertyOnEntireFlow(textFlow:TextFlow, prop:Property, val:*):Boolean
+ {
+ var idx:int = 0;
+ var elem:FlowLeafElement = textFlow.getFirstLeaf();
+ assertTrue("either the first FlowLeafElement is null or the textFlow length is zero", elem != null || textFlow.textLength == 0);
+ while (elem)
+ {
+ // error if elements have zero length
+ assertTrue("The FlowLeafElement has zero length", elem.textLength != 0);
+
+ // expect all values of prop to be supplied val
+ if (elem.format[prop.name] !== val || elem[prop.name] !== val)
+ return false;
+
+ // inherit is never computed
+ if ((val == FormatValue.INHERIT && elem.computedFormat[prop.name] == val) || elem.computedFormat[prop.name] === undefined)
+ return false;
+
+ // skip to the next element
+ var nextElem:FlowLeafElement = elem.getNextLeaf();
+ var absoluteEnd:int = elem.getAbsoluteStart() + elem.textLength;
+ if (nextElem == null)
+ assertTrue("absoluteEnd of the last FlowLeafElement is not the end of the textFlow", absoluteEnd == textFlow.textLength);
+ else
+ assertTrue("the end of this FlowLeafElement does not equal the start of the next", absoluteEnd == nextElem.getAbsoluteStart());
+
+ elem = nextElem;
+ }
+ return true;
}
}
}
http://git-wip-us.apache.org/repos/asf/flex-tlf/blob/b73314f6/automation_tests/src/UnitTest/Tests/AllContAttributeTest.as
----------------------------------------------------------------------
diff --git a/automation_tests/src/UnitTest/Tests/AllContAttributeTest.as b/automation_tests/src/UnitTest/Tests/AllContAttributeTest.as
index 978d8f1..d3eab18 100644
--- a/automation_tests/src/UnitTest/Tests/AllContAttributeTest.as
+++ b/automation_tests/src/UnitTest/Tests/AllContAttributeTest.as
@@ -18,114 +18,353 @@
////////////////////////////////////////////////////////////////////////////////
package UnitTest.Tests
{
- import UnitTest.ExtendedClasses.TestSuiteExtended;
- import UnitTest.Fixtures.TestConfig;
-
- import flashx.textLayout.container.ContainerController;
- import flashx.textLayout.elements.FlowLeafElement;
- import flashx.textLayout.elements.TextFlow;
- import flashx.textLayout.formats.Category;
- import flashx.textLayout.formats.FormatValue;
- import flashx.textLayout.formats.ITextLayoutFormat;
- import flashx.textLayout.formats.TextLayoutFormat;
- import flashx.textLayout.property.Property;
- import flashx.textLayout.tlf_internal;
+ import UnitTest.Fixtures.TestConfig;
+
+ import flash.display.Sprite;
+
+ import flashx.textLayout.container.ContainerController;
+ import flashx.textLayout.elements.FlowLeafElement;
+ import flashx.textLayout.elements.TextFlow;
+ import flashx.textLayout.formats.Category;
+ import flashx.textLayout.formats.FormatValue;
+ import flashx.textLayout.formats.TextLayoutFormat;
+ import flashx.textLayout.property.BooleanPropertyHandler;
+ import flashx.textLayout.property.EnumPropertyHandler;
+ import flashx.textLayout.property.IntPropertyHandler;
+ import flashx.textLayout.property.NumberPropertyHandler;
+ import flashx.textLayout.property.PercentPropertyHandler;
+ import flashx.textLayout.property.Property;
+ import flashx.textLayout.tlf_internal;
import org.flexunit.asserts.assertTrue;
use namespace tlf_internal;
- public class AllContAttributeTest extends AllAttributeTest
- {
- public function AllContAttributeTest(methodName:String, testID:String, testConfig:TestConfig, prop:Property, value:*, expected:*)
- {
- super (methodName, testID, testConfig, prop, value, expected);
-
- // Note: These must correspond to a Watson product area (case-sensitive)
- metaData.productArea = "Text Container";
- }
-
- public static function suite(testConfig:TestConfig, ts:TestSuiteExtended):void
- {
- testAllProperties(ts, testConfig, TextLayoutFormat.description, Category.CONTAINER, AllContAttributeTest, "runOneContainerAttributeTest");
- }
-
- public override function tearDownTest():void
- {
- SelManager.applyContainerFormat(TextLayoutFormat.defaultFormat);
- super.tearDownTest();
- }
-
- /**
- * Generic function to run one container attribute test. Uses the selection manager to set the attributes on the entire flow at the span level
- * to value and then validates that the value is expectedValue.
- */
- public function runOneContainerAttributeTest():void
- {
- if (testProp == null)
- return; // must be set
-
- SelManager.selectAll();
-
- // Test direct change on single leaf
- var controller:ContainerController = SelManager.textFlow.flowComposer.getControllerAt(0);
- var originalValue:* = controller[testProp.name];
-
- assignmentHelper(controller);
-
- var expectedResult:*;
- if (expectedValue === undefined)
- expectedResult = testValue === undefined || testValue === null ? undefined : originalValue;
- else
- expectedResult = expectedValue;
-
- assertTrue("Controller does not have the expected value after direct change", controller[testProp.name] == expectedResult);
- controller[testProp.name] = originalValue;
-
- var ca:TextLayoutFormat = new TextLayoutFormat();
- assignmentHelper(ca);
- SelManager.applyContainerFormat(ca);
-
- // expect that all FlowLeafElements have expectedValue as the properties value
- if (expectedValue !== undefined)
- assertTrue("not all ContainerElements have the expected value", validateContainerPropertyOnEntireFlow(SelManager.textFlow,testProp,expectedValue));
- }
-
- // support function to walk all FlowLeafElements and verify that prop is val
- static public function validateContainerPropertyOnEntireFlow(textFlow:TextFlow, prop:Property, val:*):Boolean
- {
- var idx:int = 0;
- var elem:FlowLeafElement = textFlow.getFirstLeaf();
- assertTrue("either the first FlowLeafElement is null or the textFlow length is zero", elem != null || textFlow.textLength == 0);
- while (elem)
- {
- // error if elements have zero length
- assertTrue("The FlowLeafElement has zero length", elem.textLength != 0);
-
- // expect all values of prop to be supplied val
- var controllerIndex:int = textFlow.flowComposer.findControllerIndexAtPosition(elem.getAbsoluteStart(),false);
- if (controllerIndex != -1)
- {
- var controller:ContainerController = textFlow.flowComposer.getControllerAt(controllerIndex);
- if (controller.format[prop.name] !== val)
- return false;
-
- // inherit is never computed
- if ((val == FormatValue.INHERIT && controller.computedFormat[prop.name] == val) || controller.computedFormat[prop.name] === undefined)
- return false;
- }
-
- // skip to the next element
- var nextElem:FlowLeafElement = elem.getNextLeaf();
- var absoluteEnd:int = elem.getAbsoluteStart() + elem.textLength;
- if (nextElem == null)
- assertTrue("absoluteEnd of the last FlowLeafElement is not the end of the textFlow", absoluteEnd == textFlow.textLength);
- else
- assertTrue("the end of this FlowLeafElement does not equal the start of the next", absoluteEnd == nextElem.getAbsoluteStart());
-
- elem = nextElem;
- }
- return true;
- }
- }
+ public class AllContAttributeTest extends AllAttributeTest
+ {
+ public function AllContAttributeTest()
+ {
+ super("", "AllContAttributeTest", TestConfig.getInstance());
+
+ // Note: These must correspond to a Watson product area (case-sensitive)
+ metaData.productArea = "Text Container";
+ }
+
+ [Before]
+ override public function setUpTest():void
+ {
+ super.setUpTest();
+ }
+
+ [After]
+ public override function tearDownTest():void
+ {
+ SelManager.applyContainerFormat(TextLayoutFormat.defaultFormat);
+ super.tearDownTest();
+
+ testProp = null;
+ expectedValue = null;
+ testValue = null;
+ }
+
+
+ /**
+ * This builds testcases for properties in description that are Number types. For each number property
+ * testcases are built to set the value to the below the minimum value, step from the minimum value to the maximum value
+ * and then above the maximum value.
+ */
+ [Test]
+ public function testAllNumberPropsFromMinToMax():void
+ {
+ for each (testProp in TextLayoutFormat.description)
+ {
+ var handler:NumberPropertyHandler = testProp.findHandler(NumberPropertyHandler) as NumberPropertyHandler;
+
+ if (handler && testProp.category == Category.CONTAINER)
+ {
+ var minVal:Number = handler.minValue;
+ var maxVal:Number = handler.maxValue;
+ assertTrue(true, minVal < maxVal);
+ var delta:Number = (maxVal - minVal) / 10;
+ var includeInMinimalTestSuite:Boolean;
+
+ for (var value:Number = minVal - delta; ;)
+ {
+ expectedValue = value < minVal ? undefined : (value > maxVal ? undefined : value);
+ testValue = value;
+ // include in the minmalTest values below the range, min value, max value and values above the range
+ includeInMinimalTestSuite = (value <= minVal || value >= maxVal)
+
+ runOneContainerAttributeTest();
+
+ if (value > maxVal)
+ break;
+ value += delta;
+ }
+ }
+ }
+ }
+
+
+ /**
+ * This builds testcases for properties in attributes in description that are Int types. For each number property
+ * testcases are built to set the value to the below the minimum value, step from the minimum value to the maximum value
+ * and then above the maximum value.
+ */
+ [Test]
+ public function testAllIntPropsFromMinToMax():void
+ {
+ for each (testProp in TextLayoutFormat.description)
+ {
+ if (testProp.category == Category.CONTAINER)
+ {
+ var handler:IntPropertyHandler = testProp.findHandler(IntPropertyHandler) as IntPropertyHandler;
+ if (handler)
+ {
+ var minVal:int = handler.minValue;
+ var maxVal:int = handler.maxValue;
+ assertTrue(true, minVal < maxVal);
+ var delta:int = (maxVal - minVal) / 10;
+ var includeInMinimalTestSuite:Boolean;
+
+ for (var value:Number = minVal - delta; ;)
+ {
+ expectedValue = value < minVal ? undefined : (value > maxVal ? undefined : value);
+ testValue = value;
+ // include in the minmalTest values below the range, min value, max value and values above the range
+ includeInMinimalTestSuite = (value <= minVal || value >= maxVal)
+
+ runOneContainerAttributeTest();
+
+ if (value > maxVal)
+ break;
+ value += delta;
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * This builds testcases for properties in description that are NumberOrPercent types. For each number property
+ * testcases are built to set the value to the below the minimum value, step from the minimum value to the maximum value
+ * and then above the maximum value. This is done first using the min/max number values and then the min/max percent values.
+ */
+ [Test]
+ public function testAllNumberOrPercentPropsFromMinToMax():void
+ {
+ for each (testProp in TextLayoutFormat.description)
+ {
+ if (testProp.category == Category.CONTAINER)
+ {
+ var numberHandler:NumberPropertyHandler = testProp.findHandler(NumberPropertyHandler) as NumberPropertyHandler;
+ var percentHandler:PercentPropertyHandler = testProp.findHandler(PercentPropertyHandler) as PercentPropertyHandler;
+ if (numberHandler && percentHandler)
+ {
+ var minVal:Number = numberHandler.minValue;
+ var maxVal:Number = numberHandler.maxValue;
+ assertTrue(true, minVal < maxVal);
+ var delta:Number = (maxVal - minVal) / 10;
+ var includeInMinimalTestSuite:Boolean;
+
+ for (var value:Number = minVal - delta; ;)
+ {
+ expectedValue = value < minVal ? undefined : (value > maxVal ? undefined : value);
+ testValue = value;
+
+ // include in the minmalTest values below the range, min value, max value and values above the range
+ includeInMinimalTestSuite = (value <= minVal || value >= maxVal)
+
+ runOneContainerAttributeTest();
+ //ts.addTestDescriptor( new TestDescriptor (testClass, methodName, testConfig, null, prop, value, expectedValue, includeInMinimalTestSuite) );
+
+ if (value > maxVal)
+ break;
+ value += delta;
+ }
+
+ // repeat with percent values
+ minVal = percentHandler.minValue;
+ maxVal = percentHandler.maxValue;
+ assertTrue(true, minVal < maxVal);
+ delta = (maxVal - minVal) / 10;
+
+ for (value = minVal - delta; ;)
+ {
+ expectedValue = value < minVal ? undefined : (value > maxVal ? undefined : value.toString() + "%");
+ //ts.addTestDescriptor( new TestDescriptor (testClass, methodName, testConfig, null, prop, value.toString()+"%", expectedValue, true) );
+
+ testValue = value.toString() + "%";
+
+ runOneContainerAttributeTest();
+
+ if (value > maxVal)
+ break;
+ value += delta;
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * This builds testcases for properties in attributes in description that are Boolean types. A testcase is generated
+ * for true and false for the value.
+ */
+ [Test]
+ public function testAllBooleanProps():void
+ {
+ for each (testProp in TextLayoutFormat.description)
+ {
+ if (testProp.category == Category.CONTAINER && testProp.findHandler(BooleanPropertyHandler) != null)
+ {
+ expectedValue = testValue = true;
+ runOneContainerAttributeTest();
+
+ expectedValue = testValue = false;
+ runOneContainerAttributeTest();
+ }
+ }
+ }
+
+
+ /**
+ * This builds testcases for properties in attributes in description that are Enumerated types types. A testcase is generated
+ * for each possible enumerated value
+ */
+ [Test]
+ public function testAllEnumProps():void
+ {
+ var range:Object = null;
+ var value:Object = null;
+
+ for each (testProp in TextLayoutFormat.description)
+ {
+ // new code
+ if (testProp.category == Category.CONTAINER)
+ {
+ var handler:EnumPropertyHandler = testProp.findHandler(EnumPropertyHandler) as EnumPropertyHandler;
+ if (handler)
+ {
+ range = handler.range;
+ for (value in range)
+ {
+ if (value != FormatValue.INHERIT)
+ {
+ expectedValue = testValue = value;
+ runOneContainerAttributeTest();
+ }
+ }
+ expectedValue = undefined;
+ testValue = "foo";
+ runOneContainerAttributeTest();
+ }
+
+ }
+ }
+ }
+
+ /**
+ * This builds testcases for setting all properties in description to inherit, null, undefined and an object.
+ */
+ [Test]
+ public function testAllSharedValues():void
+ {
+ for each (testProp in TextLayoutFormat.description)
+ {
+ if (testProp.category == Category.CONTAINER)
+ {
+
+ testValue = expectedValue = FormatValue.INHERIT;
+ runOneContainerAttributeTest();
+
+ testValue = new Sprite();
+ expectedValue = undefined;
+ runOneContainerAttributeTest();
+
+ testValue = null;
+ expectedValue = undefined;
+ runOneContainerAttributeTest();
+
+ testValue = expectedValue = undefined;
+ runOneContainerAttributeTest();
+
+ testValue = expectedValue = undefined;
+ clearFormatTest();
+ }
+ }
+ }
+
+ /**
+ * Generic function to run one container attribute test. Uses the selection manager to set the attributes on the entire flow at the span level
+ * to value and then validates that the value is expectedValue.
+ */
+ public function runOneContainerAttributeTest():void
+ {
+ if (testProp == null)
+ return; // must be set
+
+ SelManager.selectAll();
+
+ // Test direct change on single leaf
+ var controller:ContainerController = SelManager.textFlow.flowComposer.getControllerAt(0);
+ var originalValue:* = controller[testProp.name];
+
+ assignmentHelper(controller);
+
+ var expectedResult:*;
+ if (expectedValue === undefined)
+ expectedResult = testValue === undefined || testValue === null ? undefined : originalValue;
+ else
+ expectedResult = expectedValue;
+
+ assertTrue("Controller does not have the expected value after direct change", controller[testProp.name] == expectedResult);
+ controller[testProp.name] = originalValue;
+
+ var ca:TextLayoutFormat = new TextLayoutFormat();
+ assignmentHelper(ca);
+ SelManager.applyContainerFormat(ca);
+
+ // expect that all FlowLeafElements have expectedValue as the properties value
+ if (expectedValue !== undefined)
+ assertTrue("not all ContainerElements have the expected value", validateContainerPropertyOnEntireFlow(SelManager.textFlow, testProp, expectedValue));
+ }
+
+ // support function to walk all FlowLeafElements and verify that prop is val
+ static public function validateContainerPropertyOnEntireFlow(textFlow:TextFlow, prop:Property, val:*):Boolean
+ {
+ var idx:int = 0;
+ var elem:FlowLeafElement = textFlow.getFirstLeaf();
+ assertTrue("either the first FlowLeafElement is null or the textFlow length is zero", elem != null || textFlow.textLength == 0);
+ while (elem)
+ {
+ // error if elements have zero length
+ assertTrue("The FlowLeafElement has zero length", elem.textLength != 0);
+
+ // expect all values of prop to be supplied val
+ var controllerIndex:int = textFlow.flowComposer.findControllerIndexAtPosition(elem.getAbsoluteStart(), false);
+ if (controllerIndex != -1)
+ {
+ var controller:ContainerController = textFlow.flowComposer.getControllerAt(controllerIndex);
+ if (controller.format[prop.name] !== val)
+ return false;
+
+ // inherit is never computed
+ if ((val == FormatValue.INHERIT && controller.computedFormat[prop.name] == val) || controller.computedFormat[prop.name] === undefined)
+ return false;
+ }
+
+ // skip to the next element
+ var nextElem:FlowLeafElement = elem.getNextLeaf();
+ var absoluteEnd:int = elem.getAbsoluteStart() + elem.textLength;
+ if (nextElem == null)
+ assertTrue("absoluteEnd of the last FlowLeafElement is not the end of the textFlow", absoluteEnd == textFlow.textLength);
+ else
+ assertTrue("the end of this FlowLeafElement does not equal the start of the next", absoluteEnd == nextElem.getAbsoluteStart());
+
+ elem = nextElem;
+ }
+ return true;
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/flex-tlf/blob/b73314f6/automation_tests/src/UnitTest/Tests/AllParaAttributeTest.as
----------------------------------------------------------------------
diff --git a/automation_tests/src/UnitTest/Tests/AllParaAttributeTest.as b/automation_tests/src/UnitTest/Tests/AllParaAttributeTest.as
index a351514..148d9c3 100644
--- a/automation_tests/src/UnitTest/Tests/AllParaAttributeTest.as
+++ b/automation_tests/src/UnitTest/Tests/AllParaAttributeTest.as
@@ -18,90 +18,337 @@
////////////////////////////////////////////////////////////////////////////////
package UnitTest.Tests
{
- import UnitTest.ExtendedClasses.TestSuiteExtended;
- import UnitTest.Fixtures.TestConfig;
-
- import flashx.textLayout.formats.Category;
- import flashx.textLayout.formats.FormatValue;
- import flashx.textLayout.formats.TextLayoutFormat;
- import flashx.textLayout.elements.FlowLeafElement;
- import flashx.textLayout.elements.TextFlow;
- import flashx.textLayout.elements.ParagraphElement;
- import flashx.textLayout.property.Property;
- import flashx.textLayout.tlf_internal;
+ import UnitTest.Fixtures.TestConfig;
+
+ import flash.display.Sprite;
+
+ import flashx.textLayout.elements.FlowLeafElement;
+ import flashx.textLayout.elements.ParagraphElement;
+
+ import flashx.textLayout.elements.TextFlow;
+
+ import flashx.textLayout.formats.Category;
+ import flashx.textLayout.formats.FormatValue;
+ import flashx.textLayout.formats.TextLayoutFormat;
+ import flashx.textLayout.property.BooleanPropertyHandler;
+ import flashx.textLayout.property.EnumPropertyHandler;
+ import flashx.textLayout.property.IntPropertyHandler;
+ import flashx.textLayout.property.NumberPropertyHandler;
+ import flashx.textLayout.property.PercentPropertyHandler;
+ import flashx.textLayout.property.Property;
+ import flashx.textLayout.tlf_internal;
import org.flexunit.asserts.assertTrue;
use namespace tlf_internal;
- public class AllParaAttributeTest extends AllAttributeTest
- {
- public function AllParaAttributeTest(methodName:String, testID:String, testConfig:TestConfig, prop:Property, value:*, expected:*)
- {
- super (methodName, testID, testConfig, prop, value, expected);
-
- // Note: These must correspond to a Watson product area (case-sensitive)
- metaData.productArea = "Text Attributes";
- metaData.productSubArea = "Paragraph Attributes";
- }
-
- public static function suite(testConfig:TestConfig, ts:TestSuiteExtended):void
- {
- testAllProperties(ts, testConfig, TextLayoutFormat.description, Category.PARAGRAPH, AllParaAttributeTest, "runOneParagraphAttributeTest");
- }
-
- /**
- * Generic function to run one character attribute test. Uses the selection manager to set the attributes on the entire flow at the span level
- * to value and then validates that the value is expectedValue.
- */
- public function runOneParagraphAttributeTest():void
- {
- if (testProp == null)
- return; // must be set
-
- SelManager.selectAll();
-
- var ca:TextLayoutFormat = new TextLayoutFormat();
- assignmentHelper(ca);
- SelManager.applyParagraphFormat(ca);
-
- // expect that all FlowLeafElements have expectedValue as the properties value
- if (expectedValue !== undefined)
- assertTrue("not all ParagraphElements have the expected value", validateParagraphPropertyOnEntireFlow(SelManager.textFlow,testProp,expectedValue));
- }
-
- // support function to walk all FlowLeafElements and verify that prop is val
- static public function validateParagraphPropertyOnEntireFlow(textFlow:TextFlow, prop:Property,val:*):Boolean
- {
- var idx:int = 0;
- var elem:FlowLeafElement = textFlow.getFirstLeaf();
- assertTrue("either the first FlowLeafElement is null or the textFlow length is zero", elem != null || textFlow.textLength == 0);
- while (elem)
- {
- // error if elements have zero length
- assertTrue("The FlowLeafElement has zero length", elem.textLength != 0);
-
- var para:ParagraphElement = elem.getParagraph();
-
- // expect all values of prop to be supplied val
- if (para.format[prop.name] !== val)
- return false;
-
- // inherit is never computed
- if ((val == FormatValue.INHERIT && para.computedFormat[prop.name] == val) || para.computedFormat[prop.name] === undefined)
- return false;
-
- // skip to the next element
- var nextElem:FlowLeafElement = elem.getNextLeaf();
- var absoluteEnd:int = elem.getAbsoluteStart() + elem.textLength;
- if (nextElem == null)
- assertTrue("absoluteEnd of the last FlowLeafElement is not the end of the textFlow", absoluteEnd == textFlow.textLength);
- else
- assertTrue("the end of this FlowLeafElement does not equal the start of the next", absoluteEnd == nextElem.getAbsoluteStart());
-
- elem = nextElem;
- }
- return true;
- }
- }
+ public class AllParaAttributeTest extends AllAttributeTest
+ {
+ public function AllParaAttributeTest()
+ {
+ super("", "AllParaAttributeTest", TestConfig.getInstance());
+
+ // Note: These must correspond to a Watson product area (case-sensitive)
+ metaData.productArea = "Text Attributes";
+ metaData.productSubArea = "Paragraph Attributes";
+ }
+
+
+ [Before]
+ override public function setUpTest():void
+ {
+ super.setUpTest();
+ }
+
+ [After]
+ override public function tearDownTest():void
+ {
+ super.tearDownTest();
+
+ testProp = null;
+ expectedValue = null;
+ testValue = null;
+ }
+
+ /**
+ * This builds testcases for properties in description that are Number types. For each number property
+ * testcases are built to set the value to the below the minimum value, step from the minimum value to the maximum value
+ * and then above the maximum value.
+ */
+ [Test]
+ public function testAllNumberPropsFromMinToMax():void
+ {
+ for each (testProp in TextLayoutFormat.description)
+ {
+ var handler:NumberPropertyHandler = testProp.findHandler(NumberPropertyHandler) as NumberPropertyHandler;
+
+ if (handler && testProp.category == Category.PARAGRAPH)
+ {
+ var minVal:Number = handler.minValue;
+ var maxVal:Number = handler.maxValue;
+ assertTrue(true, minVal < maxVal);
+ var delta:Number = (maxVal - minVal) / 10;
+ var includeInMinimalTestSuite:Boolean;
+
+ for (var value:Number = minVal - delta; ;)
+ {
+ expectedValue = value < minVal ? undefined : (value > maxVal ? undefined : value);
+ testValue = value;
+ // include in the minmalTest values below the range, min value, max value and values above the range
+ includeInMinimalTestSuite = (value <= minVal || value >= maxVal)
+
+ runOneParagraphAttributeTest();
+
+ if (value > maxVal)
+ break;
+ value += delta;
+ }
+ }
+ }
+ }
+
+
+ /**
+ * This builds testcases for properties in attributes in description that are Int types. For each number property
+ * testcases are built to set the value to the below the minimum value, step from the minimum value to the maximum value
+ * and then above the maximum value.
+ */
+ [Test]
+ public function testAllIntPropsFromMinToMax():void
+ {
+ for each (testProp in TextLayoutFormat.description)
+ {
+ if (testProp.category == Category.PARAGRAPH)
+ {
+ var handler:IntPropertyHandler = testProp.findHandler(IntPropertyHandler) as IntPropertyHandler;
+ if (handler)
+ {
+ var minVal:int = handler.minValue;
+ var maxVal:int = handler.maxValue;
+ assertTrue(true, minVal < maxVal);
+ var delta:int = (maxVal - minVal) / 10;
+ var includeInMinimalTestSuite:Boolean;
+
+ for (var value:Number = minVal - delta; ;)
+ {
+ expectedValue = value < minVal ? undefined : (value > maxVal ? undefined : value);
+ testValue = value;
+ // include in the minmalTest values below the range, min value, max value and values above the range
+ includeInMinimalTestSuite = (value <= minVal || value >= maxVal)
+
+ runOneParagraphAttributeTest();
+
+ if (value > maxVal)
+ break;
+ value += delta;
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * This builds testcases for properties in description that are NumberOrPercent types. For each number property
+ * testcases are built to set the value to the below the minimum value, step from the minimum value to the maximum value
+ * and then above the maximum value. This is done first using the min/max number values and then the min/max percent values.
+ */
+ [Test]
+ public function testAllNumberOrPercentPropsFromMinToMax():void
+ {
+ for each (testProp in TextLayoutFormat.description)
+ {
+ if (testProp.category == Category.PARAGRAPH)
+ {
+ var numberHandler:NumberPropertyHandler = testProp.findHandler(NumberPropertyHandler) as NumberPropertyHandler;
+ var percentHandler:PercentPropertyHandler = testProp.findHandler(PercentPropertyHandler) as PercentPropertyHandler;
+ if (numberHandler && percentHandler)
+ {
+ var minVal:Number = numberHandler.minValue;
+ var maxVal:Number = numberHandler.maxValue;
+ assertTrue(true, minVal < maxVal);
+ var delta:Number = (maxVal - minVal) / 10;
+ var includeInMinimalTestSuite:Boolean;
+
+ for (var value:Number = minVal - delta; ;)
+ {
+ expectedValue = value < minVal ? undefined : (value > maxVal ? undefined : value);
+ testValue = value;
+
+ // include in the minmalTest values below the range, min value, max value and values above the range
+ includeInMinimalTestSuite = (value <= minVal || value >= maxVal)
+
+ runOneParagraphAttributeTest();
+ //ts.addTestDescriptor( new TestDescriptor (testClass, methodName, testConfig, null, prop, value, expectedValue, includeInMinimalTestSuite) );
+
+ if (value > maxVal)
+ break;
+ value += delta;
+ }
+
+ // repeat with percent values
+ minVal = percentHandler.minValue;
+ maxVal = percentHandler.maxValue;
+ assertTrue(true, minVal < maxVal);
+ delta = (maxVal - minVal) / 10;
+
+ for (value = minVal - delta; ;)
+ {
+ expectedValue = value < minVal ? undefined : (value > maxVal ? undefined : value.toString() + "%");
+ //ts.addTestDescriptor( new TestDescriptor (testClass, methodName, testConfig, null, prop, value.toString()+"%", expectedValue, true) );
+
+ testValue = value.toString() + "%";
+
+ runOneParagraphAttributeTest();
+
+ if (value > maxVal)
+ break;
+ value += delta;
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * This builds testcases for properties in attributes in description that are Boolean types. A testcase is generated
+ * for true and false for the value.
+ */
+ [Test]
+ public function testAllBooleanProps():void
+ {
+ for each (testProp in TextLayoutFormat.description)
+ {
+ if (testProp.category == Category.PARAGRAPH && testProp.findHandler(BooleanPropertyHandler) != null)
+ {
+ expectedValue = testValue = true;
+ runOneParagraphAttributeTest();
+
+ expectedValue = testValue = false;
+ runOneParagraphAttributeTest();
+ }
+ }
+ }
+
+
+ /**
+ * This builds testcases for properties in attributes in description that are Enumerated types types. A testcase is generated
+ * for each possible enumerated value
+ */
+ [Test]
+ public function testAllEnumProps():void
+ {
+ var range:Object = null;
+ var value:Object = null;
+
+ for each (testProp in TextLayoutFormat.description)
+ {
+ // new code
+ if (testProp.category == Category.PARAGRAPH)
+ {
+ var handler:EnumPropertyHandler = testProp.findHandler(EnumPropertyHandler) as EnumPropertyHandler;
+ if (handler)
+ {
+ range = handler.range;
+ for (value in range)
+ {
+ if (value != FormatValue.INHERIT)
+ {
+ expectedValue = testValue = value;
+ runOneParagraphAttributeTest();
+ }
+ }
+ expectedValue = undefined;
+ testValue = "foo";
+ runOneParagraphAttributeTest();
+ }
+
+ }
+ }
+ }
+
+ /**
+ * This builds testcases for setting all properties in description to inherit, null, undefined and an object.
+ */
+ [Test]
+ public function testAllSharedValues():void
+ {
+ for each (testProp in TextLayoutFormat.description)
+ {
+ if (testProp.category == Category.PARAGRAPH)
+ {
+
+ testValue = expectedValue = FormatValue.INHERIT;
+ runOneParagraphAttributeTest();
+
+ testValue = new Sprite();
+ expectedValue = undefined;
+ runOneParagraphAttributeTest();
+
+ testValue = null;
+ expectedValue = undefined;
+ runOneParagraphAttributeTest();
+
+ testValue = expectedValue = undefined;
+ runOneParagraphAttributeTest();
+
+ testValue = expectedValue = undefined;
+ clearFormatTest();
+ }
+ }
+ }
+
+ /**
+ * Generic function to run one character attribute test. Uses the selection manager to set the attributes on the entire flow at the span level
+ * to value and then validates that the value is expectedValue.
+ */
+ public function runOneParagraphAttributeTest():void
+ {
+ if (testProp == null)
+ return; // must be set
+
+ SelManager.selectAll();
+
+ var ca:TextLayoutFormat = new TextLayoutFormat();
+ assignmentHelper(ca);
+ SelManager.applyParagraphFormat(ca);
+
+ // expect that all FlowLeafElements have expectedValue as the properties value
+ if (expectedValue !== undefined)
+ assertTrue("not all ParagraphElements have the expected value", validateParagraphPropertyOnEntireFlow(SelManager.textFlow,testProp,expectedValue));
+ }
+
+ // support function to walk all FlowLeafElements and verify that prop is val
+ static public function validateParagraphPropertyOnEntireFlow(textFlow:TextFlow, prop:Property,val:*):Boolean
+ {
+ var idx:int = 0;
+ var elem:FlowLeafElement = textFlow.getFirstLeaf();
+ assertTrue("either the first FlowLeafElement is null or the textFlow length is zero", elem != null || textFlow.textLength == 0);
+ while (elem)
+ {
+ // error if elements have zero length
+ assertTrue("The FlowLeafElement has zero length", elem.textLength != 0);
+
+ var para:ParagraphElement = elem.getParagraph();
+
+ // expect all values of prop to be supplied val
+ if (para.format[prop.name] !== val)
+ return false;
+
+ // inherit is never computed
+ if ((val == FormatValue.INHERIT && para.computedFormat[prop.name] == val) || para.computedFormat[prop.name] === undefined)
+ return false;
+
+ // skip to the next element
+ var nextElem:FlowLeafElement = elem.getNextLeaf();
+ var absoluteEnd:int = elem.getAbsoluteStart() + elem.textLength;
+ if (nextElem == null)
+ assertTrue("absoluteEnd of the last FlowLeafElement is not the end of the textFlow", absoluteEnd == textFlow.textLength);
+ else
+ assertTrue("the end of this FlowLeafElement does not equal the start of the next", absoluteEnd == nextElem.getAbsoluteStart());
+
+ elem = nextElem;
+ }
+ return true;
+ }
+ }
}