Skip to content

Commit 7c10c6f

Browse files
committed
rustdoc: fix rustdoc-gui tests for logo changes
1 parent c6e6ecb commit 7c10c6f

File tree

6 files changed

+34
-18
lines changed

6 files changed

+34
-18
lines changed

tests/rustdoc-gui/anchors.goml

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ define-function: (
5656

5757
assert-css: ("#top-doc-prose-title", {"color": |title_color|})
5858

59-
assert-css: (".sidebar a", {"color": |sidebar_link_color|})
59+
assert-css: (".sidebar .block a", {"color": |sidebar_link_color|})
6060
assert-css: (".main-heading h1 a", {"color": |title_color|})
6161

6262
// We move the cursor over the "Implementations" title so the anchor is displayed.

tests/rustdoc-gui/rust-logo.goml

+12-3
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
// This test ensures that the correct style is applied to the rust logo in the sidebar.
2-
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
2+
go-to: "file://" + |DOC_PATH| + "/staged_api/index.html"
33

44
define-function: (
55
"check-logo",
66
(theme, filter),
77
block {
88
// Going to the doc page.
9-
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
9+
go-to: "file://" + |DOC_PATH| + "/staged_api/index.html"
1010
// Changing theme.
1111
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}
1212
reload:
1313
assert-css: (".rust-logo", {"filter": |filter|})
1414
// Going to the source code page.
15-
go-to: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html"
15+
go-to: "file://" + |DOC_PATH| + "/src/staged_api/lib.rs.html"
1616
// Changing theme (since it's local files, the local storage works by folder).
1717
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}
1818
reload:
@@ -26,6 +26,15 @@ define-function: (
2626
assert-false: ".rust-logo"
2727
// Check there is no filter.
2828
assert-css: (".sidebar .logo-container img", {"filter": "none"})
29+
// Now we check that this page has no logo at all
30+
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
31+
assert-false: ".rust-logo"
32+
assert-false: ".logo-container"
33+
assert-false: ".sub-logo-container"
34+
go-to: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html"
35+
assert-false: ".rust-logo"
36+
assert-false: ".logo-container"
37+
assert-false: ".sub-logo-container"
2938
},
3039
)
3140

tests/rustdoc-gui/sidebar-source-code-display.goml

+2-2
Original file line numberDiff line numberDiff line change
@@ -174,14 +174,14 @@ click: "#src-sidebar-toggle"
174174
wait-for-css: (".sidebar", {"left": "-1000px"})
175175
// We scroll to line 117 to change the scroll position.
176176
scroll-to: '//*[@id="117"]'
177-
assert-window-property: {"pageYOffset": "2542"}
177+
assert-window-property: {"pageYOffset": "2516"}
178178
// Expanding the sidebar...
179179
click: "#src-sidebar-toggle"
180180
wait-for-css: (".sidebar", {"left": "0px"})
181181
click: "#src-sidebar-toggle"
182182
wait-for-css: (".sidebar", {"left": "-1000px"})
183183
// The "scrollTop" property should be the same.
184-
assert-window-property: {"pageYOffset": "2542"}
184+
assert-window-property: {"pageYOffset": "2516"}
185185

186186
// We now check that opening the sidebar and clicking a link will close it.
187187
// The behavior here on mobile is different than the behavior on desktop,

tests/rustdoc-gui/source-anchor-scroll.goml

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ set-window-size: (600, 800)
88
assert-property: ("html", {"scrollTop": "0"})
99

1010
click: '//a[text() = "barbar" and @href="#5-7"]'
11-
assert-property: ("html", {"scrollTop": "149"})
11+
assert-property: ("html", {"scrollTop": "123"})
1212
click: '//a[text() = "bar" and @href="#28-36"]'
13-
assert-property: ("html", {"scrollTop": "180"})
13+
assert-property: ("html", {"scrollTop": "154"})
1414
click: '//a[text() = "sub_fn" and @href="#2-4"]'
15-
assert-property: ("html", {"scrollTop": "77"})
15+
assert-property: ("html", {"scrollTop": "51"})
1616

