summaryrefslogtreecommitdiff
path: root/xml/tests
diff options
context:
space:
mode:
authorTor Norbye <tnorbye@google.com>2013-05-31 07:45:51 -0700
committerTor Norbye <tnorbye@google.com>2013-05-31 07:45:51 -0700
commitec3fb1e06285c0467a7a20360ca80453bc7635d4 (patch)
tree2402cdec34611f34b8385ff45387d6734bf6f994 /xml/tests
parenta6eac331b3d9f0d4168b12356ea256c83f4e9c05 (diff)
downloadidea-ec3fb1e06285c0467a7a20360ca80453bc7635d4.tar.gz
Snapshot 568f05589922685b8c8f9a2f2f465043b8128542 from master branch of git://git.jetbrains.org/idea/community.git
Change-Id: I47fe8cb5d8a3c9876cd4c313dca1a8cc531288ec
Diffstat (limited to 'xml/tests')
-rw-r--r--xml/tests/src/com/intellij/codeInsight/XmlParsingTest.java2
-rw-r--r--xml/tests/src/com/intellij/codeInsight/completion/XmlCompletionTest.java34
-rw-r--r--xml/tests/src/com/intellij/xml/index/XmlSchemaIndexTest.java14
-rw-r--r--xml/tests/testData/completion/DoNotSuggestExistingAttributes.xml6
-rw-r--r--xml/tests/testData/index/1/foo.dtd1
-rw-r--r--xml/tests/testData/index/2/foo.dtd1
-rw-r--r--xml/tests/testData/index/foo.xml0
7 files changed, 57 insertions, 1 deletions
diff --git a/xml/tests/src/com/intellij/codeInsight/XmlParsingTest.java b/xml/tests/src/com/intellij/codeInsight/XmlParsingTest.java
index acb90d91a0ac..85f01c54b656 100644
--- a/xml/tests/src/com/intellij/codeInsight/XmlParsingTest.java
+++ b/xml/tests/src/com/intellij/codeInsight/XmlParsingTest.java
@@ -671,7 +671,7 @@ public class XmlParsingTest extends ParsingTestCase {
doTest("<script type=\"application/custom\">Custom Script</script>", "test.html");
}
- static class MyLanguage extends Language {
+ static class MyLanguage extends Language implements InjectableLanguage {
protected MyLanguage() {
super("MyLanguage", "application/custom");
}
diff --git a/xml/tests/src/com/intellij/codeInsight/completion/XmlCompletionTest.java b/xml/tests/src/com/intellij/codeInsight/completion/XmlCompletionTest.java
index d1e5463e6c3d..574942bc1207 100644
--- a/xml/tests/src/com/intellij/codeInsight/completion/XmlCompletionTest.java
+++ b/xml/tests/src/com/intellij/codeInsight/completion/XmlCompletionTest.java
@@ -18,6 +18,8 @@ import com.intellij.psi.statistics.impl.StatisticsManagerImpl;
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase;
import com.intellij.xml.util.XmlUtil;
+import java.util.List;
+
/**
* @by Maxim.Mossienko
*/
@@ -612,5 +614,37 @@ public class XmlCompletionTest extends LightCodeInsightFixtureTestCase {
configureByFiles("foo.xsd", "bar.xsd");
basicDoTest("");
}
+
+ public void testDoNotSuggestExistingAttributes() throws Exception {
+ myFixture.configureByFile("DoNotSuggestExistingAttributes.xml");
+ myFixture.completeBasic();
+ List<String> strings = myFixture.getLookupElementStrings();
+ assertNotNull(strings);
+ assertFalse(strings.contains("xsi:schemaLocation"));
+ assertSameElements(strings, "attributeFormDefault",
+ "blockDefault",
+ "elementFormDefault",
+ "finalDefault",
+ "id",
+ "targetNamespace",
+ "version",
+ "xml:base",
+ "xml:id",
+ "xml:lang",
+ "xml:space",
+ "xsi:nill",
+ "xsi:noNamespaceSchemaLocation",
+ "xsi:type");
+ }
+
+ public void testRequiredAttributesOnTop() throws Exception {
+ myFixture.configureByText("foo.html", "<img <caret>");
+ myFixture.completeBasic();
+ List<String> strings = myFixture.getLookupElementStrings();
+ assertNotNull(strings);
+ assertEquals("alt", strings.get(0));
+ assertEquals("src", strings.get(1));
+ assertEquals("align", strings.get(2));
+ }
}
diff --git a/xml/tests/src/com/intellij/xml/index/XmlSchemaIndexTest.java b/xml/tests/src/com/intellij/xml/index/XmlSchemaIndexTest.java
index f610b15ee1ae..b0a6380d9a92 100644
--- a/xml/tests/src/com/intellij/xml/index/XmlSchemaIndexTest.java
+++ b/xml/tests/src/com/intellij/xml/index/XmlSchemaIndexTest.java
@@ -4,6 +4,7 @@ import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleUtilCore;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.psi.PsiFile;
import com.intellij.testFramework.IdeaTestCase;
import com.intellij.testFramework.fixtures.CodeInsightFixtureTestCase;
import com.intellij.util.Function;
@@ -108,6 +109,19 @@ public class XmlSchemaIndexTest extends CodeInsightFixtureTestCase {
assertEquals(Arrays.asList("web-app"), builder.getTags());
}
+ public void testGuessDTD() throws Exception {
+ myFixture.copyDirectoryToProject("", "");
+ final List<IndexedRelevantResource<String, XsdNamespaceBuilder>> files =
+ XmlNamespaceIndex.getResourcesByNamespace("foo.dtd",
+ getProject(),
+ myModule);
+ assertEquals(2, files.size());
+
+ PsiFile file = myFixture.configureByFile("foo.xml");
+ assertTrue(XmlNamespaceIndex.guessDtd("foo://bar/1/foo.dtd", file).getVirtualFile().getPath().endsWith("/1/foo.dtd"));
+ assertTrue(XmlNamespaceIndex.guessDtd("foo://bar/2/foo.dtd", file).getVirtualFile().getPath().endsWith("/2/foo.dtd"));
+ }
+
@Override
protected String getBasePath() {
return "/xml/tests/testData/index";
diff --git a/xml/tests/testData/completion/DoNotSuggestExistingAttributes.xml b/xml/tests/testData/completion/DoNotSuggestExistingAttributes.xml
new file mode 100644
index 000000000000..3fface37878f
--- /dev/null
+++ b/xml/tests/testData/completion/DoNotSuggestExistingAttributes.xml
@@ -0,0 +1,6 @@
+<xsd:schema xmlns="http://www.foo.org/test"
+ <caret>
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.foo.org/test foo.xsd http://www.bar.org/test bar.xsd" >
+</xsd:schema>
diff --git a/xml/tests/testData/index/1/foo.dtd b/xml/tests/testData/index/1/foo.dtd
new file mode 100644
index 000000000000..be05ea6ba4a5
--- /dev/null
+++ b/xml/tests/testData/index/1/foo.dtd
@@ -0,0 +1 @@
+<!ELEMENT foo (#PCDATA)> \ No newline at end of file
diff --git a/xml/tests/testData/index/2/foo.dtd b/xml/tests/testData/index/2/foo.dtd
new file mode 100644
index 000000000000..be05ea6ba4a5
--- /dev/null
+++ b/xml/tests/testData/index/2/foo.dtd
@@ -0,0 +1 @@
+<!ELEMENT foo (#PCDATA)> \ No newline at end of file
diff --git a/xml/tests/testData/index/foo.xml b/xml/tests/testData/index/foo.xml
new file mode 100644
index 000000000000..e69de29bb2d1
--- /dev/null
+++ b/xml/tests/testData/index/foo.xml