|
Added
Link Here
|
| 1 |
/******************************************************************************* |
| 2 |
* Copyright (c) 2008 IBM Corporation and others. |
| 3 |
* All rights reserved. This program and the accompanying materials |
| 4 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 5 |
* which accompanies this distribution, and is available at |
| 6 |
* http://www.eclipse.org/legal/epl-v10.html |
| 7 |
* |
| 8 |
* Contributors: |
| 9 |
* IBM Corporation - initial API and implementation |
| 10 |
*******************************************************************************/ |
| 11 |
|
| 12 |
package org.eclipse.ua.tests.help.webapp; |
| 13 |
|
| 14 |
import org.eclipse.help.internal.base.BaseHelpSystem; |
| 15 |
import org.eclipse.help.internal.base.HelpBasePlugin; |
| 16 |
import org.eclipse.help.internal.webapp.data.UrlUtil; |
| 17 |
|
| 18 |
import junit.framework.TestCase; |
| 19 |
|
| 20 |
/** |
| 21 |
* Test for function which determines whether a topic path can be passed to the content frame |
| 22 |
*/ |
| 23 |
|
| 24 |
public class RestrictedTopicParameter extends TestCase { |
| 25 |
|
| 26 |
private static final String RESTRICT_TOPIC = "restrictTopicParameter"; |
| 27 |
private boolean restrictTopic; |
| 28 |
private int helpMode; |
| 29 |
|
| 30 |
protected void setUp() throws Exception { |
| 31 |
restrictTopic = HelpBasePlugin.getDefault().getPluginPreferences().getBoolean(RESTRICT_TOPIC); |
| 32 |
helpMode = BaseHelpSystem.getMode(); |
| 33 |
} |
| 34 |
|
| 35 |
protected void tearDown() throws Exception { |
| 36 |
setRestrictTopic(restrictTopic); |
| 37 |
BaseHelpSystem.setMode(helpMode); |
| 38 |
} |
| 39 |
|
| 40 |
private void setRestrictTopic(boolean isRestrict) { |
| 41 |
HelpBasePlugin.getDefault().getPluginPreferences().setValue(RESTRICT_TOPIC, isRestrict); |
| 42 |
} |
| 43 |
|
| 44 |
public void testWorkbenchMode() { |
| 45 |
BaseHelpSystem.setMode(BaseHelpSystem.MODE_WORKBENCH); |
| 46 |
setRestrictTopic(true); |
| 47 |
assertTrue(UrlUtil.isValidTopicURL("http://www.eclipse.org")); |
| 48 |
assertTrue(UrlUtil.isValidTopicURL("https://www.eclipse.org")); |
| 49 |
setRestrictTopic(false); |
| 50 |
assertTrue(UrlUtil.isValidTopicURL("http://www.eclipse.org")); |
| 51 |
assertTrue(UrlUtil.isValidTopicURL("https://www.eclipse.org")); |
| 52 |
} |
| 53 |
|
| 54 |
public void testStandaloneMode() { |
| 55 |
BaseHelpSystem.setMode(BaseHelpSystem.MODE_STANDALONE); |
| 56 |
setRestrictTopic(true); |
| 57 |
assertTrue(UrlUtil.isValidTopicURL("http://www.eclipse.org")); |
| 58 |
assertTrue(UrlUtil.isValidTopicURL("https://www.eclipse.org")); |
| 59 |
setRestrictTopic(false); |
| 60 |
assertTrue(UrlUtil.isValidTopicURL("http://www.eclipse.org")); |
| 61 |
assertTrue(UrlUtil.isValidTopicURL("https://www.eclipse.org")); |
| 62 |
} |
| 63 |
|
| 64 |
public void testInfocenterUnrestricted() { |
| 65 |
BaseHelpSystem.setMode(BaseHelpSystem.MODE_INFOCENTER); |
| 66 |
setRestrictTopic(false); |
| 67 |
assertTrue(UrlUtil.isValidTopicURL("http://www.eclipse.org")); |
| 68 |
assertTrue(UrlUtil.isValidTopicURL("https://www.eclipse.org")); |
| 69 |
assertTrue(UrlUtil.isValidTopicURL("org.eclipse.platform.doc.user/reference/ref-43.htm")); |
| 70 |
} |
| 71 |
|
| 72 |
public void testInfocenterResestricted() { |
| 73 |
BaseHelpSystem.setMode(BaseHelpSystem.MODE_INFOCENTER); |
| 74 |
setRestrictTopic(true); |
| 75 |
assertFalse(UrlUtil.isValidTopicURL("http://www.eclipse.org")); |
| 76 |
assertFalse(UrlUtil.isValidTopicURL("https://www.eclipse.org")); |
| 77 |
assertTrue(UrlUtil.isValidTopicURL("org.eclipse.platform.doc.user/reference/ref-43.htm")); |
| 78 |
} |
| 79 |
|
| 80 |
} |