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