diff options
author | Chris Goldthorpe | 2007-08-30 23:33:16 +0000 |
---|---|---|
committer | Chris Goldthorpe | 2007-08-30 23:33:16 +0000 |
commit | 97bfcfa2f8afba1968a2fce30bb6a7914d0b54a9 (patch) | |
tree | 3517daf734d2c0e4febae16893380fb28febd54a /org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc | |
parent | f4057081ac2cae54ed38bf2834370933ee22bc0b (diff) | |
download | eclipse.platform.ua-97bfcfa2f8afba1968a2fce30bb6a7914d0b54a9.tar.gz eclipse.platform.ua-97bfcfa2f8afba1968a2fce30bb6a7914d0b54a9.tar.xz eclipse.platform.ua-97bfcfa2f8afba1968a2fce30bb6a7914d0b54a9.zip |
Refactor to move TopicFinder out of TocData
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.java | 1 | ||||
-rw-r--r-- | org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/TopicFinderTest.java | 78 |
2 files changed, 79 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 eb51f56f4..9fced1dc7 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 @@ -32,5 +32,6 @@ public class AllTocTests extends TestSuite { addTest(TocAssemblerTest.suite()); addTest(EnabledTopicTest.suite()); addTest(TocLinkChecker.suite()); + addTestSuite(TopicFinderTest.class); } } diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/TopicFinderTest.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/TopicFinderTest.java new file mode 100644 index 000000000..90f4da5dd --- /dev/null +++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/TopicFinderTest.java @@ -0,0 +1,78 @@ +/******************************************************************************* + * Copyright (c) 2007 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 org.eclipse.help.IToc; +import org.eclipse.help.ITopic; +import org.eclipse.help.internal.HelpPlugin; +import org.eclipse.help.internal.webapp.data.TopicFinder; + +import junit.framework.TestCase; + +public class TopicFinderTest extends TestCase{ + + private IToc[] getTocs() { + return HelpPlugin.getTocManager().getTocs("en"); + } + + public void testTocsFound() { + assertTrue(getTocs().length != 0); + } + + public void testNoTocs() { + TopicFinder finder = new TopicFinder("http:", new IToc[0]); + assertEquals(-1, finder.getSelectedToc()); + assertNull(finder.getTopicPath()); + } + + public void testNoTopic() { + TopicFinder finder = new TopicFinder(null, getTocs()); + assertEquals(-1, finder.getSelectedToc()); + assertNull(finder.getTopicPath()); + } + + public void testTopicInToc() { + String topic = "http://localhost:8082/help/topic/org.eclipse.ua.tests/data/help/manual/filter.xhtml"; + TopicFinder finder = new TopicFinder(topic, getTocs()); + int selectedToc = finder.getSelectedToc(); + assertFalse(selectedToc == -1); + ITopic[] path = finder.getTopicPath(); + assertNotNull(path); + String tocHref = getTocs()[selectedToc].getHref(); + assertEquals("/org.eclipse.ua.tests/data/help/toc/root.xml", tocHref); + assertEquals(2, path.length); + assertEquals("manual", path[0].getLabel()); + assertEquals("filter", path[1].getLabel()); + } + + public void testTopicInTocWithAnchor() { + String topic = "http://localhost:8082/help/topic/org.eclipse.ua.tests/data/help/manual/filter.xhtml#ABC"; + TopicFinder finder = new TopicFinder(topic, getTocs()); + int selectedToc = finder.getSelectedToc(); + assertFalse(selectedToc == -1); + ITopic[] path = finder.getTopicPath(); + assertNotNull(path); + String tocHref = getTocs()[selectedToc].getHref(); + assertEquals("/org.eclipse.ua.tests/data/help/toc/root.xml", tocHref); + assertEquals(2, path.length); + assertEquals("manual", path[0].getLabel()); + assertEquals("filter", path[1].getLabel()); + } + + public void testTopicNotInToc() { + String topic = "http://localhost:8082/help/topic/org.eclipse.ua.tests/data/help/manual/filter25.xhtml"; + TopicFinder finder = new TopicFinder(topic, getTocs()); + assertEquals(-1, finder.getSelectedToc()); + assertNull(finder.getTopicPath()); + } + +} |