|
Added
Link Here
|
| 1 |
package org.eclipse.jdt.ui.tests.packageHover; |
| 2 |
|
| 3 |
import java.io.File; |
| 4 |
|
| 5 |
import junit.framework.Assert; |
| 6 |
import junit.framework.Test; |
| 7 |
import junit.framework.TestSuite; |
| 8 |
|
| 9 |
import org.eclipse.jdt.testplugin.JavaProjectHelper; |
| 10 |
import org.eclipse.jdt.testplugin.JavaTestPlugin; |
| 11 |
|
| 12 |
import org.eclipse.core.runtime.IPath; |
| 13 |
import org.eclipse.core.runtime.Path; |
| 14 |
|
| 15 |
import org.eclipse.core.resources.ResourcesPlugin; |
| 16 |
|
| 17 |
import org.eclipse.jface.text.Region; |
| 18 |
|
| 19 |
import org.eclipse.jdt.core.IClasspathAttribute; |
| 20 |
import org.eclipse.jdt.core.IClasspathEntry; |
| 21 |
import org.eclipse.jdt.core.ICompilationUnit; |
| 22 |
import org.eclipse.jdt.core.IJavaElement; |
| 23 |
import org.eclipse.jdt.core.IJavaProject; |
| 24 |
import org.eclipse.jdt.core.IPackageFragment; |
| 25 |
import org.eclipse.jdt.core.IPackageFragmentRoot; |
| 26 |
import org.eclipse.jdt.core.JavaCore; |
| 27 |
|
| 28 |
import org.eclipse.jdt.internal.core.JavaElement; |
| 29 |
import org.eclipse.jdt.internal.corext.javadoc.JavaDocLocations; |
| 30 |
|
| 31 |
import org.eclipse.jdt.ui.JavaElementLabels; |
| 32 |
import org.eclipse.jdt.ui.tests.core.CoreTests; |
| 33 |
import org.eclipse.jdt.ui.tests.core.ProjectTestSetup; |
| 34 |
|
| 35 |
import org.eclipse.jdt.internal.ui.JavaPlugin; |
| 36 |
import org.eclipse.jdt.internal.ui.text.java.hover.JavadocBrowserInformationControlInput; |
| 37 |
import org.eclipse.jdt.internal.ui.text.java.hover.JavadocHover; |
| 38 |
import org.eclipse.jdt.internal.ui.viewsupport.JavaElementLinks; |
| 39 |
|
| 40 |
public class PackageJavadocTest extends CoreTests { |
| 41 |
|
| 42 |
public PackageJavadocTest(String name) { |
| 43 |
super(name); |
| 44 |
} |
| 45 |
|
| 46 |
public static Test suite() { |
| 47 |
return setUpTest(new TestSuite(PackageJavadocTest.class)); |
| 48 |
} |
| 49 |
|
| 50 |
private IJavaProject fJProject1; |
| 51 |
|
| 52 |
|
| 53 |
public void testGetDocFromPackageHtml_src() throws Exception { |
| 54 |
|
| 55 |
File junitSrcArchive= JavaTestPlugin.getDefault().getFileInPlugin(new Path("testresources/JavadocHover_src.zip")); |
| 56 |
|
| 57 |
assertTrue("junit src not found", junitSrcArchive != null && junitSrcArchive.exists()); |
| 58 |
|
| 59 |
JavaProjectHelper.addSourceContainerWithImport(fJProject1, "src", junitSrcArchive, JavaProjectHelper.JUNIT_SRC_ENCODING); |
| 60 |
ICompilationUnit cu= (ICompilationUnit)fJProject1.findElement(new Path("JavadocHover_src/junit/javadochoverhtml/JavaDocHoverTest.java")); |
| 61 |
assertNotNull("JavaDocHoverTest.java", cu); |
| 62 |
|
| 63 |
IPackageFragment pack= (IPackageFragment)cu.getParent(); |
| 64 |
IJavaElement[] elements= new JavaElement[1]; |
| 65 |
elements[0]= pack; |
| 66 |
JavadocBrowserInformationControlInput hoverInfo= JavadocHover.getHoverInfo(elements, cu, new Region(21, 16), null); |
| 67 |
String actualHtmlContent= hoverInfo.getHtml(); |
| 68 |
|
| 69 |
String javadochoverLoc= JavaDocLocations.getBaseURL(pack, false); |
| 70 |
String imageLoc= JavaPlugin.getDefault().getImagesOnFSRegistry().getImageURL(pack).toExternalForm(); |
| 71 |
|
| 72 |
StringBuffer expectedHtmlContent= new StringBuffer(); |
| 73 |
|
| 74 |
expectedHtmlContent.append("<html><head><style CHARSET=\"ISO-8859-1\" TYPE=\"text/css\">/* Font definitions */\n"); |
| 75 |
expectedHtmlContent.append("html { font-family: 'Segoe UI',sans-serif; font-size: 9pt; font-style: normal; font-weight: normal; }\n"); |
| 76 |
expectedHtmlContent.append("body, h1, h2, h3, h4, h5, h6, p, table, td, caption, th, ul, ol, dl, li, dd, dt { font-size: 1em; }\n"); |
| 77 |
expectedHtmlContent.append("pre { font-family: monospace; }\n\n"); |
| 78 |
expectedHtmlContent.append("/* Margins */\n"); |
| 79 |
expectedHtmlContent.append("body { overflow: auto; margin-top: 0px; margin-bottom: 0.5em; margin-left: 0.3em; margin-right: 0px; }\n"); |
| 80 |
expectedHtmlContent.append("h1 { margin-top: 0.3em; margin-bottom: 0.04em; } \n"); |
| 81 |
expectedHtmlContent.append("h2 { margin-top: 2em; margin-bottom: 0.25em; }\n"); |
| 82 |
expectedHtmlContent.append("h3 { margin-top: 1.7em; margin-bottom: 0.25em; }\n"); |
| 83 |
expectedHtmlContent.append("h4 { margin-top: 2em; margin-bottom: 0.3em; }\n"); |
| 84 |
expectedHtmlContent.append("h5 { margin-top: 0px; margin-bottom: 0px; }\n"); |
| 85 |
expectedHtmlContent.append("p { margin-top: 1em; margin-bottom: 1em; }\n"); |
| 86 |
expectedHtmlContent.append("pre { margin-left: 0.6em; }\n"); |
| 87 |
expectedHtmlContent.append("ul { margin-top: 0px; margin-bottom: 1em; margin-left: 1em; padding-left: 1em;}\n"); |
| 88 |
expectedHtmlContent.append("li { margin-top: 0px; margin-bottom: 0px; } \n"); |
| 89 |
expectedHtmlContent.append("li p { margin-top: 0px; margin-bottom: 0px; } \n"); |
| 90 |
expectedHtmlContent.append("ol { margin-top: 0px; margin-bottom: 1em; margin-left: 1em; padding-left: 1em; }\n"); |
| 91 |
expectedHtmlContent.append("dl { margin-top: 0px; margin-bottom: 1em; }\n"); |
| 92 |
expectedHtmlContent.append("dt { margin-top: 0px; margin-bottom: 0px; font-weight: bold; }\n"); |
| 93 |
expectedHtmlContent.append("dd { margin-top: 0px; margin-bottom: 0px; }\n\n"); |
| 94 |
expectedHtmlContent.append("/* Styles and colors */\n"); |
| 95 |
expectedHtmlContent.append("a:link { color: #0000FF; }\n"); |
| 96 |
expectedHtmlContent.append("a:hover { color: #000080; }\n"); |
| 97 |
expectedHtmlContent.append("a:visited { text-decoration: underline; }\n"); |
| 98 |
expectedHtmlContent.append("a.header:link { text-decoration: none; color: #000000 }\n"); |
| 99 |
expectedHtmlContent.append("a.header:visited { text-decoration: none; color: #000000 }\n"); |
| 100 |
expectedHtmlContent.append("a.header:hover { text-decoration: underline; color: #000080; }\n"); |
| 101 |
expectedHtmlContent.append("h4 { font-style: italic; }\n"); |
| 102 |
expectedHtmlContent.append("strong { font-weight: bold; }\n"); |
| 103 |
expectedHtmlContent.append("em { font-style: italic; }\n"); |
| 104 |
expectedHtmlContent.append("var { font-style: italic; }\n"); |
| 105 |
expectedHtmlContent.append("th { font-weight: bold; }\n"); |
| 106 |
expectedHtmlContent.append("</style>\n"); |
| 107 |
expectedHtmlContent.append("<base href='" + javadochoverLoc + "'>\n"); |
| 108 |
expectedHtmlContent |
| 109 |
.append("</head><body text=\"#000000\" bgcolor=\"#ffffe1\"><h5><div style='word-wrap: break-word; position: relative; margin-left: 20px; padding-top: 2px; '><a href='" |
| 110 |
+ JavaElementLinks.createURI(JavaElementLinks.OPEN_LINK_SCHEME, pack) + "'><!--[if lte IE 6]><![if gte IE 5.5]>\n"); |
| 111 |
expectedHtmlContent |
| 112 |
.append("<span alt='Open Declaration' style=\"border:none; position: absolute; width: 16px; height: 16px; left: -21px; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" |
| 113 |
+ imageLoc + "')\"></span>\n"); |
| 114 |
expectedHtmlContent.append("<![endif]><![endif]-->\n"); |
| 115 |
expectedHtmlContent.append("<!--[if !IE]>-->\n"); |
| 116 |
expectedHtmlContent |
| 117 |
.append("<img alt='Open Declaration' style='border:none; position: absolute; width: 16px; height: 16px; left: -21px; ' src='" + imageLoc + "'/>\n"); |
| 118 |
expectedHtmlContent.append("<!--<![endif]-->\n"); |
| 119 |
expectedHtmlContent.append("<!--[if gte IE 7]>\n"); |
| 120 |
expectedHtmlContent |
| 121 |
.append("<img alt='Open Declaration' style='border:none; position: absolute; width: 16px; height: 16px; left: -21px; ' src='" + imageLoc + "'/>\n"); |
| 122 |
expectedHtmlContent.append("<![endif]-->\n"); |
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
expectedHtmlContent.append("</a>" + JavaElementLinks.getElementLabel(pack, JavaElementLabels.P_COMPRESSED) + "</div></h5><br><p>"); |
| 127 |
|
| 128 |
expectedHtmlContent.append("<!doctype html public \"-//w3c//dtd html 4.0 transitional//en\">\r\n"); |
| 129 |
expectedHtmlContent.append("<html>\r\n"); |
| 130 |
expectedHtmlContent.append("<head>\r\n"); |
| 131 |
expectedHtmlContent.append(" <meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">\r\n"); |
| 132 |
expectedHtmlContent.append(" <title>Package-level Javadoc</title>\r\n"); |
| 133 |
expectedHtmlContent.append("</head>\r\n"); |
| 134 |
expectedHtmlContent.append("<body>\r\n"); |
| 135 |
expectedHtmlContent.append("Test package documentation in package.html\r\n"); |
| 136 |
expectedHtmlContent.append("This is to test package hovering.\r\n"); |
| 137 |
expectedHtmlContent.append("</body>\r\n"); |
| 138 |
expectedHtmlContent.append("</html>\r\n"); |
| 139 |
expectedHtmlContent.append("</body></html>"); |
| 140 |
Assert.assertEquals(expectedHtmlContent.toString(), actualHtmlContent); |
| 141 |
|
| 142 |
|
| 143 |
} |
| 144 |
|
| 145 |
|
| 146 |
public void testGetDocFromPackageInfoJava_src() throws Exception { |
| 147 |
|
| 148 |
|
| 149 |
File junitSrcArchive= JavaTestPlugin.getDefault().getFileInPlugin(new Path("testresources/JavadocHover_src.zip")); |
| 150 |
|
| 151 |
assertTrue("junit src not found", junitSrcArchive != null && junitSrcArchive.exists()); |
| 152 |
|
| 153 |
JavaProjectHelper.addSourceContainerWithImport(fJProject1, "src", junitSrcArchive, JavaProjectHelper.JUNIT_SRC_ENCODING); |
| 154 |
ICompilationUnit cu= (ICompilationUnit)fJProject1.findElement(new Path("JavadocHover_src/junit/javadochover/Activator.java")); |
| 155 |
assertNotNull("Activator.java", cu); |
| 156 |
|
| 157 |
IPackageFragment pack= (IPackageFragment)cu.getParent(); |
| 158 |
IJavaElement[] elements= new JavaElement[1]; |
| 159 |
elements[0]= pack; |
| 160 |
JavadocBrowserInformationControlInput hoverInfo= JavadocHover.getHoverInfo(elements, cu, new Region(21, 12), null); |
| 161 |
String actualHtmlContent= hoverInfo.getHtml(); |
| 162 |
|
| 163 |
StringBuffer expectedHtmlContent= new StringBuffer(); |
| 164 |
expectedHtmlContent.append("<html><head><style CHARSET=\"ISO-8859-1\" TYPE=\"text/css\">/* Font definitions */\n"); |
| 165 |
expectedHtmlContent.append("html { font-family: 'Segoe UI',sans-serif; font-size: 9pt; font-style: normal; font-weight: normal; }\n"); |
| 166 |
expectedHtmlContent.append("body, h1, h2, h3, h4, h5, h6, p, table, td, caption, th, ul, ol, dl, li, dd, dt { font-size: 1em; }\n"); |
| 167 |
expectedHtmlContent.append("pre { font-family: monospace; }\n\n"); |
| 168 |
expectedHtmlContent.append("/* Margins */\n"); |
| 169 |
expectedHtmlContent.append("body { overflow: auto; margin-top: 0px; margin-bottom: 0.5em; margin-left: 0.3em; margin-right: 0px; }\n"); |
| 170 |
expectedHtmlContent.append("h1 { margin-top: 0.3em; margin-bottom: 0.04em; } \n"); |
| 171 |
expectedHtmlContent.append("h2 { margin-top: 2em; margin-bottom: 0.25em; }\n"); |
| 172 |
expectedHtmlContent.append("h3 { margin-top: 1.7em; margin-bottom: 0.25em; }\n"); |
| 173 |
expectedHtmlContent.append("h4 { margin-top: 2em; margin-bottom: 0.3em; }\n"); |
| 174 |
expectedHtmlContent.append("h5 { margin-top: 0px; margin-bottom: 0px; }\n"); |
| 175 |
expectedHtmlContent.append("p { margin-top: 1em; margin-bottom: 1em; }\n"); |
| 176 |
expectedHtmlContent.append("pre { margin-left: 0.6em; }\n"); |
| 177 |
expectedHtmlContent.append("ul { margin-top: 0px; margin-bottom: 1em; margin-left: 1em; padding-left: 1em;}\n"); |
| 178 |
expectedHtmlContent.append("li { margin-top: 0px; margin-bottom: 0px; } \n"); |
| 179 |
expectedHtmlContent.append("li p { margin-top: 0px; margin-bottom: 0px; } \n"); |
| 180 |
expectedHtmlContent.append("ol { margin-top: 0px; margin-bottom: 1em; margin-left: 1em; padding-left: 1em; }\n"); |
| 181 |
expectedHtmlContent.append("dl { margin-top: 0px; margin-bottom: 1em; }\n"); |
| 182 |
expectedHtmlContent.append("dt { margin-top: 0px; margin-bottom: 0px; font-weight: bold; }\n"); |
| 183 |
expectedHtmlContent.append("dd { margin-top: 0px; margin-bottom: 0px; }\n\n"); |
| 184 |
expectedHtmlContent.append("/* Styles and colors */\n"); |
| 185 |
expectedHtmlContent.append("a:link { color: #0000FF; }\n"); |
| 186 |
expectedHtmlContent.append("a:hover { color: #000080; }\n"); |
| 187 |
expectedHtmlContent.append("a:visited { text-decoration: underline; }\n"); |
| 188 |
expectedHtmlContent.append("a.header:link { text-decoration: none; color: #000000 }\n"); |
| 189 |
expectedHtmlContent.append("a.header:visited { text-decoration: none; color: #000000 }\n"); |
| 190 |
expectedHtmlContent.append("a.header:hover { text-decoration: underline; color: #000080; }\n"); |
| 191 |
expectedHtmlContent.append("h4 { font-style: italic; }\n"); |
| 192 |
expectedHtmlContent.append("strong { font-weight: bold; }\n"); |
| 193 |
expectedHtmlContent.append("em { font-style: italic; }\n"); |
| 194 |
expectedHtmlContent.append("var { font-style: italic; }\n"); |
| 195 |
expectedHtmlContent.append("th { font-weight: bold; }\n"); |
| 196 |
expectedHtmlContent.append("</style>\n"); |
| 197 |
String javadochoverLoc= JavaDocLocations.getBaseURL(pack, false); |
| 198 |
expectedHtmlContent.append("<base href='" + javadochoverLoc + "'>\n"); |
| 199 |
expectedHtmlContent |
| 200 |
.append("</head><body text=\"#000000\" bgcolor=\"#ffffe1\"><h5><div style='word-wrap: break-word; position: relative; margin-left: 20px; padding-top: 2px; '><a href='" |
| 201 |
+ JavaElementLinks.createURI(JavaElementLinks.OPEN_LINK_SCHEME, pack) + "'><!--[if lte IE 6]><![if gte IE 5.5]>\n"); |
| 202 |
String imageLoc= JavaPlugin.getDefault().getImagesOnFSRegistry().getImageURL(pack).toExternalForm(); |
| 203 |
expectedHtmlContent |
| 204 |
.append("<span alt='Open Declaration' style=\"border:none; position: absolute; width: 16px; height: 16px; left: -21px; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" |
| 205 |
+ imageLoc + "')\"></span>\n"); |
| 206 |
expectedHtmlContent.append("<![endif]><![endif]-->\n"); |
| 207 |
expectedHtmlContent.append("<!--[if !IE]>-->\n"); |
| 208 |
expectedHtmlContent |
| 209 |
.append("<img alt='Open Declaration' style='border:none; position: absolute; width: 16px; height: 16px; left: -21px; ' src='" + imageLoc + "'/>\n"); |
| 210 |
expectedHtmlContent.append("<!--<![endif]-->\n"); |
| 211 |
expectedHtmlContent.append("<!--[if gte IE 7]>\n"); |
| 212 |
expectedHtmlContent |
| 213 |
.append("<img alt='Open Declaration' style='border:none; position: absolute; width: 16px; height: 16px; left: -21px; ' src='" + imageLoc + "'/>\n"); |
| 214 |
expectedHtmlContent.append("<![endif]-->\n"); |
| 215 |
expectedHtmlContent.append("</a>" |
| 216 |
+ JavaElementLinks.getElementLabel(pack, JavaElementLabels.P_COMPRESSED) + "</div></h5><br><p>Test package documentation from package-info.java\n"); |
| 217 |
expectedHtmlContent.append(" This is the test content.</body></html>"); |
| 218 |
|
| 219 |
Assert.assertEquals(expectedHtmlContent.toString(), actualHtmlContent); |
| 220 |
|
| 221 |
|
| 222 |
|
| 223 |
} |
| 224 |
|
| 225 |
public void testGetDocFromPackageHtml_archive() throws Exception { |
| 226 |
|
| 227 |
File junitSrcArchive= JavaTestPlugin.getDefault().getFileInPlugin(new Path("testresources/JavadocHover_src.zip")); |
| 228 |
|
| 229 |
assertTrue("junit src not found", junitSrcArchive != null && junitSrcArchive.exists()); |
| 230 |
|
| 231 |
JavaProjectHelper.addSourceContainerWithImport(fJProject1, "src", junitSrcArchive, JavaProjectHelper.JUNIT_SRC_ENCODING); |
| 232 |
ICompilationUnit cu= (ICompilationUnit)fJProject1.findElement(new Path("JavadocHover_src/junit/javadochoverhtml/JavaDocHoverTest.java")); |
| 233 |
assertNotNull("JavaDocHoverTest.java", cu); |
| 234 |
|
| 235 |
IPackageFragment pack= (IPackageFragment)cu.getParent(); |
| 236 |
IJavaElement[] elements= new JavaElement[1]; |
| 237 |
elements[0]= pack; |
| 238 |
JavadocBrowserInformationControlInput hoverInfo= JavadocHover.getHoverInfo(elements, cu, new Region(67, 10), null); |
| 239 |
String actualHtmlContent= hoverInfo.getHtml(); |
| 240 |
|
| 241 |
String javadochoverLoc= JavaDocLocations.getBaseURL(pack, false); |
| 242 |
String imageLoc= JavaPlugin.getDefault().getImagesOnFSRegistry().getImageURL(pack).toExternalForm(); |
| 243 |
|
| 244 |
StringBuffer expectedHtmlContent= new StringBuffer(); |
| 245 |
|
| 246 |
expectedHtmlContent.append("<html><head><style CHARSET=\"ISO-8859-1\" TYPE=\"text/css\">/* Font definitions */\n"); |
| 247 |
expectedHtmlContent.append("html { font-family: 'Segoe UI',sans-serif; font-size: 9pt; font-style: normal; font-weight: normal; }\n"); |
| 248 |
expectedHtmlContent.append("body, h1, h2, h3, h4, h5, h6, p, table, td, caption, th, ul, ol, dl, li, dd, dt { font-size: 1em; }\n"); |
| 249 |
expectedHtmlContent.append("pre { font-family: monospace; }\n"); |
| 250 |
expectedHtmlContent.append("\n"); |
| 251 |
expectedHtmlContent.append("/* Margins */\n"); |
| 252 |
expectedHtmlContent.append("body { overflow: auto; margin-top: 0px; margin-bottom: 0.5em; margin-left: 0.3em; margin-right: 0px; }\n"); |
| 253 |
expectedHtmlContent.append("h1 { margin-top: 0.3em; margin-bottom: 0.04em; } \n"); |
| 254 |
expectedHtmlContent.append("h2 { margin-top: 2em; margin-bottom: 0.25em; }\n"); |
| 255 |
expectedHtmlContent.append("h3 { margin-top: 1.7em; margin-bottom: 0.25em; }\n"); |
| 256 |
expectedHtmlContent.append("h4 { margin-top: 2em; margin-bottom: 0.3em; }\n"); |
| 257 |
expectedHtmlContent.append("h5 { margin-top: 0px; margin-bottom: 0px; }\n"); |
| 258 |
expectedHtmlContent.append("p { margin-top: 1em; margin-bottom: 1em; }\n"); |
| 259 |
expectedHtmlContent.append("pre { margin-left: 0.6em; }\n"); |
| 260 |
expectedHtmlContent.append("ul { margin-top: 0px; margin-bottom: 1em; margin-left: 1em; padding-left: 1em;}\n"); |
| 261 |
expectedHtmlContent.append("li { margin-top: 0px; margin-bottom: 0px; } \n"); |
| 262 |
expectedHtmlContent.append("li p { margin-top: 0px; margin-bottom: 0px; } \n"); |
| 263 |
expectedHtmlContent.append("ol { margin-top: 0px; margin-bottom: 1em; margin-left: 1em; padding-left: 1em; }\n"); |
| 264 |
expectedHtmlContent.append("dl { margin-top: 0px; margin-bottom: 1em; }\n"); |
| 265 |
expectedHtmlContent.append("dt { margin-top: 0px; margin-bottom: 0px; font-weight: bold; }\n"); |
| 266 |
expectedHtmlContent.append("dd { margin-top: 0px; margin-bottom: 0px; }\n"); |
| 267 |
expectedHtmlContent.append("\n"); |
| 268 |
expectedHtmlContent.append("/* Styles and colors */\n"); |
| 269 |
expectedHtmlContent.append("a:link { color: #0000FF; }\n"); |
| 270 |
expectedHtmlContent.append("a:hover { color: #000080; }\n"); |
| 271 |
expectedHtmlContent.append("a:visited { text-decoration: underline; }\n"); |
| 272 |
expectedHtmlContent.append("a.header:link { text-decoration: none; color: #000000 }\n"); |
| 273 |
expectedHtmlContent.append("a.header:visited { text-decoration: none; color: #000000 }\n"); |
| 274 |
expectedHtmlContent.append("a.header:hover { text-decoration: underline; color: #000080; }\n"); |
| 275 |
expectedHtmlContent.append("h4 { font-style: italic; }\n"); |
| 276 |
expectedHtmlContent.append("strong { font-weight: bold; }\n"); |
| 277 |
expectedHtmlContent.append("em { font-style: italic; }\n"); |
| 278 |
expectedHtmlContent.append("var { font-style: italic; }\n"); |
| 279 |
expectedHtmlContent.append("th { font-weight: bold; }\n"); |
| 280 |
expectedHtmlContent.append("</style>\n"); |
| 281 |
expectedHtmlContent |
| 282 |
.append("<base href='" + javadochoverLoc + "'>\n"); |
| 283 |
expectedHtmlContent |
| 284 |
.append("</head><body text=\"#000000\" bgcolor=\"#ffffe1\"><h5><div style='word-wrap: break-word; position: relative; margin-left: 20px; padding-top: 2px; '><a href='" |
| 285 |
+ JavaElementLinks.createURI(JavaElementLinks.OPEN_LINK_SCHEME, pack) + "'><!--[if lte IE 6]><![if gte IE 5.5]>\n"); |
| 286 |
expectedHtmlContent |
| 287 |
.append("<span alt='Open Declaration' style=\"border:none; position: absolute; width: 16px; height: 16px; left: -21px; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" |
| 288 |
+ imageLoc + "')\"></span>\n"); |
| 289 |
expectedHtmlContent.append("<![endif]><![endif]-->\n"); |
| 290 |
expectedHtmlContent.append("<!--[if !IE]>-->\n"); |
| 291 |
expectedHtmlContent |
| 292 |
.append("<img alt='Open Declaration' style='border:none; position: absolute; width: 16px; height: 16px; left: -21px; ' src='" + imageLoc + "'/>\n"); |
| 293 |
expectedHtmlContent.append("<!--<![endif]-->\n"); |
| 294 |
expectedHtmlContent.append("<!--[if gte IE 7]>\n"); |
| 295 |
expectedHtmlContent |
| 296 |
.append("<img alt='Open Declaration' style='border:none; position: absolute; width: 16px; height: 16px; left: -21px; ' src='" + imageLoc + "'/>\n"); |
| 297 |
expectedHtmlContent.append("<![endif]-->\n"); |
| 298 |
expectedHtmlContent.append("</a>" + JavaElementLinks.getElementLabel(pack, JavaElementLabels.P_COMPRESSED) |
| 299 |
+ "</div></h5><br><p><!doctype html public \"-//w3c//dtd html 4.0 transitional//en\">\r\n"); |
| 300 |
expectedHtmlContent.append("<html>\r\n"); |
| 301 |
expectedHtmlContent.append("<head>\r\n"); |
| 302 |
expectedHtmlContent.append(" <meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">\r\n"); |
| 303 |
expectedHtmlContent.append(" <title>Package-level Javadoc</title>\r\n"); |
| 304 |
expectedHtmlContent.append("</head>\r\n"); |
| 305 |
expectedHtmlContent.append("<body>\r\n"); |
| 306 |
expectedHtmlContent.append("Test package documentation in package.html\r\n"); |
| 307 |
expectedHtmlContent.append("This is to test package hovering.\r\n"); |
| 308 |
expectedHtmlContent.append("</body>\r\n"); |
| 309 |
expectedHtmlContent.append("</html>\r\n"); |
| 310 |
expectedHtmlContent.append("</body></html>"); |
| 311 |
|
| 312 |
Assert.assertEquals(expectedHtmlContent.toString(), actualHtmlContent); |
| 313 |
|
| 314 |
} |
| 315 |
|
| 316 |
public void testGetDocFromPackageInfoJava_archive() throws Exception { |
| 317 |
File junitSrcArchive= JavaTestPlugin.getDefault().getFileInPlugin(new Path("testresources/JavadocHover_src.zip")); |
| 318 |
assertTrue("junit src not found", junitSrcArchive != null && junitSrcArchive.exists()); |
| 319 |
JavaProjectHelper.addSourceContainerWithImport(fJProject1, "src", junitSrcArchive, JavaProjectHelper.JUNIT_SRC_ENCODING); |
| 320 |
ICompilationUnit cu= (ICompilationUnit)fJProject1.findElement(new Path("JavadocHover_src/junit/javadochoverhtml/JavaDocHoverTest.java")); |
| 321 |
assertNotNull("JavaDocHoverTest.java", cu); |
| 322 |
|
| 323 |
File clsJarPath= JavaTestPlugin.getDefault().getFileInPlugin(new Path("/testresources/133534.zip")); |
| 324 |
File srcJarPath= JavaTestPlugin.getDefault().getFileInPlugin(new Path("/testresources/133534_src.zip")); |
| 325 |
|
| 326 |
|
| 327 |
JavaProjectHelper.addLibraryWithImport(fJProject1, new Path(clsJarPath.getAbsolutePath()), new Path(srcJarPath.getAbsolutePath()), null); |
| 328 |
fJProject1.open(null); |
| 329 |
IPackageFragmentRoot jarRoot= this.fJProject1.getPackageFragmentRoot(ResourcesPlugin.getWorkspace().getRoot().getFile(new Path("/TestSetupProject/133534.zip"))); |
| 330 |
IPackageFragment packageFragment= jarRoot.getPackageFragment("in.ibm.test"); |
| 331 |
assertNotNull(packageFragment); |
| 332 |
IPath sourceAttachmentPath= jarRoot.getSourceAttachmentPath(); |
| 333 |
Assert.assertNotNull(sourceAttachmentPath); |
| 334 |
|
| 335 |
int offset= cu.getSource().indexOf("in.ibm.test"); |
| 336 |
int length= "in.ibm.test".length(); |
| 337 |
IJavaElement[] codeSelect= cu.codeSelect(offset, length); |
| 338 |
Assert.assertNotNull(codeSelect); |
| 339 |
Assert.assertTrue("No package found !", codeSelect.length > 0); |
| 340 |
packageFragment= (IPackageFragment)codeSelect[0]; |
| 341 |
JavadocBrowserInformationControlInput hoverInfo= JavadocHover.getHoverInfo(new IJavaElement[] { packageFragment }, cu, new Region(offset, length), null); |
| 342 |
String actualHtmlContent= hoverInfo.getHtml(); |
| 343 |
String imageLoc= JavaPlugin.getDefault().getImagesOnFSRegistry().getImageURL(packageFragment).toExternalForm(); |
| 344 |
|
| 345 |
StringBuffer expectedHtmlContent= new StringBuffer(); |
| 346 |
expectedHtmlContent.append("<html><head><style CHARSET=\"ISO-8859-1\" TYPE=\"text/css\">/* Font definitions */\n"); |
| 347 |
expectedHtmlContent.append("html { font-family: 'Segoe UI',sans-serif; font-size: 9pt; font-style: normal; font-weight: normal; }\n"); |
| 348 |
expectedHtmlContent.append("body, h1, h2, h3, h4, h5, h6, p, table, td, caption, th, ul, ol, dl, li, dd, dt { font-size: 1em; }\n"); |
| 349 |
expectedHtmlContent.append("pre { font-family: monospace; }\n\n"); |
| 350 |
expectedHtmlContent.append("/* Margins */\n"); |
| 351 |
expectedHtmlContent.append("body { overflow: auto; margin-top: 0px; margin-bottom: 0.5em; margin-left: 0.3em; margin-right: 0px; }\n"); |
| 352 |
expectedHtmlContent.append("h1 { margin-top: 0.3em; margin-bottom: 0.04em; } \n"); |
| 353 |
expectedHtmlContent.append("h2 { margin-top: 2em; margin-bottom: 0.25em; }\n"); |
| 354 |
expectedHtmlContent.append("h3 { margin-top: 1.7em; margin-bottom: 0.25em; }\n"); |
| 355 |
expectedHtmlContent.append("h4 { margin-top: 2em; margin-bottom: 0.3em; }\n"); |
| 356 |
expectedHtmlContent.append("h5 { margin-top: 0px; margin-bottom: 0px; }\n"); |
| 357 |
expectedHtmlContent.append("p { margin-top: 1em; margin-bottom: 1em; }\n"); |
| 358 |
expectedHtmlContent.append("pre { margin-left: 0.6em; }\n"); |
| 359 |
expectedHtmlContent.append("ul { margin-top: 0px; margin-bottom: 1em; margin-left: 1em; padding-left: 1em;}\n"); |
| 360 |
expectedHtmlContent.append("li { margin-top: 0px; margin-bottom: 0px; } \n"); |
| 361 |
expectedHtmlContent.append("li p { margin-top: 0px; margin-bottom: 0px; } \n"); |
| 362 |
expectedHtmlContent.append("ol { margin-top: 0px; margin-bottom: 1em; margin-left: 1em; padding-left: 1em; }\n"); |
| 363 |
expectedHtmlContent.append("dl { margin-top: 0px; margin-bottom: 1em; }\n"); |
| 364 |
expectedHtmlContent.append("dt { margin-top: 0px; margin-bottom: 0px; font-weight: bold; }\n"); |
| 365 |
expectedHtmlContent.append("dd { margin-top: 0px; margin-bottom: 0px; }\n\n"); |
| 366 |
expectedHtmlContent.append("/* Styles and colors */\n"); |
| 367 |
expectedHtmlContent.append("a:link { color: #0000FF; }\n"); |
| 368 |
expectedHtmlContent.append("a:hover { color: #000080; }\n"); |
| 369 |
expectedHtmlContent.append("a:visited { text-decoration: underline; }\n"); |
| 370 |
expectedHtmlContent.append("a.header:link { text-decoration: none; color: #000000 }\n"); |
| 371 |
expectedHtmlContent.append("a.header:visited { text-decoration: none; color: #000000 }\n"); |
| 372 |
expectedHtmlContent.append("a.header:hover { text-decoration: underline; color: #000080; }\n"); |
| 373 |
expectedHtmlContent.append("h4 { font-style: italic; }\n"); |
| 374 |
expectedHtmlContent.append("strong { font-weight: bold; }\n"); |
| 375 |
expectedHtmlContent.append("em { font-style: italic; }\n"); |
| 376 |
expectedHtmlContent.append("var { font-style: italic; }\n"); |
| 377 |
expectedHtmlContent.append("th { font-weight: bold; }\n"); |
| 378 |
expectedHtmlContent |
| 379 |
.append("</style></head><body text=\"#000000\" bgcolor=\"#ffffe1\"><h5><div style='word-wrap: break-word; position: relative; margin-left: 20px; padding-top: 2px; '><a href='" |
| 380 |
+ JavaElementLinks.createURI(JavaElementLinks.OPEN_LINK_SCHEME, packageFragment) + "'><!--[if lte IE 6]><![if gte IE 5.5]>\n"); |
| 381 |
expectedHtmlContent |
| 382 |
.append("<span alt='Open Declaration' style=\"border:none; position: absolute; width: 16px; height: 16px; left: -21px; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" |
| 383 |
+ imageLoc + "')\"></span>\n"); |
| 384 |
expectedHtmlContent.append("<![endif]><![endif]-->\n"); |
| 385 |
expectedHtmlContent.append("<!--[if !IE]>-->\n"); |
| 386 |
expectedHtmlContent |
| 387 |
.append("<img alt='Open Declaration' style='border:none; position: absolute; width: 16px; height: 16px; left: -21px; ' src='" + imageLoc + "'/>\n"); |
| 388 |
expectedHtmlContent.append("<!--<![endif]-->\n"); |
| 389 |
expectedHtmlContent.append("<!--[if gte IE 7]>\n"); |
| 390 |
expectedHtmlContent |
| 391 |
.append("<img alt='Open Declaration' style='border:none; position: absolute; width: 16px; height: 16px; left: -21px; ' src='" + imageLoc + "'/>\n"); |
| 392 |
expectedHtmlContent.append("<![endif]-->\n"); |
| 393 |
expectedHtmlContent |
| 394 |
.append("</a>in.ibm.test</div></h5><br><p>This is the package documentation for in.ibm.test. The documentation is done in package-info.java file.<dl><dt>Author:</dt><dd> manju</dd></dl></body></html>"); |
| 395 |
|
| 396 |
Assert.assertEquals(expectedHtmlContent.toString(), actualHtmlContent); |
| 397 |
|
| 398 |
} |
| 399 |
|
| 400 |
public void testGetDocFromSourceAttachmentRootPath() throws Exception { |
| 401 |
File junitSrcArchive= JavaTestPlugin.getDefault().getFileInPlugin(new Path("testresources/JavadocHover_src.zip")); |
| 402 |
assertTrue("junit src not found", junitSrcArchive != null && junitSrcArchive.exists()); |
| 403 |
JavaProjectHelper.addSourceContainerWithImport(fJProject1, "src", junitSrcArchive, JavaProjectHelper.JUNIT_SRC_ENCODING); |
| 404 |
ICompilationUnit cu= (ICompilationUnit)fJProject1.findElement(new Path("JavadocHover_src/junit/javadochoverhtml/JavaDocHoverTest.java")); |
| 405 |
assertNotNull("JavaDocHoverTest.java", cu); |
| 406 |
|
| 407 |
File clsJarPath= JavaTestPlugin.getDefault().getFileInPlugin(new Path("/testresources/133534.zip")); |
| 408 |
File srcJarPath= JavaTestPlugin.getDefault().getFileInPlugin(new Path("/testresources/133534_src.zip")); |
| 409 |
|
| 410 |
|
| 411 |
JavaProjectHelper.addLibraryWithImport(fJProject1, new Path(clsJarPath.getAbsolutePath()), new Path(srcJarPath.getAbsolutePath()), new Path("src")); |
| 412 |
fJProject1.open(null); |
| 413 |
IPackageFragmentRoot jarRoot= this.fJProject1.getPackageFragmentRoot(ResourcesPlugin.getWorkspace().getRoot().getFile(new Path("/TestSetupProject/133534.zip"))); |
| 414 |
Assert.assertTrue(jarRoot != null && jarRoot.exists()); |
| 415 |
IPackageFragment packageFragment= jarRoot.getPackageFragment("in.ibm.test.html"); |
| 416 |
Assert.assertTrue(packageFragment != null && packageFragment.exists()); |
| 417 |
IPath sourceAttachmentPath= jarRoot.getSourceAttachmentPath(); |
| 418 |
Assert.assertNotNull(sourceAttachmentPath); |
| 419 |
|
| 420 |
int offset= cu.getSource().indexOf("in.ibm.test.html"); |
| 421 |
int length= "in.ibm.test.html".length(); |
| 422 |
IJavaElement[] codeSelect= cu.codeSelect(offset, length); |
| 423 |
Assert.assertNotNull(codeSelect); |
| 424 |
Assert.assertTrue("No package found !", codeSelect.length > 0); |
| 425 |
packageFragment= (IPackageFragment)codeSelect[0]; |
| 426 |
JavadocBrowserInformationControlInput hoverInfo= JavadocHover.getHoverInfo(new IJavaElement[] { packageFragment }, cu, new Region(offset, length), null); |
| 427 |
String actualHtmlContent= hoverInfo.getHtml(); |
| 428 |
String imageLoc= JavaPlugin.getDefault().getImagesOnFSRegistry().getImageURL(packageFragment).toExternalForm(); |
| 429 |
|
| 430 |
StringBuffer expectedHtmlContent= new StringBuffer(); |
| 431 |
expectedHtmlContent.append("<html><head><style CHARSET=\"ISO-8859-1\" TYPE=\"text/css\">/* Font definitions */\n"); |
| 432 |
expectedHtmlContent.append("html { font-family: 'Segoe UI',sans-serif; font-size: 9pt; font-style: normal; font-weight: normal; }\n"); |
| 433 |
expectedHtmlContent.append("body, h1, h2, h3, h4, h5, h6, p, table, td, caption, th, ul, ol, dl, li, dd, dt { font-size: 1em; }\n"); |
| 434 |
expectedHtmlContent.append("pre { font-family: monospace; }\n\n"); |
| 435 |
expectedHtmlContent.append("/* Margins */\n"); |
| 436 |
expectedHtmlContent.append("body { overflow: auto; margin-top: 0px; margin-bottom: 0.5em; margin-left: 0.3em; margin-right: 0px; }\n"); |
| 437 |
expectedHtmlContent.append("h1 { margin-top: 0.3em; margin-bottom: 0.04em; } \n"); |
| 438 |
expectedHtmlContent.append("h2 { margin-top: 2em; margin-bottom: 0.25em; }\n"); |
| 439 |
expectedHtmlContent.append("h3 { margin-top: 1.7em; margin-bottom: 0.25em; }\n"); |
| 440 |
expectedHtmlContent.append("h4 { margin-top: 2em; margin-bottom: 0.3em; }\n"); |
| 441 |
expectedHtmlContent.append("h5 { margin-top: 0px; margin-bottom: 0px; }\n"); |
| 442 |
expectedHtmlContent.append("p { margin-top: 1em; margin-bottom: 1em; }\n"); |
| 443 |
expectedHtmlContent.append("pre { margin-left: 0.6em; }\n"); |
| 444 |
expectedHtmlContent.append("ul { margin-top: 0px; margin-bottom: 1em; margin-left: 1em; padding-left: 1em;}\n"); |
| 445 |
expectedHtmlContent.append("li { margin-top: 0px; margin-bottom: 0px; } \n"); |
| 446 |
expectedHtmlContent.append("li p { margin-top: 0px; margin-bottom: 0px; } \n"); |
| 447 |
expectedHtmlContent.append("ol { margin-top: 0px; margin-bottom: 1em; margin-left: 1em; padding-left: 1em; }\n"); |
| 448 |
expectedHtmlContent.append("dl { margin-top: 0px; margin-bottom: 1em; }\n"); |
| 449 |
expectedHtmlContent.append("dt { margin-top: 0px; margin-bottom: 0px; font-weight: bold; }\n"); |
| 450 |
expectedHtmlContent.append("dd { margin-top: 0px; margin-bottom: 0px; }\n\n"); |
| 451 |
expectedHtmlContent.append("/* Styles and colors */\n"); |
| 452 |
expectedHtmlContent.append("a:link { color: #0000FF; }\n"); |
| 453 |
expectedHtmlContent.append("a:hover { color: #000080; }\n"); |
| 454 |
expectedHtmlContent.append("a:visited { text-decoration: underline; }\n"); |
| 455 |
expectedHtmlContent.append("a.header:link { text-decoration: none; color: #000000 }\n"); |
| 456 |
expectedHtmlContent.append("a.header:visited { text-decoration: none; color: #000000 }\n"); |
| 457 |
expectedHtmlContent.append("a.header:hover { text-decoration: underline; color: #000080; }\n"); |
| 458 |
expectedHtmlContent.append("h4 { font-style: italic; }\n"); |
| 459 |
expectedHtmlContent.append("strong { font-weight: bold; }\n"); |
| 460 |
expectedHtmlContent.append("em { font-style: italic; }\n"); |
| 461 |
expectedHtmlContent.append("var { font-style: italic; }\n"); |
| 462 |
expectedHtmlContent.append("th { font-weight: bold; }\n"); |
| 463 |
expectedHtmlContent |
| 464 |
.append("</style></head><body text=\"#000000\" bgcolor=\"#ffffe1\"><h5><div style='word-wrap: break-word; position: relative; margin-left: 20px; padding-top: 2px; '><a href='" |
| 465 |
+ JavaElementLinks.createURI(JavaElementLinks.OPEN_LINK_SCHEME, packageFragment) + "'><!--[if lte IE 6]><![if gte IE 5.5]>\n"); |
| 466 |
expectedHtmlContent |
| 467 |
.append("<span alt='Open Declaration' style=\"border:none; position: absolute; width: 16px; height: 16px; left: -21px; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" |
| 468 |
+ imageLoc + "')\"></span>\n"); |
| 469 |
expectedHtmlContent.append("<![endif]><![endif]-->\n"); |
| 470 |
expectedHtmlContent.append("<!--[if !IE]>-->\n"); |
| 471 |
expectedHtmlContent |
| 472 |
.append("<img alt='Open Declaration' style='border:none; position: absolute; width: 16px; height: 16px; left: -21px; ' src='" + imageLoc + "'/>\n"); |
| 473 |
expectedHtmlContent.append("<!--<![endif]-->\n"); |
| 474 |
expectedHtmlContent.append("<!--[if gte IE 7]>\n"); |
| 475 |
expectedHtmlContent.append("<img alt='Open Declaration' style='border:none; position: absolute; width: 16px; height: 16px; left: -21px; ' src='" + imageLoc + "'/>\n"); |
| 476 |
expectedHtmlContent.append("<![endif]-->\n"); |
| 477 |
|
| 478 |
expectedHtmlContent.append("</a>in.ibm.test.html</div></h5><br><p><!doctype html public \"-//w3c//dtd html 4.0 transitional//en\">\r\n"); |
| 479 |
expectedHtmlContent.append("<html>\r\n"); |
| 480 |
expectedHtmlContent.append("<head>\r\n"); |
| 481 |
expectedHtmlContent.append(" <meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">\r\n"); |
| 482 |
expectedHtmlContent.append(" <title>Package-level Javadoc</title>\r\n"); |
| 483 |
expectedHtmlContent.append("</head>\r\n"); |
| 484 |
expectedHtmlContent.append("<body>\r\n"); |
| 485 |
expectedHtmlContent.append("This is the package documentation for in.ibm.test.html. The content is present in package.html file.The source attachment root path is set.\r\n"); |
| 486 |
expectedHtmlContent.append("</body>\r\n"); |
| 487 |
expectedHtmlContent.append("</html></body></html>"); |
| 488 |
|
| 489 |
Assert.assertEquals(expectedHtmlContent.toString(), actualHtmlContent); |
| 490 |
|
| 491 |
} |
| 492 |
|
| 493 |
|
| 494 |
public void testGetPackageattacheddoc() throws Exception { |
| 495 |
// http://download.oracle.com/javase/6/docs/api/ |
| 496 |
File junitSrcArchive= JavaTestPlugin.getDefault().getFileInPlugin(new Path("testresources/JavadocHover_src.zip")); |
| 497 |
|
| 498 |
assertTrue("junit src not found", junitSrcArchive != null && junitSrcArchive.exists()); |
| 499 |
|
| 500 |
JavaProjectHelper.addSourceContainerWithImport(fJProject1, "src", junitSrcArchive, JavaProjectHelper.JUNIT_SRC_ENCODING); |
| 501 |
ICompilationUnit cu= (ICompilationUnit)fJProject1.findElement(new Path("JavadocHover_src/junit/javadochoverhtml/JavaDocHoverTest.java")); |
| 502 |
assertNotNull("JavaDocHoverTest.java", cu); |
| 503 |
|
| 504 |
|
| 505 |
IClasspathAttribute attribute= |
| 506 |
JavaCore.newClasspathAttribute( |
| 507 |
IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME, |
| 508 |
"url:http://download.oracle.com/javase/6/docs/api/"); |
| 509 |
IClasspathEntry[] rawClasspath= fJProject1.getRawClasspath(); |
| 510 |
IClasspathEntry newEntry= JavaCore.newLibraryEntry(new Path(JavaTestPlugin.getDefault().getFileInPlugin(new Path("/testresources/rtstubs15.jar")).getAbsolutePath()), null, null, null, |
| 511 |
new IClasspathAttribute[] { attribute }, false); |
| 512 |
rawClasspath[0]= newEntry; |
| 513 |
IClasspathEntry[] newPathEntry= new IClasspathEntry[] { rawClasspath[0], rawClasspath[1] }; |
| 514 |
this.fJProject1.setRawClasspath(newPathEntry, null); |
| 515 |
this.fJProject1.getResolvedClasspath(false); |
| 516 |
|
| 517 |
int offset= cu.getSource().indexOf("java.math"); |
| 518 |
int length= "java.math".length(); |
| 519 |
IJavaElement[] codeSelect= cu.codeSelect(offset, length); |
| 520 |
Assert.assertNotNull(codeSelect); |
| 521 |
Assert.assertTrue("No package found !", codeSelect.length > 0); |
| 522 |
|
| 523 |
JavadocBrowserInformationControlInput hoverInfo= JavadocHover.getHoverInfo(codeSelect, cu, new Region(offset, length), null); |
| 524 |
String actualHtmlContent= hoverInfo.getHtml(); |
| 525 |
Assert.assertNotNull(actualHtmlContent); |
| 526 |
|
| 527 |
String imageLoc= JavaPlugin.getDefault().getImagesOnFSRegistry().getImageURL(codeSelect[0]).toExternalForm(); |
| 528 |
|
| 529 |
StringBuffer expectedHtmlContent= new StringBuffer(); |
| 530 |
expectedHtmlContent.append("<html><head><style CHARSET=\"ISO-8859-1\" TYPE=\"text/css\">/* Font definitions */\n"); |
| 531 |
expectedHtmlContent.append("html { font-family: 'Segoe UI',sans-serif; font-size: 9pt; font-style: normal; font-weight: normal; }\n"); |
| 532 |
expectedHtmlContent.append("body, h1, h2, h3, h4, h5, h6, p, table, td, caption, th, ul, ol, dl, li, dd, dt { font-size: 1em; }\n"); |
| 533 |
expectedHtmlContent.append("pre { font-family: monospace; }\n\n"); |
| 534 |
|
| 535 |
expectedHtmlContent.append("/* Margins */\n"); |
| 536 |
expectedHtmlContent.append("body { overflow: auto; margin-top: 0px; margin-bottom: 0.5em; margin-left: 0.3em; margin-right: 0px; }\n"); |
| 537 |
expectedHtmlContent.append("h1 { margin-top: 0.3em; margin-bottom: 0.04em; } \n"); |
| 538 |
expectedHtmlContent.append("h2 { margin-top: 2em; margin-bottom: 0.25em; }\n"); |
| 539 |
expectedHtmlContent.append("h3 { margin-top: 1.7em; margin-bottom: 0.25em; }\n"); |
| 540 |
expectedHtmlContent.append("h4 { margin-top: 2em; margin-bottom: 0.3em; }\n"); |
| 541 |
expectedHtmlContent.append("h5 { margin-top: 0px; margin-bottom: 0px; }\n"); |
| 542 |
expectedHtmlContent.append("p { margin-top: 1em; margin-bottom: 1em; }\n"); |
| 543 |
expectedHtmlContent.append("pre { margin-left: 0.6em; }\n"); |
| 544 |
expectedHtmlContent.append("ul { margin-top: 0px; margin-bottom: 1em; margin-left: 1em; padding-left: 1em;}\n"); |
| 545 |
expectedHtmlContent.append("li { margin-top: 0px; margin-bottom: 0px; } \n"); |
| 546 |
expectedHtmlContent.append("li p { margin-top: 0px; margin-bottom: 0px; } \n"); |
| 547 |
expectedHtmlContent.append("ol { margin-top: 0px; margin-bottom: 1em; margin-left: 1em; padding-left: 1em; }\n"); |
| 548 |
expectedHtmlContent.append("dl { margin-top: 0px; margin-bottom: 1em; }\n"); |
| 549 |
expectedHtmlContent.append("dt { margin-top: 0px; margin-bottom: 0px; font-weight: bold; }\n"); |
| 550 |
expectedHtmlContent.append("dd { margin-top: 0px; margin-bottom: 0px; }\n\n"); |
| 551 |
|
| 552 |
expectedHtmlContent.append("/* Styles and colors */\n"); |
| 553 |
expectedHtmlContent.append("a:link { color: #0000FF; }\n"); |
| 554 |
expectedHtmlContent.append("a:hover { color: #000080; }\n"); |
| 555 |
expectedHtmlContent.append("a:visited { text-decoration: underline; }\n"); |
| 556 |
expectedHtmlContent.append("a.header:link { text-decoration: none; color: #000000 }\n"); |
| 557 |
expectedHtmlContent.append("a.header:visited { text-decoration: none; color: #000000 }\n"); |
| 558 |
expectedHtmlContent.append("a.header:hover { text-decoration: underline; color: #000080; }\n"); |
| 559 |
expectedHtmlContent.append("h4 { font-style: italic; }\n"); |
| 560 |
expectedHtmlContent.append("strong { font-weight: bold; }\n"); |
| 561 |
expectedHtmlContent.append("em { font-style: italic; }\n"); |
| 562 |
expectedHtmlContent.append("var { font-style: italic; }\n"); |
| 563 |
expectedHtmlContent.append("th { font-weight: bold; }\n"); |
| 564 |
expectedHtmlContent.append("</style>\n"); |
| 565 |
expectedHtmlContent.append("<base href='http://download.oracle.com/javase/6/docs/api/java/math/package-summary.html'>\n"); |
| 566 |
expectedHtmlContent |
| 567 |
.append("</head><body text=\"#000000\" bgcolor=\"#ffffe1\"><h5><div style='word-wrap: break-word; position: relative; margin-left: 20px; padding-top: 2px; '><a href='" |
| 568 |
+ JavaElementLinks.createURI(JavaElementLinks.OPEN_LINK_SCHEME, codeSelect[0]) + "'><!--[if lte IE 6]><![if gte IE 5.5]>\n"); |
| 569 |
expectedHtmlContent |
| 570 |
.append("<span alt='Open Declaration' style=\"border:none; position: absolute; width: 16px; height: 16px; left: -21px; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" |
| 571 |
+ imageLoc + "')\"></span>\n"); |
| 572 |
expectedHtmlContent.append("<![endif]><![endif]-->\n"); |
| 573 |
expectedHtmlContent.append("<!--[if !IE]>-->\n"); |
| 574 |
expectedHtmlContent |
| 575 |
.append("<img alt='Open Declaration' style='border:none; position: absolute; width: 16px; height: 16px; left: -21px; ' src='" + imageLoc + "'/>\n"); |
| 576 |
expectedHtmlContent.append("<!--<![endif]-->\n"); |
| 577 |
expectedHtmlContent.append("<!--[if gte IE 7]>\n"); |
| 578 |
expectedHtmlContent |
| 579 |
.append("<img alt='Open Declaration' style='border:none; position: absolute; width: 16px; height: 16px; left: -21px; ' src='" + imageLoc + "'/>\n"); |
| 580 |
expectedHtmlContent.append("<![endif]-->\n"); |
| 581 |
expectedHtmlContent.append("</a>java.math</div></h5><br><p>\n\n"); |
| 582 |
|
| 583 |
expectedHtmlContent.append("<P>\n"); |
| 584 |
expectedHtmlContent.append("Provides classes for performing arbitrary-precision integer arithmetic\n"); |
| 585 |
expectedHtmlContent.append("(BigInteger) and arbitrary-precision decimal arithmetic (BigDecimal).\n"); |
| 586 |
expectedHtmlContent.append("BigInteger is analogous to Java's primitive integer types except that it\n"); |
| 587 |
expectedHtmlContent.append("provides arbitrary precision, hence operations on BigIntegers do not overflow\n"); |
| 588 |
expectedHtmlContent.append("or lose precision. In addition to standard arithmetic operations, BigInteger\n"); |
| 589 |
expectedHtmlContent.append("provides modular arithmetic, GCD calculation, primality testing, prime\n"); |
| 590 |
expectedHtmlContent.append("generation, bit manipulation, and a few other miscellaneous operations.\n\n"); |
| 591 |
|
| 592 |
expectedHtmlContent.append("BigDecimal provides arbitrary-precision signed decimal numbers suitable for\n"); |
| 593 |
expectedHtmlContent.append("currency calculations and the like. BigDecimal gives the user complete\n"); |
| 594 |
expectedHtmlContent.append("control over rounding behavior, allowing the user to choose from a\n"); |
| 595 |
expectedHtmlContent.append("comprehensive set of eight rounding modes.\n\n"); |
| 596 |
|
| 597 |
expectedHtmlContent.append("<!--\n"); |
| 598 |
expectedHtmlContent.append("<h2>Related Documentation</h2>\n\n"); |
| 599 |
|
| 600 |
expectedHtmlContent.append("For overviews, tutorials, examples, guides, and tool documentation, please see:\n"); |
| 601 |
expectedHtmlContent.append("<ul>\n"); |
| 602 |
expectedHtmlContent.append(" <li><a href=\"\">##### REFER TO NON-SPEC DOCUMENTATION HERE #####</a>\n"); |
| 603 |
expectedHtmlContent.append("</ul>\n"); |
| 604 |
expectedHtmlContent.append("-->\n"); |
| 605 |
expectedHtmlContent.append("<P>\n\n"); |
| 606 |
|
| 607 |
expectedHtmlContent.append("<P>\n"); |
| 608 |
expectedHtmlContent.append("<DL>\n"); |
| 609 |
expectedHtmlContent.append("<DT><B>Since:</B></DT>\n"); |
| 610 |
expectedHtmlContent.append(" <DD>JDK1.1</DD>\n"); |
| 611 |
expectedHtmlContent.append("</DL>\n"); |
| 612 |
expectedHtmlContent.append("<HR>\n\n\n"); |
| 613 |
|
| 614 |
|
| 615 |
expectedHtmlContent.append("</body></html>"); |
| 616 |
|
| 617 |
Assert.assertEquals(expectedHtmlContent.toString(), actualHtmlContent); |
| 618 |
|
| 619 |
} |
| 620 |
|
| 621 |
public void testBug397455() throws Exception { |
| 622 |
|
| 623 |
File junitSrcArchive= JavaTestPlugin.getDefault().getFileInPlugin(new Path("testresources/JavadocHover_src.zip")); |
| 624 |
|
| 625 |
assertTrue("junit src not found", junitSrcArchive != null && junitSrcArchive.exists()); |
| 626 |
|
| 627 |
JavaProjectHelper.addSourceContainerWithImport(fJProject1, "src", junitSrcArchive, JavaProjectHelper.JUNIT_SRC_ENCODING); |
| 628 |
ICompilationUnit cu= (ICompilationUnit)fJProject1.findElement(new Path("JavadocHover_src/junit/checkPackageInfo/TestNPEHover.java")); |
| 629 |
assertNotNull("TestNPEHover.java", cu); |
| 630 |
|
| 631 |
IPackageFragment pack= (IPackageFragment)cu.getParent(); |
| 632 |
IJavaElement[] elements= new JavaElement[1]; |
| 633 |
elements[0]= pack; |
| 634 |
JavadocBrowserInformationControlInput hoverInfo= JavadocHover.getHoverInfo(elements, cu, new Region(21, 12), null); |
| 635 |
String actualHtmlContent= hoverInfo.getHtml(); |
| 636 |
|
| 637 |
StringBuffer expectedHtmlContent= new StringBuffer(); |
| 638 |
expectedHtmlContent.append("<html><head><style CHARSET=\"ISO-8859-1\" TYPE=\"text/css\">/* Font definitions */\n"); |
| 639 |
expectedHtmlContent.append("html { font-family: 'Segoe UI',sans-serif; font-size: 9pt; font-style: normal; font-weight: normal; }\n"); |
| 640 |
expectedHtmlContent.append("body, h1, h2, h3, h4, h5, h6, p, table, td, caption, th, ul, ol, dl, li, dd, dt { font-size: 1em; }\n"); |
| 641 |
expectedHtmlContent.append("pre { font-family: monospace; }\n\n"); |
| 642 |
expectedHtmlContent.append("/* Margins */\n"); |
| 643 |
expectedHtmlContent.append("body { overflow: auto; margin-top: 0px; margin-bottom: 0.5em; margin-left: 0.3em; margin-right: 0px; }\n"); |
| 644 |
expectedHtmlContent.append("h1 { margin-top: 0.3em; margin-bottom: 0.04em; } \n"); |
| 645 |
expectedHtmlContent.append("h2 { margin-top: 2em; margin-bottom: 0.25em; }\n"); |
| 646 |
expectedHtmlContent.append("h3 { margin-top: 1.7em; margin-bottom: 0.25em; }\n"); |
| 647 |
expectedHtmlContent.append("h4 { margin-top: 2em; margin-bottom: 0.3em; }\n"); |
| 648 |
expectedHtmlContent.append("h5 { margin-top: 0px; margin-bottom: 0px; }\n"); |
| 649 |
expectedHtmlContent.append("p { margin-top: 1em; margin-bottom: 1em; }\n"); |
| 650 |
expectedHtmlContent.append("pre { margin-left: 0.6em; }\n"); |
| 651 |
expectedHtmlContent.append("ul { margin-top: 0px; margin-bottom: 1em; margin-left: 1em; padding-left: 1em;}\n"); |
| 652 |
expectedHtmlContent.append("li { margin-top: 0px; margin-bottom: 0px; } \n"); |
| 653 |
expectedHtmlContent.append("li p { margin-top: 0px; margin-bottom: 0px; } \n"); |
| 654 |
expectedHtmlContent.append("ol { margin-top: 0px; margin-bottom: 1em; margin-left: 1em; padding-left: 1em; }\n"); |
| 655 |
expectedHtmlContent.append("dl { margin-top: 0px; margin-bottom: 1em; }\n"); |
| 656 |
expectedHtmlContent.append("dt { margin-top: 0px; margin-bottom: 0px; font-weight: bold; }\n"); |
| 657 |
expectedHtmlContent.append("dd { margin-top: 0px; margin-bottom: 0px; }\n\n"); |
| 658 |
expectedHtmlContent.append("/* Styles and colors */\n"); |
| 659 |
expectedHtmlContent.append("a:link { color: #0000FF; }\n"); |
| 660 |
expectedHtmlContent.append("a:hover { color: #000080; }\n"); |
| 661 |
expectedHtmlContent.append("a:visited { text-decoration: underline; }\n"); |
| 662 |
expectedHtmlContent.append("a.header:link { text-decoration: none; color: #000000 }\n"); |
| 663 |
expectedHtmlContent.append("a.header:visited { text-decoration: none; color: #000000 }\n"); |
| 664 |
expectedHtmlContent.append("a.header:hover { text-decoration: underline; color: #000080; }\n"); |
| 665 |
expectedHtmlContent.append("h4 { font-style: italic; }\n"); |
| 666 |
expectedHtmlContent.append("strong { font-weight: bold; }\n"); |
| 667 |
expectedHtmlContent.append("em { font-style: italic; }\n"); |
| 668 |
expectedHtmlContent.append("var { font-style: italic; }\n"); |
| 669 |
expectedHtmlContent.append("th { font-weight: bold; }\n"); |
| 670 |
expectedHtmlContent.append("</style>\n"); |
| 671 |
String javadochoverLoc= JavaDocLocations.getBaseURL(pack, false); |
| 672 |
expectedHtmlContent.append("<base href='" + javadochoverLoc + "'>\n"); |
| 673 |
expectedHtmlContent |
| 674 |
.append("</head><body text=\"#000000\" bgcolor=\"#ffffe1\"><h5><div style='word-wrap: break-word; position: relative; margin-left: 20px; padding-top: 2px; '><a href='" |
| 675 |
+ JavaElementLinks.createURI(JavaElementLinks.OPEN_LINK_SCHEME, pack) + "'><!--[if lte IE 6]><![if gte IE 5.5]>\n"); |
| 676 |
String imageLoc= JavaPlugin.getDefault().getImagesOnFSRegistry().getImageURL(pack).toExternalForm(); |
| 677 |
expectedHtmlContent |
| 678 |
.append("<span alt='Open Declaration' style=\"border:none; position: absolute; width: 16px; height: 16px; left: -21px; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" |
| 679 |
+ imageLoc + "')\"></span>\n"); |
| 680 |
expectedHtmlContent.append("<![endif]><![endif]-->\n"); |
| 681 |
expectedHtmlContent.append("<!--[if !IE]>-->\n"); |
| 682 |
expectedHtmlContent |
| 683 |
.append("<img alt='Open Declaration' style='border:none; position: absolute; width: 16px; height: 16px; left: -21px; ' src='" + imageLoc + "'/>\n"); |
| 684 |
expectedHtmlContent.append("<!--<![endif]-->\n"); |
| 685 |
expectedHtmlContent.append("<!--[if gte IE 7]>\n"); |
| 686 |
expectedHtmlContent |
| 687 |
.append("<img alt='Open Declaration' style='border:none; position: absolute; width: 16px; height: 16px; left: -21px; ' src='" + imageLoc + "'/>\n"); |
| 688 |
expectedHtmlContent.append("<![endif]-->\n"); |
| 689 |
expectedHtmlContent.append("</a>" |
| 690 |
+ JavaElementLinks.getElementLabel(pack, JavaElementLabels.P_COMPRESSED) |
| 691 |
+ "</div></h5><br><p><p><b>Deprecated.</b> <i> use a pick</i><p>The pack is a test package. This doc contains references like <code><a href='eclipse-javadoc:%E2%98%82=TestSetupProject/src%3CJavadocHover_src.junit.checkPackageInfo%7Bpackage-info.java%E2%98%83package-info.java%E2%98%82Object'>Object</a></code> and <code><a href='eclipse-javadoc:%E2%98%82=TestSetupProject/src%3CJavadocHover_src.junit.checkPackageInfo%7Bpackage-info.java%E2%98%83package-info.java%E2%98%82Defaults%E2%98%82foo%E2%98%82String'>Defaults.foo(String)</a></code> and tags<dl><dt>Author:</dt><dd> me</dd></dl></body></html>"); |
| 692 |
|
| 693 |
Assert.assertEquals(expectedHtmlContent.toString(), actualHtmlContent); |
| 694 |
|
| 695 |
|
| 696 |
|
| 697 |
} |
| 698 |
|
| 699 |
public static Test setUpTest(Test test) { |
| 700 |
return new ProjectTestSetup(test); |
| 701 |
} |
| 702 |
|
| 703 |
@Override |
| 704 |
protected void setUp() throws Exception { |
| 705 |
fJProject1= ProjectTestSetup.getProject(); |
| 706 |
|
| 707 |
} |
| 708 |
|
| 709 |
|
| 710 |
@Override |
| 711 |
protected void tearDown() throws Exception { |
| 712 |
JavaProjectHelper.clear(fJProject1, ProjectTestSetup.getDefaultClasspath()); |
| 713 |
} |
| 714 |
|
| 715 |
} |