1717
// We now check that clicking on lines doesn't change the scroll
1818
// Extra information: the "sub_fn" function header is on line 1.
1919
click: '//*[@id="6"]'
20-
assert-property: ("html", {"scrollTop": "77"})
20+
assert-property: ("html", {"scrollTop": "51"})

tests/rustdoc-gui/source-code-page.goml

+13-8
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,9 @@ assert-css: (".src-line-numbers", {"text-align": "right"})
8989
// do anything (and certainly not add a `#NaN` to the URL!).
9090
go-to: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html"
9191
// We use this assert-position to know where we will click.
92-
assert-position: ("//*[@id='1']", {"x": 88, "y": 112})
92+
assert-position: ("//*[@id='1']", {"x": 88, "y": 86})
9393
// We click on the left of the "1" anchor but still in the "src-line-number" `<pre>`.
94-
click: (87, 103)
94+
click: (87, 77)
9595
assert-document-property: ({"URL": "/lib.rs.html"}, ENDS_WITH)
9696

9797
// Checking the source code sidebar.
@@ -163,16 +163,16 @@ assert-css: ("nav.sub", {"flex-direction": "row"})
163163
// To check this, we maintain the invariant:
164164
//
165165
// offsetTop[nav.sub form] = offsetTop[#main-content] - offsetHeight[nav.sub form] - offsetTop[nav.sub form]
166-
assert-property: ("nav.sub form", {"offsetTop": 28, "offsetHeight": 34})
167-
assert-property: ("#main-content", {"offsetTop": 90})
168-
// 28 = 90 - 34 - 28
166+
assert-property: ("nav.sub form", {"offsetTop": 15, "offsetHeight": 34})
167+
assert-property: ("#main-content", {"offsetTop": 64})
168+
// 15 = 64 - 34 - 15
169169

170170
// Now do the same check on moderately-sized, tablet mobile.
171171
set-window-size: (700, 700)
172172
assert-css: ("nav.sub", {"flex-direction": "row"})
173-
assert-property: ("nav.sub form", {"offsetTop": 21, "offsetHeight": 34})
174-
assert-property: ("#main-content", {"offsetTop": 76})
175-
// 21 = 76 - 34 - 21
173+
assert-property: ("nav.sub form", {"offsetTop": 8, "offsetHeight": 34})
174+
assert-property: ("#main-content", {"offsetTop": 50})
175+
// 8 = 50 - 34 - 8
176176

177177
// Check the sidebar directory entries have a marker and spacing (tablet).
178178
store-property: ("#src-sidebar > .title", {
@@ -198,7 +198,12 @@ call-function: ("check-sidebar-dir-entry", {
198198
"y": |source_sidebar_title_y| + |source_sidebar_title_height| + 6,
199199
})
200200

201+
// The logo is not present on this page.
202+
assert-false: ".sub-logo-container > img"
203+
204+
// Check the staged-api page instead, which does.
201205
// Now we check that the logo has a bottom margin so it's not stuck to the search input.
206+
go-to: "file://" + |DOC_PATH| + "/src/staged_api/lib.rs.html"
202207
assert-css: (".sub-logo-container > img", {"margin-bottom": "8px"})
203208
store-property: (".sub-logo-container", {"clientHeight": logo_height})
204209
assert-position: (".search-form", {"y": |logo_height| + 8})

tests/rustdoc-gui/src/staged_api/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#![feature(staged_api)]
2+
#![feature(rustdoc_internals)]
23
#![allow(internal_features)]
34
#![stable(feature = "some_feature", since = "1.3.5")]
5+
#![doc(rust_logo)]
46

57
#[stable(feature = "some_feature", since = "1.3.5")]
68
pub struct Foo {}

0 commit comments

Comments
 (0)