From b579aab18b3bedc4643b858f1a19d6eb4f49664c Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Tue, 4 Sep 2012 19:46:56 +0400 Subject: [PATCH] LoadProjectTest moved to CE --- java/java-tests/testData/model/Model.iml | 12 + java/java-tests/testData/model/model.ipr | 177 +++++++++ java/java-tests/testData/model/model.iws | 340 ++++++++++++++++++ .../testData/model/src/x/AClass.java | 19 + .../testData/model/src/x/BClass.java | 19 + .../com/intellij/project/LoadProjectTest.java | 95 +++++ 6 files changed, 662 insertions(+) create mode 100644 java/java-tests/testData/model/Model.iml create mode 100644 java/java-tests/testData/model/model.ipr create mode 100644 java/java-tests/testData/model/model.iws create mode 100644 java/java-tests/testData/model/src/x/AClass.java create mode 100644 java/java-tests/testData/model/src/x/BClass.java create mode 100644 java/java-tests/testSrc/com/intellij/project/LoadProjectTest.java diff --git a/java/java-tests/testData/model/Model.iml b/java/java-tests/testData/model/Model.iml new file mode 100644 index 000000000000..d5c074327501 --- /dev/null +++ b/java/java-tests/testData/model/Model.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/java/java-tests/testData/model/model.ipr b/java/java-tests/testData/model/model.ipr new file mode 100644 index 000000000000..9bcc32e1e57a --- /dev/null +++ b/java/java-tests/testData/model/model.ipr @@ -0,0 +1,177 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1.6 + + + + + + + + + diff --git a/java/java-tests/testData/model/model.iws b/java/java-tests/testData/model/model.iws new file mode 100644 index 000000000000..29b5937964bd --- /dev/null +++ b/java/java-tests/testData/model/model.iws @@ -0,0 +1,340 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + localhost + 5050 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/java/java-tests/testData/model/src/x/AClass.java b/java/java-tests/testData/model/src/x/AClass.java new file mode 100644 index 000000000000..2d12eb2771a2 --- /dev/null +++ b/java/java-tests/testData/model/src/x/AClass.java @@ -0,0 +1,19 @@ +/* + * Copyright 2000-2012 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 x; + +public class AClass { +} diff --git a/java/java-tests/testData/model/src/x/BClass.java b/java/java-tests/testData/model/src/x/BClass.java new file mode 100644 index 000000000000..d5e1b6de491d --- /dev/null +++ b/java/java-tests/testData/model/src/x/BClass.java @@ -0,0 +1,19 @@ +/* + * Copyright 2000-2012 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 x; + +public class BClass { +} diff --git a/java/java-tests/testSrc/com/intellij/project/LoadProjectTest.java b/java/java-tests/testSrc/com/intellij/project/LoadProjectTest.java new file mode 100644 index 000000000000..b50e2d87c71f --- /dev/null +++ b/java/java-tests/testSrc/com/intellij/project/LoadProjectTest.java @@ -0,0 +1,95 @@ +/* + * Copyright 2000-2012 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.project; + +import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.application.ex.PathManagerEx; +import com.intellij.openapi.editor.Editor; +import com.intellij.openapi.fileEditor.FileEditor; +import com.intellij.openapi.fileEditor.FileEditorManager; +import com.intellij.openapi.fileEditor.OpenFileDescriptor; +import com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl; +import com.intellij.openapi.project.ProjectManager; +import com.intellij.openapi.project.ex.ProjectManagerEx; +import com.intellij.openapi.project.impl.ProjectImpl; +import com.intellij.openapi.roots.ProjectRootManager; +import com.intellij.openapi.vfs.LocalFileSystem; +import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.psi.PsiFile; +import com.intellij.psi.impl.source.PsiFileImpl; +import com.intellij.testFramework.LeakHunter; +import com.intellij.testFramework.PlatformTestCase; +import com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl; +import com.intellij.util.Processor; +import org.picocontainer.MutablePicoContainer; + +public class LoadProjectTest extends PlatformTestCase { + @Override + protected void setUpProject() throws Exception { + String projectPath = PathManagerEx.getTestDataPath() + "/model/model.ipr"; + myProject = ProjectManager.getInstance().loadAndOpenProject(projectPath); + MutablePicoContainer container = (MutablePicoContainer)getProject().getPicoContainer(); + container.unregisterComponent(FileEditorManager.class.getName()); + ((ProjectImpl)getProject()).registerComponentImplementation(FileEditorManager.class, FileEditorManagerImpl.class); + } + + @Override + protected void tearDown() throws Exception { + myProject = null; + super.tearDown(); + } + + public void testLoadProject() throws Exception { + VirtualFile src = ProjectRootManager.getInstance(getProject()).getContentSourceRoots()[0]; + + VirtualFile a = src.findFileByRelativePath("/x/AClass.java"); + assertNotNull(a); + PsiFile fileA = getPsiManager().findFile(a); + assertNotNull(fileA); + fileA.navigate(true); + Editor editorA = FileEditorManager.getInstance(getProject()).openTextEditor(new OpenFileDescriptor(getProject(), a), true); + assertNotNull(editorA); + CodeInsightTestFixtureImpl.instantiateAndRun(fileA, editorA, new int[0], false); + + VirtualFile b = src.findFileByRelativePath("/x/BClass.java"); + assertNotNull(b); + PsiFile fileB = getPsiManager().findFile(b); + assertNotNull(fileB); + fileB.navigate(true); + Editor editorB = FileEditorManager.getInstance(getProject()).openTextEditor(new OpenFileDescriptor(getProject(), b), true); + assertNotNull(editorB); + CodeInsightTestFixtureImpl.instantiateAndRun(fileB, editorB, new int[0], false); + + FileEditor[] allEditors = FileEditorManager.getInstance(getProject()).getAllEditors(); + assertEquals(2, allEditors.length); + + FileEditorManager.getInstance(getProject()).closeFile(a); + FileEditorManager.getInstance(getProject()).closeFile(b); + ProjectManagerEx.getInstanceEx().closeAndDispose(getProject()); + + LeakHunter.checkLeak(ApplicationManager.getApplication(), PsiFileImpl.class, new Processor() { + @Override + public boolean process(PsiFileImpl psiFile) { + return psiFile.getViewProvider().getVirtualFile().getFileSystem() instanceof LocalFileSystem; + } + }); + } + + @Override + protected boolean isRunInWriteAction() { + return false; + } +}