1 /*
   2  * Copyright (c) 2015, 2019, 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 8141492 8071982 8141636 8147890 8166175 8168965 8176794 8175218 8147881
  27  *      8181622 8182263 8074407 8187521 8198522 8182765 8199278 8196201 8196202
  28  *      8184205 8214468 8222548 8223378 8234746
  29  * @summary Test the search feature of javadoc.
  30  * @library ../../lib
  31  * @modules jdk.javadoc/jdk.javadoc.internal.tool
  32  * @build javadoc.tester.*
  33  * @run main TestSearch
  34  */
  35 import javadoc.tester.JavadocTester;
  36 
  37 public class TestSearch extends JavadocTester {
  38 
  39     public static void main(String... args) throws Exception {
  40         TestSearch tester = new TestSearch();
  41         tester.runTests();
  42     }
  43 
  44     @Test
  45     public void test1() {
  46         javadoc("-d", "out-1",
  47                 "-sourcepath",
  48                 "-use",
  49                 testSrc("UnnamedPkgClass.java"));
  50         checkExit(Exit.OK);
  51         checkSearchOutput("UnnamedPkgClass.html", true, true);
  52         checkJqueryAndImageFiles(true);
  53         checkSearchJS();
  54         checkFiles(false,
  55                 "tag-search-index.zip",
  56                 "tag-search-index.js");
  57         checkFiles(true,
  58                 "package-search-index.zip",
  59                 "member-search-index.zip",
  60                 "type-search-index.zip",
  61                 "package-search-index.js",
  62                 "member-search-index.js",
  63                 "type-search-index.js");
  64     }
  65 
  66     @Test
  67     public void test2() {
  68         javadoc("-d", "out-2",
  69                 "-Xdoclint:none",
  70                 "-sourcepath", testSrc,
  71                 "-use",
  72                 "pkg", "pkg1", "pkg2", "pkg3");
  73         checkExit(Exit.OK);
  74         checkInvalidUsageIndexTag();
  75         checkSearchOutput(true);
  76         checkSingleIndex(true, true);
  77         checkSingleIndexSearchTagDuplication();
  78         checkJqueryAndImageFiles(true);
  79         checkSearchJS();
  80         checkAllPkgsAllClasses();
  81         checkFiles(true,
  82                 "member-search-index.zip",
  83                 "package-search-index.zip",
  84                 "tag-search-index.zip",
  85                 "type-search-index.zip",
  86                 "member-search-index.js",
  87                 "package-search-index.js",
  88                 "tag-search-index.js",
  89                 "type-search-index.js");
  90     }
  91 
  92     @Test
  93     public void test2a() {
  94         javadoc("-d", "out-2a",
  95                 "-Xdoclint:all",
  96                 "-sourcepath", testSrc,
  97                 "-use",
  98                 "pkg", "pkg1", "pkg2", "pkg3");
  99         checkExit(Exit.ERROR);
 100         checkDocLintErrors();
 101         checkSearchOutput(true);
 102         checkSingleIndex(true, true);
 103         checkSingleIndexSearchTagDuplication();
 104         checkJqueryAndImageFiles(true);
 105         checkSearchJS();
 106         checkFiles(true,
 107                 "member-search-index.zip",
 108                 "package-search-index.zip",
 109                 "tag-search-index.zip",
 110                 "type-search-index.zip",
 111                 "member-search-index.js",
 112                 "package-search-index.js",
 113                 "tag-search-index.js",
 114                 "type-search-index.js");
 115     }
 116 
 117     @Test
 118     public void test3() {
 119         javadoc("-d", "out-3",
 120                 "-noindex",
 121                 "-Xdoclint:none",
 122                 "-sourcepath", testSrc,
 123                 "-use",
 124                 "pkg", "pkg1", "pkg2", "pkg3");
 125         checkExit(Exit.OK);
 126         checkSearchOutput(false);
 127         checkJqueryAndImageFiles(false);
 128         checkFiles(false,
 129                 "member-search-index.zip",
 130                 "package-search-index.zip",
 131                 "tag-search-index.zip",
 132                 "type-search-index.zip",
 133                 "member-search-index.js",
 134                 "package-search-index.js",
 135                 "tag-search-index.js",
 136                 "type-search-index.js",
 137                 "index-all.html",
 138                 "allpackages-index.html",
 139                 "allclasses-index.html");
 140     }
 141 
 142     @Test
 143     public void test4() {
 144         javadoc("-d", "out-4",
 145                 "-html5",
 146                 "-Xdoclint:none",
 147                 "-sourcepath", testSrc,
 148                 "-use",
 149                 "pkg", "pkg1", "pkg2", "pkg3");
 150         checkExit(Exit.OK);
 151         checkSearchOutput(true);
 152         checkSingleIndex(true, true);
 153         checkSingleIndexSearchTagDuplication();
 154         checkJqueryAndImageFiles(true);
 155         checkSearchJS();
 156         checkFiles(true,
 157                 "member-search-index.zip",
 158                 "package-search-index.zip",
 159                 "tag-search-index.zip",
 160                 "type-search-index.zip",
 161                 "member-search-index.js",
 162                 "package-search-index.js",
 163                 "tag-search-index.js",
 164                 "type-search-index.js");
 165     }
 166 
 167     @Test
 168     public void test5() {
 169         javadoc("-d", "out-5",
 170                 "-html5",
 171                 "-noindex",
 172                 "-Xdoclint:none",
 173                 "-sourcepath", testSrc,
 174                 "-use",
 175                 "pkg", "pkg1", "pkg2", "pkg3");
 176         checkExit(Exit.OK);
 177         checkSearchOutput(false);
 178         checkJqueryAndImageFiles(false);
 179         checkFiles(false,
 180                 "member-search-index.zip",
 181                 "package-search-index.zip",
 182                 "tag-search-index.zip",
 183                 "type-search-index.zip",
 184                 "member-search-index.js",
 185                 "package-search-index.js",
 186                 "tag-search-index.js",
 187                 "type-search-index.js",
 188                 "index-all.html");
 189     }
 190 
 191     @Test
 192     public void test6() {
 193         javadoc("-d", "out-6",
 194                 "-nocomment",
 195                 "-Xdoclint:none",
 196                 "-sourcepath", testSrc,
 197                 "-use",
 198                 "pkg", "pkg1", "pkg2", "pkg3");
 199         checkExit(Exit.OK);
 200         checkSearchOutput(true);
 201         checkIndexNoComment();
 202         checkJqueryAndImageFiles(true);
 203         checkSearchJS();
 204         checkFiles(true,
 205                 "member-search-index.zip",
 206                 "package-search-index.zip",
 207                 "tag-search-index.zip",
 208                 "type-search-index.zip",
 209                 "member-search-index.js",
 210                 "package-search-index.js",
 211                 "tag-search-index.js",
 212                 "type-search-index.js");
 213     }
 214 
 215     @Test
 216     public void test7() {
 217         javadoc("-d", "out-7",
 218                 "-nodeprecated",
 219                 "-Xdoclint:none",
 220                 "-sourcepath", testSrc,
 221                 "-use",
 222                 "pkg", "pkg1", "pkg2", "pkg3");
 223 
 224         checkExit(Exit.OK);
 225         checkSearchOutput(true);
 226         checkIndexNoDeprecated();
 227         checkJqueryAndImageFiles(true);
 228         checkSearchJS();
 229         checkFiles(true,
 230                 "member-search-index.zip",
 231                 "package-search-index.zip",
 232                 "tag-search-index.zip",
 233                 "type-search-index.zip",
 234                 "member-search-index.js",
 235                 "package-search-index.js",
 236                 "tag-search-index.js",
 237                 "type-search-index.js");
 238     }
 239 
 240     @Test
 241     public void test8() {
 242         javadoc("-d", "out-8",
 243                 "-splitindex",
 244                 "-Xdoclint:none",
 245                 "-sourcepath", testSrc,
 246                 "-use",
 247                 "pkg", "pkg1", "pkg2", "pkg3");
 248         checkExit(Exit.OK);
 249         checkInvalidUsageIndexTag();
 250         checkSearchOutput(true);
 251         checkSplitIndex();
 252         checkSplitIndexSearchTagDuplication();
 253         checkJqueryAndImageFiles(true);
 254         checkSearchJS();
 255         checkFiles(true,
 256                 "member-search-index.zip",
 257                 "package-search-index.zip",
 258                 "tag-search-index.zip",
 259                 "type-search-index.zip",
 260                 "member-search-index.js",
 261                 "package-search-index.js",
 262                 "tag-search-index.js",
 263                 "type-search-index.js");
 264     }
 265 
 266     @Test
 267     public void test9() {
 268         javadoc("-d", "out-9",
 269                 "-sourcepath", testSrc,
 270                 "-javafx",
 271                 "--disable-javafx-strict-checks",
 272                 "-package",
 273                 "-use",
 274                 "pkgfx", "pkg3");
 275         checkExit(Exit.OK);
 276         checkSearchOutput(true);
 277         checkJavaFXOutput();
 278         checkJqueryAndImageFiles(true);
 279         checkSearchJS();
 280         checkFiles(false,
 281                 "tag-search-index.zip",
 282                 "tag-search-index.js");
 283         checkFiles(true,
 284                 "member-search-index.zip",
 285                 "package-search-index.zip",
 286                 "type-search-index.zip",
 287                 "member-search-index.js",
 288                 "package-search-index.js",
 289                 "type-search-index.js");
 290     }
 291 
 292     @Test
 293     public void testURLEncoding() {
 294         javadoc("-d", "out-encode-html5",
 295                 "-Xdoclint:none",
 296                 "-sourcepath", testSrc,
 297                 "-use",
 298                 "pkg", "pkg1", "pkg2", "pkg3");
 299         checkExit(Exit.OK);
 300         checkSearchJS();
 301         checkSearchIndex(true);
 302     }
 303 
 304     @Test
 305     public void testJapaneseLocale() {
 306         javadoc("-locale", "ja_JP",
 307                 "-d", "out-jp",
 308                 "-Xdoclint:none",
 309                 "-sourcepath", testSrc,
 310                 "-use",
 311                 "pkg", "pkg1", "pkg2", "pkg3");
 312         checkExit(Exit.OK);
 313         checkOutput(Output.OUT, true,
 314                 "\u30d1\u30c3\u30b1\u30fc\u30b8pkg\u306e\u30bd\u30fc\u30b9\u30fb\u30d5\u30a1" +
 315                         "\u30a4\u30eb\u3092\u8aad\u307f\u8fbc\u3093\u3067\u3044\u307e\u3059...\n",
 316                 "\u30d1\u30c3\u30b1\u30fc\u30b8pkg1\u306e\u30bd\u30fc\u30b9\u30fb\u30d5\u30a1" +
 317                         "\u30a4\u30eb\u3092\u8aad\u307f\u8fbc\u3093\u3067\u3044\u307e\u3059...\n");
 318         checkSearchJS();
 319         checkSearchIndex(true);
 320     }
 321 
 322     @Test
 323     public void testChineseLocale() {
 324         javadoc("-locale", "zh_CN",
 325                 "-d", "out-cn",
 326                 "-Xdoclint:none",
 327                 "-sourcepath", testSrc,
 328                 "-use",
 329                 "pkg", "pkg1", "pkg2", "pkg3");
 330         checkExit(Exit.OK);
 331         checkOutput(Output.OUT, true,
 332                 "\u6b63\u5728\u52a0\u8f7d\u7a0b\u5e8f\u5305pkg\u7684\u6e90\u6587\u4ef6...\n",
 333                 "\u6b63\u5728\u52a0\u8f7d\u7a0b\u5e8f\u5305pkg1\u7684\u6e90\u6587\u4ef6...\n",
 334                 "\u6b63\u5728\u52a0\u8f7d\u7a0b\u5e8f\u5305pkg2\u7684\u6e90\u6587\u4ef6...\n",
 335                 "\u6b63\u5728\u52a0\u8f7d\u7a0b\u5e8f\u5305pkg3\u7684\u6e90\u6587\u4ef6...\n");
 336         checkSearchJS();
 337         checkSearchIndex(true);
 338     }
 339 
 340     void checkDocLintErrors() {
 341         checkOutput(Output.OUT, true,
 342                 "A sample method. Testing search tag for {@index \"unclosed quote}.",
 343                 "Another test class. Testing empty {@index }.",
 344                 "Constant field. Testing no text in index tag {@index}.",
 345                 "A test field. Testing only white-spaces in index tag text {@index       }.");
 346     }
 347 
 348     void checkSearchOutput(boolean expectedOutput) {
 349         checkSearchOutput("index.html", expectedOutput, true);
 350     }
 351 
 352     void checkSearchIndex(boolean expectedOutput) {
 353         checkOutput("member-search-index.js", expectedOutput,
 354                 "{\"p\":\"pkg\",\"c\":\"AnotherClass\",\"l\":\"AnotherClass()\",\"url\":\"%3Cinit%3E()\"}",
 355                 "{\"p\":\"pkg1\",\"c\":\"RegClass\",\"l\":\"RegClass()\",\"url\":\"%3Cinit%3E()\"}",
 356                 "{\"p\":\"pkg2\",\"c\":\"TestError\",\"l\":\"TestError()\",\"url\":\"%3Cinit%3E()\"}",
 357                 "{\"p\":\"pkg\",\"c\":\"AnotherClass\",\"l\":\"method(byte[], int, String)\",\"url\":\"method(byte[],int,java.lang.String)\"}");
 358         checkOutput("member-search-index.js", !expectedOutput,
 359                 "{\"p\":\"pkg\",\"c\":\"AnotherClass\",\"l\":\"method(RegClass)\",\"url\":\"method-pkg1.RegClass-\"}",
 360                 "{\"p\":\"pkg2\",\"c\":\"TestClass\",\"l\":\"TestClass()\",\"url\":\"TestClass--\"}",
 361                 "{\"p\":\"pkg\",\"c\":\"TestError\",\"l\":\"TestError()\",\"url\":\"TestError--\"}",
 362                 "{\"p\":\"pkg\",\"c\":\"AnotherClass\",\"l\":\"method(byte[], int, String)\",\"url\":\"method-byte:A-int-java.lang.String-\"}");
 363     }
 364 
 365     void checkSearchOutput(boolean expectedOutput, boolean moduleDirectoriesVar) {
 366         checkSearchOutput("index.html", expectedOutput, moduleDirectoriesVar);
 367     }
 368 
 369     void checkSearchOutput(String fileName, boolean expectedOutput, boolean moduleDirectoriesVar) {
 370         // Test for search related markup
 371         checkOutput(fileName, expectedOutput,
 372                 "<link rel=\"stylesheet\" type=\"text/css\" href=\"script-dir/jquery-ui.css\" title=\"Style\">\n",
 373                 "<script type=\"text/javascript\" src=\"script-dir/jszip/dist/jszip.min.js\"></script>\n",
 374                 "<script type=\"text/javascript\" src=\"script-dir/jszip-utils/dist/jszip-utils.min.js\"></script>\n",
 375                 "<!--[if IE]>\n",
 376                 "<script type=\"text/javascript\" src=\"script-dir/jszip-utils/dist/jszip-utils-ie.min.js\"></script>\n",
 377                 "<![endif]-->\n",
 378                 "<script type=\"text/javascript\" src=\"script-dir/jquery-3.4.1.js\"></script>\n",
 379                 "<script type=\"text/javascript\" src=\"script-dir/jquery-ui.js\"></script>",
 380                 "var pathtoroot = \"./\";\n"
 381                 + "loadScripts(document, 'script');",
 382                 "<div class=\"navListSearch\">",
 383                 "<label for=\"search\">SEARCH:</label>\n"
 384                 + "<input type=\"text\" id=\"search\" value=\"search\" disabled=\"disabled\">\n"
 385                 + "<input type=\"reset\" id=\"reset\" value=\"reset\" disabled=\"disabled\">\n");
 386         checkOutput(fileName, true,
 387                 "<div class=\"flexBox\">");
 388     }
 389 
 390     void checkSingleIndex(boolean expectedOutput, boolean html5) {
 391         String html_span_see_span = html5 ? "html%3Cspan%3Esee%3C/span%3E" : "html-span-see-/span-";
 392 
 393         // Test for search tags markup in index file.
 394         checkOutput("index-all.html", expectedOutput,
 395                 "<dt><span class=\"searchTagLink\"><a href=\"pkg/package-summary.html#phrasewithspaces\">"
 396                 + "phrase with spaces</a></span> - Search tag in package pkg</dt>",
 397                 "<dt><span class=\"searchTagLink\"><a href=\"pkg/package-summary.html#pkg\">"
 398                 + "pkg</a></span> - Search tag in package pkg</dt>",
 399                 "<dt><span class=\"searchTagLink\"><a href=\"pkg/package-summary.html#pkg2.5\">"
 400                 + "pkg2.5</a></span> - Search tag in package pkg</dt>",
 401                 "<dt><span class=\"searchTagLink\"><a href=\"pkg/package-summary.html#r\">"
 402                 + "r</a></span> - Search tag in package pkg</dt>",
 403                 "<dt><span class=\"searchTagLink\"><a href=\"pkg1/RegClass.html#searchphrase\">"
 404                 + "search phrase</a></span> - Search tag in class pkg1.RegClass</dt>",
 405                 "<dt><span class=\"searchTagLink\"><a href=\"pkg1/RegClass.html#SearchWordWithDescription\">"
 406                 + "SearchWordWithDescription</a></span> - Search tag in pkg1.RegClass.CONSTANT_FIELD_1</dt>",
 407                 "<dt><span class=\"searchTagLink\"><a href=\"pkg2/TestAnnotationType.html#searchphrasewithdescdeprecated\">"
 408                 + "search phrase with desc deprecated</a></span> - Search tag in annotation type pkg2.TestAnnotationType</dt>",
 409                 "<dt><span class=\"searchTagLink\"><a href=\"pkg2/TestClass.html#SearchTagDeprecatedClass\">"
 410                 + "SearchTagDeprecatedClass</a></span> - Search tag in class pkg2.TestClass</dt>",
 411                 "<dt><span class=\"searchTagLink\"><a href=\"pkg2/TestEnum.html#searchphrasedeprecated\">"
 412                 + "search phrase deprecated</a></span> - Search tag in pkg2.TestEnum.ONE</dt>",
 413                 "<dt><span class=\"searchTagLink\"><a href=\"pkg2/TestEnum.html#searchphrasedeprecated\">"
 414                 + "search phrase deprecated</a></span> - Search tag in pkg2.TestEnum.ONE</dt>",
 415                 "<dt><span class=\"searchTagLink\"><a href=\"pkg2/TestError.html#SearchTagDeprecatedMethod\">"
 416                 + "SearchTagDeprecatedMethod</a></span> - Search tag in pkg2.TestError.TestError()</dt>",
 417                 "<dt><span class=\"searchTagLink\"><a href=\"pkg2/TestError.html#SearchTagDeprecatedMethod\">"
 418                 + "SearchTagDeprecatedMethod</a></span> - Search tag in pkg2.TestError.TestError()</dt>",
 419                 "<dt><span class=\"searchTagLink\"><a href=\"pkg/package-summary.html#SingleWord\">"
 420                 + "SingleWord</a></span> - Search tag in package pkg</dt>",
 421                 "<dt><span class=\"searchTagLink\"><a href=\"pkg/AnotherClass.ModalExclusionType.html"
 422                 + "#nested%7B@indexnested_tag_test%7D\">nested {@index nested_tag_test}</a></span> - "
 423                 + "Search tag in pkg.AnotherClass.ModalExclusionType.NO_EXCLUDE</dt>",
 424                 "<dt><span class=\"searchTagLink\"><a href=\"pkg/AnotherClass.ModalExclusionType.html"
 425                 + "#" + html_span_see_span + "\">html &lt;span&gt; see &lt;/span&gt;</a></span> - Search "
 426                 + "tag in pkg.AnotherClass.ModalExclusionType.APPLICATION_EXCLUDE</dt>",
 427                 "<dt><span class=\"searchTagLink\"><a href=\"pkg/AnotherClass.html#quoted\">quoted</a>"
 428                 + "</span> - Search tag in pkg.AnotherClass.CONSTANT1</dt>",
 429                 "<dt><span class=\"memberNameLink\"><a href=\"pkg2/TestEnum.html#ONE\">ONE</a></span> - "
 430                 + "pkg2.<a href=\"pkg2/TestEnum.html\" title=\"enum in pkg2\">TestEnum</a></dt>",
 431                 "<dt><span class=\"memberNameLink\"><a href=\"pkg2/TestEnum.html#THREE\">THREE</a></span> - "
 432                 + "pkg2.<a href=\"pkg2/TestEnum.html\" title=\"enum in pkg2\">TestEnum</a></dt>",
 433                 "<dt><span class=\"memberNameLink\"><a href=\"pkg2/TestEnum.html#TWO\">TWO</a></span> - "
 434                 + "pkg2.<a href=\"pkg2/TestEnum.html\" title=\"enum in pkg2\">TestEnum</a></dt>");
 435         checkOutput("index-all.html", true,
 436                 "<div class=\"deprecationComment\">class_test1 passes. Search tag"
 437                 + " <span id=\"SearchTagDeprecatedClass\" class=\"searchTagResult\">SearchTagDeprecatedClass</span></div>",
 438                 "<div class=\"deprecationComment\">error_test3 passes. Search tag for\n"
 439                 + " method <span id=\"SearchTagDeprecatedMethod\" class=\"searchTagResult\">SearchTagDeprecatedMethod</span></div>");
 440     }
 441 
 442     void checkSplitIndex() {
 443         // Test for search tags markup in split index file.
 444         checkOutput("index-files/index-13.html", true,
 445                 "<dt><span class=\"searchTagLink\"><a href=\"../pkg1/RegClass.html#searchphrase\">"
 446                 + "search phrase</a></span> - Search tag in class pkg1.RegClass</dt>",
 447                 "<dt><span class=\"searchTagLink\"><a href=\"../pkg1/RegClass.html#SearchWordWithDescription\">"
 448                 + "SearchWordWithDescription</a></span> - Search tag in pkg1.RegClass.CONSTANT_FIELD_1</dt>",
 449                 "<dt><span class=\"searchTagLink\"><a href=\"../pkg2/TestAnnotationType.html#searchphrasewithdescdeprecated\">"
 450                 + "search phrase with desc deprecated</a></span> - Search tag in annotation type pkg2.TestAnnotationType</dt>",
 451                 "<dt><span class=\"searchTagLink\"><a href=\"../pkg2/TestClass.html#SearchTagDeprecatedClass\">"
 452                 + "SearchTagDeprecatedClass</a></span> - Search tag in class pkg2.TestClass</dt>",
 453                 "<dt><span class=\"searchTagLink\"><a href=\"../pkg2/TestEnum.html#searchphrasedeprecated\">"
 454                 + "search phrase deprecated</a></span> - Search tag in pkg2.TestEnum.ONE</dt>",
 455                 "<dt><span class=\"searchTagLink\"><a href=\"../pkg2/TestEnum.html#searchphrasedeprecated\">"
 456                 + "search phrase deprecated</a></span> - Search tag in pkg2.TestEnum.ONE</dt>",
 457                 "<dt><span class=\"searchTagLink\"><a href=\"../pkg2/TestError.html#SearchTagDeprecatedMethod\">"
 458                 + "SearchTagDeprecatedMethod</a></span> - Search tag in pkg2.TestError.TestError()</dt>",
 459                 "<dt><span class=\"searchTagLink\"><a href=\"../pkg2/TestError.html#SearchTagDeprecatedMethod\">"
 460                 + "SearchTagDeprecatedMethod</a></span> - Search tag in pkg2.TestError.TestError()</dt>",
 461                 "<dt><span class=\"searchTagLink\"><a href=\"../pkg/package-summary.html#SingleWord\">"
 462                 + "SingleWord</a></span> - Search tag in package pkg</dt>",
 463                 "<br><a href=\"../allclasses-index.html\">All&nbsp;Classes</a>"
 464                 + "<span class=\"verticalSeparator\">|</span>"
 465                 + "<a href=\"../allpackages-index.html\">All&nbsp;Packages</a>");
 466         checkOutput("index-files/index-10.html", true,
 467                 "<dt><span class=\"searchTagLink\"><a href=\"../pkg/package-summary.html#phrasewithspaces\">"
 468                 + "phrase with spaces</a></span> - Search tag in package pkg</dt>",
 469                 "<dt><span class=\"searchTagLink\"><a href=\"../pkg/package-summary.html#pkg\">"
 470                 + "pkg</a></span> - Search tag in package pkg</dt>",
 471                 "<dt><span class=\"searchTagLink\"><a href=\"../pkg/package-summary.html#pkg2.5\">"
 472                 + "pkg2.5</a></span> - Search tag in package pkg</dt>");
 473         checkOutput("index-files/index-12.html", true,
 474                 "<dt><span class=\"searchTagLink\"><a href=\"../pkg/package-summary.html#r\">"
 475                 + "r</a></span> - Search tag in package pkg</dt>");
 476         checkOutput("index-files/index-8.html", true,
 477                 "<dt><span class=\"searchTagLink\"><a href=\"../pkg/AnotherClass.ModalExclusionType.html"
 478                 + "#nested%7B@indexnested_tag_test%7D\">nested {@index nested_tag_test}</a></span> - "
 479                 + "Search tag in pkg.AnotherClass.ModalExclusionType.NO_EXCLUDE</dt>");
 480         checkOutput("index-files/index-5.html", true,
 481                 "<dt><span class=\"searchTagLink\"><a href=\"../pkg/AnotherClass.ModalExclusionType.html"
 482                 + "#html%3Cspan%3Esee%3C/span%3E\">html &lt;span&gt; see &lt;/span&gt;</a></span> - Search "
 483                 + "tag in pkg.AnotherClass.ModalExclusionType.APPLICATION_EXCLUDE</dt>");
 484         checkOutput("index-files/index-11.html", true,
 485                 "<dt><span class=\"searchTagLink\"><a href=\"../pkg/AnotherClass.html#quoted\">quoted</a>"
 486                 + "</span> - Search tag in pkg.AnotherClass.CONSTANT1</dt>");
 487         checkOutput("index-files/index-9.html", true,
 488                 "<dt><span class=\"memberNameLink\"><a href=\"../pkg2/TestEnum.html#ONE\">ONE</a>"
 489                 + "</span> - pkg2.<a href=\"../pkg2/TestEnum.html\" title=\"enum in pkg2\">TestEnum</a></dt>");
 490         checkOutput("index-files/index-14.html", true,
 491                 "<dt><span class=\"memberNameLink\"><a href=\"../pkg2/TestEnum.html#THREE\">THREE</a></span> - "
 492                 + "pkg2.<a href=\"../pkg2/TestEnum.html\" title=\"enum in pkg2\">TestEnum</a></dt>",
 493                 "<dt><span class=\"memberNameLink\"><a href=\"../pkg2/TestEnum.html#TWO\">TWO</a></span> - "
 494                 + "pkg2.<a href=\"../pkg2/TestEnum.html\" title=\"enum in pkg2\">TestEnum</a></dt>");
 495     }
 496 
 497     void checkIndexNoComment() {
 498         // Test for search tags markup in index file when javadoc is executed with -nocomment.
 499         checkOutput("index-all.html", false,
 500                 "<dt><span class=\"searchTagLink\"><a href=\"pkg/package-summary.html#phrasewithspaces\">"
 501                 + "phrase with spaces</a></span> - Search tag in package pkg</dt>",
 502                 "<dt><span class=\"searchTagLink\"><a href=\"pkg/package-summary.html#pkg\">"
 503                 + "pkg</a></span> - Search tag in package pkg</dt>",
 504                 "<dt><span class=\"searchTagLink\"><a href=\"pkg/package-summary.html#pkg2.5\">"
 505                 + "pkg2.5</a></span> - Search tag in package pkg</dt>",
 506                 "<dt><span class=\"searchTagLink\"><a href=\"pkg/package-summary.html#r\">"
 507                 + "r</a></span> - Search tag in package pkg</dt>",
 508                 "<dt><span class=\"searchTagLink\"><a href=\"pkg1/RegClass.html#searchphrase\">"
 509                 + "search phrase</a></span> - Search tag in class pkg1.RegClass</dt>",
 510                 "<dt><span class=\"searchTagLink\"><a href=\"pkg1/RegClass.html#SearchWordWithDescription\">"
 511                 + "SearchWordWithDescription</a></span> - Search tag in pkg1.RegClass.CONSTANT_FIELD_1</dt>",
 512                 "<dt><span class=\"searchTagLink\"><a href=\"pkg2/TestAnnotationType.html#searchphrasewithdescdeprecated\">"
 513                 + "search phrase with desc deprecated</a></span> - Search tag in annotation type pkg2.TestAnnotationType</dt>",
 514                 "<dt><span class=\"searchTagLink\"><a href=\"pkg2/TestClass.html#SearchTagDeprecatedClass\">"
 515                 + "SearchTagDeprecatedClass</a></span> - Search tag in class pkg2.TestClass</dt>",
 516                 "<dt><span class=\"searchTagLink\"><a href=\"pkg/package-summary.html#SingleWord\">"
 517                 + "SingleWord</a></span> - Search tag in package pkg</dt>",
 518                 "<div class=\"deprecationComment\">class_test1 passes. Search tag"
 519                 + " <span id=\"SearchTagDeprecatedClass\">SearchTagDeprecatedClass</span></div>",
 520                 "<div class=\"deprecationComment\">error_test3 passes. Search tag for\n"
 521                 + " method <span id=\"SearchTagDeprecatedMethod\">SearchTagDeprecatedMethod</span></div>");
 522         checkOutput("index-all.html", true,
 523                 "<dt><span class=\"searchTagLink\"><a href=\"pkg2/TestEnum.html#searchphrasedeprecated\">"
 524                 + "search phrase deprecated</a></span> - Search tag in pkg2.TestEnum.ONE</dt>",
 525                 "<dt><span class=\"searchTagLink\"><a href=\"pkg2/TestError.html#SearchTagDeprecatedMethod\">"
 526                 + "SearchTagDeprecatedMethod</a></span> - Search tag in pkg2.TestError.TestError()</dt>");
 527     }
 528 
 529     void checkIndexNoDeprecated() {
 530         // Test for search tags markup in index file when javadoc is executed using -nodeprecated.
 531         checkOutput("index-all.html", true,
 532                 "<dt><span class=\"searchTagLink\"><a href=\"pkg/package-summary.html#phrasewithspaces\">"
 533                 + "phrase with spaces</a></span> - Search tag in package pkg</dt>",
 534                 "<dt><span class=\"searchTagLink\"><a href=\"pkg1/RegClass.html#searchphrase\">"
 535                 + "search phrase</a></span> - Search tag in class pkg1.RegClass</dt>",
 536                 "<dt><span class=\"searchTagLink\"><a href=\"pkg1/RegClass.html#SearchWordWithDescription\">"
 537                 + "SearchWordWithDescription</a></span> - Search tag in pkg1.RegClass.CONSTANT_FIELD_1</dt>",
 538                 "<dt><span class=\"searchTagLink\"><a href=\"pkg/package-summary.html#SingleWord\">"
 539                 + "SingleWord</a></span> - Search tag in package pkg</dt>");
 540         checkOutput("index-all.html", false,
 541                 "<dt><span class=\"searchTagLink\"><a href=\"pkg2/TestAnnotationType.html#searchphrasewithdescdeprecated\">"
 542                 + "search phrase with desc deprecated</a></span> - Search tag in annotation type pkg2.TestAnnotationType</dt>",
 543                 "<dt><span class=\"searchTagLink\"><a href=\"pkg2/TestClass.html#SearchTagDeprecatedClass\">"
 544                 + "SearchTagDeprecatedClass</a></span> - Search tag in class pkg2.TestClass</dt>",
 545                 "<dt><span class=\"searchTagLink\"><a href=\"pkg2/TestEnum.html#searchphrasedeprecated\">"
 546                 + "search phrase deprecated</a></span> - Search tag in pkg2.TestEnum.ONE</dt>",
 547                 "<dt><span class=\"searchTagLink\"><a href=\"pkg2/TestError.html#SearchTagDeprecatedMethod\">"
 548                 + "SearchTagDeprecatedMethod</a></span> - Search tag in pkg2.TestError.TestError()</dt>",
 549                 "<div class=\"deprecationComment\">class_test1 passes. Search tag"
 550                 + " <span id=\"SearchTagDeprecatedClass\">SearchTagDeprecatedClass</span></div>",
 551                 "<div class=\"deprecationComment\">error_test3 passes. Search tag for\n"
 552                 + " method <span id=\"SearchTagDeprecatedMethod\">SearchTagDeprecatedMethod</span></div>");
 553     }
 554 
 555     void checkJavaFXOutput() {
 556         checkOutput("index-all.html", false, "test treat as private");
 557     }
 558 
 559     void checkInvalidUsageIndexTag() {
 560         checkOutput(Output.OUT, true,
 561                 "AnotherClass.java:29: warning - invalid usage of tag {@index",
 562                 "AnotherClass.java:39: warning - invalid usage of tag {@index",
 563                 "AnotherClass.java:34: warning - invalid usage of tag {@index",
 564                 "AnotherClass.java:68: warning - invalid usage of tag {@index");
 565     }
 566 
 567     void checkJqueryAndImageFiles(boolean expectedOutput) {
 568         checkFiles(expectedOutput,
 569                 "search.js",
 570                 "script-dir/jquery-3.4.1.js",
 571                 "script-dir/jquery-ui.js",
 572                 "script-dir/jquery-ui.css",
 573                 "script-dir/jquery-ui.min.js",
 574                 "script-dir/jquery-ui.min.css",
 575                 "script-dir/jquery-ui.structure.min.css",
 576                 "script-dir/jquery-ui.structure.css",
 577                 "script-dir/external/jquery/jquery.js",
 578                 "script-dir/jszip/dist/jszip.js",
 579                 "script-dir/jszip/dist/jszip.min.js",
 580                 "script-dir/jszip-utils/dist/jszip-utils.js",
 581                 "script-dir/jszip-utils/dist/jszip-utils.min.js",
 582                 "script-dir/jszip-utils/dist/jszip-utils-ie.js",
 583                 "script-dir/jszip-utils/dist/jszip-utils-ie.min.js",
 584                 "script-dir/images/ui-bg_glass_65_dadada_1x400.png",
 585                 "script-dir/images/ui-icons_454545_256x240.png",
 586                 "script-dir/images/ui-bg_glass_95_fef1ec_1x400.png",
 587                 "script-dir/images/ui-bg_glass_75_dadada_1x400.png",
 588                 "script-dir/images/ui-bg_highlight-soft_75_cccccc_1x100.png",
 589                 "script-dir/images/ui-icons_888888_256x240.png",
 590                 "script-dir/images/ui-icons_2e83ff_256x240.png",
 591                 "script-dir/images/ui-icons_cd0a0a_256x240.png",
 592                 "script-dir/images/ui-bg_glass_55_fbf9ee_1x400.png",
 593                 "script-dir/images/ui-icons_222222_256x240.png",
 594                 "script-dir/images/ui-bg_glass_75_e6e6e6_1x400.png",
 595                 "resources/x.png",
 596                 "resources/glass.png");
 597     }
 598 
 599     void checkSearchJS() {
 600         checkOutput("search.js", true,
 601                 "function concatResults(a1, a2) {",
 602                 "$(\"#search\").on('click keydown paste', function() {\n"
 603                 + "        if ($(this).val() == watermark) {\n"
 604                 + "            $(this).val('').removeClass('watermark');\n"
 605                 + "        }\n"
 606                 + "    });",
 607                 "function getURLPrefix(ui) {\n"
 608                 + "    var urlPrefix=\"\";\n"
 609                 + "    var slash = \"/\";\n"
 610                 + "    if (ui.item.category === catModules) {\n"
 611                 + "        return ui.item.l + slash;\n"
 612                 + "    } else if (ui.item.category === catPackages && ui.item.m) {\n"
 613                 + "        return ui.item.m + slash;\n"
 614                 + "    } else if ((ui.item.category === catTypes && ui.item.p) || ui.item.category === catMembers) {\n"
 615                 + "        $.each(packageSearchIndex, function(index, item) {\n"
 616                 + "            if (item.m && ui.item.p == item.l) {\n"
 617                 + "                urlPrefix = item.m + slash;\n"
 618                 + "            }\n"
 619                 + "        });\n"
 620                 + "        return urlPrefix;\n"
 621                 + "    } else {\n"
 622                 + "        return urlPrefix;\n"
 623                 + "    }\n"
 624                 + "    return urlPrefix;\n"
 625                 + "}",
 626                 "url += ui.item.l;");
 627     }
 628 
 629     void checkSingleIndexSearchTagDuplication() {
 630         // Test for search tags duplication in index file.
 631         checkOutput("index-all.html", true,
 632                 "<dt><span class=\"searchTagLink\"><a href=\"pkg2/TestError.html#SearchTagDeprecatedMethod\">"
 633                 + "SearchTagDeprecatedMethod</a></span> - Search tag in pkg2.TestError.TestError()</dt>\n"
 634                 + "<dd>with description</dd>");
 635         checkOutput("index-all.html", false,
 636                 "<dt><span class=\"searchTagLink\"><a href=\"pkg2/TestError.html#SearchTagDeprecatedMethod\">"
 637                 + "SearchTagDeprecatedMethod</a></span> - Search tag in pkg2.TestError.TestError()</dt>\n"
 638                 + "<dd>with description</dd>\n"
 639                 + "<dt><span class=\"searchTagLink\"><a href=\"pkg2/TestError.html#SearchTagDeprecatedMethod\">"
 640                 + "SearchTagDeprecatedMethod</a></span> - Search tag in pkg2.TestError.TestError()</dt>\n"
 641                 + "<dd>with description</dd>");
 642     }
 643 
 644     void checkSplitIndexSearchTagDuplication() {
 645         // Test for search tags duplication in index file.
 646         checkOutput("index-files/index-13.html", true,
 647                 "<dt><span class=\"searchTagLink\"><a href=\"../pkg2/TestError.html#SearchTagDeprecatedMethod\">"
 648                 + "SearchTagDeprecatedMethod</a></span> - Search tag in pkg2.TestError.TestError()</dt>\n"
 649                 + "<dd>with description</dd>");
 650         checkOutput("index-files/index-13.html", false,
 651                 "<dt><span class=\"searchTagLink\"><a href=\"../pkg2/TestError.html#SearchTagDeprecatedMethod\">"
 652                 + "SearchTagDeprecatedMethod</a></span> - Search tag in pkg2.TestError.TestError()</dt>\n"
 653                 + "<dd>with description</dd>\n"
 654                 + "<dt><span class=\"searchTagLink\"><a href=\"../pkg2/TestError.html#SearchTagDeprecatedMethod\">"
 655                 + "SearchTagDeprecatedMethod</a></span> - Search tag in pkg2.TestError.TestError()</dt>\n"
 656                 + "<dd>with description</dd>");
 657     }
 658 
 659     void checkAllPkgsAllClasses() {
 660         checkOutput("allclasses-index.html", true,
 661                 "<div class=\"typeSummary\">\n"
 662                 + "<div role=\"tablist\" aria-orientation=\"horizontal\"><button role=\"tab\""
 663                 + " aria-selected=\"true\" aria-controls=\"typeSummary_tabpanel\" tabindex=\"0\""
 664                 + " onkeydown=\"switchTab(event)\" id=\"t0\" class=\"activeTableTab\">All Classes</button>"
 665                 + "<button role=\"tab\" aria-selected=\"false\" aria-controls=\"typeSummary_tabpanel\""
 666                 + " tabindex=\"-1\" onkeydown=\"switchTab(event)\" id=\"t1\" class=\"tableTab\""
 667                 + " onclick=\"show(1);\">Interface Summary</button><button role=\"tab\" aria-selected=\"false\""
 668                 + " aria-controls=\"typeSummary_tabpanel\" tabindex=\"-1\" onkeydown=\"switchTab(event)\""
 669                 + " id=\"t2\" class=\"tableTab\" onclick=\"show(2);\">Class Summary</button><button role=\"tab\""
 670                 + " aria-selected=\"false\" aria-controls=\"typeSummary_tabpanel\" tabindex=\"-1\""
 671                 + " onkeydown=\"switchTab(event)\" id=\"t3\" class=\"tableTab\" onclick=\"show(4);\">"
 672                 + "Enum Summary</button><button role=\"tab\" aria-selected=\"false\""
 673                 + " aria-controls=\"typeSummary_tabpanel\" tabindex=\"-1\" onkeydown=\"switchTab(event)\""
 674                 + " id=\"t4\" class=\"tableTab\" onclick=\"show(8);\">Exception Summary</button><button role=\"tab\""
 675                 + " aria-selected=\"false\" aria-controls=\"typeSummary_tabpanel\" tabindex=\"-1\""
 676                 + " onkeydown=\"switchTab(event)\" id=\"t5\" class=\"tableTab\" onclick=\"show(16);\">"
 677                 + "Error Summary</button><button role=\"tab\" aria-selected=\"false\""
 678                 + " aria-controls=\"typeSummary_tabpanel\" tabindex=\"-1\" onkeydown=\"switchTab(event)\""
 679                 + " id=\"t6\" class=\"tableTab\" onclick=\"show(32);\">Annotation Types Summary</button></div>\n"
 680                 + "<div id=\"typeSummary_tabpanel\" role=\"tabpanel\">\n"
 681                 + "<table aria-labelledby=\"t0\">\n"
 682                 + "<thead>\n"
 683                 + "<tr>\n"
 684                 + "<th class=\"colFirst\" scope=\"col\">Class</th>\n"
 685                 + "<th class=\"colLast\" scope=\"col\">Description</th>\n"
 686                 + "</tr>",
 687                 "var data = {\"i0\":32,\"i1\":2,\"i2\":4,\"i3\":2,\"i4\":2,\"i5\":1,\"i6\":2,\"i7\":32,"
 688                 + "\"i8\":2,\"i9\":4,\"i10\":16,\"i11\":16,\"i12\":8,\"i13\":8,\"i14\":1,\"i15\":2};");
 689         checkOutput("allpackages-index.html", true,
 690                 "<div class=\"packagesSummary\">\n<table>\n"
 691                 + "<caption><span>Package Summary</span><span class=\"tabEnd\">&nbsp;</span></caption>\n"
 692                 + "<thead>\n"
 693                 + "<tr>\n"
 694                 + "<th class=\"colFirst\" scope=\"col\">Package</th>\n"
 695                 + "<th class=\"colLast\" scope=\"col\">Description</th>\n"
 696                 + "</tr>\n");
 697         checkOutput("type-search-index.js", true,
 698                 "{\"l\":\"All Classes\",\"url\":\"allclasses-index.html\"}");
 699         checkOutput("package-search-index.js", true,
 700                 "{\"l\":\"All Packages\",\"url\":\"allpackages-index.html\"}");
 701         checkOutput("index-all.html", true,
 702                     "<br><a href=\"allclasses-index.html\">All&nbsp;Classes</a>"
 703                     + "<span class=\"verticalSeparator\">|</span>"
 704                     + "<a href=\"allpackages-index.html\">All&nbsp;Packages</a>");
 705     }
 706 }