Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Goldthorpe2007-12-20 15:15:26 +0000
committerChris Goldthorpe2007-12-20 15:15:26 +0000
commit2dbf06930be9e4f6a0f94772dd846105942fdf51 (patch)
tree950be859f805cd67d57daa9be10520216aa4475a /org.eclipse.ua.tests/intro/org
parent779b11713699220cf080ce4fa91925061d38b840 (diff)
downloadeclipse.platform.ua-2dbf06930be9e4f6a0f94772dd846105942fdf51.tar.gz
eclipse.platform.ua-2dbf06930be9e4f6a0f94772dd846105942fdf51.tar.xz
eclipse.platform.ua-2dbf06930be9e4f6a0f94772dd846105942fdf51.zip
Add test for replacement content
Diffstat (limited to 'org.eclipse.ua.tests/intro/org')
-rw-r--r--org.eclipse.ua.tests/intro/org/eclipse/ua/tests/intro/anchors/ExtensionReorderingTest.java29
-rw-r--r--org.eclipse.ua.tests/intro/org/eclipse/ua/tests/intro/parser/ValidTest.java71
2 files changed, 72 insertions, 28 deletions
diff --git a/org.eclipse.ua.tests/intro/org/eclipse/ua/tests/intro/anchors/ExtensionReorderingTest.java b/org.eclipse.ua.tests/intro/org/eclipse/ua/tests/intro/anchors/ExtensionReorderingTest.java
index 9ee7b2594..a0e006886 100644
--- a/org.eclipse.ua.tests/intro/org/eclipse/ua/tests/intro/anchors/ExtensionReorderingTest.java
+++ b/org.eclipse.ua.tests/intro/org/eclipse/ua/tests/intro/anchors/ExtensionReorderingTest.java
@@ -17,6 +17,7 @@ package org.eclipse.ua.tests.intro.anchors;
* extn3 contributes to page 1
* extn 4 contributes to page 2
* extn5 contributes to page 4
+ * extn6 replaces content
*/
import java.util.Vector;
@@ -167,17 +168,21 @@ public class ExtensionReorderingTest extends TestCase {
public void testOrder12345() {
readIntroConfig();
assertNotNull(config);
- assertEquals(5, introConfigExtensions.length);
+ assertEquals(6, introConfigExtensions.length);
IntroModelRoot model = new IntroModelRoot(config, introConfigExtensions);
model.loadModel();
- checkModel(model, 5);
+ checkModel(model, 6);
}
private void checkModel(IntroModelRoot model, int elements) {
assertTrue(model.hasValidConfig());
Object[] pages = model.getChildrenOfType(AbstractIntroElement.ABSTRACT_PAGE);
IntroHomePage root = (IntroHomePage) model.findChild("root");
- assertEquals(elements + 2, pages.length);
+ if (elements < 6) {
+ assertEquals(elements + 2, pages.length);
+ } else {
+ assertEquals(7, pages.length);
+ }
IntroPage extn1 = (IntroPage) model.findChild("page1");
assertNotNull(extn1);
AbstractIntroElement p1link = root.findChild("page1link");
@@ -199,7 +204,14 @@ public class ExtensionReorderingTest extends TestCase {
IntroPage extn5 = (IntroPage) model.findChild("page5");
assertNotNull(extn5);
AbstractIntroElement p5link = extn4.findChild("page5link");
- assertNotNull(p5link);
+ AbstractIntroElement p5linkR = extn4.findChild("page5linkR");
+ if (elements == 5) {
+ assertNotNull(p5link);
+ assertNull(p5linkR);
+ } else {
+ assertNull(p5link);
+ assertNotNull(p5linkR);
+ }
}
}
}
@@ -211,10 +223,15 @@ public class ExtensionReorderingTest extends TestCase {
public void testAllOrdersOf4Contributions() {
new Permutations().testAll(4);
}
-
+
public void testAllOrdersOf5Contributions() {
readIntroConfig();
new Permutations().testAll(5);
- }
+ }
+
+ public void testAllOrdersOf6Contributions() {
+ readIntroConfig();
+ new Permutations().testAll(6);
+ }
}
diff --git a/org.eclipse.ua.tests/intro/org/eclipse/ua/tests/intro/parser/ValidTest.java b/org.eclipse.ua.tests/intro/org/eclipse/ua/tests/intro/parser/ValidTest.java
index d33d7fd7e..d7c62e6ab 100644
--- a/org.eclipse.ua.tests/intro/org/eclipse/ua/tests/intro/parser/ValidTest.java
+++ b/org.eclipse.ua.tests/intro/org/eclipse/ua/tests/intro/parser/ValidTest.java
@@ -50,13 +50,33 @@ public class ValidTest extends TestCase {
HelpUIPlugin.getDefault();
}
+ public void testDynamicXHTML() throws IOException {
+ singleConfigTest("org.eclipse.ua.tests.intro.config.dynamicXHTML");
+ }
+
+ public void testDynamicXML() throws IOException {
+ singleConfigTest("org.eclipse.ua.tests.intro.config.dynamicXML");
+ }
+
+ public void testAnchors() throws IOException {
+ singleConfigTest("org.eclipse.ua.tests.intro.config.anchors");
+ }
+
+ public void testMixed() throws IOException {
+ singleConfigTest("org.eclipse.ua.tests.intro.config.mixed");
+ }
+
+ public void testStatic() throws IOException {
+ singleConfigTest("org.eclipse.ua.tests.intro.config.static");
+ }
+
/*
- * Test valid intro content. This goes through all the test intro content
- * (xml files and xhtml files) and serializes them using the
+ * Test valid intro content. This goes through the test intro content
+ * (xml files and xhtml files) and serializes it using the
* IntroModelSerializer, then compares the result of the serialization
* with the expected result (the _expected.txt files).
*/
- public void testParserValid() throws IOException {
+ private void singleConfigTest(String configId) throws IOException {
IConfigurationElement[] elements = Platform.getExtensionRegistry().getConfigurationElementsFor("org.eclipse.ui.intro.config");
for (int i=0;i<elements.length;++i) {
/*
@@ -65,26 +85,33 @@ public class ValidTest extends TestCase {
if (elements[i].getDeclaringExtension().getContributor().getName().equals(UserAssistanceTestPlugin.getDefault().getBundle().getSymbolicName())) {
String content = elements[i].getAttribute("content");
String id = elements[i].getAttribute("id");
- Bundle bundle = UserAssistanceTestPlugin.getDefault().getBundle();
-
- IntroModelRoot model = ExtensionPointManager.getInst().getModel(id);
- IntroModelSerializer serializer = new IntroModelSerializer(model);
-
- String expected = FileUtil.getContents(bundle, FileUtil.getResultFile(content));
- String actual = serializer.toString();
- Assert.assertEquals("The model parsed for intro did not match the expected result for: " + id, expected, actual);
-
- Map map = IntroModelSerializerTest.getXHTMLFiles(model);
- Iterator iter = map.entrySet().iterator();
- while (iter.hasNext()) {
- Map.Entry entry = (Map.Entry)iter.next();
- String relativePath = (String)entry.getKey();
-
- expected = FileUtil.getContents(bundle, FileUtil.getResultFile(relativePath));
- actual = (String)entry.getValue();
- Assert.assertEquals("The XHTML generated for intro did not match the expected result for: " + relativePath, expected, actual);
- }
+ if (id.equals(configId)) {
+ for (int x = 0; x < 10; x++) {
+ // Perform 10 times to better detect intermittent ordering bugs
+ Bundle bundle = UserAssistanceTestPlugin.getDefault().getBundle();
+
+ IntroModelRoot model = ExtensionPointManager.getInst().getModel(id);
+ IntroModelSerializer serializer = new IntroModelSerializer(model);
+
+ String expected = FileUtil.getContents(bundle, FileUtil.getResultFile(content));
+ String actual = serializer.toString();
+ Assert.assertEquals("The model parsed for intro did not match the expected result for: " + id, expected, actual);
+
+ Map map = IntroModelSerializerTest.getXHTMLFiles(model);
+ Iterator iter = map.entrySet().iterator();
+ while (iter.hasNext()) {
+ Map.Entry entry = (Map.Entry)iter.next();
+ String relativePath = (String)entry.getKey();
+
+ expected = FileUtil.getContents(bundle, FileUtil.getResultFile(relativePath));
+ actual = (String)entry.getValue();
+ Assert.assertEquals("The XHTML generated for intro did not match the expected result for: " + relativePath, expected, actual);
+ }
+ }
+ return;
+ }
}
}
+ fail("Config extension not found");
}
}

Back to the top