HtmlCompletionTest doesn't depend on codeInsight-tests and is light
[fedora-idea.git] / platform / testFramework / src / com / intellij / testFramework / fixtures / LightPlatformCodeInsightFixtureTestCase.java
blobffc2b0973de396517fff293714d754e8a811fc4f
1 /*
2 * Copyright (c) 2000-2005 by JetBrains s.r.o. All Rights Reserved.
3 * Use is subject to license terms.
4 */
5 package com.intellij.testFramework.fixtures;
7 import com.intellij.lang.Language;
8 import com.intellij.openapi.application.PathManager;
9 import com.intellij.openapi.application.Result;
10 import com.intellij.openapi.command.WriteCommandAction;
11 import com.intellij.openapi.fileTypes.FileType;
12 import com.intellij.openapi.module.Module;
13 import com.intellij.openapi.project.Project;
14 import com.intellij.psi.PsiFile;
15 import com.intellij.psi.PsiFileFactory;
16 import com.intellij.psi.PsiManager;
17 import com.intellij.testFramework.LightProjectDescriptor;
18 import com.intellij.testFramework.UsefulTestCase;
19 import com.intellij.testFramework.fixtures.impl.LightTempDirTestFixtureImpl;
20 import org.jetbrains.annotations.NonNls;
22 import java.io.File;
24 /**
25 * @author peter
27 public abstract class LightPlatformCodeInsightFixtureTestCase extends UsefulTestCase{
28 protected CodeInsightTestFixture myFixture;
29 protected Module myModule;
31 protected void setUp() throws Exception {
32 super.setUp();
34 IdeaTestFixtureFactory factory = IdeaTestFixtureFactory.getFixtureFactory();
35 TestFixtureBuilder<IdeaProjectTestFixture> fixtureBuilder = factory.createLightFixtureBuilder(getProjectDescriptor());
36 final IdeaProjectTestFixture fixture = fixtureBuilder.getFixture();
37 myFixture = IdeaTestFixtureFactory.getFixtureFactory().createCodeInsightFixture(fixture, new LightTempDirTestFixtureImpl(true));
39 myFixture.setUp();
40 myFixture.setTestDataPath(getTestDataPath());
42 myModule = myFixture.getModule();
45 /**
46 * Return relative path to the test data.
48 * @return relative path to the test data.
50 @NonNls
51 protected String getBasePath() {
52 return "";
55 protected LightProjectDescriptor getProjectDescriptor() {
56 return null;
60 /**
61 * Return absolute path to the test data. Not intended to be overrided.
63 * @return absolute path to the test data.
65 @NonNls
66 protected final String getTestDataPath() {
67 return PathManager.getHomePath().replace(File.separatorChar, '/') + getBasePath();
70 protected void tearDown() throws Exception {
71 myFixture.tearDown();
72 myFixture = null;
73 myModule = null;
74 super.tearDown();
77 protected void runTest() throws Throwable {
78 new WriteCommandAction(getProject()) {
79 protected void run(Result result) throws Throwable {
80 LightPlatformCodeInsightFixtureTestCase.super.runTest();
82 }.execute();
85 protected Project getProject() {
86 return myFixture.getProject();
89 protected PsiManager getPsiManager() {
90 return PsiManager.getInstance(getProject());
93 protected PsiFile createLightFile(final FileType fileType, final String text) {
94 return PsiFileFactory.getInstance(getProject()).createFileFromText("a." + fileType.getDefaultExtension(), fileType, text);
97 public PsiFile createLightFile(final String fileName, final Language language, final String text) {
98 return PsiFileFactory.getInstance(getProject()).createFileFromText(fileName, language, text, false, true);