TestJavaFX.java revision 3692:87b48a8fb3cf
1/*
2 * Copyright (c) 2012, 2016, 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 * @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                "");
137
138        checkOutput("pkg1/C.html", false,
139                "A()");
140
141        checkOutput("index-all.html", true,
142                "<div class=\"block\">Gets the value of the property paused.</div>",
143                "<div class=\"block\">Defines if paused.</div>");
144
145        checkOutput("pkg1/D.html", true,
146                "<h3>Properties inherited from class&nbsp;pkg1."
147                    + "<a href=\"../pkg1/C.html\" title=\"class in pkg1\">C</a></h3>\n"
148                    + "<code><a href=\"../pkg1/C.html#pausedProperty\">"
149                    + "paused</a>, <a href=\"../pkg1/C.html#rateProperty\">rate</a></code></li>");
150
151        checkOutput("pkg1/D.html", false, "shouldNotAppear");
152    }
153    /*
154     * Test with -javafx option enabled, to ensure property getters and setters
155     * are treated correctly.
156     */
157    @Test
158    void test2() {
159        javadoc("-d", "out2a",
160                "-sourcepath", testSrc,
161                "-javafx",
162                "-package",
163                "pkg2");
164        checkExit(Exit.OK);
165        checkOutput("pkg2/Test.html", true,
166                "<li class=\"blockList\"><a name=\"property.detail\">\n"
167                + "<!--   -->\n"
168                + "</a>\n"
169                + "<h3>Property Detail</h3>\n"
170                + "<a name=\"betaProperty\">\n"
171                + "<!--   -->\n"
172                + "</a>\n"
173                + "<ul class=\"blockList\">\n"
174                + "<li class=\"blockList\">\n"
175                + "<h4>beta</h4>\n"
176                + "<pre>public&nbsp;java.lang.Object betaProperty</pre>\n"
177                + "</li>\n"
178                + "</ul>\n"
179                + "<a name=\"deltaProperty\">\n"
180                + "<!--   -->\n"
181                + "</a>\n"
182                + "<ul class=\"blockList\">\n"
183                + "<li class=\"blockList\">\n"
184                + "<h4>delta</h4>\n"
185                + "<pre>public final&nbsp;java.util.List&lt;"
186                + "java.util.Set&lt;? super java.lang.Object&gt;&gt; deltaProperty</pre>\n"
187                + "</li>\n"
188                + "</ul>\n"
189                + "<a name=\"gammaProperty\">\n"
190                + "<!--   -->\n"
191                + "</a>\n"
192                + "<ul class=\"blockListLast\">\n"
193                + "<li class=\"blockList\">\n"
194                + "<h4>gamma</h4>\n"
195                + "<pre>public final&nbsp;java.util.List&lt;"
196                + "java.lang.String&gt; gammaProperty</pre>\n"
197                + "</li>\n"
198                + "</ul>\n"
199                + "</li>");
200    }
201
202    /*
203     * Test without -javafx option, to ensure property getters and setters
204     * are treated just like any other java method.
205     */
206    @Test
207    void test3() {
208        javadoc("-d", "out2b",
209                "-sourcepath", testSrc,
210                "-package",
211                "pkg2");
212        checkExit(Exit.OK);
213        checkOutput("pkg2/Test.html", false, "<h3>Property Summary</h3>");
214        checkOutput("pkg2/Test.html", true,
215                "<th class=\"colFirst\" scope=\"col\">Modifier and Type</th>\n"
216                + "<th class=\"colSecond\" scope=\"col\">Method</th>\n"
217                + "<th class=\"colLast\" scope=\"col\">Description</th>\n"
218                + "</tr>\n"
219                + "<tr id=\"i0\" class=\"altColor\">\n"
220                + "<td class=\"colFirst\"><code>&lt;T&gt;&nbsp;java.lang.Object</code></td>\n"
221                + "<th class=\"colSecond\" scope=\"row\"><code><span class=\"memberNameLink\">"
222                + "<a href=\"../pkg2/Test.html#alphaProperty-java.util.List-\">alphaProperty</a>"
223                + "</span>(java.util.List&lt;T&gt;&nbsp;foo)</code></th>\n"
224                + "<td class=\"colLast\">&nbsp;</td>\n"
225                + "</tr>\n"
226                + "<tr id=\"i1\" class=\"rowColor\">\n"
227                + "<td class=\"colFirst\"><code>java.lang.Object</code></td>\n"
228                + "<th class=\"colSecond\" scope=\"row\"><code><span class=\"memberNameLink\">"
229                + "<a href=\"../pkg2/Test.html#betaProperty--\">betaProperty</a></span>()</code></th>\n"
230                + "<td class=\"colLast\">&nbsp;</td>\n"
231                + "</tr>\n"
232                + "<tr id=\"i2\" class=\"altColor\">\n"
233                + "<td class=\"colFirst\"><code>java.util.List&lt;java.util.Set&lt;? super java.lang.Object&gt;&gt;"
234                + "</code></td>\n"
235                + "<th class=\"colSecond\" scope=\"row\"><code><span class=\"memberNameLink\">"
236                + "<a href=\"../pkg2/Test.html#deltaProperty--\">deltaProperty</a></span>()</code></th>\n"
237                + "<td class=\"colLast\">&nbsp;</td>\n"
238                + "</tr>\n"
239                + "<tr id=\"i3\" class=\"rowColor\">\n"
240                + "<td class=\"colFirst\"><code>java.util.List&lt;java.lang.String&gt;</code></td>\n"
241                + "<th class=\"colSecond\" scope=\"row\"><code><span class=\"memberNameLink\">"
242                + "<a href=\"../pkg2/Test.html#gammaProperty--\">gammaProperty</a></span>()</code></th>\n"
243                + "<td class=\"colLast\">&nbsp;</td>"
244        );
245    }
246
247    /*
248     * Force the doclet to emit a warning when processing a synthesized,
249     * DocComment, and ensure that the run succeeds.
250     */
251    @Test
252    void test4() {
253        javadoc("-d", "out4",
254                "-javafx",
255                "-Xdoclint:none",
256                "-sourcepath", testSrc,
257                "-package",
258                "pkg4");
259        checkExit(Exit.OK);
260
261        // make sure the doclet indeed emits the warning
262        checkOutput(Output.OUT, true, "C.java:0: warning - invalid usage of tag >");
263    }
264}
265