diff options
Diffstat (limited to 'platform/platform-tests/testSrc/com/intellij/openapi/editor')
4 files changed, 113 insertions, 4 deletions
diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/editor/EditorMultiCaretTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/editor/EditorMultiCaretTest.java index 26be81d2f341..fdaf7c6ed5b0 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/editor/EditorMultiCaretTest.java +++ b/platform/platform-tests/testSrc/com/intellij/openapi/editor/EditorMultiCaretTest.java @@ -245,6 +245,38 @@ public class EditorMultiCaretTest extends AbstractEditorTest { "seven<caret>"); } + public void testCopyMultilineFromOneCaretPasteIntoTwo() throws Exception { + init("<selection>one\n" + + "two<caret></selection>\n" + + "three\n" + + "four", + TestFileType.TEXT); + executeAction("EditorCopy"); + executeAction("EditorTextStart"); + executeAction("EditorCloneCaretBelow"); + executeAction("EditorPaste"); + checkResultByText("one\n" + + "two<caret>one\n" + + "one\n" + + "two<caret>two\n" + + "three\n" + + "four"); + } + + public void testCopyPasteDoesNothingWithUnevenSelection() throws Exception { + init("<selection>one\n" + + "two<caret></selection>\n" + + "<selection>three<caret></selection>\n" + + "four", + TestFileType.TEXT); + executeAction("EditorCopy"); + executeAction("EditorPaste"); + checkResultByText("one\n" + + "two<caret>\n" + + "three<caret>\n" + + "four"); + } + public void testEscapeAfterDragDown() throws Exception { init("line1\n" + "line2", diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/editor/actions/EditorActionTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/editor/actions/EditorActionTest.java index deb63c13abf8..20bfdaced5e8 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/editor/actions/EditorActionTest.java +++ b/platform/platform-tests/testSrc/com/intellij/openapi/editor/actions/EditorActionTest.java @@ -102,4 +102,15 @@ public class EditorActionTest extends AbstractEditorTest { deleteLine(); checkResultByText(""); } + + public void testDeleteLineHonorSelection() throws Exception { + init("xxxx\n" + + "bla <selection><caret>bla\n" + + "bla</selection> bla\n" + + "yyy", + TestFileType.TEXT); + deleteLine(); + checkResultByText("xxxx\n" + + "yyy<caret>"); + } }
\ No newline at end of file diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/editor/actions/SelectUnselectOccurrenceActionsTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/editor/actions/SelectUnselectOccurrenceActionsTest.java index 34a08c0483bb..c1cc85768aed 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/editor/actions/SelectUnselectOccurrenceActionsTest.java +++ b/platform/platform-tests/testSrc/com/intellij/openapi/editor/actions/SelectUnselectOccurrenceActionsTest.java @@ -194,6 +194,63 @@ public class SelectUnselectOccurrenceActionsTest extends LightPlatformCodeInsigh "another line"); } + public void testSelectingAdjacentFragments() throws Exception { + init("fragment<selection>fragment<caret></selection>"); + executeAction(); + executeAction(); + checkResult("<selection>fragment<caret></selection><selection>fragment<caret></selection>"); + } + + public void testSkippingOccurrence() throws Exception { + init("fr<caret>uit\n" + + "fruits\n" + + "fruit\n" + + "fruits\n" + + "fruit"); + executeAction(); + executeAction(); + executeFindNext(); + checkResult("<selection>fr<caret>uit</selection>\n" + + "fruits\n" + + "fruit\n" + + "fruits\n" + + "<selection>fr<caret>uit</selection>"); + } + + public void testMovingSelectionBackAndForth() throws Exception { + init("fr<caret>uit\n" + + "fruits\n" + + "fruit\n" + + "fruits\n" + + "fruit"); + executeAction(); + executeAction(); + executeFindNext(); + executeFindPrevious(); + executeAction(); + checkResult("<selection>fr<caret>uit</selection>\n" + + "fruits\n" + + "<selection>fr<caret>uit</selection>\n" + + "fruits\n" + + "<selection>fr<caret>uit</selection>"); + } + + public void testSkipDoesNotRemovePreviousSelections() throws Exception { + init("<caret>fruit\n" + + "fruit\n" + + "fruit"); + executeAction(); + executeAction(); + executeFindNext(); + executeFindNext(); + assertEquals(1, hintCount); + executeFindNext(); + assertEquals(1, hintCount); + checkResult("<selection><caret>fruit</selection>\n" + + "fruit\n" + + "<selection><caret>fruit</selection>"); + } + private void init(String text) { myFixture.configureByText(FileTypes.PLAIN_TEXT, text); } @@ -206,6 +263,14 @@ public class SelectUnselectOccurrenceActionsTest extends LightPlatformCodeInsigh myFixture.performEditorAction(IdeActions.ACTION_SELECT_NEXT_OCCURENCE); } + private void executeFindNext() { + myFixture.performEditorAction(IdeActions.ACTION_FIND_NEXT); + } + + private void executeFindPrevious() { + myFixture.performEditorAction(IdeActions.ACTION_FIND_PREVIOUS); + } + private void executeReverseAction() { myFixture.performEditorAction(IdeActions.ACTION_UNSELECT_PREVIOUS_OCCURENCE); } diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/editor/impl/softwrap/mapping/CachingSoftWrapDataMapperTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/editor/impl/softwrap/mapping/CachingSoftWrapDataMapperTest.java index 6589fb35368b..7448c6c867f6 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/editor/impl/softwrap/mapping/CachingSoftWrapDataMapperTest.java +++ b/platform/platform-tests/testSrc/com/intellij/openapi/editor/impl/softwrap/mapping/CachingSoftWrapDataMapperTest.java @@ -122,6 +122,8 @@ public class CachingSoftWrapDataMapperTest { final Project project = myMockery.mock(Project.class); final SoftWrapPainter painter = myMockery.mock(SoftWrapPainter.class); + myRepresentationHelper = new MockEditorTextRepresentationHelper(SPACE_SIZE, TAB_SIZE); + myMockery.checking(new Expectations() {{ // Document allowing(myEditor).getDocument();will(returnValue(myDocument)); @@ -165,6 +167,7 @@ public class CachingSoftWrapDataMapperTest { return getSoftWrap((Integer)invocation.getParameter(0)); } }); + allowing(mySoftWrapModel).getEditorTextRepresentationHelper(); will(returnValue(myRepresentationHelper)); // Folding. allowing(myEditor).getFoldingModel();will(returnValue(myFoldingModel)); @@ -220,9 +223,7 @@ public class CachingSoftWrapDataMapperTest { allowing(painter).getMinDrawingWidth(SoftWrapDrawingType.AFTER_SOFT_WRAP); will(returnValue(SOFT_WRAP_DRAWING_WIDTH)); }}); - myRepresentationHelper = new MockEditorTextRepresentationHelper(SPACE_SIZE, TAB_SIZE); - - myMapper = new CachingSoftWrapDataMapper(myEditor, myStorage, myRepresentationHelper); + myMapper = new CachingSoftWrapDataMapper(myEditor, myStorage); } @After @@ -699,7 +700,7 @@ public class CachingSoftWrapDataMapperTest { int foldingStartVisualColumn; TestEditorPosition() { - super(myEditor, myRepresentationHelper); + super(myEditor); lineStartPosition = clone(); } |