1/*
2 * Copyright (c) 2012, 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 7112427 8012295 8025633 8026567 8061305 8081854 8150130 8162363
27 *      8167967 8172528 8175200 8178830
28 * @summary Test of the JavaFX doclet features.
29 * @author jvalenta
30 * @library ../lib
31 * @modules jdk.javadoc/jdk.javadoc.internal.tool
32 * @build JavadocTester
33 * @run main TestJavaFX
34 */
35
36public class TestJavaFX extends JavadocTester {
37
38    public static void main(String... args) throws Exception {
39        TestJavaFX tester = new TestJavaFX();
40        tester.runTests();
41    }
42
43    @Test
44    void test1() {
45        javadoc("-d", "out1",
46                "-sourcepath", testSrc,
47                "-javafx",
48                "-package",
49                "pkg1");
50        checkExit(Exit.OK);
51
52        checkOutput("pkg1/C.html", true,
53                "<dt><span class=\"seeLabel\">See Also:</span></dt>\n"
54                + "<dd><a href=\"../pkg1/C.html#getRate--\"><code>getRate()</code></a>, \n"
55                + "<a href=\"../pkg1/C.html#setRate-double-\">"
56                + "<code>setRate(double)</code></a></dd>",
57                "<pre>public final&nbsp;void&nbsp;setRate&#8203;(double&nbsp;value)</pre>\n"
58                + "<div class=\"block\">Sets the value of the property rate.</div>\n"
59                + "<dl>\n"
60                + "<dt><span class=\"simpleTagLabel\">Property description:</span></dt>",
61                "<pre>public final&nbsp;double&nbsp;getRate&#8203;()</pre>\n"
62                + "<div class=\"block\">Gets the value of the property rate.</div>\n"
63                + "<dl>\n"
64                + "<dt><span class=\"simpleTagLabel\">Property description:</span></dt>",
65                "<td class=\"colFirst\"><code><a href=\"../pkg1/C.DoubleProperty.html\" "
66                + "title=\"class in pkg1\">C.DoubleProperty</a></code></td>\n"
67                + "<th class=\"colSecond\" scope=\"row\"><code><span class=\"memberNameLink\">"
68                + "<a href=\"../pkg1/C.html#rateProperty\">rate</a></span></code></th>\n"
69                + "<td class=\"colLast\">\n"
70                + "<div class=\"block\">Defines the direction/speed at which the "
71                + "<code>Timeline</code> is expected to\n"
72                + " be played.</div>\n</td>",
73                "<span class=\"simpleTagLabel\">Default value:</span>",
74                "<span class=\"simpleTagLabel\">Since:</span></dt>\n"
75                + "<dd>JavaFX 8.0</dd>",
76                "<p>Sets the value of the property <code>Property</code>",
77                "<p>Gets the value of the property <code>Property</code>",
78                "<span class=\"simpleTagLabel\">Property description:</span>",
79                "<th class=\"colSecond\" scope=\"row\"><code><span class=\"memberNameLink\">"
80                + "<a href=\"../pkg1/C.html#setTestMethodProperty--\">"
81                + "setTestMethodProperty</a></span>&#8203;()</code></th>",
82                "<th class=\"colSecond\" scope=\"row\"><code><span class=\"memberNameLink\">"
83                + "<a href=\"../pkg1/C.html#pausedProperty\">paused</a></span></code></th>\n"
84                + "<td class=\"colLast\">\n"
85                + "<div class=\"block\">Defines if paused.</div>",
86                "<h4>paused</h4>\n"
87                + "<pre>public final&nbsp;<a href=\"../pkg1/C.BooleanProperty.html\" "
88                + "title=\"class in pkg1\">C.BooleanProperty</a> pausedProperty</pre>\n"
89                + "<div class=\"block\">Defines if paused. The second line.</div>",
90                "<h4>isPaused</h4>\n"
91                + "<pre>public final&nbsp;double&nbsp;isPaused&#8203;()</pre>\n"
92                + "<div class=\"block\">Gets the value of the property paused.</div>",
93                "<h4>setPaused</h4>\n"
94                + "<pre>public final&nbsp;void&nbsp;setPaused&#8203;(boolean&nbsp;value)</pre>\n"
95                + "<div class=\"block\">Sets the value of the property paused.</div>\n"
96                + "<dl>\n"
97                + "<dt><span class=\"simpleTagLabel\">Property description:</span></dt>\n"
98                + "<dd>Defines if paused. The second line.</dd>\n"
99                + "<dt><span class=\"simpleTagLabel\">Default value:</span></dt>\n"
100                + "<dd>false</dd>",
101                "<h4>isPaused</h4>\n"
102                + "<pre>public final&nbsp;double&nbsp;isPaused&#8203;()</pre>\n"
103                + "<div class=\"block\">Gets the value of the property paused.</div>\n"
104                + "<dl>\n"
105                + "<dt><span class=\"simpleTagLabel\">Property description:</span></dt>\n"
106                + "<dd>Defines if paused. The second line.</dd>\n"
107                + "<dt><span class=\"simpleTagLabel\">Default value:</span></dt>\n"
108                + "<dd>false</dd>",
109                "<h4>rate</h4>\n"
110                + "<pre>public final&nbsp;<a href=\"../pkg1/C.DoubleProperty.html\" "
111                + "title=\"class in pkg1\">C.DoubleProperty</a> rateProperty</pre>\n"
112                + "<div class=\"block\">Defines the direction/speed at which the "
113                + "<code>Timeline</code> is expected to\n"
114                + " be played. This is the second line.</div>",
115                "<h4>setRate</h4>\n"
116                + "<pre>public final&nbsp;void&nbsp;setRate&#8203;(double&nbsp;value)</pre>\n"
117                + "<div class=\"block\">Sets the value of the property rate.</div>\n"
118                + "<dl>\n"
119                + "<dt><span class=\"simpleTagLabel\">Property description:</span></dt>\n"
120                + "<dd>Defines the direction/speed at which the <code>Timeline</code> is expected to\n"
121                + " be played. This is the second line.</dd>\n"
122                + "<dt><span class=\"simpleTagLabel\">Default value:</span></dt>\n"
123                + "<dd>11</dd>\n"
124                + "<dt><span class=\"simpleTagLabel\">Since:</span></dt>\n"
125                + "<dd>JavaFX 8.0</dd>",
126                "<h4>getRate</h4>\n"
127                + "<pre>public final&nbsp;double&nbsp;getRate&#8203;()</pre>\n"
128                + "<div class=\"block\">Gets the value of the property rate.</div>\n"
129                + "<dl>\n"
130                + "<dt><span class=\"simpleTagLabel\">Property description:</span></dt>\n"
131                + "<dd>Defines the direction/speed at which the <code>Timeline</code> is expected to\n"
132                + " be played. This is the second line.</dd>\n"
133                + "<dt><span class=\"simpleTagLabel\">Default value:</span></dt>\n"
134                + "<dd>11</dd>\n"
135                + "<dt><span class=\"simpleTagLabel\">Since:</span></dt>\n"
136                + "<dd>JavaFX 8.0</dd>",
137                "<h3>Property Summary</h3>\n"
138                + "<table class=\"memberSummary\" summary=\"Property Summary table, listing properties, and an explanation\">\n"
139                + "<caption><span>Properties</span><span class=\"tabEnd\">&nbsp;</span></caption>",
140                "");
141
142        checkOutput("pkg1/C.html", false,
143                "A()",
144                "<h3>Property Summary</h3>\n"
145                + "<table class=\"memberSummary\" summary=\"Property Summary table, listing properties, and an explanation\">\n"
146                + "<caption><span id=\"t0\" class=\"activeTableTab\"><span>All Methods</span><span class=\"tabEnd\">&nbsp;</span>"
147                + "</span><span id=\"t2\" class=\"tableTab\"><span><a href=\"javascript:show(2);\">Instance Methods</a>"
148                + "</span><span class=\"tabEnd\">&nbsp;</span></span><span id=\"t4\" class=\"tableTab\"><span>"
149                + "<a href=\"javascript:show(8);\">Concrete Methods</a></span><span class=\"tabEnd\">&nbsp;</span></span>"
150                + "</caption>");
151
152        checkOutput("index-all.html", true,
153                "<div class=\"block\">Gets the value of the property paused.</div>",
154                "<div class=\"block\">Defines if paused.</div>");
155
156        checkOutput("pkg1/D.html", true,
157                "<h3>Properties inherited from class&nbsp;pkg1."
158                    + "<a href=\"../pkg1/C.html\" title=\"class in pkg1\">C</a></h3>\n"
159                    + "<code><a href=\"../pkg1/C.html#pausedProperty\">"
160                    + "paused</a>, <a href=\"../pkg1/C.html#rateProperty\">rate</a></code></li>");
161
162        checkOutput("pkg1/D.html", false, "shouldNotAppear");
163    }
164    /*
165     * Test with -javafx option enabled, to ensure property getters and setters
166     * are treated correctly.
167     */
168    @Test
169    void test2() {
170        javadoc("-d", "out2a",
171                "-sourcepath", testSrc,
172                "-javafx",
173                "-package",
174                "pkg2");
175        checkExit(Exit.OK);
176        checkOutput("pkg2/Test.html", true,
177                "<h3>Property Detail</h3>\n"
178                + "<a name=\"betaProperty\">\n"
179                + "<!--   -->\n"
180                + "</a>\n"
181                + "<ul class=\"blockList\">\n"
182                + "<li class=\"blockList\">\n"
183                + "<h4>beta</h4>\n"
184                + "<pre>public&nbsp;java.lang.Object betaProperty</pre>\n"
185                + "</li>\n"
186                + "</ul>\n"
187                + "<a name=\"gammaProperty\">\n"
188                + "<!--   -->\n"
189                + "</a>\n"
190                + "<ul class=\"blockList\">\n"
191                + "<li class=\"blockList\">\n"
192                + "<h4>gamma</h4>\n"
193                + "<pre>public final&nbsp;java.util.List&lt;java.lang.String&gt; gammaProperty</pre>\n"
194                + "</li>\n"
195                + "</ul>\n"
196                + "<a name=\"deltaProperty\">\n"
197                + "<!--   -->\n"
198                + "</a>\n"
199                + "<ul class=\"blockListLast\">\n"
200                + "<li class=\"blockList\">\n"
201                + "<h4>delta</h4>\n"
202                + "<pre>public final&nbsp;java.util.List&lt;"
203                + "java.util.Set&lt;? super java.lang.Object&gt;&gt; deltaProperty</pre>\n"
204                + "</li>\n"
205                + "</ul>\n"
206                + "</li>\n"
207                + "</ul>",
208                "<h3>Property Summary</h3>\n"
209                + "<table class=\"memberSummary\" summary=\"Property Summary table, listing properties, and an explanation\">\n"
210                + "<caption><span>Properties</span><span class=\"tabEnd\">&nbsp;</span></caption>");
211
212        checkOutput("pkg2/Test.html", false,
213                "<h3>Property Summary</h3>\n"
214                + "<table class=\"memberSummary\" summary=\"Property Summary table, listing properties, and an explanation\">\n"
215                + "<caption><span id=\"t0\" class=\"activeTableTab\"><span>All Methods</span><span class=\"tabEnd\">&nbsp;</span>"
216                + "</span><span id=\"t2\" class=\"tableTab\"><span><a href=\"javascript:show(2);\">Instance Methods</a>"
217                + "</span><span class=\"tabEnd\">&nbsp;</span></span><span id=\"t4\" class=\"tableTab\"><span>"
218                + "<a href=\"javascript:show(8);\">Concrete Methods</a></span><span class=\"tabEnd\">&nbsp;</span></span>"
219                + "</caption>");
220    }
221
222    /*
223     * Test without -javafx option, to ensure property getters and setters
224     * are treated just like any other java method.
225     */
226    @Test
227    void test3() {
228        javadoc("-d", "out2b",
229                "-sourcepath", testSrc,
230                "-package",
231                "pkg2");
232        checkExit(Exit.OK);
233        checkOutput("pkg2/Test.html", false, "<h3>Property Summary</h3>");
234        checkOutput("pkg2/Test.html", true,
235                "<th class=\"colFirst\" scope=\"col\">Modifier and Type</th>\n"
236                + "<th class=\"colSecond\" scope=\"col\">Method</th>\n"
237                + "<th class=\"colLast\" scope=\"col\">Description</th>\n"
238                + "</tr>\n"
239                + "<tr id=\"i0\" class=\"altColor\">\n"
240                + "<td class=\"colFirst\"><code>&lt;T&gt;&nbsp;java.lang.Object</code></td>\n"
241                + "<th class=\"colSecond\" scope=\"row\"><code><span class=\"memberNameLink\">"
242                + "<a href=\"../pkg2/Test.html#alphaProperty-java.util.List-\">alphaProperty</a>"
243                + "</span>&#8203;(java.util.List&lt;T&gt;&nbsp;foo)</code></th>\n"
244                + "<td class=\"colLast\">&nbsp;</td>\n"
245                + "</tr>\n"
246                + "<tr id=\"i1\" class=\"rowColor\">\n"
247                + "<td class=\"colFirst\"><code>java.lang.Object</code></td>\n"
248                + "<th class=\"colSecond\" scope=\"row\"><code><span class=\"memberNameLink\">"
249                + "<a href=\"../pkg2/Test.html#betaProperty--\">betaProperty</a></span>&#8203;()</code></th>\n"
250                + "<td class=\"colLast\">&nbsp;</td>\n"
251                + "</tr>\n"
252                + "<tr id=\"i2\" class=\"altColor\">\n"
253                + "<td class=\"colFirst\"><code>java.util.List&lt;java.util.Set&lt;? super java.lang.Object&gt;&gt;"
254                + "</code></td>\n"
255                + "<th class=\"colSecond\" scope=\"row\"><code><span class=\"memberNameLink\">"
256                + "<a href=\"../pkg2/Test.html#deltaProperty--\">deltaProperty</a></span>&#8203;()</code></th>\n"
257                + "<td class=\"colLast\">&nbsp;</td>\n"
258                + "</tr>\n"
259                + "<tr id=\"i3\" class=\"rowColor\">\n"
260                + "<td class=\"colFirst\"><code>java.util.List&lt;java.lang.String&gt;</code></td>\n"
261                + "<th class=\"colSecond\" scope=\"row\"><code><span class=\"memberNameLink\">"
262                + "<a href=\"../pkg2/Test.html#gammaProperty--\">gammaProperty</a></span>&#8203;()</code></th>\n"
263                + "<td class=\"colLast\">&nbsp;</td>"
264        );
265    }
266
267    /*
268     * Force the doclet to emit a warning when processing a synthesized,
269     * DocComment, and ensure that the run succeeds, using the newer
270     * --javafx flag.
271     */
272    @Test
273    void test4() {
274        javadoc("-d", "out4",
275                "--javafx",
276                "-Xdoclint:none",
277                "-sourcepath", testSrc,
278                "-package",
279                "pkg4");
280        checkExit(Exit.OK);
281
282        // make sure the doclet indeed emits the warning
283        checkOutput(Output.OUT, true, "C.java:0: warning - invalid usage of tag >");
284    }
285}
286