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

  95                 + "<div class=\"block\">More html tag outliers.\n"
  96                 + " <pre>\n"
  97                 + " @Override\n"
  98                 + " <code> some.function() </code>\n"
  99                 + " </pre></div>");
 100     }
 101 }
--- EOF ---