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