Skip to content

Commit

Permalink
Migrate AllContAttributeTest to FU 4
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrzarzycki21 committed May 27, 2014
1 parent 2b0067b commit b73314f
Show file tree
Hide file tree
Showing 6 changed files with 987 additions and 429 deletions.
Expand Up @@ -18,8 +18,6 @@
////////////////////////////////////////////////////////////////////////////////
package UnitTest.ExtendedClasses {

import UnitTest.ExtendedClasses.*;

import flash.events.Event;

import flexunit.framework.*;
Expand Down
7 changes: 5 additions & 2 deletions automation_tests/src/AllTestsSuite.as
Expand Up @@ -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;
Expand All @@ -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;
}

}
229 changes: 1 addition & 228 deletions automation_tests/src/UnitTest/Tests/AllAttributeTest.as
Expand Up @@ -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;
Expand All @@ -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();
Expand Down

0 comments on commit b73314f

Please sign in to comment.