From 99a2216bad3ecda97eabfa5b1e624c79a2c10085 Mon Sep 17 00:00:00 2001 From: Dmitry Avdeev Date: Tue, 30 Apr 2013 15:55:49 +0400 Subject: [PATCH] tests fixed --- .../intellij/navigation/GotoClassTest.java | 9 +-- .../HeavyFileEditorManagerTestCase.java | 62 +++++++++++++++++++ .../fileEditor/NewDocumentHistoryTest.java | 32 +++------- 3 files changed, 72 insertions(+), 31 deletions(-) create mode 100644 platform/platform-tests/testSrc/com/intellij/openapi/fileEditor/HeavyFileEditorManagerTestCase.java diff --git a/java/java-tests/testSrc/com/intellij/navigation/GotoClassTest.java b/java/java-tests/testSrc/com/intellij/navigation/GotoClassTest.java index ceae51f1dc23..41bd950dbdcb 100644 --- a/java/java-tests/testSrc/com/intellij/navigation/GotoClassTest.java +++ b/java/java-tests/testSrc/com/intellij/navigation/GotoClassTest.java @@ -1,25 +1,22 @@ package com.intellij.navigation; import com.intellij.codeInsight.navigation.NavigationUtil; -import com.intellij.idea.Bombed; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.fileEditor.FileEditor; -import com.intellij.openapi.fileEditor.FileEditorManagerTestCase; +import com.intellij.openapi.fileEditor.HeavyFileEditorManagerTestCase; import com.intellij.openapi.fileEditor.TextEditor; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiClass; import com.intellij.psi.PsiJavaFile; -import java.util.Calendar; - /** * @author Dmitry Avdeev * Date: 4/25/13 */ -public class GotoClassTest extends FileEditorManagerTestCase { +public class GotoClassTest extends HeavyFileEditorManagerTestCase { - @Bombed(month = Calendar.MAY, day = 20) public void testGotoClass() throws Exception { + PsiJavaFile file = (PsiJavaFile)myFixture.configureByText("Foo.java", "public class Foo {\n" + "}\n" + "\n" + diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/fileEditor/HeavyFileEditorManagerTestCase.java b/platform/platform-tests/testSrc/com/intellij/openapi/fileEditor/HeavyFileEditorManagerTestCase.java new file mode 100644 index 000000000000..76fdce39e99e --- /dev/null +++ b/platform/platform-tests/testSrc/com/intellij/openapi/fileEditor/HeavyFileEditorManagerTestCase.java @@ -0,0 +1,62 @@ +/* + * Copyright 2000-2013 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.fileEditor; + +import com.intellij.openapi.components.impl.ComponentManagerImpl; +import com.intellij.openapi.fileEditor.ex.IdeDocumentHistory; +import com.intellij.openapi.fileEditor.impl.EditorHistoryManager; +import com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl; +import com.intellij.openapi.fileEditor.impl.IdeDocumentHistoryImpl; +import com.intellij.openapi.vfs.LocalFileSystem; +import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.testFramework.PlatformTestCase; +import com.intellij.testFramework.PlatformTestUtil; +import com.intellij.testFramework.fixtures.CodeInsightFixtureTestCase; +import com.intellij.ui.docking.DockManager; + +import java.io.File; + +/** + * @author Dmitry Avdeev + * Date: 4/30/13 + */ +public abstract class HeavyFileEditorManagerTestCase extends CodeInsightFixtureTestCase { + + @SuppressWarnings("JUnitTestCaseWithNonTrivialConstructors") + protected HeavyFileEditorManagerTestCase() { + PlatformTestCase.autodetectPlatformPrefix(); + } + + protected FileEditorManagerImpl myManager; + + protected VirtualFile getFile(String path) { + return LocalFileSystem.getInstance().refreshAndFindFileByPath( + PlatformTestUtil.getCommunityPath().replace(File.separatorChar, '/') + "/platform/platform-tests/testData/fileEditorManager" + path); + } + + public void setUp() throws Exception { + super.setUp(); + myManager = new FileEditorManagerImpl(getProject(), DockManager.getInstance(getProject())); + ((ComponentManagerImpl)getProject()).registerComponentInstance(FileEditorManager.class, myManager); + ((IdeDocumentHistoryImpl)IdeDocumentHistory.getInstance(getProject())).projectOpened(); + EditorHistoryManager.getInstance(getProject()).projectOpened(); + } + + @Override + protected String getBasePath() { + return "/platform/platform-tests/testData/fileEditorManager"; + } +} diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/fileEditor/NewDocumentHistoryTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/fileEditor/NewDocumentHistoryTest.java index 18f429b30f30..bf284c8f756d 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/fileEditor/NewDocumentHistoryTest.java +++ b/platform/platform-tests/testSrc/com/intellij/openapi/fileEditor/NewDocumentHistoryTest.java @@ -1,26 +1,21 @@ package com.intellij.openapi.fileEditor; import com.intellij.codeInsight.navigation.NavigationUtil; -import com.intellij.openapi.components.impl.ComponentManagerImpl; import com.intellij.openapi.fileEditor.ex.IdeDocumentHistory; -import com.intellij.openapi.fileEditor.impl.EditorHistoryManager; -import com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl; -import com.intellij.openapi.fileEditor.impl.IdeDocumentHistoryImpl; -import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.testFramework.PlatformLangTestCase; +import com.intellij.psi.PsiManager; +import com.intellij.testFramework.PlatformTestCase; import com.intellij.testFramework.PlatformTestUtil; -import com.intellij.ui.docking.DockManager; - -import java.io.File; /** * @author Dmitry Avdeev * Date: 4/29/13 */ -public class NewDocumentHistoryTest extends PlatformLangTestCase { +public class NewDocumentHistoryTest extends HeavyFileEditorManagerTestCase { - private FileEditorManagerImpl myManager; + public NewDocumentHistoryTest() { + PlatformTestCase.initPlatformLangPrefix(); + } public void testBackNavigationBetweenEditors() throws Exception { PlatformTestUtil.registerExtension(FileEditorProvider.EP_FILE_EDITOR_PROVIDER, new FileEditorManagerTest.MyFileEditorProvider(), getTestRootDisposable()); @@ -42,22 +37,9 @@ public class NewDocumentHistoryTest extends PlatformLangTestCase { myManager.openFile(file1, true); VirtualFile file2 = getFile("/src/2.txt"); myManager.openFile(file2, true); - NavigationUtil.activateFileWithPsiElement(getPsiManager().findFile(file1)); + NavigationUtil.activateFileWithPsiElement(PsiManager.getInstance(getProject()).findFile(file1)); VirtualFile[] files = myManager.getSelectedFiles(); assertEquals(1, files.length); assertEquals("1.txt", files[0].getName()); } - - protected VirtualFile getFile(String path) { - return LocalFileSystem.getInstance().refreshAndFindFileByPath( - PlatformTestUtil.getCommunityPath().replace(File.separatorChar, '/') + "/platform/platform-tests/testData/fileEditorManager" + path); - } - - public void setUp() throws Exception { - super.setUp(); - myManager = new FileEditorManagerImpl(getProject(), DockManager.getInstance(getProject())); - ((ComponentManagerImpl)getProject()).registerComponentInstance(FileEditorManager.class, myManager); - ((IdeDocumentHistoryImpl)IdeDocumentHistory.getInstance(getProject())).projectOpened(); - EditorHistoryManager.getInstance(getProject()).projectOpened(); - } }