TestLiteralCodeInPre.java revision 3233:b5d08bc0d224
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 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
34public 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}
100