Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Goldthorpe2010-02-01 17:19:00 +0000
committerChris Goldthorpe2010-02-01 17:19:00 +0000
commit76da1304559b7a6c2c7fe212cc99e32f153929a6 (patch)
tree358659e0101a162c2e41da1bbb428a7d135d8b16 /org.eclipse.ua.tests
parent0fd080ff6edca80301ec1906822087b372e22fcc (diff)
downloadeclipse.platform.ua-76da1304559b7a6c2c7fe212cc99e32f153929a6.tar.gz
eclipse.platform.ua-76da1304559b7a6c2c7fe212cc99e32f153929a6.tar.xz
eclipse.platform.ua-76da1304559b7a6c2c7fe212cc99e32f153929a6.zip
Bug 223475 – [Webapp] Support filtering in TOC and index
Diffstat (limited to 'org.eclipse.ua.tests')
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/AllHelpTests.java4
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/scope/AllScopeTests.java36
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/scope/EmptyLeafRemoval.java105
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/scope/IntersectionTest.java52
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/scope/MockScope.java64
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/scope/ScopeHierarchy.java92
6 files changed, 352 insertions, 1 deletions
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/AllHelpTests.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/AllHelpTests.java
index 65f14e38b..916d15769 100644
--- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/AllHelpTests.java
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/AllHelpTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2007 IBM Corporation and others.
+ * Copyright (c) 2006, 2010 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
@@ -18,6 +18,7 @@ import org.eclipse.ua.tests.help.index.AllIndexTests;
import org.eclipse.ua.tests.help.other.AllOtherHelpTests;
import org.eclipse.ua.tests.help.preferences.AllPreferencesTests;
import org.eclipse.ua.tests.help.remote.AllRemoteTests;
+import org.eclipse.ua.tests.help.scope.AllScopeTests;
import org.eclipse.ua.tests.help.search.AllSearchTests;
import org.eclipse.ua.tests.help.toc.AllTocTests;
import org.eclipse.ua.tests.help.webapp.AllWebappTests;
@@ -46,5 +47,6 @@ public class AllHelpTests extends TestSuite {
addTest(AllWebappTests.suite());
addTest(AllOtherHelpTests.suite());
addTest(AllRemoteTests.suite());
+ addTest(AllScopeTests.suite());
}
}
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/scope/AllScopeTests.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/scope/AllScopeTests.java
new file mode 100644
index 000000000..63e9cac64
--- /dev/null
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/scope/AllScopeTests.java
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.scope;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/*
+ * Tests help dynamic content functionality (automated).
+ */
+public class AllScopeTests extends TestSuite {
+
+ /*
+ * Returns the entire test suite.
+ */
+ public static Test suite() {
+ return new AllScopeTests();
+ }
+
+ /*
+ * Constructs a new test suite.
+ */
+ public AllScopeTests() {
+ addTestSuite(IntersectionTest.class);
+ addTestSuite(ScopeHierarchy.class);
+ addTestSuite(EmptyLeafRemoval.class);
+ }
+}
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/scope/EmptyLeafRemoval.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/scope/EmptyLeafRemoval.java
new file mode 100644
index 000000000..325a25583
--- /dev/null
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/scope/EmptyLeafRemoval.java
@@ -0,0 +1,105 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.scope;
+
+import junit.framework.TestCase;
+
+/**
+ * Test that leaf topics with no href do not show in the tree
+ * In this test empty means has no href
+ */
+
+import org.eclipse.help.base.AbstractHelpScope;
+import org.eclipse.help.internal.base.scope.ScopeUtils;
+import org.eclipse.ua.tests.help.other.UserIndexEntry;
+import org.eclipse.ua.tests.help.other.UserToc;
+import org.eclipse.ua.tests.help.other.UserTopic;
+
+public class EmptyLeafRemoval extends TestCase {
+
+ public void testEmptyLeafTopic() {
+ UserTopic topic = new UserTopic("ab", null, true);
+ assertFalse(ScopeUtils.showInTree(topic, new MockScope('a', false)));
+ }
+
+ public void testEmptyParentOfEmptyLeafTopic() {
+ UserTopic topic = new UserTopic("ab", null, true);
+ UserTopic child = new UserTopic("ac", null, true);
+ topic.addTopic(child);
+ assertFalse(ScopeUtils.showInTree(topic, new MockScope('a', false)));
+ }
+
+ public void testEmptyParentOfNonEmptyLeafTopic() {
+ UserTopic topic = new UserTopic("ab", null, true);
+ UserTopic child = new UserTopic("ac", "http://www.eclipse.org", true);
+ topic.addTopic(child);
+ assertTrue(ScopeUtils.showInTree(topic, new MockScope('a', false)));
+ }
+
+ public void testEmptyParentOfNonEmptyLeafTopicHierarchical() {
+ UserTopic topic = new UserTopic("ab", null, true);
+ UserTopic child = new UserTopic("ac", "http://www.eclipse.org", true);
+ topic.addTopic(child);
+ assertTrue(ScopeUtils.showInTree(topic, new MockScope('a', true)));
+ }
+
+ public void testEmptyGrandparentOfNonEmptyLeafTopicHierarchical() {
+ UserTopic topic = new UserTopic("ab", null, true);
+ UserTopic child = new UserTopic("ac", null, true);
+ UserTopic grandChild = new UserTopic("ac", "http://www.eclipse.org", true);
+ topic.addTopic(child);
+ child.addTopic(grandChild);
+ assertTrue(ScopeUtils.showInTree(topic, new MockScope('a', true)));
+ }
+
+ public void testTocParentOfEmptyLeaf() {
+ UserToc toc = new UserToc("ab", "http://www.eclipse.org", true);
+ UserTopic child = new UserTopic("ac", null, true);
+ toc.addTopic(child);
+ AbstractHelpScope scope = new MockScope('a', false);
+ assertFalse(ScopeUtils.showInTree(toc, scope));
+ }
+
+ public void testTocParentOfNonEmptyLeaf() {
+ UserToc toc = new UserToc("ab", "http://www.eclipse.org", true);
+ UserTopic child = new UserTopic("ac", "http://www.eclipse.org", true);
+ toc.addTopic(child);
+ AbstractHelpScope scope = new MockScope('a', true);
+ assertTrue(ScopeUtils.showInTree(toc, scope));
+ }
+
+ public void testEntryParentOfEmptyLeaf() {
+ UserIndexEntry entry = new UserIndexEntry("ab", true);
+ UserTopic child = new UserTopic("ac", null, true);
+ entry.addTopic(child);
+ AbstractHelpScope scope = new MockScope('a', true);
+ assertFalse(ScopeUtils.showInTree(entry, scope));
+ }
+
+ public void testEntryParentOfNonEmptyLeaf() {
+ UserIndexEntry entry = new UserIndexEntry("ab", true);
+ UserTopic child = new UserTopic("ac", "http://www.eclipse.org", true);
+ entry.addTopic(child);
+ AbstractHelpScope scope = new MockScope('a', true);
+ assertTrue(ScopeUtils.showInTree(entry, scope));
+ }
+
+ public void testEntryGrandParentOfNonEmptyLeaf() {
+ UserIndexEntry entry = new UserIndexEntry("ab", true);
+ UserIndexEntry child = new UserIndexEntry("ab", true);
+ UserTopic grandhild = new UserTopic("ac", "http://www.eclipse.org", true);
+ entry.addEntry(child);
+ child.addTopic(grandhild);
+ AbstractHelpScope scope = new MockScope('a', true);
+ assertTrue(ScopeUtils.showInTree(entry, scope));
+ }
+
+}
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/scope/IntersectionTest.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/scope/IntersectionTest.java
new file mode 100644
index 000000000..df6970891
--- /dev/null
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/scope/IntersectionTest.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.scope;
+
+import junit.framework.TestCase;
+
+import org.eclipse.help.base.AbstractHelpScope;
+import org.eclipse.help.internal.base.scope.IntersectionScope;
+import org.eclipse.ua.tests.help.other.UserTopic;
+
+public class IntersectionTest extends TestCase {
+
+ private AbstractHelpScope createScope(char char1, char char2) {
+ AbstractHelpScope result = new IntersectionScope(
+ new AbstractHelpScope[]{new MockScope(char1, true),
+ new MockScope(char2, true)});
+ return result;
+ }
+
+ public void testInIn() {
+ UserTopic topic = new UserTopic("ab", "http://www.eclipse.org", true);
+ AbstractHelpScope scope = createScope('a', 'b');
+ assertTrue(scope.inScope(topic));
+ }
+
+ public void testInOut() {
+ UserTopic topic = new UserTopic("a", "http://www.eclipse.org", true);
+ AbstractHelpScope scope = createScope('a', 'b');
+ assertFalse(scope.inScope(topic));
+ }
+
+ public void testOutIn() {
+ UserTopic topic = new UserTopic("b", "http://www.eclipse.org", true);
+ AbstractHelpScope scope = createScope('a', 'b');
+ assertFalse(scope.inScope(topic));
+ }
+
+ public void testOutOut() {
+ UserTopic topic = new UserTopic("c", "http://www.eclipse.org", true);
+ AbstractHelpScope scope = createScope('a', 'b');
+ assertFalse(scope.inScope(topic));
+ }
+
+}
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/scope/MockScope.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/scope/MockScope.java
new file mode 100644
index 000000000..0337082d9
--- /dev/null
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/scope/MockScope.java
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.scope;
+
+import java.util.Locale;
+
+import org.eclipse.help.IIndexEntry;
+import org.eclipse.help.IIndexSee;
+import org.eclipse.help.IToc;
+import org.eclipse.help.ITopic;
+import org.eclipse.help.base.AbstractHelpScope;
+
+public class MockScope extends AbstractHelpScope {
+
+ // Used for testing of scope based classes and utilities
+ // Elements are in scope if they contain the letter specified
+ // in the constructor
+
+ private char letter;
+ private boolean isHierarchical;
+
+ public MockScope(char letter, boolean isHierarchical) {
+ this.letter = letter;
+ this.isHierarchical = isHierarchical;
+ }
+
+ public boolean inScope(IToc toc) {
+ return testForInScope(toc.getLabel());
+ }
+
+ public boolean inScope(ITopic topic) {
+ return testForInScope(topic.getLabel());
+ }
+
+ public boolean inScope(IIndexEntry entry) {
+ return testForInScope(entry.getKeyword());
+ }
+
+ public boolean inScope(IIndexSee see) {
+ return false;
+ }
+
+ public String getName(Locale locale) {
+ return null;
+ }
+
+ private boolean testForInScope(String label) {
+ return label.indexOf(letter) >= 0;
+ }
+
+ public boolean isHierarchicalScope() {
+ return isHierarchical;
+ }
+
+}
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/scope/ScopeHierarchy.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/scope/ScopeHierarchy.java
new file mode 100644
index 000000000..3ee5e7522
--- /dev/null
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/scope/ScopeHierarchy.java
@@ -0,0 +1,92 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.scope;
+
+import junit.framework.TestCase;
+
+import org.eclipse.help.base.AbstractHelpScope;
+import org.eclipse.help.internal.base.scope.ScopeUtils;
+import org.eclipse.ua.tests.help.other.UserIndexEntry;
+import org.eclipse.ua.tests.help.other.UserToc;
+import org.eclipse.ua.tests.help.other.UserTopic;
+
+public class ScopeHierarchy extends TestCase {
+
+ public void testHierarchicalToc() {
+ UserToc toc = new UserToc("ab", "http://www.eclipse.org", true);
+ UserTopic child = new UserTopic("c", "http://www.eclipse.org", true);
+ toc.addTopic(child);
+ AbstractHelpScope scope = new MockScope('c', true);
+ assertFalse(ScopeUtils.showInTree(toc, scope));
+ }
+
+ public void testNonHierarchicalToc() {
+ UserToc toc = new UserToc("ab", "http://www.eclipse.org", true);
+ UserTopic child = new UserTopic("c", "http://www.eclipse.org", true);
+ toc.addTopic(child);
+ AbstractHelpScope scope = new MockScope('c', false);
+ assertTrue(ScopeUtils.showInTree(toc, scope));
+ }
+
+ public void testHierarchicalTopic() {
+ UserTopic topic = new UserTopic("ab", "http://www.eclipse.org", true);
+ UserTopic child = new UserTopic("c", "http://www.eclipse.org", true);
+ topic.addTopic(child);
+ AbstractHelpScope scope = new MockScope('c', true);
+ assertFalse(ScopeUtils.showInTree(topic, scope));
+ }
+
+ public void testNonHierarchicalTopic() {
+ UserTopic topic = new UserTopic("ab", "http://www.eclipse.org", true);
+ UserTopic child = new UserTopic("c", "http://www.eclipse.org", true);
+ topic.addTopic(child);
+ AbstractHelpScope scope = new MockScope('c', false);
+ assertTrue(ScopeUtils.showInTree(topic, scope));
+ }
+
+ public void testNonHierarchicalTopicThreeDeep() {
+ UserTopic topic = new UserTopic("ab", "http://www.eclipse.org", true);
+ UserTopic child = new UserTopic("c", "http://www.eclipse.org", true);
+ UserTopic grandChild = new UserTopic("d", "http://www.eclipse.org", true);
+ topic.addTopic(child);
+ child.addTopic(grandChild);
+ AbstractHelpScope scope = new MockScope('d', false);
+ assertTrue(ScopeUtils.showInTree(topic, scope));
+ }
+
+
+ public void testHierarchicalEntry() {
+ UserIndexEntry entry = new UserIndexEntry("ab", true);
+ UserTopic child = new UserTopic("c", "http://www.eclipse.org", true);
+ entry.addTopic(child);
+ AbstractHelpScope scope = new MockScope('c', true);
+ assertFalse(ScopeUtils.showInTree(entry, scope));
+ }
+
+ public void testNonHierarchicalEntry() {
+ UserIndexEntry entry = new UserIndexEntry("ab", true);
+ UserTopic child = new UserTopic("c", "http://www.eclipse.org", true);
+ entry.addTopic(child);
+ AbstractHelpScope scope = new MockScope('c', false);
+ assertTrue(ScopeUtils.showInTree(entry, scope));
+ }
+
+ public void testNonHierarchicalEntryThreeDeep() {
+ UserIndexEntry entry = new UserIndexEntry("a", true);
+ UserIndexEntry childEntry = new UserIndexEntry("b", true);
+ entry.addEntry(childEntry);
+ UserTopic grandChild = new UserTopic("c", "http://www.eclipse.org", true);
+ childEntry.addTopic(grandChild);
+ AbstractHelpScope scope = new MockScope('c', false);
+ assertTrue(ScopeUtils.showInTree(entry, scope));
+ }
+
+}

Back to the top