diff options
author | Chris Goldthorpe | 2007-11-06 22:39:22 +0000 |
---|---|---|
committer | Chris Goldthorpe | 2007-11-06 22:39:22 +0000 |
commit | 7fcd8730389365b5284deb7a7263c57c8f59f20a (patch) | |
tree | 9b36195b628f216485196ecd6dacd6b7a5e3d23c /org.eclipse.ua.tests | |
parent | 8ea37b4734a7ae0ea871f3d1024b82a532d342fb (diff) | |
download | eclipse.platform.ua-7fcd8730389365b5284deb7a7263c57c8f59f20a.tar.gz eclipse.platform.ua-7fcd8730389365b5284deb7a7263c57c8f59f20a.tar.xz eclipse.platform.ua-7fcd8730389365b5284deb7a7263c57c8f59f20a.zip |
Bug 208906 [Help][Context] Original method of filtering contextual help links no longer works in 3.3
Diffstat (limited to 'org.eclipse.ua.tests')
-rw-r--r-- | org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/ContextTest.java | 138 | ||||
-rw-r--r-- | org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/TopicTest.java | 79 |
2 files changed, 201 insertions, 16 deletions
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/ContextTest.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/ContextTest.java index b43185543..67686e5e1 100644 --- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/ContextTest.java +++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/ContextTest.java @@ -17,6 +17,8 @@ import junit.framework.TestSuite; import org.eclipse.help.IHelpResource; import org.eclipse.help.IUAElement; +import org.eclipse.help.internal.Topic; +import org.eclipse.help.internal.base.HelpEvaluationContext; import org.eclipse.help.internal.context.Context; import org.eclipse.ua.tests.help.util.DocumentCreator; import org.w3c.dom.Document; @@ -27,14 +29,22 @@ public class ContextTest extends TestCase { private static final String ENABLEMENT_CHEATSHEETS = "<enablement><with variable=\"platform\">" + "<test property=\"org.eclipse.core.runtime.isBundleInstalled\" args=\"org.eclipse.ui.cheatsheets\"/>" + "</with></enablement>"; + private static final String ENABLEMENT_INVALID = "<enablement><with variable=\"platform\">" + + "<test property=\"org.eclipse.core.runtime.isBundleInstalled\" args=\"org.eclipse.ui.invalid\"/>" + + "</with></enablement>"; + private static final String FILTER_OUT = "<filter name = \"plugin\" value = \"org.eclipse.ua.invalid\"/>"; private static final String TOPIC_END = "</topic>"; private static final String TOPIC_HEAD_ECLIPSE = "<topic href=\"http://www.eclipse.org\" label=\"enabled\">"; + private final String TOPIC_OLD_FILTER_DISABLED = "<topic filter=\"plugin=org.eclipse.ua.invalid\" href=\"www.eclipse.org\"" + + " label=\"Transformations and transformation configurations\"/>"; private static final String CONTEXT_DESCRIPTION = "<description>Context Description</description>"; private static final String CONTEXT_HEAD = "<context id=\"viewer\" title=\"Sample View\">"; + private static final String CONTEXT_HEAD_WITH_ATTRIBUTE = "<context id=\"viewer\" title=\"Sample View\" att=\"abc\">"; private final String TOPIC_ECLIPSE = "<topic href=\"http://www.eclipse.org\" label=\"eclipse\"/>"; - //private final String TOPIC_ECLIPSE_WITH_ATTRIBUTE = "<topic href=\"http://www.eclipse.org\" label=\"eclipse\" att=\"abc\"/>"; private final String TOPIC_BUGZILLA = "<topic href=\"http://www.eclipse.org/bugzilla\" label=\"bugzilla\"/>"; private final String TOPIC_WITH_ENABLEMENT = TOPIC_HEAD_ECLIPSE + ENABLEMENT_CHEATSHEETS + TOPIC_END; + private final String TOPIC_DISABLED = TOPIC_HEAD_ECLIPSE + ENABLEMENT_INVALID + TOPIC_END; + private final String TOPIC_FILTER_OUT = TOPIC_HEAD_ECLIPSE + FILTER_OUT + TOPIC_END; private final String END_CONTEXT = "</context>"; public static Test suite() { @@ -87,7 +97,7 @@ public class ContextTest extends TestCase { assertEquals(1, topicChildren.length); } - public void testCopyContextWithEnablement() { + public void testCopyContext() { final String contextSource = CONTEXT_HEAD + CONTEXT_DESCRIPTION + TOPIC_WITH_ENABLEMENT + @@ -107,25 +117,22 @@ public class ContextTest extends TestCase { assertEquals(1, related.length); assertEquals("enabled", related[0].getLabel()); assertTrue(related[0] instanceof IUAElement); - IUAElement topic = (IUAElement)related[0]; - IUAElement[] topicChildren = topic.getChildren(); - assertEquals(1, topicChildren.length); + Topic topic = (Topic)related[0]; + assertEquals("http://www.eclipse.org", topic.getHref()); related = context2.getRelatedTopics(); assertEquals(1, related.length); assertEquals("enabled", related[0].getLabel()); assertTrue(related[0] instanceof IUAElement); - topic = (IUAElement)related[0]; - topicChildren = topic.getChildren(); - assertEquals(1, topicChildren.length); + topic = (Topic)related[0]; + assertEquals("http://www.eclipse.org", topic.getHref()); related = context3.getRelatedTopics(); assertEquals(1, related.length); assertEquals("enabled", related[0].getLabel()); assertTrue(related[0] instanceof IUAElement); - topic = (IUAElement)related[0]; - topicChildren = topic.getChildren(); - assertEquals(1, topicChildren.length); + topic = (Topic)related[0]; + assertEquals("http://www.eclipse.org", topic.getHref()); } public void testContextMerge() { @@ -157,16 +164,119 @@ public class ContextTest extends TestCase { assertEquals(1, topicChildren.length); } - /* - public void testContextWithAttribute() { + public void testEnablement() { + final String contextSource = CONTEXT_HEAD + + CONTEXT_DESCRIPTION + + TOPIC_WITH_ENABLEMENT + + TOPIC_DISABLED + + TOPIC_OLD_FILTER_DISABLED + + END_CONTEXT; + Context context = createContext(contextSource); + IHelpResource[] related = context.getRelatedTopics(); + assertEquals(3, related.length); + assertTrue(((Topic)related[0]).isEnabled(HelpEvaluationContext.getContext())); + assertFalse(((Topic)related[1]).isEnabled(HelpEvaluationContext.getContext())); + assertFalse(((Topic)related[2]).isEnabled(HelpEvaluationContext.getContext())); + } + + public void testOldStyleFilteringOfCopies() { + final String contextSource = CONTEXT_HEAD + + CONTEXT_DESCRIPTION + + TOPIC_WITH_ENABLEMENT + + TOPIC_OLD_FILTER_DISABLED + + END_CONTEXT; + Context context1 = createContext(contextSource); + Context context2 = new Context(context1, "id"); + Context context3 = new Context(context2, "id2"); + + IHelpResource[] related1 = context1.getRelatedTopics(); + assertEquals(2, related1.length); + assertTrue(((Topic)related1[0]).isEnabled(HelpEvaluationContext.getContext())); + assertFalse(((Topic)related1[1]).isEnabled(HelpEvaluationContext.getContext())); + + IHelpResource[] related2 = context2.getRelatedTopics(); + assertEquals(2, related2.length); + assertTrue(((Topic)related2[0]).isEnabled(HelpEvaluationContext.getContext())); + assertFalse(((Topic)related2[1]).isEnabled(HelpEvaluationContext.getContext())); + + IHelpResource[] related3 = context3.getRelatedTopics(); + assertEquals(2, related3.length); + assertTrue(((Topic)related3[0]).isEnabled(HelpEvaluationContext.getContext())); + assertFalse(((Topic)related3[1]).isEnabled(HelpEvaluationContext.getContext())); + } + + public void testFilteringOfCopies() { final String contextSource = CONTEXT_HEAD + CONTEXT_DESCRIPTION + - TOPIC_ECLIPSE_WITH_ATTRIBUTE + + TOPIC_WITH_ENABLEMENT + + TOPIC_FILTER_OUT + + END_CONTEXT; + Context context1 = createContext(contextSource); + Context context2 = new Context(context1, "id"); + Context context3 = new Context(context2, "id2"); + IHelpResource[] related1 = context1.getRelatedTopics(); + assertEquals(2, related1.length); + assertTrue(((Topic)related1[0]).isEnabled(HelpEvaluationContext.getContext())); + assertFalse(((Topic)related1[1]).isEnabled(HelpEvaluationContext.getContext())); + + IHelpResource[] related2 = context2.getRelatedTopics(); + assertEquals(2, related2.length); + assertTrue(((Topic)related2[0]).isEnabled(HelpEvaluationContext.getContext())); + assertFalse(((Topic)related2[1]).isEnabled(HelpEvaluationContext.getContext())); + + IHelpResource[] related3 = context3.getRelatedTopics(); + assertEquals(2, related3.length); + assertTrue(((Topic)related3[0]).isEnabled(HelpEvaluationContext.getContext())); + assertFalse(((Topic)related3[1]).isEnabled(HelpEvaluationContext.getContext())); + } + + public void testEnablementOfCopies() { + final String contextSource = CONTEXT_HEAD + + CONTEXT_DESCRIPTION + + TOPIC_WITH_ENABLEMENT + + TOPIC_DISABLED + + END_CONTEXT; + Context context1 = createContext(contextSource); + Context context2 = new Context(context1, "id"); + Context context3 = new Context(context2, "id2"); + IHelpResource[] related1 = context1.getRelatedTopics(); + assertEquals(2, related1.length); + assertTrue(((Topic)related1[0]).isEnabled(HelpEvaluationContext.getContext())); + assertFalse(((Topic)related1[1]).isEnabled(HelpEvaluationContext.getContext())); + + IHelpResource[] related2 = context2.getRelatedTopics(); + assertEquals(2, related2.length); + assertTrue(((Topic)related2[0]).isEnabled(HelpEvaluationContext.getContext())); + assertFalse(((Topic)related2[1]).isEnabled(HelpEvaluationContext.getContext())); + + IHelpResource[] related3 = context3.getRelatedTopics(); + assertEquals(2, related3.length); + assertTrue(((Topic)related3[0]).isEnabled(HelpEvaluationContext.getContext())); + assertFalse(((Topic)related3[1]).isEnabled(HelpEvaluationContext.getContext())); + } + + public void testContextWithAttribute() { + final String contextSource = CONTEXT_HEAD_WITH_ATTRIBUTE + + CONTEXT_DESCRIPTION + + TOPIC_ECLIPSE + END_CONTEXT; Context context; context = createContext(contextSource); assertEquals("abc", context.getAttribute("att")); } + + /* + public void testCopyContextWithAttribute() { + final String contextSource = CONTEXT_HEAD_WITH_ATTRIBUTE + + CONTEXT_DESCRIPTION + + TOPIC_ECLIPSE + + END_CONTEXT; + Context context1; + context1 = createContext(contextSource); + Context context2 = new Context(context1, "id"); + assertEquals("abc", context1.getAttribute("att")); + assertEquals("abc", context2.getAttribute("att")); + } */ } diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/TopicTest.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/TopicTest.java index 8e7db58c0..b54e0eca9 100644 --- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/TopicTest.java +++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/TopicTest.java @@ -29,15 +29,26 @@ public class TopicTest extends TestCase { "<test property=\"org.eclipse.core.runtime.isBundleInstalled\" args=\"org.eclipse.ui.cheatsheets\"/></with>"; private static final String ENABLEMENT_CHEATSHEETS = "<enablement>" + CS_INSTALLED + "</enablement>"; private static final String ENABLEMENT_INVALID = "<enablement>" + INVALID_INSTALLED + "</enablement>"; + private static final String FILTER_IN = "<filter name = \"plugin\" value = \"org.eclipse.ua.tests\"/>"; + private static final String FILTER_OUT = "<filter name = \"plugin\" value = \"org.eclipse.ua.invalid\"/>"; + private static final String NEGATED_FILTER_IN = "<filter name = \"plugin\" value = \"!org.eclipse.ua.tests\"/>"; + private static final String NEGATED_FILTER_OUT = "<filter name = \"plugin\" value = \"!org.eclipse.ua.invalid\"/>"; private static final String TOPIC_END = "</topic>"; private static final String TOPIC_HEAD_ECLIPSE = "<topic href=\"http://www.eclipse.org\" label=\"enabled\">"; private final String TOPIC_ECLIPSE = "<topic href=\"http://www.eclipse.org\" label=\"eclipse\"/>"; private final String TOPIC_WITH_ENABLEMENT = TOPIC_HEAD_ECLIPSE + ENABLEMENT_CHEATSHEETS + TOPIC_END; private final String TOPIC_NOT_ENABLED = TOPIC_HEAD_ECLIPSE + ENABLEMENT_INVALID + TOPIC_END; + private final String TOPIC_FILTER_IN = TOPIC_HEAD_ECLIPSE + FILTER_IN + TOPIC_END; + private final String TOPIC_FILTER_OUT = TOPIC_HEAD_ECLIPSE + FILTER_OUT + TOPIC_END; + private final String TOPIC_FILTER_MIXED = TOPIC_HEAD_ECLIPSE + FILTER_IN + FILTER_OUT + TOPIC_END; private final String TOPIC_OLD_FILTER = "<topic filter=\"plugin=org.eclipse.ua.tests\" href=\"www.eclipse.org\"" + " label=\"Transformations and transformation configurations\"/>"; private final String TOPIC_OLD_FILTER_DISABLED = "<topic filter=\"plugin=org.eclipse.ua.invalid\" href=\"www.eclipse.org\"" + " label=\"Transformations and transformation configurations\"/>"; + private final String TOPIC_OLD_FILTER_IN__NEGATED = "<topic filter=\"plugin!=org.eclipse.ua.tests\" href=\"www.eclipse.org\"" + + " label=\"Transformations and transformation configurations\"/>"; + private final String TOPIC_OLD_FILTER_OUT_NEGATED = "<topic filter=\"plugin!=org.eclipse.ua.invalid\" href=\"www.eclipse.org\"" + + " label=\"Transformations and transformation configurations\"/>"; public static Test suite() { return new TestSuite(TopicTest.class); } @@ -77,13 +88,23 @@ public class TopicTest extends TestCase { topic = createTopic(TOPIC_WITH_ENABLEMENT); assertTrue(topic.isEnabled(HelpEvaluationContext.getContext())); } - + public void testDisabledTopic() { Topic topic; topic = createTopic(TOPIC_NOT_ENABLED); assertFalse(topic.isEnabled(HelpEvaluationContext.getContext())); } + public void testCopyDisabledTopic() { + Topic topic1; + topic1 = createTopic(TOPIC_NOT_ENABLED); + Topic topic2 = new Topic(topic1); + Topic topic3 = new Topic(topic2); + assertFalse(topic1.isEnabled(HelpEvaluationContext.getContext())); + assertFalse(topic2.isEnabled(HelpEvaluationContext.getContext())); + assertFalse(topic3.isEnabled(HelpEvaluationContext.getContext())); + } + public void testCompoundEnablement() { Topic topic; topic = createTopic(TOPIC_HEAD_ECLIPSE + "<enablement>" @@ -103,11 +124,65 @@ public class TopicTest extends TestCase { topic = createTopic(TOPIC_OLD_FILTER); assertTrue(topic.isEnabled(HelpEvaluationContext.getContext())); } - + public void testOldStyleDisabled() { Topic topic; topic = createTopic(TOPIC_OLD_FILTER_DISABLED); assertFalse(topic.isEnabled(HelpEvaluationContext.getContext())); } + + public void testOldStyleNegated() { + Topic topic; + topic = createTopic(TOPIC_OLD_FILTER_IN__NEGATED); + assertFalse(topic.isEnabled(HelpEvaluationContext.getContext())); + topic = createTopic(TOPIC_OLD_FILTER_OUT_NEGATED); + assertTrue(topic.isEnabled(HelpEvaluationContext.getContext())); + } + + public void testCopyOldStyleDisabled() { + Topic topic1; + topic1 = createTopic(TOPIC_OLD_FILTER_DISABLED); + Topic topic2 = new Topic(topic1); + Topic topic3 = new Topic(topic2); + assertFalse(topic1.isEnabled(HelpEvaluationContext.getContext())); + assertFalse(topic2.isEnabled(HelpEvaluationContext.getContext())); + assertFalse(topic3.isEnabled(HelpEvaluationContext.getContext())); + } + + public void testFilterIn() { + Topic topic; + topic = createTopic(TOPIC_FILTER_IN); + assertTrue(topic.isEnabled(HelpEvaluationContext.getContext())); + } + + public void testFilterOut() { + Topic topic; + topic = createTopic(TOPIC_FILTER_OUT); + assertFalse(topic.isEnabled(HelpEvaluationContext.getContext())); + } + + public void testFilterMixed() { + Topic topic; + topic = createTopic(TOPIC_FILTER_MIXED); + assertFalse(topic.isEnabled(HelpEvaluationContext.getContext())); + } + + public void testNegatedFilters() { + Topic topic; + topic = createTopic(TOPIC_HEAD_ECLIPSE + NEGATED_FILTER_IN + TOPIC_END); + assertFalse(topic.isEnabled(HelpEvaluationContext.getContext())); + topic = createTopic(TOPIC_HEAD_ECLIPSE + NEGATED_FILTER_OUT + TOPIC_END); + assertTrue(topic.isEnabled(HelpEvaluationContext.getContext())); + } + + public void testCopyFilterOut() { + Topic topic1; + topic1 = createTopic(TOPIC_FILTER_OUT); + Topic topic2 = new Topic(topic1); + Topic topic3 = new Topic(topic2); + assertFalse(topic1.isEnabled(HelpEvaluationContext.getContext())); + assertFalse(topic2.isEnabled(HelpEvaluationContext.getContext())); + assertFalse(topic3.isEnabled(HelpEvaluationContext.getContext())); + } } |