////////////////////////////////////////////////////////////////////////////////
//
// Licensed to the Apache Software Foundation (ASF) under one or more
// contributor license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright ownership.
// The ASF licenses this file to You under the Apache License, Version 2.0
// (the "License"); you may not use this file except in compliance with
// the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
////////////////////////////////////////////////////////////////////////////////
package UnitTest.Tests
{
import UnitTest.ExtendedClasses.TestSuiteExtended;
import UnitTest.ExtendedClasses.VellumTestCase;
import UnitTest.Fixtures.TestConfig;
import flashx.textLayout.conversion.ConversionType;
import flashx.textLayout.conversion.ITextExporter;
import flashx.textLayout.conversion.ITextImporter;
import flashx.textLayout.conversion.TextConverter;
import flashx.textLayout.elements.TextFlow;
public class ImpliedParagraphTest extends VellumTestCase
{
public function ImpliedParagraphTest(methodName:String, testID:String, testConfig:TestConfig, testCaseXML:XML=null)
{
super(methodName, testID, testConfig, testCaseXML);
}
public static function suiteFromXML(testListXML:XML, testConfig:TestConfig, ts:TestSuiteExtended):void
{
var testCaseClass:Class = ImpliedParagraphTest;
VellumTestCase.suiteFromXML(testCaseClass, testListXML, testConfig, ts);
}
private const inputString1:String = 'Italic Plain Italic Plain Bold';
private const inputString2:String = 'Bold Italic Plain Italic Plain Bold';
private const inputString3:String = 'BoldItalic Plain Italic Plain Bold';
private const inputString4:String = '
asdf
bolditalicqwerty
'; private const inputString6:String = 'Plain Bold Italic Plain Italic Plain Bold'; private const outputString1:String = 'Italic Plain Italic Plain Bold
'; private const outputString2:String = 'Bold Italic Plain Italic Plain Bold
'; private const outputString3:String = 'BoldItalic Plain Italic Plain Bold
'; private const outputString4:String = 'BoldItalic Plain Italic Plain Bold
'; private const outputString5:String = 'asdf
bolditalic
qwerty
'; private const outputString6:String = 'Plain Bold Italic Plain Italic Plain Bold
'; private var textImporter:ITextImporter = TextConverter.getImporter(TextConverter.TEXT_FIELD_HTML_FORMAT); private var textExporter:ITextExporter = TextConverter.getExporter(TextConverter.TEXT_LAYOUT_FORMAT); public function runTheTest(inString:String, outString:String):void { var textFlow:TextFlow = textImporter.importToFlow(inString); var markupResult:String = textExporter.export(textFlow, ConversionType.STRING_TYPE) as String; var startIndex:int = markupResult.search(""); var expectedString:String = markupResult.substring(startIndex, endIndex); assertTrue("TLF model did not match expected result", expectedString == outString); } public function impliedParagraphHTMLImportTest1():void { runTheTest(inputString1, outputString1); } public function impliedParagraphHTMLImportTest2():void { runTheTest(inputString2, outputString2); } public function impliedParagraphHTMLImportTest3():void { runTheTest(inputString3, outputString3); } public function impliedParagraphHTMLImportTest4():void { runTheTest(inputString4, outputString4); } public function impliedParagraphHTMLImportTest5():void { runTheTest(inputString5, outputString5); } public function impliedParagraphHTMLImportTest6():void { runTheTest(inputString6, outputString6); } } }