diff options
Diffstat (limited to 'platform/platform-tests/testSrc/com')
10 files changed, 289 insertions, 186 deletions
diff --git a/platform/platform-tests/testSrc/com/intellij/codeInsight/actions/ReformatFilesWithFiltersTest.java b/platform/platform-tests/testSrc/com/intellij/codeInsight/actions/ReformatFilesWithFiltersTest.java index a90148799f5d..dbc05f849a49 100644 --- a/platform/platform-tests/testSrc/com/intellij/codeInsight/actions/ReformatFilesWithFiltersTest.java +++ b/platform/platform-tests/testSrc/com/intellij/codeInsight/actions/ReformatFilesWithFiltersTest.java @@ -202,42 +202,22 @@ public class ReformatFilesWithFiltersTest extends LightPlatformTestCase { TestFileStructure fileTree = new TestFileStructure(getModule(), myWorkingDirectory); fileTree.createDirectoryAndMakeItCurrent("src"); - PsiFile java2 = fileTree.addTestFile("Test2.java", "empty content"); + PsiFile java2 = fileTree.addTestFile("Test2.tj", "empty content"); PsiFile php2 = fileTree.addTestFile("Pair2.php", "empty content"); PsiFile js2 = fileTree.addTestFile("Pair2.js", "empty content"); PsiDirectory test = fileTree.createDirectoryAndMakeItCurrent("test"); - PsiFile testJava1 = fileTree.addTestFile("testJava1.java", "empty content"); + PsiFile testJava1 = fileTree.addTestFile("testJava1.tj", "empty content"); PsiFile testPhp1 = fileTree.addTestFile("testPhp1.php", "empty content"); PsiFile testJs1 = fileTree.addTestFile("testJs1.js", "empty content"); GlobalSearchScope testScope = directoryScope(test, true); - Logger logger = Logger.getInstance(getClass()); - logFiles(logger, "Previously formatted files: ", myMockCodeStyleManager.getFormattedFiles()); - - reformatWithRearrange(myWorkingDirectory, testScope); - logFiles(logger, "Currently formatted files: ", myMockCodeStyleManager.getFormattedFiles()); - logFiles(logger, "Should be formatted", ContainerUtil.newArrayList(testJava1, testPhp1, testJs1)); - - assertWasFormatted(testJava1, testPhp1, testJs1); - assertWasNotFormatted(java2, php2, js2); - reformatAndOptimize(myWorkingDirectory, testScope); assertWasFormatted(testJava1, testPhp1, testJs1); assertWasNotFormatted(java2, php2, js2); } - private void logFiles(Logger log, String message, Collection<PsiFile> files) { - StringBuilder builder; - builder = new StringBuilder(); - builder.append(message).append('\n'); - for (PsiFile file : files) { - builder.append(file).append('\n'); - } - log.info(builder.toString()); - } - public void assertWasFormatted(PsiFile... files) { final Set<PsiFile> formattedFiles = myMockCodeStyleManager.getFormattedFiles(); for (PsiFile file : files) { diff --git a/platform/platform-tests/testSrc/com/intellij/history/core/PathsTest.java b/platform/platform-tests/testSrc/com/intellij/history/core/PathsTest.java index 32f5ec2eb16e..f8bc13e05aed 100644 --- a/platform/platform-tests/testSrc/com/intellij/history/core/PathsTest.java +++ b/platform/platform-tests/testSrc/com/intellij/history/core/PathsTest.java @@ -103,6 +103,11 @@ public class PathsTest extends LocalHistoryTestCase { assertEquals(array("/", "foo"), ContainerUtil.collect(Paths.split("/foo").iterator())); assertEquals(array("/"), ContainerUtil.collect(Paths.split("/").iterator())); assertEquals(array("c:", "foo", "bar"), ContainerUtil.collect(Paths.split("c:/foo/bar").iterator())); + + assertEquals(array("//"), ContainerUtil.collect(Paths.split("//").iterator())); + assertEquals(array("//foo"), ContainerUtil.collect(Paths.split("//foo").iterator())); + assertEquals(array("//foo"), ContainerUtil.collect(Paths.split("//foo/").iterator())); + assertEquals(array("//foo", "bar"), ContainerUtil.collect(Paths.split("//foo/bar").iterator())); } @Test diff --git a/platform/platform-tests/testSrc/com/intellij/lang/PsiBuilderQuickTest.java b/platform/platform-tests/testSrc/com/intellij/lang/PsiBuilderQuickTest.java index 5a47fdf4c5f3..db833c2d8f3e 100644 --- a/platform/platform-tests/testSrc/com/intellij/lang/PsiBuilderQuickTest.java +++ b/platform/platform-tests/testSrc/com/intellij/lang/PsiBuilderQuickTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,16 +18,14 @@ package com.intellij.lang; import com.intellij.lang.impl.PsiBuilderImpl; import com.intellij.lexer.Lexer; import com.intellij.lexer.LexerBase; +import com.intellij.openapi.fileTypes.PlainTextParserDefinition; import com.intellij.openapi.project.Project; -import com.intellij.psi.FileViewProvider; -import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiFile; import com.intellij.psi.TokenType; import com.intellij.psi.impl.DebugUtil; import com.intellij.psi.impl.source.tree.ASTStructure; import com.intellij.psi.tree.*; -import com.intellij.testFramework.LightPlatformTestCase; -import com.intellij.testFramework.PlatformTestCase; +import com.intellij.testFramework.LightPlatformLangTestCase; +import com.intellij.testFramework.PlatformTestUtil; import com.intellij.util.ThreeState; import com.intellij.util.diff.DiffTree; import com.intellij.util.diff.DiffTreeChangeBuilder; @@ -36,12 +34,9 @@ import com.intellij.util.diff.ShallowNodeComparator; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; -import java.io.IOException; -import java.io.OutputStream; -import java.io.PrintStream; import java.util.List; -public class PsiBuilderQuickTest extends LightPlatformTestCase { +public class PsiBuilderQuickTest extends LightPlatformLangTestCase { private static final IFileElementType ROOT = new IFileElementType("ROOT", Language.ANY); private static final IElementType LETTER = new IElementType("LETTER", Language.ANY); @@ -57,11 +52,6 @@ public class PsiBuilderQuickTest extends LightPlatformTestCase { private static final TokenSet WHITESPACE_SET = TokenSet.create(TokenType.WHITE_SPACE); private static final TokenSet COMMENT_SET = TokenSet.create(COMMENT); - @SuppressWarnings("JUnitTestCaseWithNonTrivialConstructors") - public PsiBuilderQuickTest() { - PlatformTestCase.initPlatformLangPrefix(); - } - public void testPlain() { doTest("a<<b", new Parser() { @@ -428,15 +418,8 @@ public class PsiBuilderQuickTest extends LightPlatformTestCase { " PsiElement(OTHER)('}')\n"); } - private abstract static class MyLazyElementType extends ILazyParseableElementType implements ILightLazyParseableElementType { - protected MyLazyElementType(@NonNls String debugName) { - super(debugName, Language.ANY); - } - } - public void testLightChameleon() { final IElementType CHAMELEON_2 = new MyChameleon2Type(); - final IElementType CHAMELEON_1 = new MyChameleon1Type(CHAMELEON_2); doTest("ab{12[.?]}cd{x}", @@ -478,60 +461,26 @@ public class PsiBuilderQuickTest extends LightPlatformTestCase { " PsiElement(OTHER)('}')\n"); } - @SuppressWarnings("ConstantConditions") - private static PsiBuilderImpl createBuilder(CharSequence text) { - ParserDefinition parserDefinition = new ParserDefinition() { - @NotNull - @Override - public Lexer createLexer(Project project) { - return new MyTestLexer(); - } - - @Override - public PsiParser createParser(Project project) { - return null; - } - - @Override - public IFileElementType getFileNodeType() { - return null; - } - - @NotNull - @Override - public TokenSet getWhitespaceTokens() { - return WHITESPACE_SET; - } - - @NotNull - @Override - public TokenSet getCommentTokens() { - return COMMENT_SET; - } - - @NotNull - @Override - public TokenSet getStringLiteralElements() { - return null; - } - - @NotNull - @Override - public PsiElement createElement(ASTNode node) { - return null; - } - - @Override - public PsiFile createFile(FileViewProvider viewProvider) { - return null; - } - - @Override - public SpaceRequirements spaceExistanceTypeBetweenTokens(ASTNode left, ASTNode right) { - return null; - } - }; - return new PsiBuilderImpl(getProject(), null, parserDefinition, parserDefinition.createLexer(getProject()), null, text, null, null); + public void testEndMarkersOverlapping() { + doTest("a ", + new Parser() { + @Override + public void parse(PsiBuilder builder) { + PsiBuilder.Marker e1 = builder.mark(); + PsiBuilder.Marker e2 = builder.mark(); + builder.advanceLexer(); + e2.done(OTHER); + e2.setCustomEdgeTokenBinders(null, WhitespacesBinders.GREEDY_RIGHT_BINDER); + e1.done(OTHER); + e1.setCustomEdgeTokenBinders(null, WhitespacesBinders.DEFAULT_RIGHT_BINDER); + assertTrue(builder.eof()); + } + }, + "Element(ROOT)\n" + + " Element(OTHER)\n" + + " Element(OTHER)\n" + + " PsiElement(LETTER)('a')\n" + + " PsiWhiteSpace(' ')\n"); } private interface Parser { @@ -594,75 +543,44 @@ public class PsiBuilderQuickTest extends LightPlatformTestCase { } private static void doFailTest(@NonNls final String text, final Parser parser, @NonNls final String expected) { - final PrintStream std = System.err; - //noinspection IOResourceOpenedButNotSafelyClosed - System.setErr(new PrintStream(new NullStream())); - try { - try { - ParserDefinition parserDefinition = new ParserDefinition() { - @NotNull - @Override - public Lexer createLexer(Project project) { - return null; - } - - @Override - public PsiParser createParser(Project project) { - return null; - } - - @Override - public IFileElementType getFileNodeType() { - return null; - } - - @NotNull - @Override - public TokenSet getWhitespaceTokens() { - return TokenSet.EMPTY; - } - - @NotNull - @Override - public TokenSet getCommentTokens() { - return TokenSet.EMPTY; - } - - @NotNull - @Override - public TokenSet getStringLiteralElements() { - return null; - } - - @NotNull - @Override - public PsiElement createElement(ASTNode node) { - return null; - } - - @Override - public PsiFile createFile(FileViewProvider viewProvider) { - return null; - } - - @Override - public SpaceRequirements spaceExistanceTypeBetweenTokens(ASTNode left, ASTNode right) { - return null; - } - }; - final PsiBuilder builder = PsiBuilderFactory.getInstance().createBuilder(parserDefinition, new MyTestLexer(),text); - builder.setDebugMode(true); - parser.parse(builder); - builder.getLightTree(); - fail("should fail"); + PlatformTestUtil.withStdErrSuppressed(new Runnable() { + @Override + public void run() { + try { + PsiBuilder builder = PsiBuilderFactory.getInstance().createBuilder(new PlainTextParserDefinition(), new MyTestLexer(), text); + builder.setDebugMode(true); + parser.parse(builder); + builder.getLightTree(); + fail("should fail"); + } + catch (AssertionError e) { + assertEquals(expected, e.getMessage()); + } + } + }); + } + + private static PsiBuilderImpl createBuilder(CharSequence text) { + ParserDefinition parserDefinition = new PlainTextParserDefinition() { + @NotNull + @Override + public Lexer createLexer(Project project) { + return new MyTestLexer(); } - catch (AssertionError e) { - assertEquals(expected, e.getMessage()); + + @NotNull + @Override + public TokenSet getWhitespaceTokens() { + return WHITESPACE_SET; } - } - finally { - System.setErr(std); - } + + @NotNull + @Override + public TokenSet getCommentTokens() { + return COMMENT_SET; + } + }; + return new PsiBuilderImpl(getProject(), null, parserDefinition, parserDefinition.createLexer(getProject()), null, text, null, null); } private static class MyTestLexer extends LexerBase { @@ -719,9 +637,10 @@ public class PsiBuilderQuickTest extends LightPlatformTestCase { } } - private static class NullStream extends OutputStream { - @Override - public void write(final int b) throws IOException { } + private abstract static class MyLazyElementType extends ILazyParseableElementType implements ILightLazyParseableElementType { + protected MyLazyElementType(@NonNls String debugName) { + super(debugName, Language.ANY); + } } private static class MyChameleon1Type extends MyLazyElementType { diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/editor/actions/EditorCloneCaretAboveBelowTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/editor/actions/EditorCloneCaretAboveBelowTest.java new file mode 100644 index 000000000000..2d73640ff655 --- /dev/null +++ b/platform/platform-tests/testSrc/com/intellij/openapi/editor/actions/EditorCloneCaretAboveBelowTest.java @@ -0,0 +1,106 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.openapi.editor.actions; + +import com.intellij.openapi.actionSystem.IdeActions; +import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase; + +public class EditorCloneCaretAboveBelowTest extends LightPlatformCodeInsightFixtureTestCase { + public void testStoringDesiredXPosition() { + init("long line<caret>\n" + + "line\n" + + "long line\n" + + "very long line"); + cloneCaretBelow(); + checkResult("long line<caret>\n" + + "line<caret>\n" + + "long line\n" + + "very long line"); + cloneCaretBelow(); + checkResult("long line<caret>\n" + + "line<caret>\n" + + "long line<caret>\n" + + "very long line"); + cloneCaretBelow(); + checkResult("long line<caret>\n" + + "line<caret>\n" + + "long line<caret>\n" + + "very long<caret> line"); + } + + public void testCloneAndMove() { + init("long line<caret>\n" + + "line\n" + + "long line"); + cloneCaretBelow(); + moveCaretDown(); + checkResult("long line\n" + + "line<caret>\n" + + "long line<caret>"); + } + + public void testCloneBelowAndAbove() { + init("line\n" + + "<caret>li<caret>ne\n" + + "line"); + cloneCaretBelow(); + checkResult("line\n" + + "<caret>li<caret>ne\n" + + "<caret>li<caret>ne"); + cloneCaretAbove(); + checkResult("line\n" + + "<caret>li<caret>ne\n" + + "line"); + cloneCaretAbove(); + checkResult("<caret>li<caret>ne\n" + + "<caret>li<caret>ne\n" + + "line"); + cloneCaretBelow(); + checkResult("line\n" + + "<caret>li<caret>ne\n" + + "line"); + } + + public void testCloneWithSelection() { + init("long <selection>line<caret></selection>\n" + + "line\n" + + "long line"); + cloneCaretBelow(); + checkResult("long <selection>line<caret></selection>\n" + + "line\n" + + "long <selection>line<caret></selection>"); + } + + private void cloneCaretBelow() { + myFixture.performEditorAction(IdeActions.ACTION_EDITOR_CLONE_CARET_BELOW); + } + + private void cloneCaretAbove() { + myFixture.performEditorAction(IdeActions.ACTION_EDITOR_CLONE_CARET_ABOVE); + } + + private void moveCaretDown() { + myFixture.performEditorAction(IdeActions.ACTION_EDITOR_MOVE_CARET_DOWN); + } + + private void init(String text) { + myFixture.configureByText(getTestName(false) + ".txt", text); + } + + private void checkResult(String text) { + myFixture.checkResult(text); + } +} diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/editor/impl/AbstractEditorTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/editor/impl/AbstractEditorTest.java index 5dd8bbb8c424..fd774b5e817d 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/editor/impl/AbstractEditorTest.java +++ b/platform/platform-tests/testSrc/com/intellij/openapi/editor/impl/AbstractEditorTest.java @@ -34,6 +34,7 @@ import java.util.Arrays; import java.util.List; import java.util.Scanner; import java.util.regex.MatchResult; +import java.util.regex.Matcher; import java.util.regex.Pattern; import static org.junit.Assert.assertArrayEquals; @@ -94,6 +95,20 @@ public abstract class AbstractEditorTest extends LightPlatformCodeInsightTestCas )); } + protected static void foldOccurrences(String textToFoldRegexp, final String placeholder) { + final Matcher matcher = Pattern.compile(textToFoldRegexp).matcher(myEditor.getDocument().getCharsSequence()); + myEditor.getFoldingModel().runBatchFoldingOperation(new Runnable() { + @Override + public void run() { + while(matcher.find()) { + FoldRegion foldRegion = myEditor.getFoldingModel().addFoldRegion(matcher.start(), matcher.end(), placeholder); + assertNotNull(foldRegion); + foldRegion.setExpanded(false); + } + } + }); + } + /** * Setups document of the {@link #getEditor() current editor} according to the given text that is expected to contain * information about document lines obtained from the {@link DocumentImpl#dumpState()}. diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/editor/impl/EditorImplTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/editor/impl/EditorImplTest.java index 5a9d4da33219..aff78b0b1d27 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/editor/impl/EditorImplTest.java +++ b/platform/platform-tests/testSrc/com/intellij/openapi/editor/impl/EditorImplTest.java @@ -16,6 +16,7 @@ package com.intellij.openapi.editor.impl; import com.intellij.codeInsight.folding.CodeFoldingManager; +import com.intellij.openapi.actionSystem.IdeActions; import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.VisualPosition; import com.intellij.testFramework.EditorTestUtil; @@ -65,6 +66,29 @@ public class EditorImplTest extends AbstractEditorTest { verifySoftWrapPositions(58, 93); } + public void testCorrectVisibleLineCountCalculation() throws Exception { + init("line containing FOLDED_REGION\n" + + "next <caret>line\n" + + "last line"); + foldOccurrences("FOLDED_REGION", "..."); + EditorTestUtil.configureSoftWraps(myEditor, 16); // wrap right at folded region start + verifySoftWrapPositions(16); + + executeAction(IdeActions.ACTION_EDITOR_MOVE_CARET_DOWN); + checkResultByText("line containing FOLDED_REGION\n" + + "next line\n" + + "last <caret>line"); + } + + public void testInsertingFirstTab() throws Exception { + init(" <caret>space-indented line"); + EditorTestUtil.configureSoftWraps(myEditor, 100); + myEditor.getSettings().setUseTabCharacter(true); + + executeAction(IdeActions.ACTION_EDITOR_TAB); + checkResultByText(" \t<caret>space-indented line"); + } + private void init(String text) throws IOException { configureFromFileText(getTestName(false) + ".txt", text); } diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/editor/impl/RangeMarkerTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/editor/impl/RangeMarkerTest.java index 9f3484b35deb..d11847af849a 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/editor/impl/RangeMarkerTest.java +++ b/platform/platform-tests/testSrc/com/intellij/openapi/editor/impl/RangeMarkerTest.java @@ -34,6 +34,7 @@ import com.intellij.openapi.util.TextRange; import com.intellij.openapi.util.ThrowableComputable; import com.intellij.openapi.util.Trinity; import com.intellij.openapi.util.text.StringUtil; +import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiDocumentManager; import com.intellij.psi.PsiFile; import com.intellij.psi.impl.PsiDocumentManagerImpl; @@ -44,6 +45,7 @@ import com.intellij.testFramework.PlatformTestUtil; import com.intellij.testFramework.Timings; import com.intellij.util.CommonProcessors; import com.intellij.util.ThrowableRunnable; +import com.intellij.util.containers.WeakList; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; @@ -1077,13 +1079,13 @@ public class RangeMarkerTest extends LightPlatformTestCase { public void testRangeHighlighterLinesInRangeForLongLinePerformance() throws Exception { final int N = 50000; - Document document = EditorFactory.getInstance().createDocument(StringUtil.repeatSymbol('x', 2*N)); + Document document = EditorFactory.getInstance().createDocument(StringUtil.repeatSymbol('x', 2 * N)); final MarkupModelEx markupModel = (MarkupModelEx)DocumentMarkupModel.forDocument(document, ourProject, true); for (int i=0; i<N-1;i++) { markupModel.addRangeHighlighter(2*i, 2*i+1, 0, null, HighlighterTargetArea.EXACT_RANGE); } - markupModel.addRangeHighlighter(N/2, N/2+1, 0, null, HighlighterTargetArea.LINES_IN_RANGE); + markupModel.addRangeHighlighter(N / 2, N / 2 + 1, 0, null, HighlighterTargetArea.LINES_IN_RANGE); PlatformTestUtil.startPerformanceTest("slow highlighters lookup", (int)(N*Math.log(N)/1000), new ThrowableRunnable() { @Override @@ -1107,6 +1109,42 @@ public class RangeMarkerTest extends LightPlatformTestCase { RangeHighlighter line = markupModel.addRangeHighlighter(4, 5, 0, null, HighlighterTargetArea.LINES_IN_RANGE); List<RangeHighlighter> list = new ArrayList<RangeHighlighter>(); markupModel.processRangeHighlightersOverlappingWith(2, 9, new CommonProcessors.CollectProcessor<RangeHighlighter>(list)); - assertEquals(Arrays.asList(line,exact), list); + assertEquals(Arrays.asList(line, exact), list); + } + + public void testLazyRangeMarkers() { + psiFile = createFile("x.txt", "xxx"); + + LazyRangeMarkerFactoryImpl factory = (LazyRangeMarkerFactoryImpl)LazyRangeMarkerFactory.getInstance(getProject()); + VirtualFile virtualFile = psiFile.getVirtualFile(); + LazyRangeMarkerFactoryImpl.LazyMarker marker = (LazyRangeMarkerFactoryImpl.LazyMarker)factory.createRangeMarker(virtualFile, 0); + WeakList<LazyRangeMarkerFactoryImpl.LazyMarker> markers = LazyRangeMarkerFactoryImpl.getMarkers(virtualFile); + assertSame(marker, assertOneElement(markers)); + + assertFalse(marker.isDelegated()); + assertTrue(marker.isValid()); + assertEquals(0, marker.getStartOffset()); + assertFalse(marker.isDelegated()); + + marker.dispose(); + assertFalse(marker.isValid()); + assertEmpty(LazyRangeMarkerFactoryImpl.getMarkers(virtualFile)); + + + marker = (LazyRangeMarkerFactoryImpl.LazyMarker)factory.createRangeMarker(virtualFile, 0); + assertFalse(marker.isDelegated()); + assertTrue(marker.isValid()); + assertEquals(0, marker.getStartOffset()); + assertFalse(marker.isDelegated()); + + Document document = marker.getDocument(); + document.insertString(2, "yyy"); + assertTrue(marker.isDelegated()); + assertTrue(marker.isValid()); + assertEquals(0, marker.getStartOffset()); + + assertEmpty(LazyRangeMarkerFactoryImpl.getMarkers(virtualFile)); + marker.dispose(); + assertEmpty(LazyRangeMarkerFactoryImpl.getMarkers(virtualFile)); } } diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/editor/StripTrailingSpacesTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/editor/impl/StripTrailingSpacesTest.java index abfef7cf0657..285aadbef402 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/editor/StripTrailingSpacesTest.java +++ b/platform/platform-tests/testSrc/com/intellij/openapi/editor/impl/StripTrailingSpacesTest.java @@ -13,15 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.intellij.openapi.editor; +package com.intellij.openapi.editor.impl; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.impl.ApplicationImpl; import com.intellij.openapi.command.WriteCommandAction; +import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.ex.DocumentEx; import com.intellij.openapi.editor.ex.EditorSettingsExternalizable; import com.intellij.openapi.fileEditor.FileDocumentManager; -import com.intellij.openapi.fileEditor.impl.TrailingSpacesStripper; import com.intellij.testFramework.LightPlatformCodeInsightTestCase; import org.jdom.Element; import org.jetbrains.annotations.NonNls; diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/fileEditor/NonProjectFileAccessTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/fileEditor/NonProjectFileAccessTest.java index e517799165e2..06594d2352bf 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/fileEditor/NonProjectFileAccessTest.java +++ b/platform/platform-tests/testSrc/com/intellij/openapi/fileEditor/NonProjectFileAccessTest.java @@ -245,7 +245,7 @@ public class NonProjectFileAccessTest extends HeavyFileEditorManagerTestCase { assertNotNull(NonProjectFileWritingAccessProvider.getAccessStatus(getProject(), nonProjectFile1)); assertNull(NonProjectFileWritingAccessProvider.getAccessStatus(getProject(), nonProjectFile2)); - PsiTestUtil.removeContentEntry(myModule, contextRoot); + PsiTestUtil.removeContentEntry(myModule, contextRoot.getFile()); // do not add notification panel until access is requested assertNotNull(NonProjectFileWritingAccessProvider.getAccessStatus(getProject(), nonProjectFile1)); diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/keymap/impl/ModifierKeyDoubleClickHandlerTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/keymap/impl/ModifierKeyDoubleClickHandlerTest.java index 490aa294974d..96d85c122624 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/keymap/impl/ModifierKeyDoubleClickHandlerTest.java +++ b/platform/platform-tests/testSrc/com/intellij/openapi/keymap/impl/ModifierKeyDoubleClickHandlerTest.java @@ -118,6 +118,16 @@ public class ModifierKeyDoubleClickHandlerTest extends LightPlatformTestCase { release(); } + public void testRepeatedInvocationOnKeyHold() { + press(); + release(); + press(); + key(2); + assertInvocationCounts(0, 0, 2); + release(); + assertInvocationCounts(0, 0, 2); + } + public void assertInvocationCounts(int shiftKeyCount, int shiftShiftCount, int shiftShiftKeyCount) { assertEquals(shiftKeyCount, myShiftKeyActionInvocationCount); assertEquals(shiftShiftCount, myShiftShiftActionInvocationCount); @@ -143,18 +153,24 @@ public class ModifierKeyDoubleClickHandlerTest extends LightPlatformTestCase { } private void key() { - IdeEventQueue.getInstance().dispatchEvent(new KeyEvent(myComponent, - KeyEvent.KEY_PRESSED, - Clock.getTime(), - InputEvent.SHIFT_MASK, - KeyEvent.VK_BACK_SPACE, - '\b')); - IdeEventQueue.getInstance().dispatchEvent(new KeyEvent(myComponent, - KeyEvent.KEY_TYPED, - Clock.getTime(), - InputEvent.SHIFT_MASK, - 0, - '\b')); + key(1); + } + + private void key(int repeat) { + for (int i = 0; i < repeat; i++) { + IdeEventQueue.getInstance().dispatchEvent(new KeyEvent(myComponent, + KeyEvent.KEY_PRESSED, + Clock.getTime(), + InputEvent.SHIFT_MASK, + KeyEvent.VK_BACK_SPACE, + '\b')); + IdeEventQueue.getInstance().dispatchEvent(new KeyEvent(myComponent, + KeyEvent.KEY_TYPED, + Clock.getTime(), + InputEvent.SHIFT_MASK, + 0, + '\b')); + } IdeEventQueue.getInstance().dispatchEvent(new KeyEvent(myComponent, KeyEvent.KEY_RELEASED, Clock.getTime(), |