TestNavigation.java revision 3294:9adfb22ff08f
196267Sobrien/*
296267Sobrien * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
396267Sobrien * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
496267Sobrien *
596267Sobrien * This code is free software; you can redistribute it and/or modify it
696267Sobrien * under the terms of the GNU General Public License version 2 only, as
796267Sobrien * published by the Free Software Foundation.
896267Sobrien *
996267Sobrien * This code is distributed in the hope that it will be useful, but WITHOUT
1096267Sobrien * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1196267Sobrien * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
1296267Sobrien * version 2 for more details (a copy is included in the LICENSE file that
1396267Sobrien * accompanied this code).
1496267Sobrien *
1596267Sobrien * You should have received a copy of the GNU General Public License version
1696267Sobrien * 2 along with this work; if not, write to the Free Software Foundation,
1796267Sobrien * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1896267Sobrien *
1996267Sobrien * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2096267Sobrien * or visit www.oracle.com if you need additional information or have any
2196267Sobrien * questions.
2296267Sobrien */
2396267Sobrien
2496267Sobrien/*
2596267Sobrien * @test
2696267Sobrien * @bug      4131628 4664607 7025314 8023700 7198273 8025633 8026567 8081854 8150188
2796267Sobrien * @summary  Make sure the Next/Prev Class links iterate through all types.
2896267Sobrien *           Make sure the navagation is 2 columns, not 3.
2996267Sobrien * @author   jamieh
3096267Sobrien * @library  ../lib
3196267Sobrien * @modules jdk.javadoc
3296267Sobrien * @build    JavadocTester
3396267Sobrien * @run main TestNavigation
3496267Sobrien */
3596267Sobrien
3696267Sobrienpublic class TestNavigation extends JavadocTester {
3796267Sobrien
3896267Sobrien    public static void main(String... args) throws Exception {
3996267Sobrien        TestNavigation tester = new TestNavigation();
4096267Sobrien        tester.runTests();
4196267Sobrien    }
4296267Sobrien
4396267Sobrien    @Test
4496267Sobrien    void test() {
4596267Sobrien        javadoc("-d", "out",
4696267Sobrien                "-sourcepath", testSrc,
4796267Sobrien                "pkg");
4896267Sobrien        checkExit(Exit.OK);
4996267Sobrien
5096267Sobrien        checkOutput("pkg/A.html", true,
5196267Sobrien                "<li>Prev&nbsp;Class</li>",
5296267Sobrien                "<a href=\"../pkg/C.html\" title=\"class in pkg\"><span class=\"typeNameLink\">Next&nbsp;Class</span></a>");
5396267Sobrien
5496267Sobrien        checkOutput("pkg/C.html", true,
5596267Sobrien                "<a href=\"../pkg/A.html\" title=\"annotation in pkg\"><span class=\"typeNameLink\">Prev&nbsp;Class</span></a>",
5696267Sobrien                "<a href=\"../pkg/E.html\" title=\"enum in pkg\"><span class=\"typeNameLink\">Next&nbsp;Class</span></a>");
5796267Sobrien
5896267Sobrien        checkOutput("pkg/E.html", true,
5996267Sobrien                "<a href=\"../pkg/C.html\" title=\"class in pkg\"><span class=\"typeNameLink\">Prev&nbsp;Class</span></a>",
6096267Sobrien                "<a href=\"../pkg/I.html\" title=\"interface in pkg\"><span class=\"typeNameLink\">Next&nbsp;Class</span></a>");
6196267Sobrien
6296267Sobrien        checkOutput("pkg/I.html", true,
6396267Sobrien                "<a href=\"../pkg/E.html\" title=\"enum in pkg\"><span class=\"typeNameLink\">Prev&nbsp;Class</span></a>",
6496267Sobrien                "<li>Next&nbsp;Class</li>",
6596267Sobrien                // Test for 4664607
6696267Sobrien                "<div class=\"skipNav\"><a href=\"#skip.navbar.top\" title=\"Skip navigation links\">Skip navigation links</a></div>\n"
6796267Sobrien                + "<a name=\"navbar.top.firstrow\">\n"
6896267Sobrien                + "<!--   -->\n"
6996267Sobrien                + "</a>");
7096267Sobrien
7196267Sobrien        // Remaining tests check for additional padding to offset the fixed navigation bar.
7296267Sobrien        checkOutput("pkg/A.html", true,
7396267Sobrien                "<!-- ========= END OF TOP NAVBAR ========= -->\n"
7496267Sobrien                + "</div>\n"
7596267Sobrien                + "<div class=\"navPadding\">&nbsp;</div>\n"
7696267Sobrien                + "<!-- ======== START OF CLASS DATA ======== -->");
7796267Sobrien
7896267Sobrien        checkOutput("pkg/package-summary.html", true,
7996267Sobrien                "<!-- ========= END OF TOP NAVBAR ========= -->\n"
8096267Sobrien                + "</div>\n"
8196267Sobrien                + "<div class=\"navPadding\">&nbsp;</div>\n"
8296267Sobrien                + "<div class=\"header\">");
8396267Sobrien    }
8496267Sobrien
8596267Sobrien    // Test for checking additional padding to offset the fixed navigation bar in HTML5.
8696267Sobrien    @Test
8796267Sobrien    void test1() {
8896267Sobrien        javadoc("-d", "out-1", "-html5",
8996267Sobrien                "-sourcepath", testSrc,
9096267Sobrien                "pkg");
9196267Sobrien        checkExit(Exit.OK);
9296267Sobrien
9396267Sobrien        checkOutput("pkg/A.html", true,
9496267Sobrien                "<!-- ========= END OF TOP NAVBAR ========= -->\n"
9596267Sobrien                + "</div>\n"
9696267Sobrien                + "<div class=\"navPadding\">&nbsp;</div>\n"
9796267Sobrien                + "</nav>\n"
9896267Sobrien                + "</header>\n"
9996267Sobrien                + "<!-- ======== START OF CLASS DATA ======== -->");
10096267Sobrien
10196267Sobrien        checkOutput("pkg/package-summary.html", true,
102106105Sphk                "<!-- ========= END OF TOP NAVBAR ========= -->\n"
103106105Sphk                + "</div>\n"
104                + "<div class=\"navPadding\">&nbsp;</div>\n"
105                + "</nav>");
106    }
107
108    // Test to make sure that no extra padding for nav bar gets generated if -nonavbar is specified for HTML4.
109    @Test
110    void test2() {
111        javadoc("-d", "out-2", "-nonavbar",
112                "-sourcepath", testSrc,
113                "pkg");
114        checkExit(Exit.OK);
115
116        checkOutput("pkg/A.html", false,
117                "<!-- ========= END OF TOP NAVBAR ========= -->\n"
118                + "</div>\n"
119                + "<div class=\"navPadding\">&nbsp;</div>\n"
120                + "<!-- ======== START OF CLASS DATA ======== -->");
121
122        checkOutput("pkg/package-summary.html", false,
123                "<!-- ========= END OF TOP NAVBAR ========= -->\n"
124                + "</div>\n"
125                + "<div class=\"navPadding\">&nbsp;</div>\n"
126                + "<div class=\"header\">");
127    }
128
129    // Test to make sure that no extra padding for nav bar gets generated if -nonavbar is specified for HTML5.
130    @Test
131    void test3() {
132        javadoc("-d", "out-3", "-html5", "-nonavbar",
133                "-sourcepath", testSrc,
134                "pkg");
135        checkExit(Exit.OK);
136
137        checkOutput("pkg/A.html", false,
138                "<!-- ========= END OF TOP NAVBAR ========= -->\n"
139                + "</div>\n"
140                + "<div class=\"navPadding\">&nbsp;</div>\n"
141                + "</nav>\n"
142                + "</header>\n"
143                + "<!-- ======== START OF CLASS DATA ======== -->");
144
145        checkOutput("pkg/package-summary.html", false,
146                "<!-- ========= END OF TOP NAVBAR ========= -->\n"
147                + "</div>\n"
148                + "<div class=\"navPadding\">&nbsp;</div>\n"
149                + "</nav>");
150    }
151}
152