Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Goldthorpe2010-02-12 21:56:08 +0000
committerChris Goldthorpe2010-02-12 21:56:08 +0000
commit731c50d1522b2ba509cd31097068452734169857 (patch)
tree33f0113f252912924244a3cbdbc21dc3ecc977f0 /org.eclipse.ua.tests
parent3a67bf3253ba63a2946c4508e0918c4c5971f4cb (diff)
downloadeclipse.platform.ua-731c50d1522b2ba509cd31097068452734169857.tar.gz
eclipse.platform.ua-731c50d1522b2ba509cd31097068452734169857.tar.xz
eclipse.platform.ua-731c50d1522b2ba509cd31097068452734169857.zip
Bug 76005 – [Help] Ability for users to filter what they see in the help system navigation acc to some criteria (all help modes)
Diffstat (limited to 'org.eclipse.ua.tests')
-rw-r--r--org.eclipse.ua.tests/data/help/criteria/criteria_definition/a.xml22
-rw-r--r--org.eclipse.ua.tests/data/help/criteria/criteria_definition/b.xml37
-rw-r--r--org.eclipse.ua.tests/data/help/criteria/criteria_definition/result_a_b.xml33
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/criteria/AllCriteriaTests.java1
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/criteria/CriteriaUtilitiesTest.java2
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/criteria/ParseCriteriaDefinition.java87
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/criteria/ParseTocWithCriteria.java4
7 files changed, 183 insertions, 3 deletions
diff --git a/org.eclipse.ua.tests/data/help/criteria/criteria_definition/a.xml b/org.eclipse.ua.tests/data/help/criteria/criteria_definition/a.xml
new file mode 100644
index 000000000..047edb32c
--- /dev/null
+++ b/org.eclipse.ua.tests/data/help/criteria/criteria_definition/a.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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
+ -->
+
+<criteriaDefinition>
+ <criterion id="version" name="Version">
+ <criterion-value id="1.0" name ="1.0.0"/>
+ <criterion-value id="2.0" name ="2.0.0"/>
+ </criterion>
+ <criterion id="platform" name="Platform">
+ <criterion-value id="AIX" name ="AIX"/>
+ <criterion-value id="WINDOWS" name ="Windows"/>
+ </criterion>
+</criteriaDefinition>
diff --git a/org.eclipse.ua.tests/data/help/criteria/criteria_definition/b.xml b/org.eclipse.ua.tests/data/help/criteria/criteria_definition/b.xml
new file mode 100644
index 000000000..c732b07e2
--- /dev/null
+++ b/org.eclipse.ua.tests/data/help/criteria/criteria_definition/b.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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
+ -->
+
+<criteriaDefinition>
+ <criterion id="version" name="Version">
+ <criterion-value id="1.0" name ="1.0.0"/>
+ <criterion-value id="3.0" name ="3.0.0"/>
+ <criterion-value id="4.0" name = "4.0.0"/>
+ <criterion-value id="5.0"/>
+ <criterion-value id=""/>
+ <criterion-value id="" name ="aaa"/>
+ <criterion-value name =""/>
+ <criterion-value name ="aaa"/>
+ </criterion>
+ <criterion id="platform" name="Platform">
+ <criterion-value id="AIX" name ="AIX"/>
+ <criterion-value id="Linux" name ="LINUX"/>
+ </criterion>
+ <criterion id="product" name="Product">
+ <criterion-value id="DB2" name ="DB2"/>
+ <criterion-value id="WAS" name ="WAS"/>
+ </criterion>
+ <criterion id="no criterion value" name ="no criterion value"/>
+ <criterion id="no name">
+ <criterion-value id="bb" name ="bb"/>
+ </criterion>
+ <criterion name="no id"/>
+</criteriaDefinition>
diff --git a/org.eclipse.ua.tests/data/help/criteria/criteria_definition/result_a_b.xml b/org.eclipse.ua.tests/data/help/criteria/criteria_definition/result_a_b.xml
new file mode 100644
index 000000000..7ff9f6260
--- /dev/null
+++ b/org.eclipse.ua.tests/data/help/criteria/criteria_definition/result_a_b.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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
+ -->
+
+<criteriaDefinition>
+ <criterion id="version" name="Version">
+ <criterion-value id="1.0" name ="1.0.0"/>
+ <criterion-value id="2.0" name ="2.0.0"/>
+ <criterion-value id="3.0" name ="3.0.0"/>
+ <criterion-value id="4.0" name = "4.0.0"/>
+ </criterion>
+ <criterion id="platform" name="Platform">
+ <criterion-value id="AIX" name ="AIX"/>
+ <criterion-value id="WINDOWS" name ="Windows"/>
+ <criterion-value id="Linux" name ="LINUX"/>
+ </criterion>
+ <criterion id="product" name="Product">
+ <criterion-value id="DB2" name ="DB2"/>
+ <criterion-value id="WAS" name ="WAS"/>
+ </criterion>
+ <criterion id="no criterion value" name ="no criterion value"/>
+ <criterion id="no name">
+ <criterion-value id="bb" name ="bb"/>
+ </criterion>
+</criteriaDefinition>
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/criteria/AllCriteriaTests.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/criteria/AllCriteriaTests.java
index 9fb4c415c..82046d6b0 100644
--- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/criteria/AllCriteriaTests.java
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/criteria/AllCriteriaTests.java
@@ -31,5 +31,6 @@ public class AllCriteriaTests extends TestSuite {
public AllCriteriaTests() {
addTestSuite(ParseTocWithCriteria.class);
addTestSuite(CriteriaUtilitiesTest.class);
+ addTestSuite(ParseCriteriaDefinition.class);
}
}
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/criteria/CriteriaUtilitiesTest.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/criteria/CriteriaUtilitiesTest.java
index 8a1464ddf..8b3b0e7b0 100644
--- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/criteria/CriteriaUtilitiesTest.java
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/criteria/CriteriaUtilitiesTest.java
@@ -45,7 +45,7 @@ public class CriteriaUtilitiesTest extends TestCase {
public void testUppercaseValue() {
List values = CriteriaUtilities.getCriteriaValues("LINUX");
assertEquals(1, values.size());
- assertEquals("linux", values.get(0));
+ assertNotSame("linux", values.get(0));
}
}
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/criteria/ParseCriteriaDefinition.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/criteria/ParseCriteriaDefinition.java
new file mode 100644
index 000000000..392f795fc
--- /dev/null
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/criteria/ParseCriteriaDefinition.java
@@ -0,0 +1,87 @@
+/*******************************************************************************
+ * 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.criteria;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.eclipse.help.internal.UAElement;
+import org.eclipse.help.internal.criteria.CriteriaDefinition;
+import org.eclipse.help.internal.criteria.CriteriaDefinitionAssembler;
+import org.eclipse.help.internal.criteria.CriteriaDefinitionContribution;
+import org.eclipse.help.internal.criteria.CriteriaDefinitionFile;
+import org.eclipse.help.internal.criteria.CriteriaDefinitionFileParser;
+import org.eclipse.help.internal.dynamic.DocumentWriter;
+import org.eclipse.ua.tests.plugin.UserAssistanceTestPlugin;
+
+public class ParseCriteriaDefinition extends TestCase {
+
+ /*
+ * Returns an instance of this Test.
+ */
+ public static Test suite() {
+ return new TestSuite(ParseCriteriaDefinition.class);
+ }
+
+ public void testAssemble() throws Exception {
+ CriteriaDefinitionFileParser parser = new CriteriaDefinitionFileParser();
+ CriteriaDefinitionContribution a = parser.parse(new CriteriaDefinitionFile(UserAssistanceTestPlugin.getPluginId(), "data/help/criteria/criteria_definition/a.xml", "en"));
+ CriteriaDefinitionContribution b = parser.parse(new CriteriaDefinitionFile(UserAssistanceTestPlugin.getPluginId(), "data/help/criteria/criteria_definition/b.xml", "en"));
+ CriteriaDefinitionContribution result_a_b = parser.parse(new CriteriaDefinitionFile(UserAssistanceTestPlugin.getPluginId(), "data/help/criteria/criteria_definition/result_a_b.xml", "en"));
+
+ CriteriaDefinitionAssembler assembler = new CriteriaDefinitionAssembler();
+ List contributions = new ArrayList(Arrays.asList(new Object[] { a, b }));
+ CriteriaDefinition assembled = assembler.assemble(contributions);
+
+ String expected = serialize((UAElement)result_a_b.getCriteriaDefinition());
+ String actual = serialize(assembled);
+ assertEquals(trimWhiteSpace(expected), trimWhiteSpace(actual));
+ }
+
+
+ // Replaces white space between ">" and "<" by a single newline
+
+ private String trimWhiteSpace(String input) {
+ StringBuffer result = new StringBuffer();
+ boolean betweenElements = false;
+ for (int i = 0; i < input.length(); i++) {
+ char next = input.charAt(i);
+ if (betweenElements) {
+ if (!Character.isWhitespace(next)) {
+ result.append(next);
+ if (next == '<') {
+ betweenElements = false;
+ }
+ }
+ } else {
+ result.append(next);
+ if (next == '>') {
+ betweenElements = true;
+ result.append('\r');
+ result.append('\n');
+ }
+ }
+ }
+ String resString = result.toString();
+ return resString;
+ }
+
+ private String serialize(UAElement element) throws Exception {
+ DocumentWriter writer = new DocumentWriter();
+ return writer.writeString(element, true);
+ }
+
+}
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/criteria/ParseTocWithCriteria.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/criteria/ParseTocWithCriteria.java
index 8dca4d739..e00de0df0 100644
--- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/criteria/ParseTocWithCriteria.java
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/criteria/ParseTocWithCriteria.java
@@ -27,13 +27,13 @@ import org.eclipse.help.IToc2;
import org.eclipse.help.ITopic;
import org.eclipse.help.ITopic2;
import org.eclipse.help.internal.Topic;
+import org.eclipse.help.internal.base.scope.CriteriaHelpScope;
import org.eclipse.help.internal.base.util.CriteriaUtilities;
import org.eclipse.help.internal.criteria.CriterionResource;
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.workingset.CriteriaHelpScope;
import org.eclipse.ua.tests.help.other.UserCriteria;
import org.eclipse.ua.tests.help.other.UserToc2;
import org.eclipse.ua.tests.help.other.UserTopic2;
@@ -273,7 +273,7 @@ public class ParseTocWithCriteria extends TestCase {
linuxResource[0] = new CriterionResource("platform");
linuxResource[0].addCriterionValue("linux");
CriteriaHelpScope linuxScope = new CriteriaHelpScope(linuxResource);
- assertTrue(linuxScope.inScope(topics[0]));
+ assertFalse(linuxScope.inScope(topics[0]));
}
public void testValuesWithWhitespace() throws Exception {

Back to the top