1 /*
   2  * Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /*
  25  * @test
  26  * @bug      6786688 8008164
  27  * @summary  HTML tables should have table summary, caption and table headers.
  28  * @author   Bhavesh Patel
  29  * @library  ../lib
  30  * @modules jdk.javadoc
  31  * @build    JavadocTester
  32  * @run main TestHtmlTableTags
  33  */
  34 
  35 public class TestHtmlTableTags extends JavadocTester {
  36 
  37     //Javadoc arguments.
  38     private static final String[] ARGS = new String[] {
  39 
  40     };
  41 
  42 
  43     public static void main(String... args) throws Exception {
  44         TestHtmlTableTags tester = new TestHtmlTableTags();
  45         tester.runTests();
  46     }
  47 
  48     @Test
  49     void test() {
  50         javadoc("-d", "out",
  51                 "-sourcepath", testSrc,
  52                 "-use",
  53                 "pkg1", "pkg2");
  54         checkExit(Exit.OK);
  55 
  56         checkHtmlTableSummaries();
  57         checkHtmlTableCaptions();
  58         checkHtmlTableHeaders();
  59     }
  60 
  61     /*
  62      * Tests for validating summary for HTML tables
  63      */
  64     void checkHtmlTableSummaries() {
  65         //Package summary
  66         checkOutput("pkg1/package-summary.html", true,
  67                 "<table class=\"typeSummary\" summary=\"Class Summary table, "
  68                 + "listing classes, and an explanation\">",
  69                 "<table class=\"typeSummary\" summary=\"Interface Summary table, "
  70                 + "listing interfaces, and an explanation\">");
  71 
  72         checkOutput("pkg2/package-summary.html", true,
  73                 "<table class=\"typeSummary\" summary=\"Enum Summary table, "
  74                 + "listing enums, and an explanation\">",
  75                 "<table class=\"typeSummary\" summary=\"Annotation Types Summary table, "
  76                 + "listing annotation types, and an explanation\">");
  77 
  78         // Class documentation
  79         checkOutput("pkg1/C1.html", true,
  80                 "<table class=\"memberSummary\" summary=\"Field Summary table, listing fields, "
  81                 + "and an explanation\">",
  82                 "<table class=\"memberSummary\" summary=\"Method Summary table, listing methods, "
  83                 + "and an explanation\">");
  84 
  85         checkOutput("pkg2/C2.html", true,
  86                 "<table class=\"memberSummary\" summary=\"Nested Class Summary table, listing "
  87                 + "nested classes, and an explanation\">",
  88                 "<table class=\"memberSummary\" summary=\"Constructor Summary table, listing "
  89                 + "constructors, and an explanation\">");
  90 
  91         checkOutput("pkg2/C2.ModalExclusionType.html", true,
  92                 "<table class=\"memberSummary\" summary=\"Enum Constant Summary table, listing "
  93                 + "enum constants, and an explanation\">");
  94 
  95         checkOutput("pkg2/C3.html", true,
  96                 "<table class=\"memberSummary\" summary=\"Required Element Summary table, "
  97                 + "listing required elements, and an explanation\">");
  98 
  99         checkOutput("pkg2/C4.html", true,
 100                 "<table class=\"memberSummary\" summary=\"Optional Element Summary table, "
 101                 + "listing optional elements, and an explanation\">");
 102 
 103         // Class use documentation
 104         checkOutput("pkg1/class-use/I1.html", true,
 105                 "<table class=\"useSummary\" summary=\"Use table, listing packages, and an explanation\">");
 106 
 107         checkOutput("pkg1/class-use/C1.html", true,
 108                 "<table class=\"useSummary\" summary=\"Use table, listing fields, and an explanation\">",
 109                 "<table class=\"useSummary\" summary=\"Use table, listing methods, and an explanation\">");
 110 
 111         checkOutput("pkg2/class-use/C2.html", true,
 112                 "<table class=\"useSummary\" summary=\"Use table, listing fields, and an explanation\">",
 113                 "<table class=\"useSummary\" summary=\"Use table, listing methods, and an explanation\">");
 114 
 115         checkOutput("pkg2/class-use/C2.ModalExclusionType.html", true,
 116                 "<table class=\"useSummary\" summary=\"Use table, listing packages, and an explanation\">");
 117 
 118         checkOutput("pkg2/class-use/C2.ModalExclusionType.html", true,
 119                 "<table class=\"useSummary\" summary=\"Use table, listing methods, and an explanation\">");
 120 
 121         // Package use documentation
 122         checkOutput("pkg1/package-use.html", true,
 123                 "<table class=\"useSummary\" summary=\"Use table, listing packages, and an explanation\">",
 124                 "<table class=\"useSummary\" summary=\"Use table, listing classes, and an explanation\">");
 125 
 126         checkOutput("pkg2/package-use.html", true,
 127                 "<table class=\"useSummary\" summary=\"Use table, listing packages, and an explanation\">",
 128                 "<table class=\"useSummary\" summary=\"Use table, listing classes, and an explanation\">");
 129 
 130         // Deprecated
 131         checkOutput("deprecated-list.html", true,
 132                 "<table class=\"deprecatedSummary\" summary=\"Deprecated Fields table, listing deprecated fields, "
 133                 + "and an explanation\">",
 134                 "<table class=\"deprecatedSummary\" summary=\"Deprecated Methods table, listing deprecated methods, "
 135                 + "and an explanation\">");
 136 
 137         // Constant values
 138         checkOutput("constant-values.html", true,
 139                 "<table class=\"constantsSummary\" summary=\"Constant Field Values table, listing "
 140                 + "constant fields, and values\">");
 141 
 142         // Overview Summary
 143         checkOutput("overview-summary.html", true,
 144                 "<table class=\"overviewSummary\" "
 145                 + "summary=\"Packages table, listing packages, and an explanation\">");
 146     }
 147 
 148     /*
 149      * Tests for validating caption for HTML tables
 150      */
 151     void checkHtmlTableCaptions() {
 152         //Package summary
 153         checkOutput("pkg1/package-summary.html", true,
 154                 "<caption><span>Class Summary</span><span class=\"tabEnd\">"
 155                 + "&nbsp;</span></caption>",
 156                 "<caption><span>Interface Summary</span><span class=\"tabEnd\">"
 157                 + "&nbsp;</span></caption>");
 158 
 159         checkOutput("pkg2/package-summary.html", true,
 160                 "<caption><span>Enum Summary</span><span class=\"tabEnd\">"
 161                 + "&nbsp;</span></caption>",
 162                 "<caption><span>Annotation Types Summary</span><span class=\"tabEnd\">"
 163                 + "&nbsp;</span></caption>");
 164 
 165         // Class documentation
 166         checkOutput("pkg1/C1.html", true,
 167                 "<caption><span>Fields</span><span class=\"tabEnd\">&nbsp;</span></caption>",
 168                 "<caption><span id=\"t0\" class=\"activeTableTab\"><span>All "
 169                 + "Methods</span><span class=\"tabEnd\">&nbsp;</span></span>"
 170                 + "<span id=\"t2\" class=\"tableTab\"><span><a href=\"javascript:show(2);\">"
 171                 + "Instance Methods</a></span><span class=\"tabEnd\">&nbsp;</span></span>"
 172                 + "<span id=\"t4\" class=\"tableTab\"><span><a href=\"javascript:show(8);\">"
 173                 + "Concrete Methods</a></span><span class=\"tabEnd\">&nbsp;</span></span>"
 174                 + "<span id=\"t6\" class=\"tableTab\"><span><a href=\"javascript:show(32);\">"
 175                 + "Deprecated Methods</a></span><span class=\"tabEnd\">&nbsp;</span></span>"
 176                 + "</caption>");
 177 
 178         checkOutput("pkg2/C2.html", true,
 179                 "<caption><span>Nested Classes</span><span class=\"tabEnd\">&nbsp;</span></caption>",
 180                 "<caption><span>Constructors</span><span class=\"tabEnd\">&nbsp;</span></caption>");
 181 
 182         checkOutput("pkg2/C2.ModalExclusionType.html", true,
 183                 "<caption><span>Enum Constants</span><span class=\"tabEnd\">&nbsp;</span></caption>");
 184 
 185         checkOutput("pkg2/C3.html", true,
 186                 "<caption><span>Required Elements</span><span class=\"tabEnd\">&nbsp;"
 187                 + "</span></caption>");
 188 
 189         checkOutput("pkg2/C4.html", true,
 190                 "<caption><span>Optional Elements</span><span class=\"tabEnd\">&nbsp;"
 191                 + "</span></caption>");
 192 
 193         // Class use documentation
 194         checkOutput("pkg1/class-use/I1.html", true,
 195                 "<caption><span>Packages that use <a href=\"../../pkg1/I1.html\" "
 196                 + "title=\"interface in pkg1\">I1</a></span><span class=\"tabEnd\">"
 197                 + "&nbsp;</span></caption>");
 198 
 199         checkOutput("pkg1/class-use/C1.html", true,
 200                 "<caption><span>Fields in <a href=\"../../pkg2/package-summary.html\">"
 201                 + "pkg2</a> declared as <a href=\"../../pkg1/C1.html\" "
 202                 + "title=\"class in pkg1\">C1</a></span><span class=\"tabEnd\">&nbsp;"
 203                 + "</span></caption>",
 204                 "<caption><span>Methods in <a href=\"../../pkg2/package-summary.html\">"
 205                 + "pkg2</a> that return <a href=\"../../pkg1/C1.html\" "
 206                 + "title=\"class in pkg1\">C1</a></span><span class=\"tabEnd\">"
 207                 + "&nbsp;</span></caption>");
 208 
 209         checkOutput("pkg2/class-use/C2.html", true,
 210                 "<caption><span>Fields in <a href=\"../../pkg1/package-summary.html\">"
 211                 + "pkg1</a> declared as <a href=\"../../pkg2/C2.html\" "
 212                 + "title=\"class in pkg2\">C2</a></span><span class=\"tabEnd\">"
 213                 + "&nbsp;</span></caption>",
 214                 "<caption><span>Methods in <a href=\"../../pkg1/package-summary.html\">"
 215                 + "pkg1</a> that return <a href=\"../../pkg2/C2.html\" "
 216                 + "title=\"class in pkg2\">C2</a></span><span class=\"tabEnd\">"
 217                 + "&nbsp;</span></caption>");
 218 
 219         checkOutput("pkg2/class-use/C2.ModalExclusionType.html", true,
 220                 "<caption><span>Methods in <a href=\"../../pkg2/package-summary.html\">"
 221                 + "pkg2</a> that return <a href=\"../../pkg2/C2.ModalExclusionType.html\" "
 222                 + "title=\"enum in pkg2\">C2.ModalExclusionType</a></span>"
 223                 + "<span class=\"tabEnd\">&nbsp;</span></caption>");
 224 
 225         // Package use documentation
 226         checkOutput("pkg1/package-use.html", true,
 227                 "<caption><span>Packages that use <a href=\"../pkg1/package-summary.html\">"
 228                 + "pkg1</a></span><span class=\"tabEnd\">&nbsp;</span></caption>",
 229                 "<caption><span>Classes in <a href=\"../pkg1/package-summary.html\">"
 230                 + "pkg1</a> used by <a href=\"../pkg1/package-summary.html\">pkg1</a>"
 231                 + "</span><span class=\"tabEnd\">&nbsp;</span></caption>");
 232 
 233         checkOutput("pkg2/package-use.html", true,
 234                 "<caption><span>Packages that use <a href=\"../pkg2/package-summary.html\">"
 235                 + "pkg2</a></span><span class=\"tabEnd\">&nbsp;</span></caption>",
 236                 "<caption><span>Classes in <a href=\"../pkg2/package-summary.html\">"
 237                 + "pkg2</a> used by <a href=\"../pkg1/package-summary.html\">pkg1</a>"
 238                 + "</span><span class=\"tabEnd\">&nbsp;</span></caption>");
 239 
 240         // Deprecated
 241         checkOutput("deprecated-list.html", true,
 242                 "<caption><span>Deprecated Fields</span><span class=\"tabEnd\">"
 243                 + "&nbsp;</span></caption>",
 244                 "<caption><span>Deprecated Methods</span><span class=\"tabEnd\">"
 245                 + "&nbsp;</span></caption>");
 246 
 247         // Constant values
 248         checkOutput("constant-values.html", true,
 249                 "<caption><span>pkg1.<a href=\"pkg1/C1.html\" title=\"class in pkg1\">"
 250                 + "C1</a></span><span class=\"tabEnd\">&nbsp;</span></caption>");
 251 
 252         // Overview Summary
 253         checkOutput("overview-summary.html", true,
 254                 "<caption><span>Packages</span><span class=\"tabEnd\">&nbsp;</span></caption>");
 255     }
 256 
 257     /*
 258      * Test for validating headers for HTML tables
 259      */
 260     void checkHtmlTableHeaders() {
 261         //Package summary
 262         checkOutput("pkg1/package-summary.html", true,
 263                 "<th class=\"colFirst\" scope=\"col\">"
 264                 + "Class</th>\n"
 265                 + "<th class=\"colLast\" scope=\"col\""
 266                 + ">Description</th>",
 267                 "<th class=\"colFirst\" scope=\"col\">"
 268                 + "Interface</th>\n"
 269                 + "<th class=\"colLast\" scope=\"col\""
 270                 + ">Description</th>");
 271 
 272         checkOutput("pkg2/package-summary.html", true,
 273                 "<th class=\"colFirst\" scope=\"col\">"
 274                 + "Enum</th>\n"
 275                 + "<th class=\"colLast\" scope=\"col\""
 276                 + ">Description</th>",
 277                 "<th class=\"colFirst\" scope=\"col\">"
 278                 + "Annotation Type</th>\n"
 279                 + "<th class=\"colLast\""
 280                 + " scope=\"col\">Description</th>");
 281 
 282         // Class documentation
 283         checkOutput("pkg1/C1.html", true,
 284                 "<th class=\"colFirst\" scope=\"col\">Modifier and Type</th>\n"
 285                 + "<th class=\"colLast\" scope=\"col\">Field and Description</th>",
 286                 "<th class=\"colFirst\" scope=\"col\">Modifier and Type</th>\n"
 287                 + "<th class=\"colLast\" scope=\"col\">Method and Description</th>");
 288 
 289         checkOutput("pkg2/C2.html", true,
 290                 "<th class=\"colFirst\" scope=\"col\">Modifier and Type</th>\n"
 291                 + "<th class=\"colLast\" scope=\"col\">Class and Description</th>",
 292                 "<th class=\"colOne\" scope=\"col\">Constructor and Description</th>");
 293 
 294         checkOutput("pkg2/C2.ModalExclusionType.html", true,
 295                 "<th class=\"colOne\" scope=\"col\">Enum Constant and Description</th>");
 296 
 297         checkOutput("pkg2/C3.html", true,
 298                 "<th class=\"colFirst\" scope=\"col\">Modifier and Type</th>\n"
 299                 + "<th class=\"colLast\" scope=\"col\">Required Element and Description</th>");
 300 
 301         checkOutput("pkg2/C4.html", true,
 302                 "<th class=\"colFirst\" scope=\"col\">Modifier and Type</th>\n"
 303                 + "<th class=\"colLast\" scope=\"col\">Optional Element and Description</th>");
 304 
 305         // Class use documentation
 306         checkOutput("pkg1/class-use/I1.html", true,
 307                 "<th class=\"colFirst\" scope=\"col\">Package</th>\n"
 308                 + "<th class=\"colLast\" scope=\"col\">Description</th>");
 309 
 310         checkOutput("pkg1/class-use/C1.html", true,
 311                 "<th class=\"colFirst\" scope=\"col\">Modifier and Type</th>\n"
 312                 + "<th class=\"colLast\" scope=\"col\">Field and Description</th>",
 313                 "<th class=\"colFirst\" scope=\"col\">Modifier and Type</th>\n"
 314                 + "<th class=\"colLast\" scope=\"col\">Method and Description</th>");
 315 
 316         checkOutput("pkg2/class-use/C2.html", true,
 317                 "<th class=\"colFirst\" scope=\"col\">Modifier and Type</th>\n"
 318                 + "<th class=\"colLast\" scope=\"col\">Field and Description</th>",
 319                 "<th class=\"colFirst\" scope=\"col\">Modifier and Type</th>\n"
 320                 + "<th class=\"colLast\" scope=\"col\">Method and Description</th>");
 321 
 322         checkOutput("pkg2/class-use/C2.ModalExclusionType.html", true,
 323                 "<th class=\"colFirst\" scope=\"col\">Package</th>\n"
 324                 + "<th class=\"colLast\" scope=\"col\">Description</th>",
 325                 "<th class=\"colFirst\" scope=\"col\">Modifier and Type</th>\n"
 326                 + "<th class=\"colLast\" scope=\"col\">Method and Description</th>");
 327 
 328         // Package use documentation
 329         checkOutput("pkg1/package-use.html", true,
 330                 "<th class=\"colFirst\" scope=\"col\">Package</th>\n"
 331                 + "<th class=\"colLast\" scope=\"col\">Description</th>",
 332                 "<th class=\"colOne\" scope=\"col\">Class and Description</th>");
 333 
 334         checkOutput("pkg2/package-use.html", true,
 335                 "<th class=\"colFirst\" scope=\"col\">Package</th>\n"
 336                 + "<th class=\"colLast\" scope=\"col\">Description</th>",
 337                 "<th class=\"colOne\" scope=\"col\">Class and Description</th>");
 338 
 339         // Deprecated
 340         checkOutput("deprecated-list.html", true,
 341                 "<th class=\"colOne\" scope=\"col\">Field and Description</th>",
 342                 "<th class=\"colOne\" scope=\"col\">Method and Description</th>");
 343 
 344         // Constant values
 345         checkOutput("constant-values.html", true,
 346                 "<th class=\"colFirst\" scope=\"col\">"
 347                 + "Modifier and Type</th>\n"
 348                 + "<th"
 349                 + " scope=\"col\">Constant Field</th>\n"
 350                 + "<th class=\"colLast\" scope=\"col\">Value</th>");
 351 
 352         // Overview Summary
 353         checkOutput("overview-summary.html", true,
 354                 "<th class=\"colFirst\" scope=\"col\">"
 355                 + "Package</th>\n"
 356                 + "<th class=\"colLast\" scope=\"col\""
 357                 + ">Description</th>");
 358     }
 359 }