diff options
Diffstat (limited to 'src/test/rustdoc-gui/sidebar.goml')
-rw-r--r-- | src/test/rustdoc-gui/sidebar.goml | 73 |
1 files changed, 46 insertions, 27 deletions
diff --git a/src/test/rustdoc-gui/sidebar.goml b/src/test/rustdoc-gui/sidebar.goml index 32fe3334f..5058630f4 100644 --- a/src/test/rustdoc-gui/sidebar.goml +++ b/src/test/rustdoc-gui/sidebar.goml @@ -1,5 +1,6 @@ // Checks multiple things on the sidebar display (width of its elements, colors, etc). -goto: file://|DOC_PATH|/test_docs/index.html +goto: "file://" + |DOC_PATH| + "/test_docs/index.html" +assert-property: (".sidebar", {"clientWidth": "200"}) show-text: true local-storage: {"rustdoc-theme": "light"} // We reload the page so the local storage settings are being used. @@ -8,26 +9,29 @@ reload: assert-text: (".sidebar > .location", "Crate test_docs") // In modules, we only have one "location" element. assert-count: (".sidebar .location", 1) +assert-count: (".sidebar h2", 1) assert-text: ("#all-types", "All Items") assert-css: ("#all-types", {"color": "rgb(53, 109, 164)"}) // We check that we have the crates list and that the "current" on is "test_docs". -assert-text: (".sidebar-elems .crate > ul > li > a.current", "test_docs") +assert-text: (".sidebar-elems ul.crate > li > a.current", "test_docs") // And we're also supposed to have the list of items in the current module. assert-text: (".sidebar-elems section ul > li:nth-child(1)", "Re-exports") assert-text: (".sidebar-elems section ul > li:nth-child(2)", "Modules") assert-text: (".sidebar-elems section ul > li:nth-child(3)", "Macros") assert-text: (".sidebar-elems section ul > li:nth-child(4)", "Structs") assert-text: (".sidebar-elems section ul > li:nth-child(5)", "Enums") -assert-text: (".sidebar-elems section ul > li:nth-child(6)", "Traits") -assert-text: (".sidebar-elems section ul > li:nth-child(7)", "Functions") -assert-text: (".sidebar-elems section ul > li:nth-child(8)", "Type Definitions") -assert-text: (".sidebar-elems section ul > li:nth-child(9)", "Unions") -assert-text: (".sidebar-elems section ul > li:nth-child(10)", "Keywords") +assert-text: (".sidebar-elems section ul > li:nth-child(6)", "Constants") +assert-text: (".sidebar-elems section ul > li:nth-child(7)", "Traits") +assert-text: (".sidebar-elems section ul > li:nth-child(8)", "Functions") +assert-text: (".sidebar-elems section ul > li:nth-child(9)", "Type Definitions") +assert-text: (".sidebar-elems section ul > li:nth-child(10)", "Unions") +assert-text: (".sidebar-elems section ul > li:nth-child(11)", "Keywords") assert-text: ("#structs + .item-table .item-left > a", "Foo") click: "#structs + .item-table .item-left > a" // PAGE: struct.Foo.html -assert-count: (".sidebar .location", 2) +assert-count: (".sidebar .location", 1) +assert-count: (".sidebar h2", 2) // We check that there is no crate listed outside of the top level. assert-false: ".sidebar-elems > .crate" @@ -38,38 +42,43 @@ click: ".sidebar h2.location a" assert-property: ("html", {"scrollTop": "0"}) // We now go back to the crate page to click on the "lib2" crate link. -goto: file://|DOC_PATH|/test_docs/index.html -assert-css: (".sidebar-elems .crate > ul > li:first-child > a", {"color": "rgb(53, 109, 164)"}) -click: ".sidebar-elems .crate > ul > li:first-child > a" +goto: "file://" + |DOC_PATH| + "/test_docs/index.html" +assert-property: (".sidebar", {"clientWidth": "200"}) +assert-css: (".sidebar-elems ul.crate > li:first-child > a", {"color": "rgb(53, 109, 164)"}) +click: ".sidebar-elems ul.crate > li:first-child > a" // PAGE: lib2/index.html -goto: file://|DOC_PATH|/lib2/index.html +goto: "file://" + |DOC_PATH| + "/lib2/index.html" +assert-property: (".sidebar", {"clientWidth": "200"}) assert-text: (".sidebar > .location", "Crate lib2") // We check that we have the crates list and that the "current" on is now "lib2". -assert-text: (".sidebar-elems .crate > ul > li > a.current", "lib2") +assert-text: (".sidebar-elems ul.crate > li > a.current", "lib2") // We now go to the "foobar" function page. -assert-text: (".sidebar-elems > section .block ul > li:nth-child(1)", "Modules") -assert-text: (".sidebar-elems > section .block ul > li:nth-child(2)", "Structs") -assert-text: (".sidebar-elems > section .block ul > li:nth-child(3)", "Traits") -assert-text: (".sidebar-elems > section .block ul > li:nth-child(4)", "Functions") -assert-text: (".sidebar-elems > section .block ul > li:nth-child(5)", "Type Definitions") +assert-text: (".sidebar-elems > section ul.block > li:nth-child(1)", "Modules") +assert-text: (".sidebar-elems > section ul.block > li:nth-child(2)", "Structs") +assert-text: (".sidebar-elems > section ul.block > li:nth-child(3)", "Traits") +assert-text: (".sidebar-elems > section ul.block > li:nth-child(4)", "Functions") +assert-text: (".sidebar-elems > section ul.block > li:nth-child(5)", "Type Definitions") assert-text: ("#functions + .item-table .item-left > a", "foobar") click: "#functions + .item-table .item-left > a" // PAGE: fn.foobar.html -// In items containing no items (like functions or constants) and in modules, we have one -// "location" elements. -assert-count: (".sidebar .location", 1) -assert-text: (".sidebar .sidebar-elems .location", "In lib2") +// In items containing no items (like functions or constants) and in modules, we have no +// "location" elements. Only the parent module h2. +assert-count: (".sidebar .location", 0) +assert-count: (".sidebar h2", 1) +assert-text: (".sidebar .sidebar-elems h2", "In lib2") // We check that we don't have the crate list. assert-false: ".sidebar-elems > .crate" -goto: ./module/index.html +goto: "./module/index.html" +assert-property: (".sidebar", {"clientWidth": "200"}) assert-text: (".sidebar > .location", "Module module") // We check that we don't have the crate list. assert-false: ".sidebar-elems > .crate" -goto: ./sub_module/sub_sub_module/index.html +goto: "./sub_module/sub_sub_module/index.html" +assert-property: (".sidebar", {"clientWidth": "200"}) assert-text: (".sidebar > .location", "Module sub_sub_module") // We check that we don't have the crate list. assert-false: ".sidebar-elems .crate" @@ -77,12 +86,22 @@ assert-text: (".sidebar-elems > section ul > li:nth-child(1)", "Functions") assert-text: ("#functions + .item-table .item-left > a", "foo") // Links to trait implementations in the sidebar should not wrap even if they are long. -goto: file://|DOC_PATH|/lib2/struct.HasALongTraitWithParams.html +goto: "file://" + |DOC_PATH| + "/lib2/struct.HasALongTraitWithParams.html" +assert-property: (".sidebar", {"clientWidth": "200"}) assert-property: (".sidebar-elems section .block li > a", {"offsetHeight": 29}) // Test that clicking on of the "In <module>" headings in the sidebar links to the // appropriate anchor in index.html. -goto: file://|DOC_PATH|/test_docs/struct.Foo.html -click: ".block.mod h3 a" +goto: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html" +assert-property: (".sidebar", {"clientWidth": "200"}) +click: "//ul[@class='block mod']/preceding-sibling::h3/a" // PAGE: index.html assert-css: ("#modules", {"background-color": "rgb(253, 255, 211)"}) + +// Finally, assert that the `[+]/[−]` toggle doesn't affect sidebar width. +click: "#toggle-all-docs" +assert-text: ("#toggle-all-docs", "[+]") +assert-property: (".sidebar", {"clientWidth": "200"}) +click: "#toggle-all-docs" +assert-text: ("#toggle-all-docs", "[−]") +assert-property: (".sidebar", {"clientWidth": "200"})
\ No newline at end of file |