to LightTest

This commit is contained in:
Anna.Kozlova
2019-01-31 18:22:13 +01:00
parent f2b9476d0f
commit 600438d003
@@ -15,56 +15,85 @@
*/
package com.intellij.java.codeInsight.daemon;
import com.intellij.codeInsight.daemon.DaemonAnalyzerTestCase;
import com.intellij.JavaTestUtil;
import com.intellij.codeInsight.daemon.impl.analysis.FileHighlightingSetting;
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingSettingsPerFile;
import com.intellij.psi.PsiFile;
import com.intellij.codeInspection.unusedImport.UnusedImportInspection;
import com.intellij.psi.PsiFile;
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase;
public class UnusedImportsTest extends DaemonAnalyzerTestCase {
private static final String BASE_PATH = "/codeInsight/daemonCodeAnalyzer/unusedImports";
public class UnusedImportsTest extends LightCodeInsightFixtureTestCase {
private static final String BASE_PATH = "/codeInsight/daemonCodeAnalyzer/unusedImports/";
@Override
protected String getBasePath() {
return JavaTestUtil.getRelativeJavaTestDataPath() + BASE_PATH;
}
@Override
protected void setUp() throws Exception {
super.setUp();
enableInspectionTool(new UnusedImportInspection());
myFixture.enableInspections(new UnusedImportInspection());
}
public void test1() throws Exception { doTest(); }
public void test2() throws Exception { doTest(); }
public void test1() { doTest(); }
public void test2() { doTest(); }
public void testWithHighlightingOff() throws Exception {
configureByFile(BASE_PATH + "/" + getTestName(false) + ".java");
public void testWithHighlightingOff() {
myFixture.configureByFile(getTestName(false) + ".java");
final PsiFile file = getFile();
final HighlightingSettingsPerFile settingsPerFile = HighlightingSettingsPerFile.getInstance(myProject);
final HighlightingSettingsPerFile settingsPerFile = HighlightingSettingsPerFile.getInstance(getProject());
final FileHighlightingSetting oldSetting = settingsPerFile.getHighlightingSettingForRoot(file);
try {
settingsPerFile.setHighlightingSettingForRoot(file, FileHighlightingSetting.NONE);
doDoTest(true, false, false);
myFixture.checkHighlighting(true, false, false);
}
finally {
settingsPerFile.setHighlightingSettingForRoot(file, oldSetting);
}
}
public void testUnclosed() throws Exception { doTest(); }
public void testUnclosed() { doTest(); }
public void testQualified() throws Exception { doTest(); }
public void testQualified() { doTest(); }
public void testInnersOnDemand1() throws Exception { doTest(); }
public void testInnersOnDemand2() throws Exception { doTest(); }
public void testStaticImportingInner() throws Exception {
doTest(BASE_PATH + "/" + getTestName(false) + ".java", BASE_PATH, true, false);
public void testInnersOnDemand1() { doTest(); }
public void testInnersOnDemand2() { doTest(); }
public void testStaticImportingInner() {
myFixture.addClass("package package1;\n" +
"/** @noinspection ALL*/ public interface c\n" +
"{\n" +
" public interface MyInner\n" +
" {\n" +
" int a = 1;\n" +
" int b = 2;\n" +
" }\n" +
"}");
myFixture.configureByFile(getTestName(false) + ".java");
myFixture.checkHighlighting(true, false, false);
}
public void testImportFromSamePackage1() throws Exception {
doTest(BASE_PATH+"/package1/a.java", BASE_PATH,true,false);
public void testImportFromSamePackage1() {
myFixture.addClass("package package1;\n" +
"import package1.*;" +
"class b {\n" +
" a a = null;\n" +
"}");
myFixture.configureByFile("/package1/a.java");
myFixture.checkHighlighting(true,false, false);
}
public void testImportFromSamePackage2() throws Exception {
doTest(BASE_PATH+"/package1/b.java", BASE_PATH,true,false);
public void testImportFromSamePackage2() {
myFixture.addClass("package package1;\n" +
"import package1.b;\n" +
"class a {\n" +
" b b = null;\n" +
"}");
myFixture.configureByFile("/package1/b.java");
myFixture.checkHighlighting(true,false, false);
}
protected void doTest() throws Exception {
doTest(BASE_PATH + "/" + getTestName(false) + ".java", true, false);
private void doTest() {
myFixture.configureByFile(getTestName(false) + ".java");
myFixture.checkHighlighting(true, false, false);
}
}