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