Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Goldthorpe2009-06-24 23:13:20 +0000
committerChris Goldthorpe2009-06-24 23:13:20 +0000
commit8a039bb448aa3e66616d2ae81f6a97ca1b871c85 (patch)
treef65ec1c509ea5a85d9ceb71f2b56867865d7e620 /org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc
parent5ffff50353ec5b6e27500225eea463e7323fac52 (diff)
downloadeclipse.platform.ua-8a039bb448aa3e66616d2ae81f6a97ca1b871c85.tar.gz
eclipse.platform.ua-8a039bb448aa3e66616d2ae81f6a97ca1b871c85.tar.xz
eclipse.platform.ua-8a039bb448aa3e66616d2ae81f6a97ca1b871c85.zip
Bug 38052 – [Help] Add alphabetical ordering attribute to TOC DTD
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/TopicSortingTest.java65
2 files changed, 66 insertions, 0 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 7f0915497..43f447f49 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
@@ -34,6 +34,7 @@ public class AllTocTests extends TestSuite {
addTest(TocLinkChecker.suite());
addTestSuite(TopicFinderTest.class);
addTestSuite(TocSortingTest.class);
+ addTestSuite(TopicSortingTest.class);
addTestSuite(TocIconTest.class);
addTestSuite(TocIconPathTest.class);
addTestSuite(TocProviderTest.class);
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/TopicSortingTest.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/TopicSortingTest.java
new file mode 100644
index 000000000..728b9f320
--- /dev/null
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/TopicSortingTest.java
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright (c) 2009 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 junit.framework.TestCase;
+
+import org.eclipse.help.ITopic;
+import org.eclipse.help.internal.toc.Toc;
+import org.eclipse.help.internal.toc.TocContribution;
+import org.eclipse.help.internal.toc.TocFile;
+import org.eclipse.help.internal.toc.TocFileParser;
+import org.eclipse.help.internal.toc.TopicSorter;
+import org.eclipse.ua.tests.plugin.UserAssistanceTestPlugin;
+
+public class TopicSortingTest extends TestCase {
+
+ public void testSortTocChildren() throws Exception {
+ TocFileParser parser = new TocFileParser();
+ TocContribution contribution = parser.parse(new TocFile(UserAssistanceTestPlugin.getPluginId(), "data/help/toc/assembler/sorted.xml", true, "en", null, null));
+ TopicSorter sorter = new TopicSorter();
+ Toc toc = (Toc) contribution.getToc();
+ sorter.sortChildren(toc);
+ ITopic[] children = toc.getTopics();
+ assertEquals("A Topic (sorted)", children[0].getLabel());
+ assertEquals("B Topic", children[1].getLabel());
+ assertEquals("C Topic", children[2].getLabel());
+ }
+
+ public void testSortNestedTopics() throws Exception {
+ TocFileParser parser = new TocFileParser();
+ TocContribution contribution = parser.parse(new TocFile(UserAssistanceTestPlugin.getPluginId(), "data/help/toc/assembler/sorted.xml", true, "en", null, null));
+ TopicSorter sorter = new TopicSorter();
+ Toc toc = (Toc) contribution.getToc();
+ sorter.sortChildren(toc);
+ ITopic[] children = toc.getTopics();
+ ITopic topicA = children[0];
+ assertEquals("A Topic (sorted)", topicA.getLabel());
+ ITopic[] childrenOfA = topicA.getSubtopics();
+ assertEquals("A Child", childrenOfA[0].getLabel());
+ assertEquals("B Child", childrenOfA[1].getLabel());
+ }
+
+ public void testUnsortedNestedTopics() throws Exception {
+ TocFileParser parser = new TocFileParser();
+ TocContribution contribution = parser.parse(new TocFile(UserAssistanceTestPlugin.getPluginId(), "data/help/toc/assembler/sorted.xml", true, "en", null, null));
+ TopicSorter sorter = new TopicSorter();
+ Toc toc = (Toc) contribution.getToc();
+ sorter.sortChildren(toc);
+ ITopic[] children = toc.getTopics();
+ ITopic topicC = children[2];
+ assertEquals("C Topic", topicC.getLabel());
+ ITopic[] childrenOfC = topicC.getSubtopics();
+ assertEquals("B Child of C", childrenOfC[0].getLabel());
+ assertEquals("A Child of C", childrenOfC[1].getLabel());
+ }
+
+}

Back to the top