Repository: flex-tlf Updated Branches: refs/heads/develop ea6ff6f81 -> 4991d3eb3
http://git-wip-us.apache.org/repos/asf/flex-tlf/blob/4991d3eb/automation_tests/src/UnitTest/Tests/KeyboardGestureTest.as ---------------------------------------------------------------------- diff --git a/automation_tests/src/UnitTest/Tests/KeyboardGestureTest.as b/automation_tests/src/UnitTest/Tests/KeyboardGestureTest.as index f95e8a3..58fe46c 100644 --- a/automation_tests/src/UnitTest/Tests/KeyboardGestureTest.as +++ b/automation_tests/src/UnitTest/Tests/KeyboardGestureTest.as @@ -18,3939 +18,4151 @@ //////////////////////////////////////////////////////////////////////////////// package UnitTest.Tests { - import UnitTest.ExtendedClasses.TestDescriptor; - import UnitTest.ExtendedClasses.TestSuiteExtended; - import UnitTest.ExtendedClasses.VellumTestCase; - import UnitTest.Fixtures.FileRepository; - import UnitTest.Fixtures.TestConfig; - - import flash.events.KeyboardEvent; - import flash.ui.KeyLocation; - - import flashx.textLayout.container.ScrollPolicy; - import flashx.textLayout.conversion.*; - import flashx.textLayout.edit.TextScrap; - import flashx.textLayout.elements.Configuration; - import flashx.textLayout.elements.FlowLeafElement; - import flashx.textLayout.elements.IConfiguration; - import flashx.textLayout.elements.InlineGraphicElement; - import flashx.textLayout.elements.ParagraphElement; - import flashx.textLayout.elements.SpanElement; - import flashx.textLayout.elements.TextFlow; - import flashx.textLayout.elements.ListElement; - import flashx.textLayout.elements.ListItemElement; - - import flashx.textLayout.formats.BlockProgression; - import flashx.textLayout.formats.Direction; - - import mx.utils.LoaderUtil; + import UnitTest.ExtendedClasses.VellumTestCase; + import UnitTest.Fixtures.FileRepository; + import UnitTest.Fixtures.TestConfig; + + import flash.events.KeyboardEvent; + import flash.ui.KeyLocation; + + import flashx.textLayout.container.ScrollPolicy; + import flashx.textLayout.conversion.*; + import flashx.textLayout.edit.TextScrap; + import flashx.textLayout.elements.FlowLeafElement; + import flashx.textLayout.elements.InlineGraphicElement; + import flashx.textLayout.elements.ListElement; + import flashx.textLayout.elements.ListItemElement; + import flashx.textLayout.elements.ParagraphElement; + import flashx.textLayout.elements.SpanElement; + import flashx.textLayout.elements.TextFlow; + import flashx.textLayout.formats.BlockProgression; + import flashx.textLayout.formats.Direction; + + import mx.utils.LoaderUtil; import org.flexunit.asserts.assertTrue; import org.flexunit.asserts.fail; + [TestCase(order=28)] public class KeyboardGestureTest extends VellumTestCase - { - private var version:Number; - - public function KeyboardGestureTest(methodName:String, testID:String, testConfig:TestConfig, testCaseXML:XML=null) - { - super(methodName, testID, testConfig, testCaseXML); - - // Note: These must correspond to a Watson product area (case-sensitive) - metaData.productArea = "Editing"; - metaData.productSubArea = "Keyboard Gestures"; - } - - public static function suiteFromXML(testListXML:XML, testConfig:TestConfig, ts:TestSuiteExtended):void - { - FileRepository.readFile(testConfig.baseURL,"../../test/testFiles/markup/tlf/school.xml"); - FileRepository.readFile(testConfig.baseURL,"../../test/testFiles/markup/tlf/tcyTestBase.xml"); - var testCaseClass:Class = KeyboardGestureTest; - - VellumTestCase.suiteFromXML(testCaseClass, testListXML, testConfig, ts); - } - - private const BASIC_TEST:String = "This is a test of the keyboard gesture system."; - private const HYPHEN_TEST:String = "This is-a test-of-the keyboard-gesture system.-"; - - public override function setUpTest():void - { - super.setUpTest(); - - SelManager.selectAll(); - SelManager.deleteNextCharacter(); - - SelManager.insertText(BASIC_TEST); - SelManager.flushPendingOperations(); - } - - public override function loadTestFile(fileName:String):void - { - super.loadTestFile(fileName); - - SelManager.textFlow.blockProgression = writingDirection[0];; - SelManager.textFlow.direction = writingDirection[1];; - SelManager.flushPendingOperations(); - } - - private function setUpLanguageTest():void - { - loadTestFile("school.xml"); - - SelManager.selectRange(75,75); - SelManager.insertText("abc"); - } - - private function setUpTCYTest():void - { - loadTestFile("tcyTestBase.xml"); - - SelManager.textFlow.blockProgression = BlockProgression.RL; - SelManager.textFlow.direction = Direction.LTR; - SelManager.flushPendingOperations(); - - SelManager.selectRange(15,22); - SelManager.applyTCY(true); - SelManager.selectRange(62,73); - SelManager.applyTCY(true); - } - - // List of available keyboard gestures - // Note that on Mac: CTRL == COMMAND - // and: ALT == OPTION - // These are directly mapped in flash player - private static const CTRL_BACKSPACE:int = 100; - private static const CTRL_DELETE:int = 101; - private static const OPT_BACKSPACE:int = 102; - private static const OPT_DELETE:int = 103; - private static const CTRL_LEFT:int = 104; - private static const CTRL_RIGHT:int = 105; - private static const CTRL_UP:int = 106; - private static const CTRL_DOWN:int = 107; - private static const OPT_LEFT:int = 108; - private static const OPT_RIGHT:int = 109; - private static const OPT_UP:int = 110; - private static const OPT_DOWN:int = 111; - private static const SHIFT_CTRL_LEFT:int = 112; - private static const SHIFT_CTRL_RIGHT:int = 113; - private static const SHIFT_CTRL_UP:int = 114; - private static const SHIFT_CTRL_DOWN:int = 115; - private static const SHIFT_OPT_LEFT:int = 116; - private static const SHIFT_OPT_RIGHT:int = 117; - private static const SHIFT_OPT_UP:int = 118; - private static const SHIFT_OPT_DOWN:int = 119; - private static const HOME:int = 120; - private static const END:int = 121; - private static const SHIFT_HOME:int = 122; - private static const SHIFT_END:int = 123; - private static const CTRL_HOME:int = 124; - private static const CTRL_END:int = 125; - private static const SHIFT_CTRL_HOME:int = 126; - private static const SHIFT_CTRL_END:int = 127; - private static const PG_UP:int = 128; - private static const PG_DOWN:int = 129; - private static const SHIFT_PG_UP:int = 130; - private static const SHIFT_PG_DOWN:int = 131; - private static const UP:int = 132; - private static const DOWN:int = 133; - private static const LEFT:int = 134; - private static const RIGHT:int = 135; - private static const TAB:int = 136; - private static const SHIFT_TAB:int = 137; - - // Send a keyboard gesture using values listed above - // Code folding extremely recommended here - private function sendKeyboardGesture( type:int ): void - { - var charCode:int; - var keyCode:int; - var ctrlDown:Boolean = false; - var shiftDown:Boolean = false; - var altDown:Boolean = false; - - var leftCode:int = 37; - var rightCode:int = 39; - var upCode:int = 38; - var downCode:int = 40; - - // Arrow keys behave differently on Right to Left Blockprogression - // For the sake of test simplicity, I am translating the directions here - if( SelManager.textFlow.computedFormat.blockProgression == BlockProgression.RL ) - { - leftCode = 38; - rightCode = 40; - upCode = 39; - downCode = 37; - } - - // Gestures are expected to move with visual order for RTL text - // Sending the "opposite" direction in order to test for this - if( SelManager.textFlow.computedFormat.direction == Direction.RTL ) - { - leftCode = 39; - rightCode = 37; - upCode = 38; - downCode = 40; - } - - switch( type ) - { - case CTRL_BACKSPACE: - charCode = 8; - keyCode = 8; - ctrlDown = true; - break; - case CTRL_DELETE: - charCode = 127; - keyCode = 46; - ctrlDown = true; - break; - case OPT_BACKSPACE: - charCode = 8; - keyCode = 8; - altDown = true; - break; - case OPT_DELETE: - charCode = 127; - keyCode = 46; - altDown = true; - break; - case CTRL_LEFT: - charCode = 0; - keyCode = leftCode; - ctrlDown = true; - break; - case CTRL_RIGHT: - charCode = 0; - keyCode = rightCode; - ctrlDown = true; - break; - case CTRL_UP: - charCode = 0; - keyCode = upCode; - ctrlDown = true; - break; - case CTRL_DOWN: - charCode = 0; - keyCode = downCode; - ctrlDown = true; - break; - case OPT_LEFT: - charCode = 0; - keyCode = leftCode; - altDown = true; - break; - case OPT_RIGHT: - charCode = 0; - keyCode = rightCode; - altDown = true; - break; - case OPT_UP: - charCode = 0; - keyCode = upCode; - altDown = true; - break; - case OPT_DOWN: - charCode = 0; - keyCode = downCode; - altDown = true; - break; - case SHIFT_CTRL_LEFT: - charCode = 0; - keyCode = leftCode; - ctrlDown = true; - shiftDown = true; - break; - case SHIFT_CTRL_RIGHT: - charCode = 0; - keyCode = rightCode; - ctrlDown = true; - shiftDown = true; - break; - case SHIFT_CTRL_UP: - charCode = 0; - keyCode = upCode; - ctrlDown = true; - shiftDown = true; - break; - case SHIFT_CTRL_DOWN: - charCode = 0; - keyCode = downCode; - ctrlDown = true; - shiftDown = true; - break; - case SHIFT_OPT_LEFT: - charCode = 0; - keyCode = leftCode; - ctrlDown = true; - shiftDown = true; - break; - case SHIFT_OPT_RIGHT: - charCode = 0; - keyCode = rightCode; - ctrlDown = true; - shiftDown = true; - break; - case SHIFT_OPT_UP: - charCode = 0; - keyCode = upCode; - ctrlDown = true; - shiftDown = true; - break; - case SHIFT_OPT_DOWN: - charCode = 0; - keyCode = downCode; - altDown = true; - shiftDown = true; - break; - case HOME: - charCode = 0; - keyCode = 36; - break; - case END: - charCode = 0; - keyCode = 35; - break; - case SHIFT_HOME: - charCode = 0; - keyCode = 36; - shiftDown = true; - break; - case SHIFT_END: - charCode = 0; - keyCode = 35; - shiftDown = true; - break; - case CTRL_HOME: - charCode = 0; - keyCode = 36; - ctrlDown = true; - break; - case CTRL_END: - charCode = 0; - keyCode = 35; - ctrlDown = true; - break; - case SHIFT_CTRL_HOME: - charCode = 0; - keyCode = 36; - shiftDown = true; - ctrlDown = true; - break; - case SHIFT_CTRL_END: - charCode = 0; - keyCode = 35; - shiftDown = true; - ctrlDown = true; - break; - case PG_UP: - charCode = 0; - keyCode = 33; - break; - case PG_DOWN: - charCode = 0; - keyCode = 34; - break; - case SHIFT_PG_UP: - charCode = 0; - keyCode = 33; - shiftDown = true; - break; - case SHIFT_PG_DOWN: - charCode = 0; - keyCode = 34; - shiftDown = true; - break; - case UP: - charCode = 0; - keyCode = upCode; - break; - case DOWN: - charCode = 0; - keyCode = downCode; - break; - case LEFT: - charCode = 0; - keyCode = leftCode; - break; - case RIGHT: - charCode = 0; - keyCode = rightCode; - break; - case TAB: - charCode = 9; - keyCode = 9; - break; - case SHIFT_TAB: - charCode = 9; - keyCode = 9; - shiftDown = true; - break; - default: - return; - } - - var kEvent:KeyboardEvent = new KeyboardEvent( KeyboardEvent.KEY_DOWN, - true, false, charCode, keyCode, KeyLocation.STANDARD, ctrlDown, altDown, shiftDown); - TestFrame.container["dispatchEvent"](kEvent); - } - - // Returns the string from begIdx through and including endIdx - private function getText( begIdx:int, endIdx:int ): String - { - var outString:String = ""; - - for ( var x:int = begIdx; x < endIdx; x++ ) - { - outString += SelManager.textFlow.getCharAtPosition(x); - } - - return outString; - } - - // Returns the text contents of the entire textflow - private function getAllText(): String - { - var begIdx:int = SelManager.textFlow.parentRelativeStart; - var endIdx:int = SelManager.textFlow.parentRelativeEnd-1; - var outString:String = ""; - - for ( var x:int = begIdx; x < endIdx; x++ ) - { - outString += SelManager.textFlow.getCharAtPosition(x); - } - - return outString; - } - - // Returns the presently selected text - private function getSelectedText():String - { - var begIdx:int = SelManager.absoluteStart; - var endIdx:int = SelManager.absoluteEnd; - var outString:String = ""; - - for ( var x:int = begIdx; x < endIdx; x++ ) - { - outString += SelManager.textFlow.getCharAtPosition(x); - } - - return outString; - } - -/*********** CTRL-BACKSPACE TESTS **************************************************************/ - - // Test the basic functionality and undo/redo - public function CtrlBackspaceGeneralTest():void - { - BackspaceGeneralTest( CTRL_BACKSPACE ); - } - public function OptBackspaceGeneralTest():void - { - BackspaceGeneralTest( OPT_BACKSPACE ); - } - public function BackspaceGeneralTest( bsKey:int ):void - { - SelManager.selectRange(31,31); - - // Test Generic Functionality - - sendKeyboardGesture( bsKey ); - - assertTrue( "Ctrl-Backspace failed to delete previous word", - getAllText() == "This is a test of the gesture system." ); - - sendKeyboardGesture( bsKey ); - - assertTrue( "Ctrl-Backspace failed to delete previous word", - getAllText() == "This is a test of gesture system." ); - - SelManager.selectAll(); - sendKeyboardGesture( bsKey ); - - assertTrue( "Ctrl-Backspace should not remove all text", - getAllText() == "This is a test of gesture system." ); - - // Undo/Redo it all - - SelManager.undo(); - assertTrue( "Ctrl-Backspace failed to undo", - getAllText() == "This is a test of the gesture system." ); - - SelManager.undo(); - assertTrue( "Ctrl-Backspace failed to undo", - getAllText() == BASIC_TEST ); - - SelManager.redo(); - assertTrue( "Ctrl-Backspace failed to redo", - getAllText() == "This is a test of the gesture system." ); - - SelManager.redo(); - assertTrue( "Ctrl-Backspace failed to redo", - getAllText() == "This is a test of gesture system." ); - } + { + private const BASIC_TEST:String = "This is a test of the keyboard gesture system."; + private const HYPHEN_TEST:String = "This is-a test-of-the keyboard-gesture system.-"; + + // List of available keyboard gestures + // Note that on Mac: CTRL == COMMAND + // and: ALT == OPTION + // These are directly mapped in flash player + private static const CTRL_BACKSPACE:int = 100; + private static const CTRL_DELETE:int = 101; + private static const OPT_BACKSPACE:int = 102; + private static const OPT_DELETE:int = 103; + private static const CTRL_LEFT:int = 104; + private static const CTRL_RIGHT:int = 105; + private static const CTRL_UP:int = 106; + private static const CTRL_DOWN:int = 107; + private static const OPT_LEFT:int = 108; + private static const OPT_RIGHT:int = 109; + private static const OPT_UP:int = 110; + private static const OPT_DOWN:int = 111; + private static const SHIFT_CTRL_LEFT:int = 112; + private static const SHIFT_CTRL_RIGHT:int = 113; + private static const SHIFT_CTRL_UP:int = 114; + private static const SHIFT_CTRL_DOWN:int = 115; + private static const SHIFT_OPT_LEFT:int = 116; + private static const SHIFT_OPT_RIGHT:int = 117; + private static const SHIFT_OPT_UP:int = 118; + private static const SHIFT_OPT_DOWN:int = 119; + private static const HOME:int = 120; + private static const END:int = 121; + private static const SHIFT_HOME:int = 122; + private static const SHIFT_END:int = 123; + private static const CTRL_HOME:int = 124; + private static const CTRL_END:int = 125; + private static const SHIFT_CTRL_HOME:int = 126; + private static const SHIFT_CTRL_END:int = 127; + private static const PG_UP:int = 128; + private static const PG_DOWN:int = 129; + private static const SHIFT_PG_UP:int = 130; + private static const SHIFT_PG_DOWN:int = 131; + private static const UP:int = 132; + private static const DOWN:int = 133; + private static const LEFT:int = 134; + private static const RIGHT:int = 135; + private static const TAB:int = 136; + private static const SHIFT_TAB:int = 137; + + private var version:Number; + + public function KeyboardGestureTest() + { + super("", "KeyboardGestureTest", TestConfig.getInstance()); + + metaData = {}; + + // Note: These must correspond to a Watson product area (case-sensitive) + metaData.productArea = "Editing"; + metaData.productSubArea = "Keyboard Gestures"; + } + + [BeforeClass] + public static function setUpClass():void + { + var testConfig = TestConfig.getInstance(); + FileRepository.readFile(testConfig.baseURL, "../../test/testFiles/markup/tlf/empty.xml"); + FileRepository.readFile(testConfig.baseURL, "../../test/testFiles/markup/tlf/school.xml"); + FileRepository.readFile(testConfig.baseURL, "../../test/testFiles/markup/tlf/tcyTestBase.xml"); + } + + [Before] + public override function setUpTest():void + { + super.setUpTest(); + + SelManager.selectAll(); + SelManager.deleteNextCharacter(); + + SelManager.insertText(BASIC_TEST); + SelManager.flushPendingOperations(); + } + + [After] + override public function tearDownTest():void + { + super.tearDownTest(); + } + + public override function loadTestFile(fileName:String):void + { + super.loadTestFile(fileName); + + SelManager.textFlow.blockProgression = writingDirection[0]; + SelManager.textFlow.direction = writingDirection[1]; + SelManager.flushPendingOperations(); + } + + /*********** CTRL-BACKSPACE TESTS **************************************************************/ + + /** + * Test the basic functionality and undo/redo + */ + [Test] + public function CtrlBackspaceGeneralTest():void + { + BackspaceGeneralTest(CTRL_BACKSPACE); + } + + /** + * Test the basic functionality and undo/redo + */ + [Test] + public function OptBackspaceGeneralTest():void + { + BackspaceGeneralTest(OPT_BACKSPACE); + } + + /** + * Test a bunch of different places in a line that Ctrl-Backspace could be pressed + */ + [Test] + public function CtrlBackspaceLocationTest():void + { + SelManager.selectRange(0, 0); + sendKeyboardGesture(CTRL_BACKSPACE); + assertTrue("Ctrl-Backspace changed something when exectuted at position 0", + getAllText() == BASIC_TEST); + + SelManager.selectRange(46, 46); + sendKeyboardGesture(CTRL_BACKSPACE); + + assertTrue("Ctrl-Backspace failed on punctutation", + getAllText() == "This is a test of the keyboard gesture system"); + + SelManager.selectRange(45, 45); + sendKeyboardGesture(CTRL_BACKSPACE); + + assertTrue("Ctrl-Backspace failed at the end of a line", + getAllText() == "This is a test of the keyboard gesture "); + + SelManager.selectRange(9, 9); + sendKeyboardGesture(CTRL_BACKSPACE); + + assertTrue("Ctrl-Backspace failed on a single character word", + getAllText() == "This is test of the keyboard gesture "); + + SelManager.selectRange(8, 8); + SelManager.insertText(" "); + SelManager.selectRange(11, 11); + sendKeyboardGesture(CTRL_BACKSPACE); + + assertTrue("Ctrl-Backspace failed over extra whitespace", + getAllText() == "This test of the keyboard gesture "); + + SelManager.selectRange(20, 20); + sendKeyboardGesture(CTRL_BACKSPACE); + + assertTrue("Ctrl-Backspace failed in the middle of a word", + getAllText() == "This test of the board gesture "); + + SelManager.selectRange(29, 29); + sendKeyboardGesture(CTRL_BACKSPACE); + + assertTrue("Ctrl-Backspace failed 1 from the end of a word", + getAllText() == "This test of the board e "); + + SelManager.selectRange(18, 18); + sendKeyboardGesture(CTRL_BACKSPACE); + + assertTrue("Ctrl-Backspace failed on the first character of a word", + getAllText() == "This test of the oard e "); + + SelManager.selectRange(10, 10); + sendKeyboardGesture(CTRL_BACKSPACE); + + assertTrue("Ctrl-Backspace failed after a single whitespace", + getAllText() == "This of the oard e "); + + SelManager.selectRange(19, 19); + sendKeyboardGesture(CTRL_BACKSPACE); + + assertTrue("Ctrl-Backspace failed after a training whitespace", + getAllText() == "This of the oard "); + } + + [Test] + public function CtrlBackspaceHyphenTest():void + { + SelManager.selectAll(); + SelManager.deleteNextCharacter(); + SelManager.flushPendingOperations(); + SelManager.insertText(HYPHEN_TEST); + SelManager.selectRange(47, 47); + SelManager.insertText(BASIC_TEST); + SelManager.selectRange(47, 47); + SelManager.splitParagraph(); + + SelManager.selectRange(48, 48); + sendKeyboardGesture(CTRL_BACKSPACE); + assertTrue("Ctrl-Backspace failed over a paragraph break w/ hypen", + getAllText() == "This is-a test-of-the keyboard-gesture system.-This is a test of the keyboard gesture system."); + + sendKeyboardGesture(CTRL_BACKSPACE); + assertTrue("Ctrl-Backspace failed with a hyphen punctuation combination", + getAllText() == "This is-a test-of-the keyboard-gesture system.This is a test of the keyboard gesture system."); + + sendKeyboardGesture(CTRL_BACKSPACE); + assertTrue("Ctrl-Backspace failed with a hyphen punctuation combination", + getAllText() == "This is-a test-of-the keyboard-gesture This is a test of the keyboard gesture system."); + + sendKeyboardGesture(CTRL_BACKSPACE); + assertTrue("Ctrl-Backspace failed with a hyphen", + getAllText() == "This is-a test-of-the keyboard-This is a test of the keyboard gesture system."); + + sendKeyboardGesture(CTRL_BACKSPACE); + assertTrue("Ctrl-Backspace failed with a hyphen", + getAllText() == "This is-a test-of-the keyboardThis is a test of the keyboard gesture system."); + + sendKeyboardGesture(CTRL_BACKSPACE); + assertTrue("Ctrl-Backspace failed with a hyphen", + getAllText() == "This is-a test-of-the This is a test of the keyboard gesture system."); + + SelManager.selectRange(21, 21); + + sendKeyboardGesture(CTRL_BACKSPACE); + assertTrue("Ctrl-Backspace failed with a hyphen", + getAllText() == "This is-a test-of- This is a test of the keyboard gesture system."); + + sendKeyboardGesture(CTRL_BACKSPACE); + assertTrue("Ctrl-Backspace failed with a hyphen", + getAllText() == "This is-a test-of This is a test of the keyboard gesture system."); + + sendKeyboardGesture(CTRL_BACKSPACE); + assertTrue("Ctrl-Backspace failed with a hyphen", + getAllText() == "This is-a test- This is a test of the keyboard gesture system."); + + sendKeyboardGesture(CTRL_BACKSPACE); + assertTrue("Ctrl-Backspace failed with a hyphen", + getAllText() == "This is-a test This is a test of the keyboard gesture system."); + + SelManager.selectRange(9, 9); + + sendKeyboardGesture(CTRL_BACKSPACE); + assertTrue("Ctrl-Backspace failed with a hyphen", + getAllText() == "This is- test This is a test of the keyboard gesture system."); + + sendKeyboardGesture(CTRL_BACKSPACE); + assertTrue("Ctrl-Backspace failed with a hyphen", + getAllText() == "This is test This is a test of the keyboard gesture system."); + + sendKeyboardGesture(CTRL_BACKSPACE); + assertTrue("Ctrl-Backspace failed with a hyphen", + getAllText() == "This test This is a test of the keyboard gesture system."); + } + + [Test] + public function CtrlBackspaceParagraphTest():void + { + SelManager.insertText(BASIC_TEST); + SelManager.insertText(BASIC_TEST); + SelManager.insertText(BASIC_TEST); + SelManager.insertText(BASIC_TEST); + + SelManager.selectRange(46, 46); + SelManager.splitParagraph(); + SelManager.selectRange(93, 93); + SelManager.splitParagraph(); + SelManager.selectRange(140, 140); + SelManager.splitParagraph(); + SelManager.selectRange(187, 187); + SelManager.splitParagraph(); + + SelManager.selectRange(179, 219); + sendKeyboardGesture(CTRL_BACKSPACE); + + var elem:FlowLeafElement = SelManager.textFlow.findLeaf(179); + assertTrue("Ctrl-Backspace failed between paragraphs", elem is SpanElement); + + SelManager.selectRange(171, 210); + SelManager.deleteNextCharacter(); + + SelManager.selectRange(141, 141); + sendKeyboardGesture(CTRL_BACKSPACE); + + SelManager.selectRange(0, 94); // Should do nothing + sendKeyboardGesture(CTRL_BACKSPACE); + + // This is the correct functionality of Ctrl-Backspace + // Bug #1891186 deferred for player fix + //SelManager.selectRange(94,186); + //assertTrue("Ctrl-Backspace failed across multiple paragraphs", + // getSelectedText() == "This is a test of the keyboard gesture system. This is a test of the keyboard gesture system."); + + SelManager.selectRange(94, 186); + assertTrue("Ctrl-Backspace behavior across multiple paragraphs changed", + getSelectedText() == "This is a test of the keyboard gesture system.This is a test of the keyboard gesture system."); + } + + [Test] + public function CtrlBackspaceImageTest():void + { + SelManager.selectRange(20, 20); + SelManager.insertInlineGraphic(LoaderUtil.createAbsoluteURL(baseURL, "../../test/testFiles/assets/gremlin.jpg"), 60, 60); + + SelManager.selectRange(26, 26); + SelManager.insertInlineGraphic(LoaderUtil.createAbsoluteURL(baseURL, "../../test/testFiles/assets/gremlin.jpg"), 60, 60); + + SelManager.selectRange(32, 32); + SelManager.insertText(" "); + SelManager.selectRange(33, 33); + SelManager.insertInlineGraphic(LoaderUtil.createAbsoluteURL(baseURL, "../../test/testFiles/assets/gremlin.jpg"), 60, 50); + SelManager.insertInlineGraphic(LoaderUtil.createAbsoluteURL(baseURL, "../../test/testFiles/assets/gremlin.jpg"), 60, 40); + SelManager.insertInlineGraphic(LoaderUtil.createAbsoluteURL(baseURL, "../../test/testFiles/assets/gremlin.jpg"), 60, 50); + + SelManager.selectRange(37, 37); + sendKeyboardGesture(CTRL_BACKSPACE); + var elem:FlowLeafElement = SelManager.textFlow.findLeaf(34); + assertTrue("Ctrl-Backspace removed multiple images in one operation", elem is InlineGraphicElement); + + sendKeyboardGesture(CTRL_BACKSPACE); + elem = SelManager.textFlow.findLeaf(33); + assertTrue("Ctrl-Backspace removed multiple images in one operation", elem is InlineGraphicElement); + sendKeyboardGesture(CTRL_BACKSPACE); + + SelManager.selectRange(27, 27); + sendKeyboardGesture(CTRL_BACKSPACE); + elem = SelManager.textFlow.findLeaf(26); + assertTrue("Ctrl-Backspace failed to remove image in word", !(elem is InlineGraphicElement)); + + SelManager.selectRange(23, 23); + sendKeyboardGesture(CTRL_BACKSPACE); + sendKeyboardGesture(CTRL_BACKSPACE); + elem = SelManager.textFlow.findLeaf(20); + assertTrue("Ctrl-Backspace failed to remove image with word", !(elem is InlineGraphicElement)); + sendKeyboardGesture(CTRL_BACKSPACE); + + assertTrue("Ctrl-Backspace failed to removed extra text in image test", + getAllText() == "This is a test of keyboard gesture system."); + } + + [Test] + public function CtrlBackspaceLanguageTest():void + { + setUpLanguageTest(); + + SelManager.selectRange(22, 22); + sendKeyboardGesture(CTRL_BACKSPACE); + SelManager.selectRange(18, 25); + assertTrue("Ctrl-Backspace failed in Right to Left Arabic text", + getSelectedText() == "n رسة i"); + + SelManager.selectRange(76, 77); + SelManager.deleteNextCharacter(); + + SelManager.selectRange(82, 82); + sendKeyboardGesture(CTRL_BACKSPACE); + SelManager.selectRange(66, 69); + assertTrue("Ctrl-Backspace failed to delete a bidi word", + getSelectedText() == ", i"); + + SelManager.undo(); + SelManager.undo(); + sendKeyboardGesture(CTRL_BACKSPACE); + + SelManager.selectRange(68, 78); + assertTrue("Ctrl-Backspace changed removal behavior within a bidi word", + getSelectedText() == "־סֵפֶר in "); + + SelManager.selectRange(261, 261); + sendKeyboardGesture(CTRL_BACKSPACE); + + SelManager.selectRange(257, 260); + assertTrue("Ctrl-Backspace changed removal behavior within right to left text", + getSelectedText() == "٠ب"); + + setUpTCYTest(); + + // TCY Tests + SelManager.selectRange(18, 18); + sendKeyboardGesture(CTRL_BACKSPACE); + SelManager.selectRange(14, 18); + assertTrue("Ctrl-Backspace changed removal behavior within TCY text", + getSelectedText() == "ãlis"); + + SelManager.selectRange(20, 20); + sendKeyboardGesture(CTRL_BACKSPACE); + SelManager.selectRange(18, 20); + assertTrue("Ctrl-Backspace changed removal behavior within TCY text", + getSelectedText() == "hã"); + } + + /*********** CTRL-DELETE TESTS **************************************************************/ + + /** + * Test the basic functionality and undo/redo + */ + [Test] + public function CtrlDeleteGeneralTest():void + { + deleteGeneralTest(CTRL_DELETE); + } + + [Test] + public function OptDeleteGeneralTest():void + { + deleteGeneralTest(OPT_DELETE); + } + + /** + * Test a bunch of different places in a line that Ctrl-Delete could be pressed + */ + [Test] + public function CtrlDeleteLocationTest():void + { + SelManager.selectRange(46, 46); + sendKeyboardGesture(CTRL_DELETE); + assertTrue("Ctrl-Delete changed something when exectuted at end position", + getAllText() == BASIC_TEST); + + SelManager.selectRange(45, 45); + sendKeyboardGesture(CTRL_DELETE); + + assertTrue("Ctrl-Delete failed on punctutation", + getAllText() == "This is a test of the keyboard gesture system"); + + SelManager.selectRange(39, 39); + sendKeyboardGesture(CTRL_DELETE); + + assertTrue("Ctrl-Delete failed at the end of a line", + getAllText() == "This is a test of the keyboard gesture "); + + SelManager.selectRange(8, 8); + sendKeyboardGesture(CTRL_DELETE); + + assertTrue("Ctrl-Delete failed on a single character word", + getAllText() == "This is test of the keyboard gesture "); + + SelManager.selectRange(5, 5); + SelManager.insertText(" "); + SelManager.selectRange(4, 4); + sendKeyboardGesture(CTRL_DELETE); + + assertTrue("Ctrl-Delete failed over extra whitespace", + getAllText() == "This test of the keyboard gesture "); + + SelManager.selectRange(20, 20); + sendKeyboardGesture(CTRL_DELETE); + + assertTrue("Ctrl-Delete failed in the middle of a word", + getAllText() == "This test of the key gesture "); + + SelManager.selectRange(27, 27); + sendKeyboardGesture(CTRL_DELETE); + + assertTrue("Ctrl-Delete failed 1 from the end of a word", + getAllText() == "This test of the key gestur "); + + SelManager.selectRange(18, 18); + sendKeyboardGesture(CTRL_DELETE); + + assertTrue("Ctrl-Delete failed on the first character of a word", + getAllText() == "This test of the k gestur "); + + SelManager.selectRange(25, 25); + sendKeyboardGesture(CTRL_DELETE); + + assertTrue("Ctrl-Delete failed after a trailing whitespace", + getAllText() == "This test of the k gestur"); + } + + [Test] + public function CtrlDeleteHyphenTest():void + { + SelManager.selectAll(); + SelManager.deleteNextCharacter(); + SelManager.flushPendingOperations(); + SelManager.insertText(HYPHEN_TEST); + SelManager.selectRange(47, 47); + SelManager.insertText(BASIC_TEST); + SelManager.selectRange(47, 47); + SelManager.splitParagraph(); + + SelManager.selectRange(47, 47); + sendKeyboardGesture(CTRL_DELETE); + assertTrue("Ctrl-Delete failed over a paragraph break w/ hypen", + getAllText() == "This is-a test-of-the keyboard-gesture system.-This is a test of the keyboard gesture system."); + + SelManager.selectRange(46, 46); + sendKeyboardGesture(CTRL_DELETE); + assertTrue("Ctrl-Delete failed with a hyphen punctuation combination", + getAllText() == "This is-a test-of-the keyboard-gesture system.This is a test of the keyboard gesture system."); + + SelManager.selectRange(45, 45); + sendKeyboardGesture(CTRL_DELETE); + assertTrue("Ctrl-Delete failed with a hyphen punctuation combination", + getAllText() == "This is-a test-of-the keyboard-gesture system is a test of the keyboard gesture system."); + + SelManager.selectRange(5, 5); + sendKeyboardGesture(CTRL_DELETE); + assertTrue("Ctrl-Delete failed with a hyphen", + getAllText() == "This -a test-of-the keyboard-gesture system is a test of the keyboard gesture system."); + + sendKeyboardGesture(CTRL_DELETE); + assertTrue("Ctrl-Delete failed with a hyphen", + getAllText() == "This a test-of-the keyboard-gesture system is a test of the keyboard gesture system."); + + sendKeyboardGesture(CTRL_DELETE); + assertTrue("Ctrl-Delete failed with a hyphen", + getAllText() == "This test-of-the keyboard-gesture system is a test of the keyboard gesture system."); + + sendKeyboardGesture(CTRL_DELETE); + assertTrue("Ctrl-Delete failed with a hyphen", + getAllText() == "This -of-the keyboard-gesture system is a test of the keyboard gesture system."); + + sendKeyboardGesture(CTRL_DELETE); + assertTrue("Ctrl-Delete failed with a hyphen", + getAllText() == "This of-the keyboard-gesture system is a test of the keyboard gesture system."); + + sendKeyboardGesture(CTRL_DELETE); + assertTrue("Ctrl-Delete failed with a hyphen", + getAllText() == "This -the keyboard-gesture system is a test of the keyboard gesture system."); + + sendKeyboardGesture(CTRL_DELETE); + assertTrue("Ctrl-Delete failed with a hyphen", + getAllText() == "This the keyboard-gesture system is a test of the keyboard gesture system."); + + SelManager.selectRange(9, 9); + + sendKeyboardGesture(CTRL_DELETE); + assertTrue("Ctrl-Delete failed with a hyphen", + getAllText() == "This the -gesture system is a test of the keyboard gesture system."); + + sendKeyboardGesture(CTRL_DELETE); + assertTrue("Ctrl-Delete failed with a hyphen", + getAllText() == "This the gesture system is a test of the keyboard gesture system."); + + sendKeyboardGesture(CTRL_DELETE); + assertTrue("Ctrl-Delete failed with a hyphen", + getAllText() == "This the system is a test of the keyboard gesture system."); + } + + [Test] + public function CtrlDeleteParagraphTest():void + { + SelManager.insertText(BASIC_TEST); + SelManager.insertText(BASIC_TEST); + SelManager.insertText(BASIC_TEST); + SelManager.insertText(BASIC_TEST); + + SelManager.selectRange(46, 46); + SelManager.splitParagraph(); + SelManager.selectRange(93, 93); + SelManager.splitParagraph(); + SelManager.selectRange(140, 140); + SelManager.splitParagraph(); + SelManager.selectRange(187, 187); + SelManager.splitParagraph(); + + SelManager.selectRange(179, 219); + sendKeyboardGesture(CTRL_DELETE); + + var elem:FlowLeafElement = SelManager.textFlow.findLeaf(180); + assertTrue("Ctrl-Delete failed across paragraphs", + elem is SpanElement); + + SelManager.selectRange(140, 140); + sendKeyboardGesture(CTRL_DELETE); + + SelManager.selectRange(0, 94); + SelManager.deleteNextCharacter(); + + SelManager.selectRange(0, 85); + assertTrue("Ctrl-Delete failed to remove multiple paragraphs", + getSelectedText() == "This is a test of the keyboard gesture system.This is a test of the keyboard gesture."); + } + + [Test] + public function CtrlDeleteImageTest():void + { + SelManager.selectRange(20, 20); + SelManager.insertInlineGraphic(LoaderUtil.createAbsoluteURL(baseURL, "../../test/testFiles/assets/gremlin.jpg"), 60, 60); + + SelManager.selectRange(26, 26); + SelManager.insertInlineGraphic(LoaderUtil.createAbsoluteURL(baseURL, "../../test/testFiles/assets/gremlin.jpg"), 60, 60); + + SelManager.selectRange(32, 32); + SelManager.insertText(" "); + SelManager.selectRange(33, 33); + SelManager.insertInlineGraphic(LoaderUtil.createAbsoluteURL(baseURL, "../../test/testFiles/assets/gremlin.jpg"), 60, 50); + SelManager.insertInlineGraphic(LoaderUtil.createAbsoluteURL(baseURL, "../../test/testFiles/assets/gremlin.jpg"), 60, 40); + SelManager.insertInlineGraphic(LoaderUtil.createAbsoluteURL(baseURL, "../../test/testFiles/assets/gremlin.jpg"), 60, 50); + + SelManager.selectRange(32, 32); + sendKeyboardGesture(CTRL_DELETE); + var elem:FlowLeafElement = SelManager.textFlow.findLeaf(32); + assertTrue("Ctrl-Delete removed multiple images in one operation", elem is InlineGraphicElement); + + sendKeyboardGesture(CTRL_DELETE); + elem = SelManager.textFlow.findLeaf(32); + assertTrue("Ctrl-Delete removed multiple images in one operation", elem is InlineGraphicElement); + sendKeyboardGesture(CTRL_DELETE); + + SelManager.selectRange(20, 20); + sendKeyboardGesture(CTRL_DELETE); + elem = SelManager.textFlow.findLeaf(20); + assertTrue("Ctrl-Delete failed to remove image in word", !(elem is InlineGraphicElement)); + + SelManager.selectRange(22, 22); + sendKeyboardGesture(CTRL_DELETE); + sendKeyboardGesture(CTRL_DELETE); + elem = SelManager.textFlow.findLeaf(20); + assertTrue("Ctrl-Delete failed to remove image with word", !(elem is InlineGraphicElement)); + sendKeyboardGesture(CTRL_DELETE); + + assertTrue("Ctrl-Delete failed to removed extra text in image test", + getAllText() == "This is a test of the gesture system."); + } + + [Test] + public function CtrlDeleteLanguageTest():void + { + setUpLanguageTest(); + + SelManager.selectRange(22, 22); + sendKeyboardGesture(CTRL_DELETE); + SelManager.selectRange(18, 24); + assertTrue("Ctrl-Delete failed in Right to Left Arabic text", + getSelectedText() == "n ٠د i"); + + SelManager.selectRange(75, 76); + SelManager.deleteNextCharacter(); + + SelManager.selectRange(66, 66); + sendKeyboardGesture(CTRL_DELETE); + SelManager.selectRange(65, 68); + assertTrue("Ctrl-Delete failed to delete a bidi word", + getSelectedText() == ", i"); + + SelManager.undo(); + SelManager.undo(); + SelManager.selectRange(66, 66); + sendKeyboardGesture(CTRL_DELETE); + + SelManager.selectRange(67, 75); + assertTrue("Ctrl-Delete changed removal behavior within a bidi word", + getSelectedText() == "סֵפֶר in"); + + SelManager.selectRange(254, 254); + sendKeyboardGesture(CTRL_DELETE); + + SelManager.selectRange(254, 257); + assertTrue("Ctrl-Delete changed removal behavior within right to left text", + getSelectedText() == " بع"); + + setUpTCYTest(); + + // TCY Tests + SelManager.selectRange(18, 18); + sendKeyboardGesture(CTRL_DELETE); + SelManager.selectRange(14, 18); + assertTrue("Ctrl-Delete changed removal behavior within TCY text", + getSelectedText() == "ãEng"); + + SelManager.selectRange(19, 19); + sendKeyboardGesture(CTRL_DELETE); + SelManager.selectRange(17, 19); + assertTrue("Ctrl-Delete changed removal behavior within TCY text", + getSelectedText() == "gã"); + } + + /*********** CTRL-LEFT TESTS **************************************************************/ + + /** + * Test the basic functionality and undo/redo + */ + [Test] + public function CtrlLeftGeneralTest():void + { + leftGeneralTest(CTRL_LEFT); + } + + [Test] + public function OptLeftGeneralTest():void + { + leftGeneralTest(OPT_LEFT); + } + + /** + * Test a bunch of different places in a line that Ctrl-Left could be pressed + */ + [Test] + public function CtrlLeftLocationTest():void + { + SelManager.selectRange(0, 0); + sendKeyboardGesture(CTRL_LEFT); + assertTrue("Ctrl-Left changed position when exectuted at position 0", + SelManager.activePosition == 0 && + SelManager.anchorPosition == 0); + + SelManager.selectRange(46, 46); + sendKeyboardGesture(CTRL_LEFT); + + assertTrue("Ctrl-Left failed on punctutation", + SelManager.activePosition == 45 && + SelManager.anchorPosition == 45); + + sendKeyboardGesture(CTRL_LEFT); + + assertTrue("Ctrl-Left failed at the end of a line", + SelManager.activePosition == 39 && + SelManager.anchorPosition == 39); + + SelManager.selectRange(9, 9); + sendKeyboardGesture(CTRL_LEFT); + + assertTrue("Ctrl-Left failed on a single character word", + SelManager.activePosition == 8 && + SelManager.anchorPosition == 8); + + SelManager.insertText(" "); + SelManager.selectRange(11, 11); + sendKeyboardGesture(CTRL_LEFT); + + assertTrue("Ctrl-Left failed over extra whitespace", + SelManager.activePosition == 5 && + SelManager.anchorPosition == 5); + + SelManager.selectRange(28, 28); + sendKeyboardGesture(CTRL_LEFT); + + assertTrue("Ctrl-Left failed in the middle of a word", + SelManager.activePosition == 25 && + SelManager.anchorPosition == 25); + + SelManager.selectRange(40, 40); + sendKeyboardGesture(CTRL_LEFT); + + assertTrue("Ctrl-Left failed 1 from the end of a word", + SelManager.activePosition == 34 && + SelManager.anchorPosition == 34); + + SelManager.selectRange(26, 26); + sendKeyboardGesture(CTRL_LEFT); + + assertTrue("Ctrl-Left failed on the first character of a word", + SelManager.activePosition == 25 && + SelManager.anchorPosition == 25); + + sendKeyboardGesture(CTRL_LEFT); + + assertTrue("Ctrl-Left failed after a single whitespace", + SelManager.activePosition == 21 && + SelManager.anchorPosition == 21); + } + + [Test] + public function CtrlLeftHyphenTest():void + { + SelManager.selectAll(); + SelManager.deleteNextCharacter(); + SelManager.flushPendingOperations(); + SelManager.insertText(HYPHEN_TEST); + SelManager.selectRange(47, 47); + SelManager.insertText(BASIC_TEST); + SelManager.selectRange(47, 47); + SelManager.splitParagraph(); + + SelManager.selectRange(48, 48); + sendKeyboardGesture(CTRL_LEFT); + assertTrue("Ctrl-Left failed over a paragraph break w/ hypen", + SelManager.activePosition == 47 && + SelManager.anchorPosition == 47); + + sendKeyboardGesture(CTRL_LEFT); + assertTrue("Ctrl-Left failed with a hyphen punctuation combination", + SelManager.activePosition == 46 && + SelManager.anchorPosition == 46); + + sendKeyboardGesture(CTRL_LEFT); + assertTrue("Ctrl-Left failed with a hyphen punctuation combination", + SelManager.activePosition == 45 && + SelManager.anchorPosition == 45); + + sendKeyboardGesture(CTRL_LEFT); + sendKeyboardGesture(CTRL_LEFT); + assertTrue("Ctrl-Left failed with a hyphen", + SelManager.activePosition == 31 && + SelManager.anchorPosition == 31); + + sendKeyboardGesture(CTRL_LEFT); + assertTrue("Ctrl-Left failed with a hyphen", + SelManager.activePosition == 30 && + SelManager.anchorPosition == 30); + + sendKeyboardGesture(CTRL_LEFT); + assertTrue("Ctrl-Left failed with a hyphen", + SelManager.activePosition == 22 && + SelManager.anchorPosition == 22); + + SelManager.selectRange(21, 21); + + sendKeyboardGesture(CTRL_LEFT); + assertTrue("Ctrl-Left failed with a hyphen", + SelManager.activePosition == 18 && + SelManager.anchorPosition == 18); + + sendKeyboardGesture(CTRL_LEFT); + assertTrue("Ctrl-Left failed with a hyphen", + SelManager.activePosition == 17 && + SelManager.anchorPosition == 17); + + sendKeyboardGesture(CTRL_LEFT); + assertTrue("Ctrl-Left failed with a hyphen", + SelManager.activePosition == 15 && + SelManager.anchorPosition == 15); + + sendKeyboardGesture(CTRL_LEFT); + assertTrue("Ctrl-Left failed with a hyphen", + SelManager.activePosition == 14 && + SelManager.anchorPosition == 14); + + SelManager.selectRange(9, 9); + + sendKeyboardGesture(CTRL_LEFT); + assertTrue("Ctrl-Left failed with a hyphen", + SelManager.activePosition == 8 && + SelManager.anchorPosition == 8); + + sendKeyboardGesture(CTRL_LEFT); + assertTrue("Ctrl-Left failed with a hyphen", + SelManager.activePosition == 7 && + SelManager.anchorPosition == 7); + + sendKeyboardGesture(CTRL_LEFT); + assertTrue("Ctrl-Left failed with a hyphen", + SelManager.activePosition == 5 && + SelManager.anchorPosition == 5); + } + + [Test] + public function CtrlLeftParagraphTest():void + { + SelManager.insertText(BASIC_TEST); + SelManager.insertText(BASIC_TEST); + SelManager.insertText(BASIC_TEST); + SelManager.insertText(BASIC_TEST); + + SelManager.selectRange(46, 46); + SelManager.splitParagraph(); + SelManager.selectRange(93, 93); + SelManager.splitParagraph(); + SelManager.selectRange(140, 140); + SelManager.splitParagraph(); + SelManager.selectRange(187, 187); + SelManager.splitParagraph(); + + SelManager.selectRange(179, 219); + sendKeyboardGesture(CTRL_LEFT); + + assertTrue("Ctrl-Left moved cursor with selection across paragraphs", + SelManager.activePosition == 179 && + SelManager.anchorPosition == 179); + + SelManager.selectRange(141, 141); + sendKeyboardGesture(CTRL_LEFT); + + assertTrue("Ctrl-Left failed to move between paragraphs", + SelManager.activePosition == 140 && + SelManager.anchorPosition == 140); + } + + [Test] + public function CtrlLeftImageTest():void + { + SelManager.selectRange(20, 20); + SelManager.insertInlineGraphic(LoaderUtil.createAbsoluteURL(baseURL, "../../test/testFiles/assets/gremlin.jpg"), 60, 60); + + SelManager.selectRange(26, 26); + SelManager.insertInlineGraphic(LoaderUtil.createAbsoluteURL(baseURL, "../../test/testFiles/assets/gremlin.jpg"), 60, 60); + + SelManager.selectRange(32, 32); + SelManager.insertText(" "); + SelManager.selectRange(33, 33); + SelManager.insertInlineGraphic(LoaderUtil.createAbsoluteURL(baseURL, "../../test/testFiles/assets/gremlin.jpg"), 60, 50); + SelManager.insertInlineGraphic(LoaderUtil.createAbsoluteURL(baseURL, "../../test/testFiles/assets/gremlin.jpg"), 60, 40); + SelManager.insertInlineGraphic(LoaderUtil.createAbsoluteURL(baseURL, "../../test/testFiles/assets/gremlin.jpg"), 60, 50); + + SelManager.selectRange(37, 37); + sendKeyboardGesture(CTRL_LEFT); + assertTrue("Ctrl-Left incorrectly navigated around images", + SelManager.activePosition == 35 && + SelManager.anchorPosition == 35); + + sendKeyboardGesture(CTRL_LEFT); + assertTrue("Ctrl-Left incorrectly navigated around images", + SelManager.activePosition == 34 && + SelManager.anchorPosition == 34); + sendKeyboardGesture(CTRL_LEFT); + + sendKeyboardGesture(CTRL_LEFT); + assertTrue("Ctrl-Left incorrectly navigated around images", + SelManager.activePosition == 27 && + SelManager.anchorPosition == 27); + + sendKeyboardGesture(CTRL_LEFT); + assertTrue("Ctrl-Left incorrectly navigated around images", + SelManager.activePosition == 26 && + SelManager.anchorPosition == 26); + + sendKeyboardGesture(CTRL_LEFT); + assertTrue("Ctrl-Left incorrectly navigated around images", + SelManager.activePosition == 23 && + SelManager.anchorPosition == 23); + + sendKeyboardGesture(CTRL_LEFT); + assertTrue("Ctrl-Left incorrectly navigated around images", + SelManager.activePosition == 21 && + SelManager.anchorPosition == 21); + } + + [Test] + public function CtrlLeftLanguageTest():void + { + setUpLanguageTest(); + + SelManager.selectRange(22, 22); + sendKeyboardGesture(CTRL_LEFT); + assertTrue("Ctrl-Left failed in Right to Left Arabic text", + SelManager.activePosition == 20 && + SelManager.anchorPosition == 20); + + SelManager.selectRange(85, 85); + sendKeyboardGesture(CTRL_LEFT); + assertTrue("Ctrl-Left failed to move through a bidi word", + SelManager.activePosition == 79 && + SelManager.anchorPosition == 79); + + sendKeyboardGesture(CTRL_LEFT); + assertTrue("Ctrl-Left changed movement behavior within a bidi word", + SelManager.activePosition == 78 && + SelManager.anchorPosition == 78); + + sendKeyboardGesture(CTRL_LEFT); + assertTrue("Ctrl-Left changed movement behavior within a bidi word", + SelManager.activePosition == 70 && + SelManager.anchorPosition == 70); + + SelManager.selectRange(261, 261); + sendKeyboardGesture(CTRL_LEFT); + + assertTrue("Ctrl-Left changed movement behavior within right to left text", + SelManager.activePosition == 257 && + SelManager.anchorPosition == 257); + + setUpTCYTest(); + + // TCY Tests + SelManager.selectRange(18, 18); + sendKeyboardGesture(CTRL_LEFT); + assertTrue("Ctrl-Left changed removal behavior within TCY text", + SelManager.activePosition == 15 && + SelManager.anchorPosition == 15); + + SelManager.selectRange(23, 23); + sendKeyboardGesture(CTRL_LEFT); + assertTrue("Ctrl-Left changed removal behavior within TCY text", + SelManager.activePosition == 22 && + SelManager.anchorPosition == 22); + } + + /*********** CTRL-RIGHT TESTS **************************************************************/ + + /** + * Test the basic functionality and undo/redo + */ + [Test] + public function CtrlRightGeneralTest():void + { + rightGeneralTest(CTRL_RIGHT); + } + + [Test] + public function OptRightGeneralTest():void + { + rightGeneralTest(OPT_RIGHT); + } + + /** + * Test a bunch of different places in a line that Ctrl-Right could be pressed + */ + [Test] + public function CtrlRightLocationTest():void + { + // Extending the selection to include the terminator at the end of the flow works or not depending on + // the backwards compatibility flag. Version 1.0 does not allow it. Version 2.0 and later does allow it. + SelManager.selectRange(SelManager.textFlow.textLength - 1, SelManager.textFlow.textLength - 1); + sendKeyboardGesture(CTRL_RIGHT); + assertTrue("Key code changed position when executed at last position", + SelManager.activePosition == SelManager.textFlow.textLength - 1 && + SelManager.anchorPosition == SelManager.textFlow.textLength - 1); + + SelManager.selectRange(45, 45); + sendKeyboardGesture(CTRL_RIGHT); + assertTrue("Ctrl-Right failed on punctutation", + SelManager.activePosition == 46 && + SelManager.anchorPosition == 46); + + SelManager.selectRange(0, 0); + sendKeyboardGesture(CTRL_RIGHT); + assertTrue("Ctrl-Right failed at the beginning of a line", + SelManager.activePosition == 5 && + SelManager.anchorPosition == 5); + + SelManager.selectRange(8, 8); + sendKeyboardGesture(CTRL_RIGHT); + assertTrue("Ctrl-Right failed on a single character word", + SelManager.activePosition == 10 && + SelManager.anchorPosition == 10); + + SelManager.insertText(" "); + SelManager.selectRange(9, 9); + sendKeyboardGesture(CTRL_RIGHT); + assertTrue("Ctrl-Right failed over extra whitespace", + SelManager.activePosition == 13 && + SelManager.anchorPosition == 13); + + SelManager.selectRange(28, 28); + sendKeyboardGesture(CTRL_RIGHT); + assertTrue("Ctrl-Right failed in the middle of a word", + SelManager.activePosition == 34 && + SelManager.anchorPosition == 34); + + SelManager.selectRange(40, 40); + sendKeyboardGesture(CTRL_RIGHT); + assertTrue("Ctrl-Right failed 1 from the end of a word", + SelManager.activePosition == 42 && + SelManager.anchorPosition == 42); + + SelManager.selectRange(26, 26); + sendKeyboardGesture(CTRL_RIGHT); + assertTrue("Ctrl-Right failed on the first character of a word", + SelManager.activePosition == 34 && + SelManager.anchorPosition == 34); + + SelManager.selectRange(33, 33); + sendKeyboardGesture(CTRL_RIGHT); + assertTrue("Ctrl-Right failed after a single whitespace", + SelManager.activePosition == 34 && + SelManager.anchorPosition == 34); + } + + [Test] + public function CtrlRightHyphenTest():void + { + SelManager.selectAll(); + SelManager.deleteNextCharacter(); + SelManager.flushPendingOperations(); + SelManager.insertText(HYPHEN_TEST); + SelManager.selectRange(47, 47); + SelManager.insertText(BASIC_TEST); + SelManager.selectRange(47, 47); + SelManager.splitParagraph(); + + SelManager.selectRange(47, 47); + sendKeyboardGesture(CTRL_RIGHT); + assertTrue("Ctrl-Right failed over a paragraph break w/ hypen", + SelManager.activePosition == 48 && + SelManager.anchorPosition == 48); + + SelManager.selectRange(46, 46); + sendKeyboardGesture(CTRL_RIGHT); + assertTrue("Ctrl-Right failed with a hyphen punctuation combination", + SelManager.activePosition == 47 && + SelManager.anchorPosition == 47); + + SelManager.selectRange(45, 45); + sendKeyboardGesture(CTRL_RIGHT); + assertTrue("Ctrl-Right failed with a hyphen punctuation combination", + SelManager.activePosition == 46 && + SelManager.anchorPosition == 46); + + SelManager.selectRange(5, 5); + sendKeyboardGesture(CTRL_RIGHT); + assertTrue("Ctrl-Right failed with a hyphen", + SelManager.activePosition == 7 && + SelManager.anchorPosition == 7); + + sendKeyboardGesture(CTRL_RIGHT); + assertTrue("Ctrl-Right failed with a hyphen", + SelManager.activePosition == 8 && + SelManager.anchorPosition == 8); + + sendKeyboardGesture(CTRL_RIGHT); + assertTrue("Ctrl-Right failed with a hyphen", + SelManager.activePosition == 10 && + SelManager.anchorPosition == 10); + + sendKeyboardGesture(CTRL_RIGHT); + assertTrue("Ctrl-Right failed with a hyphen", + SelManager.activePosition == 14 && + SelManager.anchorPosition == 14); + + sendKeyboardGesture(CTRL_RIGHT); + assertTrue("Ctrl-Right failed with a hyphen", + SelManager.activePosition == 15 && + SelManager.anchorPosition == 15); + + sendKeyboardGesture(CTRL_RIGHT); + assertTrue("Ctrl-Right failed with a hyphen", + SelManager.activePosition == 17 && + SelManager.anchorPosition == 17); + + sendKeyboardGesture(CTRL_RIGHT); + assertTrue("Ctrl-Right failed with a hyphen", + SelManager.activePosition == 18 && + SelManager.anchorPosition == 18); + + sendKeyboardGesture(CTRL_RIGHT); + assertTrue("Ctrl-Right failed with a hyphen", + SelManager.activePosition == 22 && + SelManager.anchorPosition == 22); + + sendKeyboardGesture(CTRL_RIGHT); + assertTrue("Ctrl-Right failed with a hyphen", + SelManager.activePosition == 30 && + SelManager.anchorPosition == 30); + + sendKeyboardGesture(CTRL_RIGHT); + assertTrue("Ctrl-Right failed with a hyphen", + SelManager.activePosition == 31 && + SelManager.anchorPosition == 31); + + sendKeyboardGesture(CTRL_RIGHT); + assertTrue("Ctrl-Right failed with a hyphen", + SelManager.activePosition == 39 && + SelManager.anchorPosition == 39); + } + + [Test] + public function CtrlRightParagraphTest():void + { + SelManager.insertText(BASIC_TEST); + SelManager.insertText(BASIC_TEST); + SelManager.insertText(BASIC_TEST); + SelManager.insertText(BASIC_TEST); + + SelManager.selectRange(46, 46); + SelManager.splitParagraph(); + SelManager.selectRange(93, 93); + SelManager.splitParagraph(); + SelManager.selectRange(140, 140); + SelManager.splitParagraph(); + SelManager.selectRange(187, 187); + SelManager.splitParagraph(); + + SelManager.selectRange(179, 219); + sendKeyboardGesture(CTRL_RIGHT); + + assertTrue("Ctrl-Right moved cursor with selection across paragraphs", + SelManager.activePosition == 219 && + SelManager.anchorPosition == 219); + + SelManager.selectRange(140, 140); + sendKeyboardGesture(CTRL_RIGHT); + + assertTrue("Ctrl-Right failed to move between paragraphs", + SelManager.activePosition == 141 && + SelManager.anchorPosition == 141); + } + + [Test] + public function CtrlRightImageTest():void + { + SelManager.selectRange(20, 20); + SelManager.insertInlineGraphic(LoaderUtil.createAbsoluteURL(baseURL, "../../test/testFiles/assets/gremlin.jpg"), 60, 60); + + SelManager.selectRange(26, 26); + SelManager.insertInlineGraphic(LoaderUtil.createAbsoluteURL(baseURL, "../../test/testFiles/assets/gremlin.jpg"), 60, 60); + + SelManager.selectRange(32, 32); + SelManager.insertText(" "); + SelManager.selectRange(33, 33); + SelManager.insertInlineGraphic(LoaderUtil.createAbsoluteURL(baseURL, "../../test/testFiles/assets/gremlin.jpg"), 60, 50); + SelManager.insertInlineGraphic(LoaderUtil.createAbsoluteURL(baseURL, "../../test/testFiles/assets/gremlin.jpg"), 60, 40); + SelManager.insertInlineGraphic(LoaderUtil.createAbsoluteURL(baseURL, "../../test/testFiles/assets/gremlin.jpg"), 60, 50); + + SelManager.selectRange(18, 18); + sendKeyboardGesture(CTRL_RIGHT); + assertTrue("Ctrl-Right incorrectly navigated around images", + SelManager.activePosition == 20 && + SelManager.anchorPosition == 20); + + sendKeyboardGesture(CTRL_RIGHT); + assertTrue("Ctrl-Right incorrectly navigated around images", + SelManager.activePosition == 21 && + SelManager.anchorPosition == 21); + + sendKeyboardGesture(CTRL_RIGHT); + assertTrue("Ctrl-Right incorrectly navigated around images", + SelManager.activePosition == 23 && + SelManager.anchorPosition == 23); + + sendKeyboardGesture(CTRL_RIGHT); + assertTrue("Ctrl-Right incorrectly navigated around images", + SelManager.activePosition == 26 && + SelManager.anchorPosition == 26); + + sendKeyboardGesture(CTRL_RIGHT); + assertTrue("Ctrl-Right incorrectly navigated around images", + SelManager.activePosition == 27 && + SelManager.anchorPosition == 27); + + sendKeyboardGesture(CTRL_RIGHT); + assertTrue("Ctrl-Right incorrectly navigated around images", + SelManager.activePosition == 33 && + SelManager.anchorPosition == 33); + + sendKeyboardGesture(CTRL_RIGHT); + assertTrue("Ctrl-Right incorrectly navigated around images", + SelManager.activePosition == 34 && + SelManager.anchorPosition == 34); + + sendKeyboardGesture(CTRL_RIGHT); + assertTrue("Ctrl-Right incorrectly navigated around images", + SelManager.activePosition == 35 && + SelManager.anchorPosition == 35); + + sendKeyboardGesture(CTRL_RIGHT); + assertTrue("Ctrl-Right incorrectly navigated around images", + SelManager.activePosition == 37 && + SelManager.anchorPosition == 37); + } + + [Test] + public function CtrlRightLanguageTest():void + { + setUpLanguageTest(); + + SelManager.selectRange(22, 22); + sendKeyboardGesture(CTRL_RIGHT); + assertTrue("Ctrl-Right failed in Right to Right Arabic text", + SelManager.activePosition == 26 && + SelManager.anchorPosition == 26); + + SelManager.selectRange(68, 68); + sendKeyboardGesture(CTRL_RIGHT); + assertTrue("Ctrl-Right failed to move through a bidi word", + SelManager.activePosition == 70 && + SelManager.anchorPosition == 70); + + sendKeyboardGesture(CTRL_RIGHT); + assertTrue("Ctrl-Right changed movement behavior within a bidi word", + SelManager.activePosition == 78 && + SelManager.anchorPosition == 78); + + sendKeyboardGesture(CTRL_RIGHT); + assertTrue("Ctrl-Right changed movement behavior within a bidi word", + SelManager.activePosition == 79 && + SelManager.anchorPosition == 79); + + sendKeyboardGesture(CTRL_RIGHT); + assertTrue("Ctrl-Right changed movement behavior within a bidi word", + SelManager.activePosition == 85 && + SelManager.anchorPosition == 85); + + SelManager.selectRange(257, 257); + sendKeyboardGesture(CTRL_RIGHT); + + assertTrue("Ctrl-Right changed movement behavior within right to left text", + SelManager.activePosition == 264 && + SelManager.anchorPosition == 264); + + setUpTCYTest(); + + // TCY Tests + SelManager.selectRange(18, 18); + sendKeyboardGesture(CTRL_RIGHT); + assertTrue("Ctrl-Right changed removal behavior within TCY text", + SelManager.activePosition == 22 && + SelManager.anchorPosition == 22); + + SelManager.selectRange(14, 14); + sendKeyboardGesture(CTRL_RIGHT); + assertTrue("Ctrl-Right changed removal behavior within TCY text", + SelManager.activePosition == 15 && + SelManager.anchorPosition == 15); + } + + /*********** CTRL-UP AND CTRL-HOME TESTS *****************************************************/ + + /** + * Test the basic functionality and undo/redo + */ + [Test] + public function CtrlUpGeneralTest():void + { + flowBeginGeneralTest(CTRL_UP, "Ctrl-Up"); + } + + [Test] + public function OptUpGeneralTest():void + { + flowBeginGeneralTest(OPT_UP, "Opt-Up"); + } + + [Test] + public function CtrlHomeGeneralTest():void + { + flowBeginGeneralTest(CTRL_HOME, "Ctrl-Home"); + } + + [Test] + public function CtrlUpLocationTest():void + { + flowBeginLocationTest(CTRL_UP, "Ctrl-Up"); + } + + [Test] + public function CtrlHomeLocationTest():void + { + flowBeginLocationTest(CTRL_HOME, "Ctrl-Home"); + } + + [Test] + public function CtrlUpLanguageTest():void + { + flowBeginLanguageTest(CTRL_UP, "Ctrl-Up"); + } + + [Test] + public function CtrlHomeLanguageTest():void + { + flowBeginLanguageTest(CTRL_HOME, "Ctrl-Home"); + } + + /*********** CTRL-DOWN AND CTRL-END TESTS *****************************************************/ + + /** + * Test the basic functionality and undo/redo + */ + [Test] + public function CtrlDownGeneralTest():void + { + flowEndGeneralTest(CTRL_DOWN, "Ctrl-Down"); + } + + [Test] + public function OptDownGeneralTest():void + { + flowEndGeneralTest(OPT_DOWN, "Opt-Down"); + } + + [Test] + public function CtrlEndGeneralTest():void + { + flowEndGeneralTest(CTRL_END, "Ctrl-End"); + } + + [Test] + public function CtrlDownLocationTest():void + { + flowEndLocationTest(CTRL_DOWN, "Ctrl-Down"); + } + + [Test] + public function CtrlEndLocationTest():void + { + flowEndLocationTest(CTRL_END, "Ctrl-End"); + } + + [Test] + public function CtrlDownLanguageTest():void + { + flowEndLanguageTest(CTRL_DOWN, "Ctrl-Down"); + } + + [Test] + public function CtrlEndLanguageTest():void + { + flowEndLanguageTest(CTRL_END, "Ctrl-End"); + } + + /*********** SHIFT-CTRL-LEFT TESTS **************************************************************/ + + /** + * Test the basic functionality and undo/redo + */ + [Test] + public function ShiftCtrlLeftGeneralTest():void + { + shiftLeftGeneralTest(SHIFT_CTRL_LEFT); + } + + [Test] + public function ShiftOptLeftGeneralTest():void + { + shiftLeftGeneralTest(SHIFT_OPT_LEFT); + } + + /** + * Test a bunch of different places in a line that Shift-Ctrl-Left could be pressed + */ + [Test] + public function ShiftCtrlLeftLocationTest():void + { + SelManager.selectRange(0, 0); + sendKeyboardGesture(SHIFT_CTRL_LEFT); + assertTrue("Shift-Ctrl-Left changed position when exectuted at position 0", + SelManager.activePosition == 0 && + SelManager.anchorPosition == 0); + + SelManager.selectRange(46, 46); + sendKeyboardGesture(SHIFT_CTRL_LEFT); + + assertTrue("Shift-Ctrl-Left failed on punctutation", + SelManager.activePosition == 45 && + SelManager.anchorPosition == 46); + + sendKeyboardGesture(SHIFT_CTRL_LEFT); + + assertTrue("Shift-Ctrl-Left failed at the end of a line", + SelManager.activePosition == 39 && + SelManager.anchorPosition == 46); + + SelManager.selectRange(9, 9); + sendKeyboardGesture(SHIFT_CTRL_LEFT); + + assertTrue("Shift-Ctrl-Left failed on a single character word", + SelManager.activePosition == 8 && + SelManager.anchorPosition == 9); + + SelManager.insertText(" "); + SelManager.selectRange(12, 12); + sendKeyboardGesture(SHIFT_CTRL_LEFT); + + assertTrue("Shift-Ctrl-Left failed over extra whitespace", + SelManager.activePosition == 5 && + SelManager.anchorPosition == 12); + + SelManager.selectRange(28, 28); + sendKeyboardGesture(SHIFT_CTRL_LEFT); + + assertTrue("Shift-Ctrl-Left failed in the middle of a word", + SelManager.activePosition == 24 && + SelManager.anchorPosition == 28); + + SelManager.selectRange(40, 40); + sendKeyboardGesture(SHIFT_CTRL_LEFT); + + assertTrue("Shift-Ctrl-Left failed 1 from the end of a word", + SelManager.activePosition == 33 && + SelManager.anchorPosition == 40); + + SelManager.selectRange(25, 25); + sendKeyboardGesture(SHIFT_CTRL_LEFT); + + assertTrue("Shift-Ctrl-Left failed on the first character of a word", + SelManager.activePosition == 24 && + SelManager.anchorPosition == 25); + + sendKeyboardGesture(SHIFT_CTRL_LEFT); + + assertTrue("Shift-Ctrl-Left failed after a single whitespace", + SelManager.activePosition == 20 && + SelManager.anchorPosition == 25); + } + + [Test] + public function ShiftCtrlLeftHyphenTest():void + { + SelManager.selectAll(); + SelManager.deleteNextCharacter(); + SelManager.flushPendingOperations(); + SelManager.insertText(HYPHEN_TEST); + SelManager.selectRange(47, 47); + SelManager.insertText(BASIC_TEST); + SelManager.selectRange(47, 47); + SelManager.splitParagraph(); + + SelManager.selectRange(48, 48); + sendKeyboardGesture(SHIFT_CTRL_LEFT); + assertTrue("Shift-Ctrl-Left failed over a paragraph break w/ hypen", + SelManager.activePosition == 47 && + SelManager.anchorPosition == 48); + + sendKeyboardGesture(SHIFT_CTRL_LEFT); + assertTrue("Shift-Ctrl-Left failed with a hyphen punctuation combination", + SelManager.activePosition == 46 && + SelManager.anchorPosition == 48); + + sendKeyboardGesture(SHIFT_CTRL_LEFT); + assertTrue("Shift-Ctrl-Left failed with a hyphen punctuation combination", + SelManager.activePosition == 45 && + SelManager.anchorPosition == 48); + + sendKeyboardGesture(SHIFT_CTRL_LEFT); + sendKeyboardGesture(SHIFT_CTRL_LEFT); + assertTrue("Shift-Ctrl-Left failed with a hyphen", + SelManager.activePosition == 31 && + SelManager.anchorPosition == 48); + + sendKeyboardGesture(SHIFT_CTRL_LEFT); + assertTrue("Shift-Ctrl-Left failed with a hyphen", + SelManager.activePosition == 30 && + SelManager.anchorPosition == 48); + + sendKeyboardGesture(SHIFT_CTRL_LEFT); + assertTrue("Shift-Ctrl-Left failed with a hyphen", + SelManager.activePosition == 22 && + SelManager.anchorPosition == 48); + + SelManager.selectRange(21, 21); + + sendKeyboardGesture(SHIFT_CTRL_LEFT); + assertTrue("Shift-Ctrl-Left failed with a hyphen", + SelManager.activePosition == 18 && + SelManager.anchorPosition == 21); + + sendKeyboardGesture(SHIFT_CTRL_LEFT); + assertTrue("Shift-Ctrl-Left failed with a hyphen", + SelManager.activePosition == 17 && + SelManager.anchorPosition == 21); + + sendKeyboardGesture(SHIFT_CTRL_LEFT); + assertTrue("Shift-Ctrl-Left failed with a hyphen", + SelManager.activePosition == 15 && + SelManager.anchorPosition == 21); + + sendKeyboardGesture(SHIFT_CTRL_LEFT); + assertTrue("Shift-Ctrl-Left failed with a hyphen", + SelManager.activePosition == 14 && + SelManager.anchorPosition == 21); + + SelManager.selectRange(9, 9); + + sendKeyboardGesture(SHIFT_CTRL_LEFT); + assertTrue("Shift-Ctrl-Left failed with a hyphen", + SelManager.activePosition == 8 && + SelManager.anchorPosition == 9); + + sendKeyboardGesture(SHIFT_CTRL_LEFT); + assertTrue("Shift-Ctrl-Left failed with a hyphen", + SelManager.activePosition == 7 && + SelManager.anchorPosition == 9); + + sendKeyboardGesture(SHIFT_CTRL_LEFT); + assertTrue("Shift-Ctrl-Left failed with a hyphen", + SelManager.activePosition == 5 && + SelManager.anchorPosition == 9); + } + + [Test] + public function ShiftCtrlLeftParagraphTest():void + { + SelManager.insertText(BASIC_TEST); + SelManager.insertText(BASIC_TEST); + SelManager.insertText(BASIC_TEST); + SelManager.insertText(BASIC_TEST); + + SelManager.selectRange(46, 46); + SelManager.splitParagraph(); + SelManager.selectRange(93, 93); + SelManager.splitParagraph(); + SelManager.selectRange(140, 140); + SelManager.splitParagraph(); + SelManager.selectRange(187, 187); + SelManager.splitParagraph(); + + SelManager.selectRange(179, 219); + sendKeyboardGesture(SHIFT_CTRL_LEFT); + + assertTrue("Shift-Ctrl-Left moved cursor with selection across paragraphs", + SelManager.activePosition == 210 && + SelManager.anchorPosition == 179); + + SelManager.selectRange(141, 141); + sendKeyboardGesture(SHIFT_CTRL_LEFT); + + assertTrue("Shift-Ctrl-Left failed to move between paragraphs", + SelManager.activePosition == 140 && + SelManager.anchorPosition == 141); + } + + [Test] + public function ShiftCtrlLeftImageTest():void + { + SelManager.selectRange(20, 20); + SelManager.insertInlineGraphic(LoaderUtil.createAbsoluteURL(baseURL, "../../test/testFiles/assets/gremlin.jpg"), 60, 60); + + SelManager.selectRange(26, 26); + SelManager.insertInlineGraphic(LoaderUtil.createAbsoluteURL(baseURL, "../../test/testFiles/assets/gremlin.jpg"), 60, 60); + + SelManager.selectRange(32, 32); + SelManager.insertText(" "); + SelManager.selectRange(33, 33); + SelManager.insertInlineGraphic(LoaderUtil.createAbsoluteURL(baseURL, "../../test/testFiles/assets/gremlin.jpg"), 60, 50); + SelManager.insertInlineGraphic(LoaderUtil.createAbsoluteURL(baseURL, "../../test/testFiles/assets/gremlin.jpg"), 60, 40); + SelManager.insertInlineGraphic(LoaderUtil.createAbsoluteURL(baseURL, "../../test/testFiles/assets/gremlin.jpg"), 60, 50); + + SelManager.selectRange(37, 37); + sendKeyboardGesture(SHIFT_CTRL_LEFT); + assertTrue("Shift-Ctrl-Left incorrectly navigated around images", + SelManager.activePosition == 35 && + SelManager.anchorPosition == 37); + + sendKeyboardGesture(SHIFT_CTRL_LEFT); + assertTrue("Shift-Ctrl-Left incorrectly navigated around images", + SelManager.activePosition == 34 && + SelManager.anchorPosition == 37); + sendKeyboardGesture(SHIFT_CTRL_LEFT); + + sendKeyboardGesture(SHIFT_CTRL_LEFT); + assertTrue("Shift-Ctrl-Left incorrectly navigated around images", + SelManager.activePosition == 27 && + SelManager.anchorPosition == 37); + + sendKeyboardGesture(SHIFT_CTRL_LEFT); + assertTrue("Shift-Ctrl-Left incorrectly navigated around images", + SelManager.activePosition == 26 && + SelManager.anchorPosition == 37); + + sendKeyboardGesture(SHIFT_CTRL_LEFT); + assertTrue("Shift-Ctrl-Left incorrectly navigated around images", + SelManager.activePosition == 23 && + SelManager.anchorPosition == 37); + + sendKeyboardGesture(SHIFT_CTRL_LEFT); + assertTrue("Shift-Ctrl-Left incorrectly navigated around images", + SelManager.activePosition == 21 && + SelManager.anchorPosition == 37); + } + + [Test] + public function ShiftCtrlLeftLanguageTest():void + { + setUpLanguageTest(); + + SelManager.selectRange(22, 22); + sendKeyboardGesture(SHIFT_CTRL_LEFT); + assertTrue("Shift-Ctrl-Left failed in Right to Left Arabic text", + SelManager.activePosition == 20 && + SelManager.anchorPosition == 22); + + SelManager.selectRange(85, 85); + sendKeyboardGesture(SHIFT_CTRL_LEFT); + assertTrue("Shift-Ctrl-Left failed to move through a bidi word", + SelManager.activePosition == 79 && + SelManager.anchorPosition == 85); + + sendKeyboardGesture(SHIFT_CTRL_LEFT); + assertTrue("Shift-Ctrl-Left changed movement behavior within a bidi word", + SelManager.activePosition == 78 && + SelManager.anchorPosition == 85); + + sendKeyboardGesture(SHIFT_CTRL_LEFT); + assertTrue("Shift-Ctrl-Left changed movement behavior within a bidi word", + SelManager.activePosition == 70 && + SelManager.anchorPosition == 85); + + SelManager.selectRange(261, 261); + sendKeyboardGesture(SHIFT_CTRL_LEFT); + + assertTrue("Shift-Ctrl-Left changed movement behavior within right to left text", + SelManager.activePosition == 257 && + SelManager.anchorPosition == 261); + + setUpTCYTest(); + + // TCY Tests + SelManager.selectRange(18, 18); + sendKeyboardGesture(SHIFT_CTRL_LEFT); + assertTrue("Shift-Ctrl-Left changed removal behavior within TCY text", + SelManager.activePosition == 15 && + SelManager.anchorPosition == 18); + + SelManager.selectRange(23, 23); + sendKeyboardGesture(SHIFT_CTRL_LEFT); + assertTrue("Shift-Ctrl-Left changed removal behavior within TCY text", + SelManager.activePosition == 22 && + SelManager.anchorPosition == 23); + + sendKeyboardGesture(SHIFT_CTRL_LEFT); + assertTrue("Shift-Ctrl-Left changed removal behavior within TCY text", + SelManager.activePosition == 15 && + SelManager.anchorPosition == 23); + } + + /*********** SHIFT-CTRL-RIGHT TESTS **************************************************************/ + + /** + * Test the basic functionality and undo/redo + */ + [Test] + public function ShiftCtrlRightGeneralTest():void + { + shiftRightGeneralTest(SHIFT_CTRL_RIGHT); + } + + [Test] + public function ShiftOptRightGeneralTest():void + { + shiftRightGeneralTest(SHIFT_OPT_RIGHT); + } + + /** + * Test a bunch of different places in a line that Shift-Ctrl-Right could be pressed + */ + [Test] + public function ShiftCtrlRightLocationTest():void + { + // Extending the selection to include the terminator at the end of the flow works or not depending on + // the backwards compatibility flag. Version 1.0 does not allow it. Version 2.0 and later does allow it. + var lastRangeSelectionPos:int = SelManager.textFlow.textLength - 1; + + SelManager.selectRange(SelManager.textFlow.textLength - 1, SelManager.textFlow.textLength - 1); + sendKeyboardGesture(SHIFT_CTRL_RIGHT); + assertTrue("Shift-Ctrl-Right should be at end when executed at last position", + SelManager.activePosition == lastRangeSelectionPos && + SelManager.anchorPosition == SelManager.textFlow.textLength - 1); + + SelManager.selectRange(45, 45); + sendKeyboardGesture(SHIFT_CTRL_RIGHT); + assertTrue("Shift-Ctrl-Right failed on punctutation", + SelManager.activePosition == 46 && + SelManager.anchorPosition == 45); + + SelManager.selectRange(0, 0); + sendKeyboardGesture(SHIFT_CTRL_RIGHT); + assertTrue("Shift-Ctrl-Right failed at the beginning of a line", + SelManager.activePosition == 5 && + SelManager.anchorPosition == 0); + + SelManager.selectRange(8, 8); + sendKeyboardGesture(SHIFT_CTRL_RIGHT); + assertTrue("Shift-Ctrl-Right failed on a single character word", + SelManager.activePosition == 10 && + SelManager.anchorPosition == 8); + + SelManager.insertText(" "); + SelManager.selectRange(7, 7); + sendKeyboardGesture(SHIFT_CTRL_RIGHT); + assertTrue("Shift-Ctrl-Right failed over extra whitespace", + <TRUNCATED>
