1 /*
   2  * Copyright (c) 2002, 2015, 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      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 }