diff options
Diffstat (limited to 'tests/rustdoc-gui')
| -rw-r--r-- | tests/rustdoc-gui/hide-mobile-topbar.goml | 20 | ||||
| -rw-r--r-- | tests/rustdoc-gui/links-color.goml | 4 | ||||
| -rw-r--r-- | tests/rustdoc-gui/sidebar-links-color.goml | 4 | ||||
| -rw-r--r-- | tests/rustdoc-gui/sidebar-resize-setting.goml | 23 | ||||
| -rw-r--r-- | tests/rustdoc-gui/sidebar-resize-window.goml | 37 | ||||
| -rw-r--r-- | tests/rustdoc-gui/sidebar-resize.goml | 28 | ||||
| -rw-r--r-- | tests/rustdoc-gui/sidebar-source-code.goml | 3 | ||||
| -rw-r--r-- | tests/rustdoc-gui/sidebar.goml | 4 | ||||
| -rw-r--r-- | tests/rustdoc-gui/src/theme_css/custom-theme.css | 2 |
9 files changed, 118 insertions, 7 deletions
diff --git a/tests/rustdoc-gui/hide-mobile-topbar.goml b/tests/rustdoc-gui/hide-mobile-topbar.goml new file mode 100644 index 00000000000..46eb8acfe8c --- /dev/null +++ b/tests/rustdoc-gui/hide-mobile-topbar.goml @@ -0,0 +1,20 @@ +// Checks sidebar resizing stays synced with the setting +go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" +set-window-size: (400, 600) + +// Verify that the "hide" option is unchecked +click: "#settings-menu" +wait-for: "#settings" +assert-css: ("#settings", {"display": "block"}) +assert-property: ("#hide-sidebar", {"checked": "false"}) +assert-css: (".mobile-topbar", {"display": "flex"}) + +// Toggle it +click: "#hide-sidebar" +assert-property: ("#hide-sidebar", {"checked": "true"}) +assert-css: (".mobile-topbar", {"display": "none"}) + +// Toggle it again +click: "#hide-sidebar" +assert-property: ("#hide-sidebar", {"checked": "false"}) +assert-css: (".mobile-topbar", {"display": "flex"}) diff --git a/tests/rustdoc-gui/links-color.goml b/tests/rustdoc-gui/links-color.goml index 0789d785f58..d88ebfb40d7 100644 --- a/tests/rustdoc-gui/links-color.goml +++ b/tests/rustdoc-gui/links-color.goml @@ -26,12 +26,12 @@ define-function: ( assert-css: (".item-table .keyword", {"color": |keyword|}, ALL) // Checking sidebar elements. assert-css: ( - ".sidebar-elems a:not(.current)", + ".sidebar-elems li:not(.current) a", {"color": |sidebar|, "background-color": "rgba(0, 0, 0, 0)", "font-weight": "400"}, ALL, ) assert-css: ( - ".sidebar-elems a.current", + ".sidebar-elems li.current a", { "color": |sidebar_current|, "background-color": |sidebar_current_background|, diff --git a/tests/rustdoc-gui/sidebar-links-color.goml b/tests/rustdoc-gui/sidebar-links-color.goml index 079d582a567..774fbcac1e2 100644 --- a/tests/rustdoc-gui/sidebar-links-color.goml +++ b/tests/rustdoc-gui/sidebar-links-color.goml @@ -17,10 +17,10 @@ define-function: ( reload: // Struct assert-css: ( - ".sidebar .block.struct a:not(.current)", + ".sidebar .block.struct li:not(.current) a", {"color": |struct|, "background-color": "rgba(0, 0, 0, 0)"}, ) - move-cursor-to: ".sidebar .block.struct a:not(.current)" + move-cursor-to: ".sidebar .block.struct li:not(.current) a" assert-css: ( ".sidebar .block.struct a:hover", {"color": |struct_hover|, "background-color": |struct_hover_background|}, diff --git a/tests/rustdoc-gui/sidebar-resize-setting.goml b/tests/rustdoc-gui/sidebar-resize-setting.goml new file mode 100644 index 00000000000..2fdb2faa864 --- /dev/null +++ b/tests/rustdoc-gui/sidebar-resize-setting.goml @@ -0,0 +1,23 @@ +// Checks sidebar resizing stays synced with the setting +go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" +assert-property: (".sidebar", {"clientWidth": "200"}) +show-text: true + +// Verify that the "hide" option is unchecked +click: "#settings-menu" +wait-for: "#settings" +assert-css: ("#settings", {"display": "block"}) +assert-property: ("#hide-sidebar", {"checked": "false"}) +press-key: "Escape" +wait-for-css: ("#settings", {"display": "none"}) + +drag-and-drop: ((205, 100), (5, 100)) +assert-css: (".sidebar", {"display": "none"}) + +// Verify that the "hide" option is checked +focus: "#settings-menu a" +press-key: "Enter" +wait-for-css: ("#settings", {"display": "block"}) +assert-property: ("#hide-sidebar", {"checked": "true"}) +click: "#hide-sidebar" +wait-for-css: (".sidebar", {"display": "block"}) diff --git a/tests/rustdoc-gui/sidebar-resize-window.goml b/tests/rustdoc-gui/sidebar-resize-window.goml new file mode 100644 index 00000000000..fb6baafda71 --- /dev/null +++ b/tests/rustdoc-gui/sidebar-resize-window.goml @@ -0,0 +1,37 @@ +// Checks sidebar resizing +go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" +set-window-size: (1280, 600) +wait-for-property: (".sidebar", {"clientWidth": 200}, [NEAR]) + +// resize past maximum (don't grow past 500) +drag-and-drop: ((205, 100), (600, 100)) +wait-for-property: (".sidebar", {"clientWidth": 500}, [NEAR]) + +// make the window small enough that the sidebar has to shrink +set-window-size: (750, 600) +wait-for-property: (".sidebar", {"clientWidth": 350}, [NEAR]) + +// grow the window again to make the sidebar bigger +set-window-size: (1280, 600) +wait-for-property: (".sidebar", {"clientWidth": 500}, [NEAR]) + +// make the window small enough that the sidebar has to shrink +set-window-size: (750, 600) +wait-for-property: (".sidebar", {"clientWidth": 350}, [NEAR]) +assert-local-storage: {"rustdoc-desktop-sidebar-width": "350"} +set-window-size: (400, 600) +wait-for-css: (".sidebar", {"display": "block", "left": "-1000px"}) +assert-local-storage: {"rustdoc-desktop-sidebar-width": "350"} + +// grow the window again to make the sidebar bigger +set-window-size: (1280, 600) +wait-for-property: (".sidebar", {"clientWidth": 500}, [NEAR]) + +// shrink back down again, then reload the page +// the "desired size" is a bit of remembered implicit state, +// and rustdoc tries to minimize things like this +set-window-size: (800, 600) +wait-for-property: (".sidebar", {"clientWidth": 400}, [NEAR]) +reload: +set-window-size: (1280, 600) +wait-for-property: (".sidebar", {"clientWidth": 400}, [NEAR]) diff --git a/tests/rustdoc-gui/sidebar-resize.goml b/tests/rustdoc-gui/sidebar-resize.goml new file mode 100644 index 00000000000..543d5d390c7 --- /dev/null +++ b/tests/rustdoc-gui/sidebar-resize.goml @@ -0,0 +1,28 @@ +// Checks sidebar resizing +go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" +assert-property: (".sidebar", {"clientWidth": "200"}) +show-text: true +// normal resizing +drag-and-drop: ((205, 100), (185, 100)) +assert-property: (".sidebar", {"clientWidth": "182"}) +// resize past maximum (don't grow past 500) +drag-and-drop: ((185, 100), (600, 100)) +assert-property: (".sidebar", {"clientWidth": "500"}) +// resize past minimum (hide sidebar) +drag-and-drop: ((501, 100), (5, 100)) +assert-property: (".sidebar", {"clientWidth": "0"}) +assert-css: (".sidebar", {"display": "none"}) +assert-local-storage: {"rustdoc-hide-sidebar": "true"} +set-local-storage: {"rustdoc-hide-sidebar": "false"} + +// Now same thing, but for source code +go-to: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html" +assert-property: (".sidebar", {"clientWidth": "49"}) +drag-and-drop: ((52, 100), (185, 100)) +assert-property: (".sidebar", {"clientWidth": "181"}) +drag-and-drop: ((185, 100), (600, 100)) +assert-property: (".sidebar", {"clientWidth": "499"}) +drag-and-drop: ((500, 100), (5, 100)) +// instead of hiding the sidebar entirely, this +// will switch to the toggle mode +assert-property: (".sidebar", {"clientWidth": "49"}) diff --git a/tests/rustdoc-gui/sidebar-source-code.goml b/tests/rustdoc-gui/sidebar-source-code.goml index 0d72e670cf4..9fc1409e86f 100644 --- a/tests/rustdoc-gui/sidebar-source-code.goml +++ b/tests/rustdoc-gui/sidebar-source-code.goml @@ -48,6 +48,7 @@ call-function: ( // Next, desktop mode layout. set-window-size: (1100, 800) +wait-for: "#src-sidebar-toggle" // We check that the sidebar isn't expanded and has the expected width. assert-css: ("nav.sidebar", {"width": "50px"}) // We now click on the button to expand the sidebar. @@ -58,7 +59,7 @@ assert-css: (".src-sidebar-expanded nav.sidebar a", {"font-size": "14px"}) // We collapse the sidebar. click: (10, 10) // We ensure that the class has been removed. -wait-for: "html:not(.expanded)" +wait-for: "html:not(.src-sidebar-expanded)" assert: "nav.sidebar" // Checking that only the path to the current file is "open". diff --git a/tests/rustdoc-gui/sidebar.goml b/tests/rustdoc-gui/sidebar.goml index eff66d803d2..82b4f2e9429 100644 --- a/tests/rustdoc-gui/sidebar.goml +++ b/tests/rustdoc-gui/sidebar.goml @@ -57,7 +57,7 @@ assert-count: (".sidebar h2", 1) assert-text: ("#all-types", "All Items") assert-css: ("#all-types", {"color": "#356da4"}) // We check that we have the crates list and that the "current" on is "test_docs". -assert-text: (".sidebar-elems ul.crate > li > a.current", "test_docs") +assert-text: (".sidebar-elems ul.crate > li.current > a", "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") @@ -98,7 +98,7 @@ assert-property: (".sidebar", {"clientWidth": "200"}) assert-text: (".sidebar > .sidebar-crate > h2 > a", "lib2") assert-count: (".sidebar .location", 0) // We check that we have the crates list and that the "current" on is now "lib2". -assert-text: (".sidebar-elems ul.crate > li > a.current", "lib2") +assert-text: (".sidebar-elems ul.crate > li.current > a", "lib2") // We now go to the "foobar" function page. assert-text: (".sidebar-elems > section ul.block > li:nth-child(1)", "Modules") assert-text: (".sidebar-elems > section ul.block > li:nth-child(2)", "Structs") diff --git a/tests/rustdoc-gui/src/theme_css/custom-theme.css b/tests/rustdoc-gui/src/theme_css/custom-theme.css index 260ef87f6ea..49227d9ea11 100644 --- a/tests/rustdoc-gui/src/theme_css/custom-theme.css +++ b/tests/rustdoc-gui/src/theme_css/custom-theme.css @@ -96,4 +96,6 @@ --scrape-example-help-hover-color: #000; --scrape-example-code-wrapper-background-start: rgba(255, 255, 255, 1); --scrape-example-code-wrapper-background-end: rgba(255, 255, 255, 0); + --sidebar-resizer-hover: hsl(207, 90%, 66%); + --sidebar-resizer-active: hsl(207, 90%, 54%); } |
