diff options
author | Chris Goldthorpe | 2009-02-11 19:15:10 +0000 |
---|---|---|
committer | Chris Goldthorpe | 2009-02-11 19:15:10 +0000 |
commit | 813edb6cc02bcfb1e8e47c7c263ad9b8403c6c3b (patch) | |
tree | 78fd4ed0bbc1fa26190ebc05b9466fbc38b2b5ac /org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc | |
parent | ea3c5d982d12d0169c7c612bcb1bbd43d9f891e9 (diff) | |
download | eclipse.platform.ua-813edb6cc02bcfb1e8e47c7c263ad9b8403c6c3b.tar.gz eclipse.platform.ua-813edb6cc02bcfb1e8e47c7c263ad9b8403c6c3b.tar.xz eclipse.platform.ua-813edb6cc02bcfb1e8e47c7c263ad9b8403c6c3b.zip |
Bug 230842 – [Help] new Toc(IToc ...) does not copy over the linkTo field:
Diffstat (limited to 'org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc')
3 files changed, 128 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 b7558b367..4e330fbda 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 @@ -36,6 +36,7 @@ public class AllTocTests extends TestSuite { addTestSuite(TocSortingTest.class); addTestSuite(TocIconTest.class); addTestSuite(TocIconPathTest.class); + addTestSuite(TocProviderTest.class); addTestSuite(HelpData.class); } } diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/TocProviderTest.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/TocProviderTest.java new file mode 100644 index 000000000..3a1ac6b0b --- /dev/null +++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/TocProviderTest.java @@ -0,0 +1,48 @@ +/******************************************************************************* + * 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.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +import org.eclipse.help.IToc; +import org.eclipse.help.ITopic; +import org.eclipse.help.internal.HelpPlugin; + +public class TocProviderTest extends TestCase { + + /* + * Returns an instance of this Test. + */ + public static Test suite() { + return new TestSuite(TocProviderTest.class); + } + + /** + * Verify that the tocProvider extension in this plug-in contributes a TOC which can be linked to an anchor + */ + public void testTocProvider() throws Exception { + IToc[] tocs = HelpPlugin.getTocManager().getTocs("en"); + IToc uaToc = null; + for (int i = 0; i < tocs.length; i++) { + if ("User Assistance Tests".equals(tocs[i].getLabel())) { + uaToc = tocs[i]; + } + } + assertNotNull("User Assistance Tests not found", uaToc); + ITopic[] children = uaToc.getTopics(); + ITopic lastChild = children[children.length - 1]; + assertEquals("Generated Parent", lastChild.getLabel()); + assertEquals(4, lastChild.getSubtopics().length); + } + +} diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/UaTestTocProvider.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/UaTestTocProvider.java new file mode 100644 index 000000000..63074827d --- /dev/null +++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/UaTestTocProvider.java @@ -0,0 +1,79 @@ +/******************************************************************************* + * 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 org.eclipse.help.AbstractTocProvider; +import org.eclipse.help.IToc; +import org.eclipse.help.ITocContribution; +import org.eclipse.ua.tests.help.other.UserToc; +import org.eclipse.ua.tests.help.other.UserTopic; + +public class UaTestTocProvider extends AbstractTocProvider { + + UserToc toc; + TocContribution contribution; + private ITocContribution[] contributions; + + private class TocContribution implements ITocContribution { + + public String getCategoryId() { + return null; + } + + public String getContributorId() { + return "org.eclipse.ua.tests"; + } + + public String[] getExtraDocuments() { + return new String[0]; + } + + public String getId() { + return "generatedToc"; + } + + public String getLinkTo() { + return "data/help/toc/root.xml#generatedContent"; + } + + public String getLocale() { + return null; + } + + public IToc getToc() { + return toc; + } + + public boolean isPrimary() { + return false; + } + + }; + + public UaTestTocProvider() { + toc = new UserToc("Generated Toc", null, true); + UserTopic parentTopic = new UserTopic("Generated Parent", "data/help/index/topic1.html", true); + for (int i = 1; i <= 4; i++) { + UserTopic childTopic = new UserTopic("Generated Child #" + i, + "data/help/index/topic" + i + ".html", true); + parentTopic.addTopic(childTopic); + } + toc.addTopic(parentTopic); + contribution = new TocContribution(); + contributions = new ITocContribution[] { contribution }; + } + + public ITocContribution[] getTocContributions(String locale) { + return contributions; + } + +} |