diff options
| author | Michael Howell <michael@notriddle.com> | 2023-09-19 18:08:55 -0700 |
|---|---|---|
| committer | Michael Howell <michael@notriddle.com> | 2023-10-08 20:17:53 -0700 |
| commit | 7c10c6f63d3b3567ea0e8ecb3b15652957ad0cc6 (patch) | |
| tree | 68549c34a519c736cfd2ee30eb706f96ca2226ac | |
| parent | c6e6ecb1afea9695a42d0f148ce153536b279eb5 (diff) | |
| download | rust-7c10c6f63d3b3567ea0e8ecb3b15652957ad0cc6.tar.gz rust-7c10c6f63d3b3567ea0e8ecb3b15652957ad0cc6.zip | |
rustdoc: fix rustdoc-gui tests for logo changes
| -rw-r--r-- | tests/rustdoc-gui/anchors.goml | 2 | ||||
| -rw-r--r-- | tests/rustdoc-gui/rust-logo.goml | 15 | ||||
| -rw-r--r-- | tests/rustdoc-gui/sidebar-source-code-display.goml | 4 | ||||
| -rw-r--r-- | tests/rustdoc-gui/source-anchor-scroll.goml | 8 | ||||
| -rw-r--r-- | tests/rustdoc-gui/source-code-page.goml | 21 | ||||
| -rw-r--r-- | tests/rustdoc-gui/src/staged_api/lib.rs | 2 |
6 files changed, 34 insertions, 18 deletions
diff --git a/tests/rustdoc-gui/anchors.goml b/tests/rustdoc-gui/anchors.goml index 30b83f0da38..72e0bcd77e0 100644 --- a/tests/rustdoc-gui/anchors.goml +++ b/tests/rustdoc-gui/anchors.goml @@ -56,7 +56,7 @@ define-function: ( assert-css: ("#top-doc-prose-title", {"color": |title_color|}) - assert-css: (".sidebar a", {"color": |sidebar_link_color|}) + assert-css: (".sidebar .block a", {"color": |sidebar_link_color|}) assert-css: (".main-heading h1 a", {"color": |title_color|}) // We move the cursor over the "Implementations" title so the anchor is displayed. diff --git a/tests/rustdoc-gui/rust-logo.goml b/tests/rustdoc-gui/rust-logo.goml index cd453aea276..696cab34dcc 100644 --- a/tests/rustdoc-gui/rust-logo.goml +++ b/tests/rustdoc-gui/rust-logo.goml @@ -1,18 +1,18 @@ // This test ensures that the correct style is applied to the rust logo in the sidebar. -go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" +go-to: "file://" + |DOC_PATH| + "/staged_api/index.html" define-function: ( "check-logo", (theme, filter), block { // Going to the doc page. - go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" + go-to: "file://" + |DOC_PATH| + "/staged_api/index.html" // Changing theme. set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} reload: assert-css: (".rust-logo", {"filter": |filter|}) // Going to the source code page. - go-to: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html" + go-to: "file://" + |DOC_PATH| + "/src/staged_api/lib.rs.html" // Changing theme (since it's local files, the local storage works by folder). set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} reload: @@ -26,6 +26,15 @@ define-function: ( assert-false: ".rust-logo" // Check there is no filter. assert-css: (".sidebar .logo-container img", {"filter": "none"}) + // Now we check that this page has no logo at all + go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" + assert-false: ".rust-logo" + assert-false: ".logo-container" + assert-false: ".sub-logo-container" + go-to: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html" + assert-false: ".rust-logo" + assert-false: ".logo-container" + assert-false: ".sub-logo-container" }, ) diff --git a/tests/rustdoc-gui/sidebar-source-code-display.goml b/tests/rustdoc-gui/sidebar-source-code-display.goml index 88546ed2549..cea4db1466b 100644 --- a/tests/rustdoc-gui/sidebar-source-code-display.goml +++ b/tests/rustdoc-gui/sidebar-source-code-display.goml @@ -174,14 +174,14 @@ click: "#src-sidebar-toggle" wait-for-css: (".sidebar", {"left": "-1000px"}) // We scroll to line 117 to change the scroll position. scroll-to: '//*[@id="117"]' -assert-window-property: {"pageYOffset": "2542"} +assert-window-property: {"pageYOffset": "2516"} // Expanding the sidebar... click: "#src-sidebar-toggle" wait-for-css: (".sidebar", {"left": "0px"}) click: "#src-sidebar-toggle" wait-for-css: (".sidebar", {"left": "-1000px"}) // The "scrollTop" property should be the same. -assert-window-property: {"pageYOffset": "2542"} +assert-window-property: {"pageYOffset": "2516"} // We now check that opening the sidebar and clicking a link will close it. // The behavior here on mobile is different than the behavior on desktop, diff --git a/tests/rustdoc-gui/source-anchor-scroll.goml b/tests/rustdoc-gui/source-anchor-scroll.goml index 0e4913cafb2..940851ea146 100644 --- a/tests/rustdoc-gui/source-anchor-scroll.goml +++ b/tests/rustdoc-gui/source-anchor-scroll.goml @@ -8,13 +8,13 @@ set-window-size: (600, 800) assert-property: ("html", {"scrollTop": "0"}) click: '//a[text() = "barbar" and @href="#5-7"]' -assert-property: ("html", {"scrollTop": "149"}) +assert-property: ("html", {"scrollTop": "123"}) click: '//a[text() = "bar" and @href="#28-36"]' -assert-property: ("html", {"scrollTop": "180"}) +assert-property: ("html", {"scrollTop": "154"}) click: '//a[text() = "sub_fn" and @href="#2-4"]' -assert-property: ("html", {"scrollTop": "77"}) +assert-property: ("html", {"scrollTop": "51"}) // We now check that clicking on lines doesn't change the scroll // Extra information: the "sub_fn" function header is on line 1. click: '//*[@id="6"]' -assert-property: ("html", {"scrollTop": "77"}) +assert-property: ("html", {"scrollTop": "51"}) diff --git a/tests/rustdoc-gui/source-code-page.goml b/tests/rustdoc-gui/source-code-page.goml index f19e3ce80e1..ad57380ae25 100644 --- a/tests/rustdoc-gui/source-code-page.goml +++ b/tests/rustdoc-gui/source-code-page.goml @@ -89,9 +89,9 @@ assert-css: (".src-line-numbers", {"text-align": "right"}) // do anything (and certainly not add a `#NaN` to the URL!). go-to: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html" // We use this assert-position to know where we will click. -assert-position: ("//*[@id='1']", {"x": 88, "y": 112}) +assert-position: ("//*[@id='1']", {"x": 88, "y": 86}) // We click on the left of the "1" anchor but still in the "src-line-number" `<pre>`. -click: (87, 103) +click: (87, 77) assert-document-property: ({"URL": "/lib.rs.html"}, ENDS_WITH) // Checking the source code sidebar. @@ -163,16 +163,16 @@ assert-css: ("nav.sub", {"flex-direction": "row"}) // To check this, we maintain the invariant: // // offsetTop[nav.sub form] = offsetTop[#main-content] - offsetHeight[nav.sub form] - offsetTop[nav.sub form] -assert-property: ("nav.sub form", {"offsetTop": 28, "offsetHeight": 34}) -assert-property: ("#main-content", {"offsetTop": 90}) -// 28 = 90 - 34 - 28 +assert-property: ("nav.sub form", {"offsetTop": 15, "offsetHeight": 34}) +assert-property: ("#main-content", {"offsetTop": 64}) +// 15 = 64 - 34 - 15 // Now do the same check on moderately-sized, tablet mobile. set-window-size: (700, 700) assert-css: ("nav.sub", {"flex-direction": "row"}) -assert-property: ("nav.sub form", {"offsetTop": 21, "offsetHeight": 34}) -assert-property: ("#main-content", {"offsetTop": 76}) -// 21 = 76 - 34 - 21 +assert-property: ("nav.sub form", {"offsetTop": 8, "offsetHeight": 34}) +assert-property: ("#main-content", {"offsetTop": 50}) +// 8 = 50 - 34 - 8 // Check the sidebar directory entries have a marker and spacing (tablet). store-property: ("#src-sidebar > .title", { @@ -198,7 +198,12 @@ call-function: ("check-sidebar-dir-entry", { "y": |source_sidebar_title_y| + |source_sidebar_title_height| + 6, }) +// The logo is not present on this page. +assert-false: ".sub-logo-container > img" + +// Check the staged-api page instead, which does. // Now we check that the logo has a bottom margin so it's not stuck to the search input. +go-to: "file://" + |DOC_PATH| + "/src/staged_api/lib.rs.html" assert-css: (".sub-logo-container > img", {"margin-bottom": "8px"}) store-property: (".sub-logo-container", {"clientHeight": logo_height}) assert-position: (".search-form", {"y": |logo_height| + 8}) diff --git a/tests/rustdoc-gui/src/staged_api/lib.rs b/tests/rustdoc-gui/src/staged_api/lib.rs index 0c914470e28..9b5ad1c5ff3 100644 --- a/tests/rustdoc-gui/src/staged_api/lib.rs +++ b/tests/rustdoc-gui/src/staged_api/lib.rs @@ -1,6 +1,8 @@ #![feature(staged_api)] +#![feature(rustdoc_internals)] #![allow(internal_features)] #![stable(feature = "some_feature", since = "1.3.5")] +#![doc(rust_logo)] #[stable(feature = "some_feature", since = "1.3.5")] pub struct Foo {} |
