diff --git a/plugins/htmltools/BUILD.bazel b/plugins/htmltools/BUILD.bazel index 841391252c31..aecf6bc3f5b8 100644 --- a/plugins/htmltools/BUILD.bazel +++ b/plugins/htmltools/BUILD.bazel @@ -54,7 +54,6 @@ jvm_library( "//platform/editor-ui-api:editor-ui", "//platform/projectModel-api:projectModel", "//xml/impl", - "//java/testFramework", "//platform/testFramework", "//platform/testFramework:testFramework_test_lib", "//spellchecker", @@ -64,6 +63,10 @@ jvm_library( "//platform/core-ui", "//tools/intellij.tools.ide.metrics.benchmark:ide-metrics-benchmark", "//tools/intellij.tools.ide.metrics.benchmark:ide-metrics-benchmark_test_lib", + "//platform/analysis-impl", + "//platform/lang-impl", + "//xml/xml-parser:parser", + "//platform/refactoring", ] ) diff --git a/plugins/htmltools/intellij.html.tools.tests.iml b/plugins/htmltools/intellij.html.tools.tests.iml index 3dc49ee350e7..cf6ce47a4000 100644 --- a/plugins/htmltools/intellij.html.tools.tests.iml +++ b/plugins/htmltools/intellij.html.tools.tests.iml @@ -14,12 +14,15 @@ - + + + + \ No newline at end of file diff --git a/plugins/htmltools/testData/inspections/reportingXmlHighlightVisitorProblems/expected.xml b/plugins/htmltools/testData/inspections/reportingXmlHighlightVisitorProblems/expected.xml deleted file mode 100644 index 4806a9b32562..000000000000 --- a/plugins/htmltools/testData/inspections/reportingXmlHighlightVisitorProblems/expected.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - ReportingXmlHighlightVisitorProblems.xhtml - 2 - Attribute cl is not allowed here #loc - - - diff --git a/plugins/htmltools/testData/inspections/reportingXmlHighlightVisitorProblems/src/ReportingXmlHighlightVisitorProblems.xhtml b/plugins/htmltools/testData/inspections/reportingXmlHighlightVisitorProblems/src/ReportingXmlHighlightVisitorProblems.xhtml deleted file mode 100644 index eb110228248d..000000000000 --- a/plugins/htmltools/testData/inspections/reportingXmlHighlightVisitorProblems/src/ReportingXmlHighlightVisitorProblems.xhtml +++ /dev/null @@ -1,3 +0,0 @@ -
-
-
\ No newline at end of file diff --git a/plugins/htmltools/testData/inspections/xmlHighlightVisitor/ReportingXmlHighlightVisitorProblems.xhtml b/plugins/htmltools/testData/inspections/xmlHighlightVisitor/ReportingXmlHighlightVisitorProblems.xhtml new file mode 100644 index 000000000000..eb706eb9ce23 --- /dev/null +++ b/plugins/htmltools/testData/inspections/xmlHighlightVisitor/ReportingXmlHighlightVisitorProblems.xhtml @@ -0,0 +1,3 @@ +
+
cl="aaa"/> +
\ No newline at end of file diff --git a/plugins/htmltools/testData/refactoring/move/html/after/A.html b/plugins/htmltools/testData/refactoring/move/html/after/A.html deleted file mode 100644 index 9dd0b1383c53..000000000000 --- a/plugins/htmltools/testData/refactoring/move/html/after/A.html +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/plugins/htmltools/testData/refactoring/move/html/after/toDir/B.html b/plugins/htmltools/testData/refactoring/move/html/after/toDir/B.html deleted file mode 100644 index a2f7f362ccd9..000000000000 --- a/plugins/htmltools/testData/refactoring/move/html/after/toDir/B.html +++ /dev/null @@ -1 +0,0 @@ -anchor \ No newline at end of file diff --git a/plugins/htmltools/testData/refactoring/move/html/after/toDir/donotdelete.txt b/plugins/htmltools/testData/refactoring/move/html/after/toDir/donotdelete.txt deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/plugins/htmltools/testData/refactoring/move/html/before/A.html b/plugins/htmltools/testData/refactoring/move/html/before/A.html deleted file mode 100644 index a2a657d51f37..000000000000 --- a/plugins/htmltools/testData/refactoring/move/html/before/A.html +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/plugins/htmltools/testData/refactoring/move/html/before/B.html b/plugins/htmltools/testData/refactoring/move/html/before/B.html deleted file mode 100644 index 93d059c9a8a6..000000000000 --- a/plugins/htmltools/testData/refactoring/move/html/before/B.html +++ /dev/null @@ -1 +0,0 @@ -anchor \ No newline at end of file diff --git a/plugins/htmltools/testData/refactoring/move/html/before/toDir/donotdelete.txt b/plugins/htmltools/testData/refactoring/move/html/before/toDir/donotdelete.txt deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/plugins/htmltools/testSrc/com/intellij/htmltools/codeInsight/daemon/GlobalHtmlHighlightingTest.java b/plugins/htmltools/testSrc/com/intellij/htmltools/codeInsight/daemon/GlobalHtmlHighlightingTest.java index 8677c1208955..d9d217104cce 100644 --- a/plugins/htmltools/testSrc/com/intellij/htmltools/codeInsight/daemon/GlobalHtmlHighlightingTest.java +++ b/plugins/htmltools/testSrc/com/intellij/htmltools/codeInsight/daemon/GlobalHtmlHighlightingTest.java @@ -3,13 +3,13 @@ package com.intellij.htmltools.codeInsight.daemon; import com.intellij.codeInsight.daemon.impl.analysis.XmlHighlightVisitorBasedInspection; import com.intellij.javaee.ExternalResourceManagerEx; import com.intellij.openapi.application.PathManager; -import com.intellij.testFramework.JavaInspectionTestCase; +import com.intellij.testFramework.fixtures.BasePlatformTestCase; import com.intellij.xml.util.XmlUtil; /** * @author Maxim.Mossienko */ -public class GlobalHtmlHighlightingTest extends JavaInspectionTestCase { +public class GlobalHtmlHighlightingTest extends BasePlatformTestCase { private String myOldDoctype; @Override @@ -18,6 +18,7 @@ public class GlobalHtmlHighlightingTest extends JavaInspectionTestCase { final ExternalResourceManagerEx manager = ExternalResourceManagerEx.getInstanceEx(); myOldDoctype = manager.getDefaultHtmlDoctype(getProject()); manager.setDefaultHtmlDoctype(XmlUtil.XHTML_URI, getProject()); + myFixture.enableInspections(new XmlHighlightVisitorBasedInspection()); } @Override @@ -34,11 +35,17 @@ public class GlobalHtmlHighlightingTest extends JavaInspectionTestCase { } public void testReportingXmlHighlightVisitorProblems() { - doTest(getTestName(true), new XmlHighlightVisitorBasedInspection()); + myFixture.configureByFile(getBasePath() + getTestName(false) + ".xhtml"); + myFixture.testHighlighting(); } @Override public String getTestDataPath() { return PathManager.getCommunityHomePath() + "/plugins/htmltools/testData/inspections"; } + + @Override + protected String getBasePath() { + return "xmlHighlightVisitor/"; + } } \ No newline at end of file diff --git a/plugins/htmltools/testSrc/com/intellij/htmltools/codeInspection/HtmlDeprecatedTagsReplaceTest.java b/plugins/htmltools/testSrc/com/intellij/htmltools/codeInspection/HtmlDeprecatedTagsReplaceTest.java index f7c4d28521ad..6cb960cc8a68 100644 --- a/plugins/htmltools/testSrc/com/intellij/htmltools/codeInspection/HtmlDeprecatedTagsReplaceTest.java +++ b/plugins/htmltools/testSrc/com/intellij/htmltools/codeInspection/HtmlDeprecatedTagsReplaceTest.java @@ -1,12 +1,11 @@ package com.intellij.htmltools.codeInspection; -import com.intellij.codeInsight.daemon.quickFix.LightQuickFixTestCase; import com.intellij.codeInsight.intention.IntentionAction; -import com.intellij.codeInspection.LocalInspectionTool; import com.intellij.htmltools.codeInspection.htmlInspections.HtmlDeprecatedTagInspection; import com.intellij.htmltools.codeInspection.htmlInspections.HtmlPresentationalElementInspection; import com.intellij.javaee.ExternalResourceManagerEx; import com.intellij.openapi.application.PathManager; +import com.intellij.testFramework.fixtures.BasePlatformTestCase; import com.intellij.testFramework.fixtures.CodeInsightTestUtil; import com.intellij.xml.analysis.XmlAnalysisBundle; import com.intellij.xml.util.XmlUtil; @@ -14,17 +13,9 @@ import org.jetbrains.annotations.NotNull; import java.util.List; -public class HtmlDeprecatedTagsReplaceTest extends LightQuickFixTestCase { +public class HtmlDeprecatedTagsReplaceTest extends BasePlatformTestCase { static final String BASE_PATH = "/deprecatedTag"; - @Override - protected LocalInspectionTool @NotNull [] configureLocalInspectionTools() { - return new LocalInspectionTool[] { - new HtmlDeprecatedTagInspection(), - new HtmlPresentationalElementInspection() - }; - } - private String myOldDoctype; @Override @@ -33,6 +24,7 @@ public class HtmlDeprecatedTagsReplaceTest extends LightQuickFixTestCase { final ExternalResourceManagerEx manager = ExternalResourceManagerEx.getInstanceEx(); myOldDoctype = manager.getDefaultHtmlDoctype(getProject()); manager.setDefaultHtmlDoctype(XmlUtil.XHTML_URI, getProject()); + myFixture.enableInspections(new HtmlDeprecatedTagInspection(), new HtmlPresentationalElementInspection()); } @Override @@ -60,29 +52,29 @@ public class HtmlDeprecatedTagsReplaceTest extends LightQuickFixTestCase { } public void testXml() { - configureByFile(BASE_PATH + "/html_deptag5.xml"); - final List list = getAvailableActions(); + myFixture.configureByFile(BASE_PATH + "/html_deptag5.xml"); + final List list = myFixture.getAvailableIntentions(); final IntentionAction action = CodeInsightTestUtil.findIntentionByText(list, "Replace font tag with CSS"); assertNull(action); } public void testFitMenu() { - configureByFile(BASE_PATH + "/html_deptag5.xhtml"); - final List list = getAvailableActions(); + myFixture.configureByFile(BASE_PATH + "/html_deptag5.xhtml"); + final List list = myFixture.getAvailableIntentions(); final IntentionAction action = CodeInsightTestUtil.findIntentionByText(list, "Replace menu tag with ul tag"); assertNull(action); } public void testSwitchToHtml5QuickFix() { - configureByFile(BASE_PATH + '/' + getTestName(false) + ".html"); - final List list = getAvailableActions(); + myFixture.configureByFile(BASE_PATH + '/' + getTestName(false) + ".html"); + final List list = myFixture.getAvailableIntentions(); final IntentionAction action = CodeInsightTestUtil.findIntentionByText(list, XmlAnalysisBundle.message("html.quickfix.switch.to.html5")); assertNotNull(action); } public void testSwitchToHtml5QuickFix1() { - configureByFile(BASE_PATH + '/' + getTestName(false) + ".html"); - final List list = getAvailableActions(); + myFixture.configureByFile(BASE_PATH + '/' + getTestName(false) + ".html"); + final List list = myFixture.getAvailableIntentions(); final IntentionAction action = CodeInsightTestUtil.findIntentionByText(list, XmlAnalysisBundle.message("html.quickfix.switch.to.html5")); assertNull(action); } diff --git a/plugins/htmltools/testSrc/com/intellij/htmltools/codeInspection/HtmlInsertRequiredAttributeTest.java b/plugins/htmltools/testSrc/com/intellij/htmltools/codeInspection/HtmlInsertRequiredAttributeTest.java index d1d6019c89c7..b4541a009ae1 100644 --- a/plugins/htmltools/testSrc/com/intellij/htmltools/codeInspection/HtmlInsertRequiredAttributeTest.java +++ b/plugins/htmltools/testSrc/com/intellij/htmltools/codeInspection/HtmlInsertRequiredAttributeTest.java @@ -1,9 +1,7 @@ package com.intellij.htmltools.codeInspection; import com.intellij.application.options.CodeStyle; -import com.intellij.codeInsight.daemon.quickFix.LightQuickFixTestCase; import com.intellij.codeInsight.intention.IntentionAction; -import com.intellij.codeInspection.LocalInspectionTool; import com.intellij.codeInspection.htmlInspections.RequiredAttributesInspection; import com.intellij.htmltools.HtmlToolsBundle; import com.intellij.htmltools.codeInspection.htmlInspections.HtmlRequiredAltAttributeInspection; @@ -13,28 +11,26 @@ import com.intellij.htmltools.codeInspection.htmlInspections.HtmlRequiredTitleEl import com.intellij.openapi.application.PathManager; import com.intellij.psi.codeStyle.CodeStyleSettings; import com.intellij.psi.formatter.xml.HtmlCodeStyleSettings; +import com.intellij.testFramework.fixtures.BasePlatformTestCase; import com.intellij.testFramework.fixtures.CodeInsightTestUtil; import com.intellij.xml.psi.XmlPsiBundle; import org.jetbrains.annotations.NotNull; import java.util.List; -public class HtmlInsertRequiredAttributeTest extends LightQuickFixTestCase { - +public class HtmlInsertRequiredAttributeTest extends BasePlatformTestCase { public static final String BASE_PATH = "/insertRequiredAttribute"; @Override - protected LocalInspectionTool @NotNull [] configureLocalInspectionTools() { - return new LocalInspectionTool[]{ - new RequiredAttributesInspection(), - new HtmlRequiredAltAttributeInspection(), - new HtmlRequiredLangAttributeInspection(), - new HtmlRequiredTitleElementInspection(), - new HtmlRequiredSummaryAttributeInspection() - }; + protected void setUp() throws Exception { + super.setUp(); + myFixture.enableInspections(new RequiredAttributesInspection(), + new HtmlRequiredAltAttributeInspection(), + new HtmlRequiredLangAttributeInspection(), + new HtmlRequiredTitleElementInspection(), + new HtmlRequiredSummaryAttributeInspection()); } - @Override protected String getBasePath() { return BASE_PATH; @@ -47,7 +43,7 @@ public class HtmlInsertRequiredAttributeTest extends LightQuickFixTestCase { } public void testInsertDefaultAttribute() { - doSingleTest(getTestName(false) + ".html"); + doSingleTest(); } public void testDefaultWithChangedQuote() { @@ -55,13 +51,20 @@ public class HtmlInsertRequiredAttributeTest extends LightQuickFixTestCase { final CodeStyleSettings.QuoteStyle oldQuote = settings.HTML_QUOTE_STYLE; try { settings.HTML_QUOTE_STYLE = CodeStyleSettings.QuoteStyle.Single; - doSingleTest(getTestName(false) + ".html"); + doSingleTest(); } finally { settings.HTML_QUOTE_STYLE = oldQuote; } } + private void doSingleTest() { + myFixture.configureByFile(BASE_PATH + "/before" + getTestName(false) + ".html"); + var intention = myFixture.findSingleIntention("Insert required attribute 'src'"); + myFixture.launchAction(intention); + myFixture.checkResultByFile(BASE_PATH + "/after" + getTestName(false) + ".html"); + } + public void testInsertRequiredAltInput() { checkInspection("insertRequiredAltInput_before.html", "insertRequiredAltInput_after.html", "alt", XmlPsiBundle.message("xml.quickfix.insert.required.attribute.text", "alt")); @@ -141,17 +144,17 @@ public class HtmlInsertRequiredAttributeTest extends LightQuickFixTestCase { } private void checkInspection(String fileNameBefore, String fileNameAfter, String folder, String intention) { - configureByFile(BASE_PATH + "/" + folder + "/" + fileNameBefore); - final List list = getAvailableActions(); + myFixture.configureByFile(BASE_PATH + "/" + folder + "/" + fileNameBefore); + final List list = myFixture.getAvailableIntentions(); final IntentionAction action = CodeInsightTestUtil.findIntentionByPartialText(list, intention); assertNotNull(action); - invoke(action); - checkResultByFile(BASE_PATH + "/" + folder + "/" + fileNameAfter); + myFixture.launchAction(action); + myFixture.checkResultByFile(BASE_PATH + "/" + folder + "/" + fileNameAfter); } private void checkInspectionDoesNotExist(String fileNameBefore, String intention, String folder) { - configureByFile(BASE_PATH + "/" + folder + "/" + fileNameBefore); - final List list = getAvailableActions(); + myFixture.configureByFile(BASE_PATH + "/" + folder + "/" + fileNameBefore); + final List list = myFixture.getAvailableIntentions(); final IntentionAction action = CodeInsightTestUtil.findIntentionByPartialText(list, intention); assertNull(action); } diff --git a/plugins/htmltools/testSrc/com/intellij/refactoring/MoveHtmlFileTest.java b/plugins/htmltools/testSrc/com/intellij/refactoring/MoveHtmlFileTest.java index 9bc8644a0356..29e44cf8523e 100644 --- a/plugins/htmltools/testSrc/com/intellij/refactoring/MoveHtmlFileTest.java +++ b/plugins/htmltools/testSrc/com/intellij/refactoring/MoveHtmlFileTest.java @@ -1,13 +1,36 @@ package com.intellij.refactoring; -import com.intellij.openapi.application.PathManager; -import org.jetbrains.annotations.NotNull; +import com.intellij.openapi.application.WriteAction; +import com.intellij.psi.PsiElement; +import com.intellij.refactoring.move.moveFilesOrDirectories.MoveFilesOrDirectoriesProcessor; +import com.intellij.testFramework.fixtures.BasePlatformTestCase; -public class MoveHtmlFileTest extends MoveFileTestCase { - @Override - protected @NotNull String getTestDataPath() { - return PathManager.getCommunityHomePath() + "/plugins/htmltools/testData/refactoring/move/"; +public class MoveHtmlFileTest extends BasePlatformTestCase { + public void testHtml() { + myFixture.configureByText("A.html", """ + + + + + + + + """); + var b = myFixture.addFileToProject("B.html", """ + anchor + """); + var targetDir = WriteAction.compute(() -> myFixture.getFile().getContainingDirectory().createSubdirectory("toDir")); + new MoveFilesOrDirectoriesProcessor( + getProject(), new PsiElement[]{b}, targetDir, false, false, null, null + ).run(); + myFixture.checkResult(""" + + + + + + + + """); } - - public void testHtml() { doTest("toDir", "B.html"); } }