FLEX-34807
Added unit test to make sure the bug is not present.
Also corrected some comments and added semi-colons at the end of lines.


Project: http://git-wip-us.apache.org/repos/asf/flex-tlf/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-tlf/commit/422b5536
Tree: http://git-wip-us.apache.org/repos/asf/flex-tlf/tree/422b5536
Diff: http://git-wip-us.apache.org/repos/asf/flex-tlf/diff/422b5536

Branch: refs/heads/develop
Commit: 422b5536a9d5e006ae473eb6c63e24868fcbfeff
Parents: 2d5df2a
Author: Mihai Chira <[email protected]>
Authored: Tue Sep 22 12:46:45 2015 +0200
Committer: Mihai Chira <[email protected]>
Committed: Tue Sep 22 12:46:45 2015 +0200

----------------------------------------------------------------------
 automation_apps/src/VellumUnit.mxml             |   8 +-
 automation_tests/src/UnitTest/Tests/FETest.as   |   4 +-
 .../src/UnitTest/Tests/FLEX_34807_Test.as       | 127 +++++++++++++++++++
 .../src/UnitTest/Tests/FloatTest.as             |   4 +-
 .../PasteWithMutliParagraph_FLEX_34876_Test.as  |   1 -
 5 files changed, 134 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-tlf/blob/422b5536/automation_apps/src/VellumUnit.mxml
----------------------------------------------------------------------
diff --git a/automation_apps/src/VellumUnit.mxml 
b/automation_apps/src/VellumUnit.mxml
index dc21fbd..afae29d 100644
--- a/automation_apps/src/VellumUnit.mxml
+++ b/automation_apps/src/VellumUnit.mxml
@@ -134,11 +134,11 @@
             testApp.getTextFlow = function ():TextFlow
             {
                 return 
SystemManager(loadedSWF.content).application["activeFlow"];
-            }
+            };
             testApp.getDisplayObject = function ():DisplayObject
             {
                 return 
SystemManager(loadedSWF.content).application["rootPanel"];
-            }
+            };
             testApp.setInteractionManager = 
SystemManager(loadedSWF.content).application["setInteractionManager"];
             testApp.contentChange = 
SystemManager(loadedSWF.content).application["changeContent"];
             testApp.detachActiveFlow = 
SystemManager(loadedSWF.content).application["detachActiveFlow"];
@@ -359,12 +359,12 @@
 
         private function onXmlFileListError(event:IOErrorEvent):void
         {
-            //TODO: Error handlig for xml config filex
+            //TODO: Error handlig for xml config files
         }
 
         private function 
onXmlFileListSecurityError(event:SecurityErrorEvent):void
         {
-            //TODO: Error handlig for xml config filex
+            //TODO: Error handlig for xml config files
         }
         ]]>
     </Script>

http://git-wip-us.apache.org/repos/asf/flex-tlf/blob/422b5536/automation_tests/src/UnitTest/Tests/FETest.as
----------------------------------------------------------------------
diff --git a/automation_tests/src/UnitTest/Tests/FETest.as 
b/automation_tests/src/UnitTest/Tests/FETest.as
index b8d80f2..cc07cde 100644
--- a/automation_tests/src/UnitTest/Tests/FETest.as
+++ b/automation_tests/src/UnitTest/Tests/FETest.as
@@ -426,9 +426,7 @@ package UnitTest.Tests
                                var endIndx:int = startIndx + 5;                
// replace existing text
                                var flowLength:int = 
SelManager.textFlow.textLength;
 
-                               var sprite:Sprite = createFilledSprite(100, 
100, 0xff0000);
-
-                               var src:Object = sprite;
+                               var src:Object = createFilledSprite(100, 100, 
0xff0000);
                                var width:int = 100;
                                var height:int = 100;
 

