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