mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
convert to light test
This commit is contained in:
@@ -1,16 +1,31 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.codeInsight;
|
||||
|
||||
import com.intellij.codeInsight.daemon.DaemonAnalyzerTestCase;
|
||||
import com.intellij.codeInsight.documentation.DocumentationManager;
|
||||
import com.intellij.lang.documentation.DocumentationProvider;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VfsUtilCore;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiDocumentManager;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.testFramework.PlatformTestUtil;
|
||||
import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
@@ -19,7 +34,7 @@ import java.io.File;
|
||||
* @by maxim
|
||||
*/
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
public class XmlDocumentationTest extends DaemonAnalyzerTestCase {
|
||||
public class XmlDocumentationTest extends LightPlatformCodeInsightFixtureTestCase {
|
||||
|
||||
public void testXmlDoc() throws Exception {
|
||||
doOneTest("1.xml", "display-name", false, "web-app_2_3.dtd");
|
||||
@@ -96,10 +111,16 @@ public class XmlDocumentationTest extends DaemonAnalyzerTestCase {
|
||||
}
|
||||
|
||||
private void doOneTest(String fileName, String lookupObject, boolean testExternal, String... additional) throws Exception {
|
||||
configureByFiles(null, additional);
|
||||
copyAdditionalFiles(additional);
|
||||
doOneTest(fileName, lookupObject, testExternal, true, "web-app_2_4.xsd");
|
||||
}
|
||||
|
||||
private void copyAdditionalFiles(String[] additional) {
|
||||
for (String file : additional) {
|
||||
myFixture.copyFileToProject(file);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
public class DocumentationTestContext {
|
||||
final DocumentationProvider documentationProvider;
|
||||
@@ -108,10 +129,10 @@ public class XmlDocumentationTest extends DaemonAnalyzerTestCase {
|
||||
final PsiFile psiFile;
|
||||
|
||||
DocumentationTestContext(String... fileNames) throws Exception {
|
||||
configureByFiles(null,fileNames);
|
||||
psiFile = PsiDocumentManager.getInstance(myProject).getPsiFile(myEditor.getDocument());
|
||||
originalElement = psiFile.findElementAt(myEditor.getCaretModel().getOffset());
|
||||
element = DocumentationManager.getInstance(myProject).findTargetElement(myEditor, myFile, originalElement);
|
||||
copyAdditionalFiles(fileNames);
|
||||
psiFile = myFixture.configureByFile(fileNames[0]);
|
||||
originalElement = psiFile.findElementAt(myFixture.getEditor().getCaretModel().getOffset());
|
||||
element = DocumentationManager.getInstance(getProject()).findTargetElement(myFixture.getEditor(), psiFile, originalElement);
|
||||
|
||||
if (element == null) {
|
||||
element = originalElement;
|
||||
@@ -132,15 +153,14 @@ public class XmlDocumentationTest extends DaemonAnalyzerTestCase {
|
||||
|
||||
@Nullable
|
||||
public String generateDocForCompletion(Object completionVariant) {
|
||||
PsiElement lookupItem = documentationProvider.getDocumentationElementForLookupItem(myPsiManager, completionVariant, originalElement);
|
||||
PsiElement lookupItem = documentationProvider.getDocumentationElementForLookupItem(getPsiManager(), completionVariant, originalElement);
|
||||
assert lookupItem != null;
|
||||
return documentationProvider.generateDoc(lookupItem, originalElement);
|
||||
}
|
||||
}
|
||||
|
||||
private void doOneTest(String fileName, String lookupObject, boolean testExternal, boolean testForElementUnderCaret, String... additional) throws Exception {
|
||||
|
||||
configureByFiles(null, additional);
|
||||
copyAdditionalFiles(additional);
|
||||
final DocumentationTestContext context = new DocumentationTestContext(fileName);
|
||||
|
||||
if (testForElementUnderCaret) {
|
||||
@@ -169,6 +189,7 @@ public class XmlDocumentationTest extends DaemonAnalyzerTestCase {
|
||||
doQuickDocGenerationTestWithCheckExpectedResult((Object)"apply-imports", "xslCompletion.xsl");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected String getTestDataPath() {
|
||||
return PlatformTestUtil.getCommunityPath() + "/xml/tests/testData/documentation/";
|
||||
|
||||
@@ -1,10 +1,26 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.codeInsight;
|
||||
|
||||
import com.intellij.openapi.fileTypes.StdFileTypes;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiFileFactory;
|
||||
import com.intellij.psi.xml.XmlFile;
|
||||
import com.intellij.psi.xml.XmlTag;
|
||||
import com.intellij.testFramework.PsiTestCase;
|
||||
import com.intellij.testFramework.LightPlatformTestCase;
|
||||
import com.intellij.xml.XmlAttributeDescriptor;
|
||||
import com.intellij.xml.XmlElementDescriptor;
|
||||
import com.intellij.xml.XmlNSDescriptor;
|
||||
@@ -14,7 +30,7 @@ import com.intellij.xml.impl.dtd.XmlNSDescriptorImpl;
|
||||
/**
|
||||
* @author Mike
|
||||
*/
|
||||
public class XmlDtdTest extends PsiTestCase {
|
||||
public class XmlDtdTest extends LightPlatformTestCase {
|
||||
public void testDocumentDescriptor1() throws Exception {
|
||||
XmlNSDescriptor NSDescriptor = createDescriptor("<!ELEMENT principals (#PCDATA)><!ELEMENT data-sources (#PCDATA)>");
|
||||
|
||||
@@ -294,7 +310,7 @@ public class XmlDtdTest extends PsiTestCase {
|
||||
}
|
||||
|
||||
public void testEmbeddedDtd1() throws Exception {
|
||||
XmlFile xmlFile = (XmlFile)createDummyFile("test.xml",
|
||||
XmlFile xmlFile = (XmlFile)createFile("test.xml",
|
||||
"<!DOCTYPE tv [ <!ELEMENT tv (date)*> <!ELEMENT date (#PCDATA)> ]> <tv></tv>");
|
||||
|
||||
final XmlTag tag = xmlFile.getDocument().getRootTag();
|
||||
@@ -307,16 +323,16 @@ public class XmlDtdTest extends PsiTestCase {
|
||||
assertEquals("date", elements[0].getName());
|
||||
}
|
||||
|
||||
private XmlNSDescriptor createDescriptor(String dtdText) throws Exception {
|
||||
PsiFile dtdFile = createDummyFile("test.dtd", dtdText);
|
||||
private static XmlNSDescriptor createDescriptor(String dtdText) throws Exception {
|
||||
PsiFile dtdFile = createLightFile("test.dtd", dtdText);
|
||||
|
||||
XmlNSDescriptorImpl descriptor = new XmlNSDescriptorImpl();
|
||||
descriptor.init(dtdFile);
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
private XmlTag tag(String tagName) throws Exception {
|
||||
XmlFile file = (XmlFile)PsiFileFactory.getInstance(myPsiManager.getProject()).createFileFromText("tag.xml", "<" + tagName + "/>");
|
||||
private static XmlTag tag(String tagName) throws Exception {
|
||||
XmlFile file = (XmlFile)PsiFileFactory.getInstance(getProject()).createFileFromText("tag.xml", StdFileTypes.XML, "<" + tagName + "/>");
|
||||
return file.getDocument().getRootTag();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,23 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.codeInsight;
|
||||
|
||||
import com.intellij.psi.PsiFileFactory;
|
||||
import com.intellij.psi.xml.XmlFile;
|
||||
import com.intellij.psi.xml.XmlTag;
|
||||
import com.intellij.testFramework.PsiTestCase;
|
||||
import com.intellij.testFramework.LightPlatformTestCase;
|
||||
import com.intellij.xml.XmlAttributeDescriptor;
|
||||
import com.intellij.xml.XmlElementDescriptor;
|
||||
import com.intellij.xml.XmlNSDescriptor;
|
||||
@@ -11,7 +25,7 @@ import com.intellij.xml.XmlNSDescriptor;
|
||||
/**
|
||||
* @author Mike
|
||||
*/
|
||||
public class XmlInsightTest extends PsiTestCase {
|
||||
public class XmlInsightTest extends LightPlatformTestCase {
|
||||
public void testDocumentDescriptor1() throws Exception {
|
||||
XmlFile file = createFile("<root><a></a><b></b><a></a></root>");
|
||||
XmlNSDescriptor descriptor = createDescriptor(file);
|
||||
@@ -129,16 +143,12 @@ public class XmlInsightTest extends PsiTestCase {
|
||||
assertTrue(attributes[1].isRequired());
|
||||
}
|
||||
|
||||
private XmlFile createFile(String text) throws Exception {
|
||||
return (XmlFile)createDummyFile("test.xml", text);
|
||||
private static XmlFile createFile(String text) throws Exception {
|
||||
return (XmlFile)createFile("test.xml", text);
|
||||
}
|
||||
|
||||
private XmlNSDescriptor createDescriptor(XmlFile file) throws Exception{
|
||||
private static XmlNSDescriptor createDescriptor(XmlFile file) throws Exception{
|
||||
return file.getDocument().getRootTagNSDescriptor();
|
||||
}
|
||||
|
||||
private XmlTag tag(String tagName) throws Exception {
|
||||
XmlFile file = (XmlFile)PsiFileFactory.getInstance(myPsiManager.getProject()).createFileFromText("tag.xml", "<" + tagName + "/>");
|
||||
return file.getDocument().getRootTag();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -15,9 +15,9 @@
|
||||
*/
|
||||
package com.intellij.codeInsight.editorActions.moveUpDown;
|
||||
|
||||
import com.intellij.codeInsight.CodeInsightTestCase;
|
||||
import com.intellij.openapi.command.WriteCommandAction;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorActionHandler;
|
||||
import com.intellij.testFramework.LightPlatformCodeInsightTestCase;
|
||||
import com.intellij.testFramework.PlatformTestUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
@@ -27,7 +27,7 @@ import java.io.File;
|
||||
* @author spleaner
|
||||
*/
|
||||
@SuppressWarnings({"ALL"})
|
||||
public class XmlMoverTest extends CodeInsightTestCase {
|
||||
public class XmlMoverTest extends LightPlatformCodeInsightTestCase {
|
||||
|
||||
public void testTag() throws Exception { doTest("xml"); }
|
||||
public void testTag2() throws Exception { doTest("xml"); }
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -15,13 +15,12 @@
|
||||
*/
|
||||
package com.intellij.html;
|
||||
|
||||
import com.intellij.codeInsight.CodeInsightTestCase;
|
||||
import com.intellij.codeInsight.documentation.DocumentationManager;
|
||||
import com.intellij.lang.documentation.DocumentationProvider;
|
||||
import com.intellij.openapi.fileTypes.StdFileTypes;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.testFramework.LightPlatformCodeInsightTestCase;
|
||||
|
||||
public class HtmlDocumentationTest extends CodeInsightTestCase {
|
||||
public class HtmlDocumentationTest extends LightPlatformCodeInsightTestCase {
|
||||
public void testQuickDocumentationHtml5Tag() throws Exception {
|
||||
doTest("<!DOCTYPE html>\n" +
|
||||
"<html>\n" +
|
||||
@@ -65,8 +64,8 @@ public class HtmlDocumentationTest extends CodeInsightTestCase {
|
||||
"</html>");
|
||||
}
|
||||
|
||||
private void doTest(String text) throws Exception {
|
||||
configureByText(StdFileTypes.HTML, text);
|
||||
private static void doTest(String text) throws Exception {
|
||||
configureFromFileText("test.html", text);
|
||||
PsiElement originalElement = getFile().findElementAt(myEditor.getCaretModel().getOffset());
|
||||
PsiElement element = DocumentationManager.getInstance(getProject()).findTargetElement(getEditor(), getFile());
|
||||
DocumentationProvider documentationProvider = DocumentationManager.getProviderFromElement(originalElement);
|
||||
|
||||
Reference in New Issue
Block a user