http://git-wip-us.apache.org/repos/asf/flex-tlf/blob/422b5536/automation_tests/src/UnitTest/Tests/FLEX_34807_Test.as
----------------------------------------------------------------------
diff --git a/automation_tests/src/UnitTest/Tests/FLEX_34807_Test.as 
b/automation_tests/src/UnitTest/Tests/FLEX_34807_Test.as
new file mode 100644
index 0000000..99d0892
--- /dev/null
+++ b/automation_tests/src/UnitTest/Tests/FLEX_34807_Test.as
@@ -0,0 +1,127 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.
+//
+////////////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////
+//
+// This file contains content from Ethan Brand by Nathaniel Hawthorne,
+// now in the public domain.
+//
+////////////////////////////////////////////////////////////////////////////////
+
+package UnitTest.Tests
+{
+
+    import UnitTest.ExtendedClasses.VellumTestCase;
+    import UnitTest.Fixtures.FileRepository;
+    import UnitTest.Fixtures.TestConfig;
+
+    import flashx.textLayout.conversion.ConversionType;
+    import flashx.textLayout.conversion.TextConverter;
+    import flashx.textLayout.edit.TextScrap;
+
+    import org.flexunit.asserts.assertEquals;
+
+    public class FLEX_34807_Test extends VellumTestCase
+    {
+        private const PASTED_TEXT:String = '...Hello world!...';
+        private const PASTED_HTML:String = '...<i>Hello<b> world</b>!</i>...';
+        private const PASTE:TextScrap = new 
TextScrap(TextConverter.importToFlow(PASTED_HTML, 
TextConverter.TEXT_FIELD_HTML_FORMAT));
+
+        private var sourceAsPlainText:String;
+
+        public function FLEX_34807_Test()
+        {
+            // super(methodName, testID, testConfig, testCaseXML);
+            super("", "FLEX_34807_Test", TestConfig.getInstance());
+
+            metaData = {};
+
+            TestData.fileName = "HtmlTest.xml";
+        }
+
+        [BeforeClass]
+        public static function setUpClass():void
+        {
+            FileRepository.readFile(TestConfig.getInstance().baseURL, 
"../../test/testFiles/markup/tlf/HtmlTest.xml");
+        }
+
+        [Before]
+        override public function setUpTest():void
+        {
+            super.setUpTest();
+            if(!sourceAsPlainText)
+                sourceAsPlainText = 
TextConverter.export(testApp.getTextFlow(), TextConverter.PLAIN_TEXT_FORMAT, 
ConversionType.STRING_TYPE) as String;
+        }
+
+        [After]
+        public override function tearDownTest():void
+        {
+            super.tearDownTest();
+        }
+
+        [Test]
+        public function paste_in_beginning():void
+        {
+            //given
+            SelManager.selectFirstPosition();
+
+            //when
+            SelManager.pasteTextScrap(PASTE);
+
+            //then
+            const result:String = TextConverter.export(testApp.getTextFlow(), 
TextConverter.PLAIN_TEXT_FORMAT, ConversionType.STRING_TYPE) as String;
+            assertAllTextHasBeenPasted(result, 0);
+        }
+
+        [Test]
+        public function paste_in_first_paragraph():void
+        {
+            //given
+            const PASTE_POSITION:int = 5; //after "That"
+            SelManager.selectRange(PASTE_POSITION, PASTE_POSITION);
+
+            //when
+            SelManager.pasteTextScrap(PASTE);
+
+            //then
+            const result:String = TextConverter.export(testApp.getTextFlow(), 
TextConverter.PLAIN_TEXT_FORMAT, ConversionType.STRING_TYPE) as String;
+            assertAllTextHasBeenPasted(result, PASTE_POSITION);
+        }
+
+        [Test]
+        public function 
paste_in_first_paragraph_in_middle_of_bold_section():void
+        {
+            //given
+            const PASTE_POSITION:int = 16;
+            SelManager.selectRange(PASTE_POSITION, PASTE_POSITION);
+
+            //when
+            SelManager.pasteTextScrap(PASTE);
+
+            //then
+            const result:String = TextConverter.export(testApp.getTextFlow(), 
TextConverter.PLAIN_TEXT_FORMAT, ConversionType.STRING_TYPE) as String;
+            assertAllTextHasBeenPasted(result, PASTE_POSITION);
+        }
+
+        private function 
assertAllTextHasBeenPasted(currentSourceAsPlainText:String, 
pastePosition:int):void
+        {
+            assertEquals("Not all the pasted content appears in the new 
TextFlow!", sourceAsPlainText.substr(0, pastePosition) + PASTED_TEXT + 
sourceAsPlainText.substr(pastePosition), currentSourceAsPlainText);
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-tlf/blob/422b5536/automation_tests/src/UnitTest/Tests/FloatTest.as
----------------------------------------------------------------------
diff --git a/automation_tests/src/UnitTest/Tests/FloatTest.as 
b/automation_tests/src/UnitTest/Tests/FloatTest.as
index 9601aa7..47d698a 100644
--- a/automation_tests/src/UnitTest/Tests/FloatTest.as
+++ b/automation_tests/src/UnitTest/Tests/FloatTest.as
@@ -78,7 +78,7 @@ package UnitTest.Tests
         // axies
         private static var floatTypeList:Array;
         private static var contentLanguageList:Array = [ _englishContent, 
_japaneseContent];
-        private static var floatWidthList:Array = [ 5, 20, 50, 100, 200, 400 ]
+        private static var floatWidthList:Array = [ 5, 20, 50, 100, 200, 400 ];
         private static var floatHeightList:Array = [ 5, 20, 50, 100, 200, 400 
];
 
         private static var _englishContent:String;
@@ -109,7 +109,7 @@ package UnitTest.Tests
         public static function setUpClass():void
         {
             _englishContent = "The Apache Flex SDK is the evolution of the 
popular Adobe Flex SDK. The Apache Flex SDK is an application development 
framework for easily building Flash based applications for mobile devices, web 
browsers, and desktop platforms. The Apache Flex SDK is the evolution of the 
popular Adobe Flex SDK. The Apache Flex SDK is an application development 
framework for easily building Flash based applications for mobile devices, web 
browsers, and desktop platforms. The Apache Flex SDK is the evolution of the 
popular Adobe Flex SDK. The Apache Flex SDK is an application development 
framework for easily building Flash based applications for mobile devices, web 
browsers, and desktop platforms. The Apache Flex SDK is the evolution of the 
popular Adobe Flex SDK. The Apache Flex SDK is an application development 
framework for easily building Flash based applications for mobile devices, web 
browsers, and desktop platforms. The Apache Flex SDK is the evolution of the po
 pular Adobe Flex SDK. The Apache Flex SDK is an application development 
framework for easily building Flash based applications for mobile devices, web 
browsers, and desktop platforms.The Apache Flex SDK is the evolution of the 
popular Adobe Flex SDK. The Apache Flex SDK is an application development 
framework for easily building Flash based applications for mobile devices, web 
browsers, and desktop platforms.\n" +
-                    "The Apache Flex SDK is the evolution of the popular Adobe 
Flex SDK. The Apache Flex SDK is an application development framework for 
easily building Flash based applications for mobile devices, web browsers, and 
desktop platforms. The Apache Flex SDK is the evolution of the popular Adobe 
Flex SDK. The Apache Flex SDK is an application development framework for 
easily building Flash based applications for mobile devices, web browsers, and 
desktop platforms. The Apache Flex SDK is the evolution of the popular Adobe 
Flex SDK. The Apache Flex SDK is an application development framework for 
easily building Flash based applications for mobile devices, web browsers, and 
desktop platforms. The Apache Flex SDK is the evolution of the popular Adobe 
Flex SDK. The Apache Flex SDK is an application development framework for 
easily building Flash based applications for mobile devices, web browsers, and 
desktop platforms. The Apache Flex SDK is the evolution of the popular Adob
 e Flex SDK. The Apache Flex SDK is an application development framework for 
easily building Flash based applications for mobile devices, web browsers, and 
desktop platforms."
+                    "The Apache Flex SDK is the evolution of the popular Adobe 
Flex SDK. The Apache Flex SDK is an application development framework for 
easily building Flash based applications for mobile devices, web browsers, and 
desktop platforms. The Apache Flex SDK is the evolution of the popular Adobe 
Flex SDK. The Apache Flex SDK is an application development framework for 
easily building Flash based applications for mobile devices, web browsers, and 
desktop platforms. The Apache Flex SDK is the evolution of the popular Adobe 
Flex SDK. The Apache Flex SDK is an application development framework for 
easily building Flash based applications for mobile devices, web browsers, and 
desktop platforms. The Apache Flex SDK is the evolution of the popular Adobe 
Flex SDK. The Apache Flex SDK is an application development framework for 
easily building Flash based applications for mobile devices, web browsers, and 
desktop platforms. The Apache Flex SDK is the evolution of the popular Adob
 e Flex SDK. The Apache Flex SDK is an application development framework for 
easily building Flash based applications for mobile devices, web browsers, and 
desktop platforms.";
 
                        _japaneseContent = 'ApacheのFlex 
SDKには、人気のAdobeのFlex SDKの進化である。 ApacheのFlex 
SDKには、人気のAdobeのFlex SDKの進化である。 ApacheのFlex 
SDKには、人気のAdobeのFlex SDKの進化である。 ApacheのFlex 
SDKには、人気のAdobeのFlex SDKの進化である。 ApacheのFlex 
SDKには、人気のAdobeのFlex SDKの進化である。 ApacheのFlex 
SDKには、人気のAdobeのFlex SDKの進化である。 ApacheのFlex 
SDKには、人気のAdobeのFlex SDKの進化である。 ApacheのFlex 
SDKには、人気のAdobeのFlex SDKの進化である。\n' +
                     'ApacheのFlex SDKには、人気のAdobeのFlex 
SDKの進化である。ApacheのFlex SDKには、人気のAdobeのFlex 
SDKの進化である。ApacheのFlex SDKには、人気のAdobeのFlex 
SDKの進化である。ApacheのFlex SDKには、人気のAdobeのFlex 
SDKの進化である。ApacheのFlex SDKには、人気のAdobeのFlex 
SDKの進化である。ApacheのFlex SDKには、人気のAdobeのFlex 
SDKの進化である。ApacheのFlex SDKには、人気のAdobeのFlex 
SDKの進化である。ApacheのFlex SDKには、人気のAdobeのFlex 
SDKの進化である。ApacheのFlex SDKには、人気のAdobeのFlex 
SDKの進化である。ApacheのFlex SDKには、人気のAdobeのFlex 
SDKの進化である。';

http://git-wip-us.apache.org/repos/asf/flex-tlf/blob/422b5536/automation_tests/src/UnitTest/Tests/PasteWithMutliParagraph_FLEX_34876_Test.as
----------------------------------------------------------------------
diff --git 
a/automation_tests/src/UnitTest/Tests/PasteWithMutliParagraph_FLEX_34876_Test.as
 
b/automation_tests/src/UnitTest/Tests/PasteWithMutliParagraph_FLEX_34876_Test.as
index e17ed4d..e676b58 100644
--- 
a/automation_tests/src/UnitTest/Tests/PasteWithMutliParagraph_FLEX_34876_Test.as
+++ 
b/automation_tests/src/UnitTest/Tests/PasteWithMutliParagraph_FLEX_34876_Test.as
@@ -107,7 +107,6 @@ package UnitTest.Tests
             var multiLineScrap:TextScrap = 
TextClipboard.importToScrap(inputString, TextConverter.PLAIN_TEXT_FORMAT);
 
             (SelManager.textFlow.interactionManager as 
EditManager).pasteTextScrap(multiLineScrap);
-
         }
     }
 }

Reply via email to