Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Goldthorpe2010-03-01 17:30:19 -0500
committerChris Goldthorpe2010-03-01 17:30:19 -0500
commit77b551b275bfd7b6cfd71c619c3988d14dcec7a5 (patch)
treeb61a436537c197d3214e393e253846ac44b7e605 /org.eclipse.ua.tests
parent94be1b5d90055af0cbea6b5b4a478769f1299e43 (diff)
downloadeclipse.platform.ua-77b551b275bfd7b6cfd71c619c3988d14dcec7a5.tar.gz
eclipse.platform.ua-77b551b275bfd7b6cfd71c619c3988d14dcec7a5.tar.xz
eclipse.platform.ua-77b551b275bfd7b6cfd71c619c3988d14dcec7a5.zip
Bug 290831 - [Help] Eclipse Help shortcuts the <a> in XHTML content.
Diffstat (limited to 'org.eclipse.ua.tests')
-rw-r--r--org.eclipse.ua.tests/base/org/eclipse/ua/tests/util/XMLUtil.java13
-rw-r--r--org.eclipse.ua.tests/data/help/dynamic/xhtml/emptyAnchor.xhtml32
-rw-r--r--org.eclipse.ua.tests/data/help/dynamic/xhtml/emptyAnchorWithComment.xhtml32
-rw-r--r--org.eclipse.ua.tests/data/help/dynamic/xhtml/emptyDiv.xhtml24
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/dynamic/AllDynamicTests.java3
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/dynamic/DynamicXHTMLProcessorTest.java109
6 files changed, 210 insertions, 3 deletions
diff --git a/org.eclipse.ua.tests/base/org/eclipse/ua/tests/util/XMLUtil.java b/org.eclipse.ua.tests/base/org/eclipse/ua/tests/util/XMLUtil.java
index 04f4b6d4d..b81b1d203 100644
--- a/org.eclipse.ua.tests/base/org/eclipse/ua/tests/util/XMLUtil.java
+++ b/org.eclipse.ua.tests/base/org/eclipse/ua/tests/util/XMLUtil.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2008 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
@@ -41,13 +41,22 @@ public class XMLUtil extends Assert {
InputStream in2 = new ByteArrayInputStream(s2.getBytes("UTF-8"));
assertXMLEquals(msg, in1, in2);
}
-
+
public static void assertXMLEquals(String msg, InputStream in1, InputStream in2) throws Exception {
String s1 = process(in1);
String s2 = process(in2);
assertEquals(msg, s1, s2);
}
+ public static void assertParseableXML(String s) {
+ try {
+ InputStream in1 = new ByteArrayInputStream(s.getBytes("UTF-8"));
+ process(in1);
+ } catch (Exception e) {
+ fail("Unable to parse source: " + s);
+ }
+ }
+
private static String process(InputStream in) throws Exception {
SAXParserFactory factory = SAXParserFactory.newInstance();
SAXParser parser = factory.newSAXParser();
diff --git a/org.eclipse.ua.tests/data/help/dynamic/xhtml/emptyAnchor.xhtml b/org.eclipse.ua.tests/data/help/dynamic/xhtml/emptyAnchor.xhtml
new file mode 100644
index 000000000..c9b70baee
--- /dev/null
+++ b/org.eclipse.ua.tests/data/help/dynamic/xhtml/emptyAnchor.xhtml
@@ -0,0 +1,32 @@
+<!--
+ 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
+ -->
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
+<meta http-equiv="Content-Style-Type" content="text/css" />
+
+<link rel="STYLESHEET" href="../book.css" charset="ISO-8859-1" type="text/css" />
+<title>Title</title>
+<script language="JavaScript" src="livehelp.js" type="text/javascript"></script>
+</head>
+
+<body bgcolor="#ffffff">
+<div></div>
+<div>
+Check that paragraph is not collapsed.
+<p></p>
+Check that anchor is not collapsed.
+<a></a>
+</div>
+
+</body>
+</html>
diff --git a/org.eclipse.ua.tests/data/help/dynamic/xhtml/emptyAnchorWithComment.xhtml b/org.eclipse.ua.tests/data/help/dynamic/xhtml/emptyAnchorWithComment.xhtml
new file mode 100644
index 000000000..afbe9bc94
--- /dev/null
+++ b/org.eclipse.ua.tests/data/help/dynamic/xhtml/emptyAnchorWithComment.xhtml
@@ -0,0 +1,32 @@
+<!--
+ 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
+ -->
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
+<meta http-equiv="Content-Style-Type" content="text/css" />
+
+<link rel="STYLESHEET" href="../book.css" charset="ISO-8859-1" type="text/css" />
+<title>Title</title>
+<script language="JavaScript" src="livehelp.js" type="text/javascript"></script>
+</head>
+
+<body bgcolor="#ffffff">
+<div></div>
+<div>
+Check that paragraph is not collapsed.
+<p><!-- --></p>
+Check that anchor is not collapsed.
+<a><!-- --></a>
+</div>
+
+</body>
+</html>
diff --git a/org.eclipse.ua.tests/data/help/dynamic/xhtml/emptyDiv.xhtml b/org.eclipse.ua.tests/data/help/dynamic/xhtml/emptyDiv.xhtml
new file mode 100644
index 000000000..5c5c7b026
--- /dev/null
+++ b/org.eclipse.ua.tests/data/help/dynamic/xhtml/emptyDiv.xhtml
@@ -0,0 +1,24 @@
+<!--
+ 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
+ -->
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
+<meta http-equiv="Content-Style-Type" content="text/css" />
+
+<link rel="STYLESHEET" href="../book.css" charset="ISO-8859-1" type="text/css" />
+<title>Title</title>
+<script language="JavaScript" src="livehelp.js" type="text/javascript"></script>
+</head>
+
+<body bgcolor="#ffffff">
+<div></div></body>
+</html>
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/dynamic/AllDynamicTests.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/dynamic/AllDynamicTests.java
index 7d7a739f5..e259a9795 100644
--- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/dynamic/AllDynamicTests.java
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/dynamic/AllDynamicTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006 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
@@ -30,5 +30,6 @@ public class AllDynamicTests extends TestSuite {
*/
public AllDynamicTests() {
addTest(XMLProcessorTest.suite());
+ addTest(DynamicXHTMLProcessorTest.suite());
}
}
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/dynamic/DynamicXHTMLProcessorTest.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/dynamic/DynamicXHTMLProcessorTest.java
new file mode 100644
index 000000000..fcf0a42ea
--- /dev/null
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/dynamic/DynamicXHTMLProcessorTest.java
@@ -0,0 +1,109 @@
+/*******************************************************************************
+ * 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.dynamic;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.eclipse.help.internal.xhtml.DynamicXHTMLProcessor;
+import org.eclipse.help.ui.internal.HelpUIPlugin;
+import org.eclipse.ua.tests.plugin.UserAssistanceTestPlugin;
+import org.eclipse.ua.tests.util.XMLUtil;
+import org.osgi.framework.Bundle;
+import org.xml.sax.SAXException;
+
+public class DynamicXHTMLProcessorTest extends TestCase {
+
+ /*
+ * Returns an instance of this Test.
+ */
+ public static Test suite() {
+ return new TestSuite(DynamicXHTMLProcessorTest.class);
+ }
+
+ protected void setUp() throws Exception {
+ // activate the UI plug-in for UI filtering ability
+ HelpUIPlugin.getDefault();
+ }
+
+ private String process(String path) throws Exception {
+ Bundle bundle = UserAssistanceTestPlugin.getDefault().getBundle();
+ InputStream is = getProcessedInput(path, bundle);
+ return readStream(is);
+ }
+
+ protected InputStream getProcessedInput(String path, Bundle bundle)
+ throws IOException, SAXException, ParserConfigurationException,
+ TransformerException, TransformerConfigurationException {
+ InputStream in = bundle.getEntry(path).openStream();
+ String href = '/' + bundle.getBundleId() +path;
+ return DynamicXHTMLProcessor.process(href, in, "en", true);
+ }
+
+ private String readStream(InputStream is) throws Exception {
+ InputStreamReader inputStreamReader = new InputStreamReader(is, "UTF-8");
+ StringBuffer buffer = new StringBuffer();
+ char[] cbuf = new char[256];
+ int len;
+ do {
+ len = inputStreamReader.read(cbuf);
+ if (len > 0) {
+ buffer.append(cbuf, 0, len);
+ }
+ } while (len >= 0);
+ return buffer.toString();
+ }
+
+ public void testXhtmlNoCollapseAnchor() throws Exception {
+ String processed = process("data/help/dynamic/xhtml/emptyAnchor.xhtml");
+ assertTrue("Anchor collapsed in " + processed, processed.indexOf("</a>") > 0);
+ }
+
+ public void testXhtmlNoCollapseParagraph() throws Exception {
+ String processed = process("data/help/dynamic/xhtml/emptyAnchor.xhtml");
+ assertTrue("Paragraph collapsed in " + processed, processed.indexOf("</p>") > 0);
+ }
+
+ public void testXhtmlNoCollapseAnchorIC() throws Exception {
+ String processed = process("data/help/dynamic/xhtml/emptyAnchorWithComment.xhtml");
+ assertTrue("Anchor collapsed in " + processed, processed.indexOf("</a>") > 0);
+ }
+
+ public void testXhtmlNoCollapseParagraphIC() throws Exception {
+ String processed = process("data/help/dynamic/xhtml/emptyAnchorWithComment.xhtml");
+ assertTrue("Paragraph collapsed in " + processed, processed.indexOf("</p>") > 0);
+ }
+
+ public void testXhtmlNoCollapseDiv() throws Exception {
+ String processed = process("data/help/dynamic/xhtml/emptyDiv.xhtml");
+ assertTrue("Div collapsed in " + processed, processed.indexOf("</div>") > 0);
+ }
+
+ public void testXhtmlNoCollapseScript() throws Exception {
+ String processed = process("data/help/dynamic/xhtml/emptyAnchor.xhtml");
+ assertTrue("Div collapsed in " + processed, processed.indexOf("</script>") > 0);
+ }
+
+ public void testValidXML() throws Exception {
+ String processed = process("data/help/dynamic/xhtml/emptyAnchor.xhtml");
+ XMLUtil.assertParseableXML(processed);
+ }
+
+}

Back to the top