1 /*
   2  * Copyright (c) 2005, 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      4494033 7028815 7052425 8007338 8023608 8008164 8016549 8072461 8154261 8162363 8160196 8151743 8177417
  27  *           8175218 8176452 8181215 8182263 8183511 8169819 8183037 8185369 8182765 8196201 8184205
  28  * @summary  Run tests on doclet stylesheet.
  29  * @author   jamieh
  30  * @library  ../../lib
  31  * @modules jdk.javadoc/jdk.javadoc.internal.tool
  32  * @build    javadoc.tester.*
  33  * @run main TestStylesheet
  34  */
  35 
  36 import javadoc.tester.JavadocTester;
  37 
  38 public class TestStylesheet extends JavadocTester {
  39 
  40     public static void main(String... args) throws Exception {
  41         TestStylesheet tester = new TestStylesheet();
  42         tester.runTests();
  43     }
  44 
  45     @Test
  46     public void test() {
  47         javadoc("-d", "out",
  48                 "-sourcepath", testSrc,
  49                 "pkg");
  50         checkExit(Exit.ERROR);
  51 
  52         checkOutput(Output.OUT, true,
  53                 "attribute not supported in HTML5: name");
  54 
  55         // TODO: most of this test seems a bit silly, since javadoc is simply
  56         // copying in the stylesheet from the source directory
  57         checkOutput("stylesheet.css", true,
  58                 "body {\n"
  59                 + "    background-color:#ffffff;\n"
  60                 + "    color:#353833;\n"
  61                 + "    font-family:'DejaVu Sans', Arial, Helvetica, sans-serif;\n"
  62                 + "    font-size:14px;\n"
  63                 + "    margin:0;\n"
  64                 + "    padding:0;\n"
  65                 + "    height:100%;\n"
  66                 + "    width:100%;\n"
  67                 + "}",
  68                 "iframe {\n"
  69                 + "    margin:0;\n"
  70                 + "    padding:0;\n"
  71                 + "    height:100%;\n"
  72                 + "    width:100%;\n"
  73                 + "    overflow-y:scroll;\n"
  74                 + "    border:none;\n"
  75                 + "}",
  76                 "ul {\n"
  77                 + "    list-style-type:disc;\n"
  78                 + "}",
  79                 ".overviewSummary caption, .memberSummary caption, .typeSummary caption,\n"
  80                 + ".useSummary caption, .constantsSummary caption, .deprecatedSummary caption,\n"
  81                 + ".requiresSummary caption, .packagesSummary caption, .providesSummary caption, .usesSummary caption {\n"
  82                 + "    position:relative;\n"
  83                 + "    text-align:left;\n"
  84                 + "    background-repeat:no-repeat;\n"
  85                 + "    color:#253441;\n"
  86                 + "    font-weight:bold;\n"
  87                 + "    clear:none;\n"
  88                 + "    overflow:hidden;\n"
  89                 + "    padding:0px;\n"
  90                 + "    padding-top:10px;\n"
  91                 + "    padding-left:1px;\n"
  92                 + "    margin:0px;\n"
  93                 + "    white-space:pre;\n"
  94                 + "}",
  95                 ".overviewSummary caption span, .memberSummary caption span, .typeSummary caption span,\n"
  96                 + ".useSummary caption span, .constantsSummary caption span, .deprecatedSummary caption span,\n"
  97                 + ".requiresSummary caption span, .packagesSummary caption span, .providesSummary caption span,\n"
  98                 + ".usesSummary caption span {\n"
  99                 + "    white-space:nowrap;\n"
 100                 + "    padding-top:5px;\n"
 101                 + "    padding-left:12px;\n"
 102                 + "    padding-right:12px;\n"
 103                 + "    padding-bottom:7px;\n"
 104                 + "    display:inline-block;\n"
 105                 + "    float:left;\n"
 106                 + "    background-color:#F8981D;\n"
 107                 + "    border: none;\n"
 108                 + "    height:16px;\n"
 109                 + "}",
 110                 ".overviewSummary [role=tablist] button, .memberSummary [role=tablist] button,\n"
 111                 + ".typeSummary [role=tablist] button, .packagesSummary [role=tablist] button {\n"
 112                 + "   border: none;\n"
 113                 + "   cursor: pointer;\n"
 114                 + "   padding: 5px 12px 7px 12px;\n"
 115                 + "   font-weight: bold;\n"
 116                 + "   margin-right: 3px;\n"
 117                 + "}",
 118                 ".overviewSummary [role=tablist] .activeTableTab, .memberSummary [role=tablist] .activeTableTab,\n"
 119                 + ".typeSummary [role=tablist] .activeTableTab, .packagesSummary [role=tablist] .activeTableTab {\n"
 120                 + "   background: #F8981D;\n"
 121                 + "   color: #253441;\n"
 122                 + "}",
 123                 ".overviewSummary [role=tablist] .tableTab, .memberSummary [role=tablist] .tableTab,\n"
 124                 + ".typeSummary [role=tablist] .tableTab, .packagesSummary [role=tablist] .tableTab {\n"
 125                 + "   background: #4D7A97;\n"
 126                 + "   color: #FFFFFF;\n"
 127                 + "}",
 128                 // Test the formatting styles for proper content display in use and constant values pages.
 129                 ".overviewSummary td.colFirst, .overviewSummary th.colFirst,\n"
 130                 + ".requiresSummary td.colFirst, .requiresSummary th.colFirst,\n"
 131                 + ".packagesSummary td.colFirst, .packagesSummary td.colSecond, .packagesSummary th.colFirst, .packagesSummary th,\n"
 132                 + ".usesSummary td.colFirst, .usesSummary th.colFirst,\n"
 133                 + ".providesSummary td.colFirst, .providesSummary th.colFirst,\n"
 134                 + ".memberSummary td.colFirst, .memberSummary th.colFirst,\n"
 135                 + ".memberSummary td.colSecond, .memberSummary th.colSecond, .memberSummary th.colConstructorName,\n"
 136                 + ".typeSummary td.colFirst, .typeSummary th.colFirst {\n"
 137                 + "    vertical-align:top;\n"
 138                 + "}",
 139                 ".overviewSummary td, .memberSummary td, .typeSummary td,\n"
 140                 + ".useSummary td, .constantsSummary td, .deprecatedSummary td,\n"
 141                 + ".requiresSummary td, .packagesSummary td, .providesSummary td, .usesSummary td {\n"
 142                 + "    text-align:left;\n"
 143                 + "    padding:0px 0px 12px 10px;\n"
 144                 + "}",
 145                 "@import url('resources/fonts/dejavu.css');",
 146                 ".navPadding {\n"
 147                 + "    padding-top: 107px;\n"
 148                 + "}",
 149                 "a[name]:before, a[name]:target, a[id]:before, a[id]:target {\n"
 150                 + "    content:\"\";\n"
 151                 + "    display:inline-block;\n"
 152                 + "    position:relative;\n"
 153                 + "    padding-top:129px;\n"
 154                 + "    margin-top:-129px;\n"
 155                 + "}",
 156                 ".searchTagResult:before, .searchTagResult:target {\n"
 157                 + "    color:red;\n"
 158                 + "}",
 159                 "a[href]:hover, a[href]:focus {\n"
 160                 + "    text-decoration:none;\n"
 161                 + "    color:#bb7a2a;\n"
 162                 + "}",
 163                 "td.colFirst a:link, td.colFirst a:visited,\n"
 164                 + "td.colSecond a:link, td.colSecond a:visited,\n"
 165                 + "th.colFirst a:link, th.colFirst a:visited,\n"
 166                 + "th.colSecond a:link, th.colSecond a:visited,\n"
 167                 + "th.colConstructorName a:link, th.colConstructorName a:visited,\n"
 168                 + "th.colDeprecatedItemName a:link, th.colDeprecatedItemName a:visited, \n"
 169                 + ".constantValuesContainer td a:link, .constantValuesContainer td a:visited, \n"
 170                 + ".allClassesContainer td a:link, .allClassesContainer td a:visited, \n"
 171                 + ".allPackagesContainer td a:link, .allPackagesContainer td a:visited {\n"
 172                 + "    font-weight:bold;\n"
 173                 + "}",
 174                 ".deprecationBlock {\n"
 175                 + "    font-size:14px;\n"
 176                 + "    font-family:'DejaVu Serif', Georgia, \"Times New Roman\", Times, serif;\n"
 177                 + "    border-style:solid;\n"
 178                 + "    border-width:thin;\n"
 179                 + "    border-radius:10px;\n"
 180                 + "    padding:10px;\n"
 181                 + "    margin-bottom:10px;\n"
 182                 + "    margin-right:10px;\n"
 183                 + "    display:inline-block;\n"
 184                 + "}",
 185                 "#reset {\n"
 186                 + "    background-color: rgb(255,255,255);\n"
 187                 + "    background-image:url('resources/x.png');\n"
 188                 + "    background-position:center;\n"
 189                 + "    background-repeat:no-repeat;\n"
 190                 + "    background-size:12px;\n"
 191                 + "    border:0 none;\n"
 192                 + "    width:16px;\n"
 193                 + "    height:17px;\n"
 194                 + "    position:relative;\n"
 195                 + "    left:-4px;\n"
 196                 + "    top:-4px;\n"
 197                 + "    font-size:0px;\n"
 198                 + "}",
 199                 ".watermark {\n"
 200                 + "    color:#545454;\n"
 201                 + "}");
 202 
 203         checkOutput("pkg/A.html", true,
 204                 // Test whether a link to the stylesheet file is inserted properly
 205                 // in the class documentation.
 206                 "<link rel=\"stylesheet\" type=\"text/css\" "
 207                 + "href=\"../stylesheet.css\" title=\"Style\">",
 208                 "<div class=\"block\">Test comment for a class which has an <a name=\"named_anchor\">"
 209                 + "anchor_with_name</a> and\n"
 210                 + " an <a id=\"named_anchor1\">anchor_with_id</a>.</div>");
 211 
 212         checkOutput("pkg/package-summary.html", true,
 213                 "<td class=\"colLast\">\n"
 214                 + "<div class=\"block\">Test comment for a class which has an <a name=\"named_anchor\">"
 215                 + "anchor_with_name</a> and\n"
 216                 + " an <a id=\"named_anchor1\">anchor_with_id</a>.</div>\n"
 217                 + "</td>");
 218 
 219         checkOutput("index.html", true,
 220                 "<link rel=\"stylesheet\" type=\"text/css\" href=\"stylesheet.css\" title=\"Style\">");
 221 
 222         checkOutput("stylesheet.css", false,
 223                 "* {\n"
 224                 + "    margin:0;\n"
 225                 + "    padding:0;\n"
 226                 + "}",
 227                 "a:active {\n"
 228                 + "    text-decoration:none;\n"
 229                 + "    color:#4A6782;\n"
 230                 + "}",
 231                 "a[name]:hover {\n"
 232                 + "    text-decoration:none;\n"
 233                 + "    color:#353833;\n"
 234                 + "}",
 235                 "td.colFirst a:link, td.colFirst a:visited,\n"
 236                 + "td.colSecond a:link, td.colSecond a:visited,\n"
 237                 + "th.colFirst a:link, th.colFirst a:visited,\n"
 238                 + "th.colSecond a:link, th.colSecond a:visited,\n"
 239                 + "th.colConstructorName a:link, th.colConstructorName a:visited,\n"
 240                 + "td.colLast a:link, td.colLast a:visited,\n"
 241                 + ".constantValuesContainer td a:link, .constantValuesContainer td a:visited {\n"
 242                 + "    font-weight:bold;\n"
 243                 + "}");
 244     }
 245 }