Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCurtis D'Entremont2006-11-02 20:41:27 +0000
committerCurtis D'Entremont2006-11-02 20:41:27 +0000
commit30caa2bacbc0f40cea3466170fcf058439baca88 (patch)
treeb158c0107e6b2eeec0f2e28be13f8d7f6c55fd20 /org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc
parent0c090ee282e9791f40896518ae19af25807db3e8 (diff)
downloadeclipse.platform.ua-30caa2bacbc0f40cea3466170fcf058439baca88.tar.gz
eclipse.platform.ua-30caa2bacbc0f40cea3466170fcf058439baca88.tar.xz
eclipse.platform.ua-30caa2bacbc0f40cea3466170fcf058439baca88.zip
dynamic content across all UA
Diffstat (limited to 'org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc')
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/AllTocTests.java1
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/TocAssemblerTest.java79
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/TocFileParserTest.java122
3 files changed, 16 insertions, 186 deletions
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/AllTocTests.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/AllTocTests.java
index a42ee2e54..3addeb37e 100644
--- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/AllTocTests.java
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/AllTocTests.java
@@ -29,7 +29,6 @@ public class AllTocTests extends TestSuite {
* Constructs a new test suite.
*/
public AllTocTests() {
- addTest(TocFileParserTest.suite());
addTest(TocAssemblerTest.suite());
}
}
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/TocAssemblerTest.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/TocAssemblerTest.java
index af500347b..542f0ef80 100644
--- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/TocAssemblerTest.java
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/TocAssemblerTest.java
@@ -18,10 +18,8 @@ import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
-import org.eclipse.help.IToc;
-import org.eclipse.help.ITocContribution;
-import org.eclipse.help.ITopic;
-import org.eclipse.help.UAContentFilter;
+import org.eclipse.help.TocContribution;
+import org.eclipse.help.internal.dynamic.NodeWriter;
import org.eclipse.help.internal.toc.TocAssembler;
import org.eclipse.help.internal.toc.TocFile;
import org.eclipse.help.internal.toc.TocFileParser;
@@ -38,82 +36,37 @@ public class TocAssemblerTest extends TestCase {
public void testAssemble() throws Exception {
TocFileParser parser = new TocFileParser();
- ITocContribution b = parser.parse(new TocFile(UserAssistanceTestPlugin.getPluginId(), "data/help/toc/assembler/b.xml", true, "en", null, null));
- ITocContribution c = parser.parse(new TocFile(UserAssistanceTestPlugin.getPluginId(), "data/help/toc/assembler/c.xml", true, "en", null, null));
- ITocContribution result_b_c = parser.parse(new TocFile(UserAssistanceTestPlugin.getPluginId(), "data/help/toc/assembler/result_b_c.xml", true, "en", null, null));
+ TocContribution b = parser.parse(new TocFile(UserAssistanceTestPlugin.getPluginId(), "data/help/toc/assembler/b.xml", true, "en", null, null));
+ TocContribution c = parser.parse(new TocFile(UserAssistanceTestPlugin.getPluginId(), "data/help/toc/assembler/c.xml", true, "en", null, null));
+ TocContribution result_b_c = parser.parse(new TocFile(UserAssistanceTestPlugin.getPluginId(), "data/help/toc/assembler/result_b_c.xml", true, "en", null, null));
TocAssembler assembler = new TocAssembler();
List contributions = new ArrayList(Arrays.asList(new Object[] { b, c }));
contributions = assembler.assemble(contributions);
assertEquals(1, contributions.size());
String expected = serialize(result_b_c);
- String actual = serialize((ITocContribution)contributions.get(0));
+ String actual = serialize((TocContribution)contributions.get(0));
assertEquals(expected, actual);
- ITocContribution a = parser.parse(new TocFile(UserAssistanceTestPlugin.getPluginId(), "data/help/toc/assembler/a.xml", true, "en", null, null));
+ TocContribution a = parser.parse(new TocFile(UserAssistanceTestPlugin.getPluginId(), "data/help/toc/assembler/a.xml", true, "en", null, null));
b = parser.parse(new TocFile(UserAssistanceTestPlugin.getPluginId(), "data/help/toc/assembler/b.xml", true, "en", null, null));
c = parser.parse(new TocFile(UserAssistanceTestPlugin.getPluginId(), "data/help/toc/assembler/c.xml", true, "en", null, null));
- ITocContribution result_a_b_c = parser.parse(new TocFile(UserAssistanceTestPlugin.getPluginId(), "data/help/toc/assembler/result_a_b_c.xml", true, "en", null, null));
+ TocContribution d = parser.parse(new TocFile(UserAssistanceTestPlugin.getPluginId(), "data/help/toc/assembler/d.xml", false, "en", null, null));
+ TocContribution result_a_b_c_d = parser.parse(new TocFile(UserAssistanceTestPlugin.getPluginId(), "data/help/toc/assembler/result_a_b_c_d.xml", true, "en", null, null));
- contributions = new ArrayList(Arrays.asList(new Object[] { a, b, c }));
+ contributions = new ArrayList(Arrays.asList(new Object[] { a, b, c, d }));
contributions = assembler.assemble(contributions);
assertEquals(1, contributions.size());
- expected = serialize(result_a_b_c);
- actual = serialize((ITocContribution)contributions.get(0));
+ expected = serialize(result_a_b_c_d);
+ actual = serialize((TocContribution)contributions.get(0));
assertEquals(expected, actual);
}
- private String serialize(ITocContribution contribution) {
- return serialize(contribution.getToc());
- }
-
- private String serialize(IToc toc) {
+ private String serialize(TocContribution contribution) {
StringBuffer buf = new StringBuffer();
- buf.append("<toc");
- if (toc.getLabel() != null) {
- buf.append(" label=\"" + toc.getLabel() + "\"");
- }
- if (toc.getTopic(null).getHref() != null) {
- buf.append(" topic=\"" + toc.getTopic(null).getHref() + "\"");
- }
- buf.append(">\n");
-
- ITopic[] topics = toc.getTopics();
- String indent = " ";
- for (int i=0;i<topics.length;++i) {
- if (!UAContentFilter.isFiltered(topics[i])) {
- buf.append(serialize(topics[i], indent));
- }
- }
-
- buf.append("</toc>\n");
- return buf.toString();
- }
-
- private String serialize(ITopic topic, String indent) {
- StringBuffer buf = new StringBuffer();
- buf.append(indent + "<topic");
- if (topic.getLabel() != null) {
- buf.append(" label=\"" + topic.getLabel() + "\"");
- }
- String href = topic.getHref();
- if (href != null) {
- buf.append(" href=\"" + href.substring(href.indexOf('/', 1) + 1) + "\"");
- }
-
- ITopic[] subtopics = topic.getSubtopics();
- if (subtopics.length == 0) {
- buf.append("/>\n");
- }
- else {
- buf.append(">\n");
- for (int i=0;i<subtopics.length;++i) {
- if (!UAContentFilter.isFiltered(subtopics[i])) {
- buf.append(serialize(subtopics[i], indent + " "));
- }
- }
- buf.append(indent + "</topic>\n");
- }
+ String indent = "";
+ NodeWriter writer = new NodeWriter();
+ writer.write(contribution.getToc(), buf, true, indent, false);
return buf.toString();
}
}
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/TocFileParserTest.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/TocFileParserTest.java
deleted file mode 100644
index 73dc86915..000000000
--- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/TocFileParserTest.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ua.tests.help.toc;
-
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Set;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import org.eclipse.help.IAnchor;
-import org.eclipse.help.INode;
-import org.eclipse.help.IFilter;
-import org.eclipse.help.IInclude;
-import org.eclipse.help.IToc;
-import org.eclipse.help.ITocContribution;
-import org.eclipse.help.ITopic;
-import org.eclipse.help.internal.toc.TocFile;
-import org.eclipse.help.internal.toc.TocFileParser;
-import org.eclipse.ua.tests.plugin.UserAssistanceTestPlugin;
-
-public class TocFileParserTest extends TestCase {
-
- /*
- * Returns an instance of this Test.
- */
- public static Test suite() {
- return new TestSuite(TocFileParserTest.class);
- }
-
- public void testParse() throws Exception {
- String pluginId = UserAssistanceTestPlugin.getPluginId();
- String file = "data/help/toc/parser/toc.xml";
- boolean isPrimary = false;
- String locale = "en_CA";
- String extraDir = "data/help/toc/parser/extraDir";
- String category = null;
-
- TocFile tocFile = new TocFile(pluginId, file, isPrimary, locale, extraDir, category);
- TocFileParser parser = new TocFileParser();
- ITocContribution contribution = parser.parse(tocFile);
- assertNotNull(contribution);
- assertEquals("/org.eclipse.ua.tests/data/help/toc/parser/toc.xml", contribution.getId());
- assertEquals(isPrimary, contribution.isPrimary());
- assertEquals(locale, contribution.getLocale());
-
- String[] extraDocs = contribution.getExtraDocuments();
- Set set = new HashSet(Arrays.asList(extraDocs));
- assertTrue(set.contains("/org.eclipse.ua.tests/data/help/toc/parser/extraDir/page1.html"));
- assertTrue(set.contains("/org.eclipse.ua.tests/data/help/toc/parser/extraDir/page2.html"));
- assertTrue(set.contains("/org.eclipse.ua.tests/data/help/toc/parser/extraDir/otherDir/page3.html"));
-
- assertEquals(category, contribution.getCategoryId());
- assertEquals("/org.eclipse.ua.tests/myOtherToc.xml", contribution.getLinkTo());
-
- IToc toc = contribution.getToc();
- assertNotNull(toc);
-
- assertEquals("myToc", toc.getLabel());
- assertEquals("myToc", toc.getTopic(null).getLabel());
- assertEquals("/org.eclipse.ua.tests/myFakeTopic.html", toc.getTopic(null).getHref());
- assertEquals(3, toc.getChildren().length);
- assertEquals(1, toc.getTopics().length);
- assertNotNull(toc.getTopic(null));
- assertNull(toc.getParent());
-
- INode node = toc.getChildren()[0];
- assertTrue(node instanceof IAnchor);
- IAnchor anchor = (IAnchor)node;
- assertEquals("myAnchor", anchor.getId());
- assertEquals(0, anchor.getChildren().length);
- assertEquals(toc, anchor.getParent());
-
- node = toc.getChildren()[1];
- assertEquals(node, toc.getTopics()[0]);
- assertTrue(node instanceof ITopic);
- ITopic topic = (ITopic)node;
- assertEquals("myTopic", topic.getLabel());
- assertEquals("/org.eclipse.ua.tests/myTopic.html", topic.getHref());
- assertEquals(1, topic.getChildren().length);
- assertEquals(toc, topic.getParent());
-
- node = topic.getChildren()[0];
- assertTrue(node instanceof IFilter);
- IFilter filter = (IFilter)node;
- assertEquals("os=win32", filter.getExpression());
- assertEquals(1, filter.getChildren().length);
- assertEquals(topic, filter.getParent());
-
- node = filter.getChildren()[0];
- assertTrue(node instanceof ITopic);
- topic = (ITopic)node;
- assertEquals("mySubtopic", topic.getLabel());
- assertEquals("/org.eclipse.ua.tests/mySubtopic.html", topic.getHref());
- assertEquals(0, topic.getChildren().length);
- assertEquals(filter, topic.getParent());
-
- node = toc.getChildren()[2];
- assertTrue(node instanceof IFilter);
- filter = (IFilter)node;
- assertEquals("ws!=gtk", filter.getExpression());
- assertEquals(1, filter.getChildren().length);
- assertEquals(toc, filter.getParent());
-
- node = filter.getChildren()[0];
- assertTrue(node instanceof IInclude);
- IInclude include = (IInclude)node;
- assertEquals("/org.eclipse.ua.tests/myOtherToc2.xml", include.getTarget());
- assertEquals(0, include.getChildren().length);
- assertEquals(filter, include.getParent());
- }
-}

Back to the top