test/jdk/javadoc/doclet/testLiteralCodeInPre/TestLiteralCodeInPre.java

Print this page




   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      8002387 8014636
  27  * @summary  Improve rendered HTML formatting for {@code}
  28  * @library  ../lib
  29  * @modules jdk.javadoc
  30  * @build    JavadocTester
  31  * @run main TestLiteralCodeInPre
  32  */
  33 
  34 public class TestLiteralCodeInPre extends JavadocTester {
  35 
  36     public static void main(String... args) throws Exception {
  37         TestLiteralCodeInPre tester = new TestLiteralCodeInPre();
  38         tester.runTests();
  39     }
  40 
  41     @Test
  42     void test() {
  43         javadoc("-d", "out",
  44                 "-sourcepath", testSrc,
  45                 "-Xdoclint:none",
  46                 "pkg");
  47         checkExit(Exit.OK);
  48 
  49         checkOutput("pkg/Test.html", true,
  50                 "no_pre()</pre>\n"
  51                 + "<div class=\"block\">abc<code>def</code>ghi</div>",
  52                 "no_pre_extra_whitespace()</pre>\n"
  53                 + "<div class=\"block\">abc<code>def  </code>ghi</div>",
  54                 "in_pre()</pre>\n"
  55                 + "<div class=\"block\"><pre> abc<code>  def  </code>ghi</pre></div>",
  56                 "pre_after_text()</pre>\n"
  57                 + "<div class=\"block\">xyz <pre> abc<code>  def  </code>ghi</pre></div>",
  58                 "after_pre()</pre>\n"
  59                 + "<div class=\"block\">xyz <pre> pqr </pre> abc<code>def  </code>ghi</div>",
  60                 "back_in_pre()</pre>\n"
  61                 + "<div class=\"block\">xyz <pre> pqr </pre> mno <pre> abc<code>  def  </code>ghi</pre></div>",
  62                 "typical_usage_code()</pre>\n"
  63                 + "<div class=\"block\">Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n"
  64                 + " Example:  <pre><code>\n"

  65                 + "   line 1 &lt;T&gt; void m(T t) {\n"
  66                 + "   line 2     // do something with T\n"
  67                 + "   line 3 }\n"
  68                 + " </code></pre>\n"
  69                 + " and so it goes.</div>",
  70                 "typical_usage_literal()</pre>\n"
  71                 + "<div class=\"block\">Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n"
  72                 + " Example:  <pre>\n"

  73                 + "   line 1 &lt;T&gt; void m(T t) {\n"
  74                 + "   line 2     // do something with T\n"
  75                 + "   line 3 }\n"
  76                 + " </pre>\n"
  77                 + " and so it goes.</div>",
  78                 "recommended_usage_literal()</pre>\n"
  79                 + "<div class=\"block\">Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n"
  80                 + " Example:  <pre>\n"

  81                 + "   line 1 &lt;T&gt; void m(T t) {\n"
  82                 + "   line 2     // do something with T\n"
  83                 + "   line 3 } </pre>\n"
  84                 + " and so it goes.</div>");










  85     }
  86 }


   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      8002387 8014636 8078320
  27  * @summary  Improve rendered HTML formatting for {@code}
  28  * @library  ../lib
  29  * @modules jdk.javadoc
  30  * @build    JavadocTester
  31  * @run main TestLiteralCodeInPre
  32  */
  33 
  34 public class TestLiteralCodeInPre extends JavadocTester {
  35 
  36     public static void main(String... args) throws Exception {
  37         TestLiteralCodeInPre tester = new TestLiteralCodeInPre();
  38         tester.runTests();
  39     }
  40 
  41     @Test
  42     void test() {
  43         javadoc("-d", "out",
  44                 "-sourcepath", testSrc,
  45                 "-Xdoclint:none",
  46                 "pkg");
  47         checkExit(Exit.OK);
  48 
  49         checkOutput("pkg/Test.html", true,
  50                 "no_pre()</pre>\n"
  51                 + "<div class=\"block\">abc<code>def</code>ghi</div>",
  52                 "no_pre_extra_whitespace()</pre>\n"
  53                 + "<div class=\"block\">abc<code> def  </code>ghi</div>",
  54                 "in_pre()</pre>\n"
  55                 + "<div class=\"block\"><pre> abc<code> def  </code>ghi</pre></div>",
  56                 "pre_after_text()</pre>\n"
  57                 + "<div class=\"block\">xyz <pre> abc<code> def  </code>ghi</pre></div>",
  58                 "after_pre()</pre>\n"
  59                 + "<div class=\"block\">xyz <pre> pqr </pre> abc<code> def  </code>ghi</div>",
  60                 "back_in_pre()</pre>\n"
  61                 + "<div class=\"block\">xyz <pre> pqr </pre> mno <pre> abc<code> def  </code>ghi</pre></div>",
  62                 "typical_usage_code()</pre>\n"
  63                 + "<div class=\"block\">Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n"
  64                 + " Example:  <pre><code>\n"
  65                 + "   line 0 @Override\n"
  66                 + "   line 1 &lt;T&gt; void m(T t) {\n"
  67                 + "   line 2     // do something with T\n"
  68                 + "   line 3 }\n"
  69                 + " </code></pre>\n"
  70                 + " and so it goes.</div>",
  71                 "typical_usage_literal()</pre>\n"
  72                 + "<div class=\"block\">Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n"
  73                 + " Example:  <pre>\n"
  74                 + "   line 0 @Override\n"
  75                 + "   line 1 &lt;T&gt; void m(T t) {\n"
  76                 + "   line 2     // do something with T\n"
  77                 + "   line 3 }\n"
  78                 + " </pre>\n"
  79                 + " and so it goes.</div>",
  80                 "recommended_usage_literal()</pre>\n"
  81                 + "<div class=\"block\">Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n"
  82                 + " Example:  <pre>\n"
  83                 + "   line 0 @Override\n"
  84                 + "   line 1 &lt;T&gt; void m(T t) {\n"
  85                 + "   line 2     // do something with T\n"
  86                 + "   line 3 } </pre>\n"
  87                 + " and so it goes.</div>",
  88                 "<div class=\"block\">Test for html in pre, note the spaces\n"
  89                 + " <PRE>\n"
  90                 + " <b>id           </b>\n"
  91                 + " </PRE></div>",
  92                 "<pre>public&nbsp;void&nbsp;htmlAttrInPre1()</pre>\n"
  93                 + "<div class=\"block\">More html tag outliers.\n"
  94                 + " <pre>\n"
  95                 + " @Override\n"
  96                 + " <code> some.function() </code>\n"
  97                 + " </pre></div>");
  98     }
  99 }