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