Skip to content

Commit ae717c7

Browse files
authored
Rollup merge of #103115 - GuillaumeGomez:clean-up-anchors-gui-test, r=notriddle
Clean up anchors.goml rustdoc GUI test r? ``@notriddle``
2 parents 0bd24c5 + e77e5f3 commit ae717c7

File tree

2 files changed

+101
-148
lines changed

2 files changed

+101
-148
lines changed
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.12.4
1+
0.12.5

src/test/rustdoc-gui/anchors.goml

+100-147
Original file line numberDiff line numberDiff line change
@@ -1,154 +1,107 @@
11
// This test is to ensure that the anchors (`§`) have the expected color and position.
2-
goto: "file://" + |DOC_PATH| + "/staged_api/struct.Foo.html"
32

4-
// This is needed to ensure that the text color is computed.
5-
show-text: true
6-
7-
// Set the theme to light.
8-
local-storage: {"rustdoc-theme": "light", "rustdoc-use-system-theme": "false"}
9-
// We reload the page so the local storage settings are being used.
10-
reload:
11-
12-
assert-css: ("#toggle-all-docs", {"color": "rgb(0, 0, 0)"})
13-
assert-css: (".fqn a:nth-of-type(1)", {"color": "rgb(0, 0, 0)"})
14-
assert-css: (".fqn a:nth-of-type(2)", {"color": "rgb(173, 55, 138)"})
15-
assert-css: (
16-
".rightside .srclink",
17-
{"color": "rgb(56, 115, 173)", "text-decoration": "none solid rgb(56, 115, 173)"},
18-
ALL,
19-
)
20-
compare-elements-css: (".rightside .srclink", ".rightside.srclink", ["color", "text-decoration"])
21-
compare-elements-css: (".main-heading .srclink", ".rightside.srclink", ["color", "text-decoration"])
22-
23-
move-cursor-to: ".main-heading .srclink"
24-
assert-css: (
25-
".main-heading .srclink",
26-
{"color": "rgb(56, 115, 173)", "text-decoration": "underline solid rgb(56, 115, 173)"},
27-
)
28-
move-cursor-to: ".impl-items .rightside .srclink"
29-
assert-css: (
30-
".impl-items .rightside .srclink",
31-
{"color": "rgb(56, 115, 173)", "text-decoration": "none solid rgb(56, 115, 173)"},
32-
)
33-
move-cursor-to: ".impl-items .rightside.srclink"
34-
assert-css: (
35-
".impl-items .rightside.srclink",
36-
{"color": "rgb(56, 115, 173)", "text-decoration": "none solid rgb(56, 115, 173)"},
37-
)
38-
39-
goto: "file://" + |DOC_PATH| + "/test_docs/struct.HeavilyDocumentedStruct.html"
40-
41-
assert-css: ("#top-doc-prose-title", {"color": "rgb(0, 0, 0)"})
42-
43-
assert-css: (".sidebar a", {"color": "rgb(53, 109, 164)"})
44-
assert-css: ("h1.fqn a", {"color": "rgb(0, 0, 0)"})
45-
46-
// We move the cursor over the "Implementations" title so the anchor is displayed.
47-
move-cursor-to: "h2#implementations"
48-
assert-css: ("h2#implementations a.anchor", {"color": "rgb(0, 0, 0)"})
49-
50-
// Same thing with the impl block title.
51-
move-cursor-to: "#impl-HeavilyDocumentedStruct"
52-
assert-css: ("#impl-HeavilyDocumentedStruct a.anchor", {"color": "rgb(0, 0, 0)"})
53-
54-
assert-css: ("#title-for-struct-impl-item-doc", {"margin-left": "0px"})
55-
56-
//
57-
// We do the same checks with the dark theme now.
58-
//
59-
local-storage: {"rustdoc-theme": "dark", "rustdoc-use-system-theme": "false"}
60-
goto: "file://" + |DOC_PATH| + "/staged_api/struct.Foo.html"
61-
62-
assert-css: ("#toggle-all-docs", {"color": "rgb(221, 221, 221)"})
63-
assert-css: (".fqn a:nth-of-type(1)", {"color": "rgb(221, 221, 221)"})
64-
assert-css: (".fqn a:nth-of-type(2)", {"color": "rgb(45, 191, 184)"})
65-
assert-css: (
66-
".rightside .srclink",
67-
{"color": "rgb(210, 153, 29)", "text-decoration": "none solid rgb(210, 153, 29)"},
68-
ALL,
69-
)
70-
compare-elements-css: (".rightside .srclink", ".rightside.srclink", ["color", "text-decoration"])
71-
compare-elements-css: (".main-heading .srclink", ".rightside.srclink", ["color", "text-decoration"])
72-
73-
move-cursor-to: ".main-heading .srclink"
74-
assert-css: (
75-
".main-heading .srclink",
76-
{"color": "rgb(210, 153, 29)", "text-decoration": "underline solid rgb(210, 153, 29)"},
3+
define-function: (
4+
"check-colors",
5+
(theme, main_color, title_color, fqn_color, fqn_type_color, src_link_color, sidebar_link_color),
6+
[
7+
("goto", "file://" + |DOC_PATH| + "/staged_api/struct.Foo.html"),
8+
// This is needed to ensure that the text color is computed.
9+
("show-text", true),
10+
11+
// Setting the theme.
12+
("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}),
13+
// We reload the page so the local storage settings are being used.
14+
("reload"),
15+
16+
("assert-css", ("#toggle-all-docs", {"color": |main_color|})),
17+
("assert-css", (".fqn a:nth-of-type(1)", {"color": |fqn_color|})),
18+
("assert-css", (".fqn a:nth-of-type(2)", {"color": |fqn_type_color|})),
19+
("assert-css", (
20+
".rightside .srclink",
21+
{"color": |src_link_color|, "text-decoration": "none solid " + |src_link_color|},
22+
ALL,
23+
)),
24+
(
25+
"compare-elements-css",
26+
(".rightside .srclink", ".rightside.srclink", ["color", "text-decoration"]),
27+
),
28+
(
29+
"compare-elements-css",
30+
(".main-heading .srclink", ".rightside.srclink", ["color", "text-decoration"]),
31+
),
32+
33+
("move-cursor-to", ".main-heading .srclink"),
34+
("assert-css", (
35+
".main-heading .srclink",
36+
{"color": |src_link_color|, "text-decoration": "underline solid " + |src_link_color|},
37+
)),
38+
("move-cursor-to", ".impl-items .rightside .srclink"),
39+
("assert-css", (
40+
".impl-items .rightside .srclink",
41+
{"color": |src_link_color|, "text-decoration": "none solid " + |src_link_color|},
42+
)),
43+
("move-cursor-to", ".impl-items .rightside.srclink"),
44+
("assert-css", (
45+
".impl-items .rightside.srclink",
46+
{"color": |src_link_color|, "text-decoration": "none solid " + |src_link_color|},
47+
)),
48+
49+
("goto", "file://" + |DOC_PATH| + "/test_docs/struct.HeavilyDocumentedStruct.html"),
50+
// Since we changed page, we need to set the theme again.
51+
("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}),
52+
// We reload the page so the local storage settings are being used.
53+
("reload"),
54+
55+
("assert-css", ("#top-doc-prose-title", {"color": |title_color|})),
56+
57+
("assert-css", (".sidebar a", {"color": |sidebar_link_color|})),
58+
("assert-css", ("h1.fqn a", {"color": |title_color|})),
59+
60+
// We move the cursor over the "Implementations" title so the anchor is displayed.
61+
("move-cursor-to", "h2#implementations"),
62+
("assert-css", ("h2#implementations a.anchor", {"color": |main_color|})),
63+
64+
// Same thing with the impl block title.
65+
("move-cursor-to", "#impl-HeavilyDocumentedStruct"),
66+
("assert-css", ("#impl-HeavilyDocumentedStruct a.anchor", {"color": |main_color|})),
67+
68+
("assert-css", ("#title-for-struct-impl-item-doc", {"margin-left": "0px"})),
69+
],
7770
)
78-
move-cursor-to: ".impl-items .rightside .srclink"
79-
assert-css: (
80-
".impl-items .rightside .srclink",
81-
{"color": "rgb(210, 153, 29)", "text-decoration": "none solid rgb(210, 153, 29)"},
82-
)
83-
move-cursor-to: ".impl-items .rightside.srclink"
84-
assert-css: (
85-
".impl-items .rightside.srclink",
86-
{"color": "rgb(210, 153, 29)", "text-decoration": "none solid rgb(210, 153, 29)"},
87-
)
88-
89-
goto: "file://" + |DOC_PATH| + "/test_docs/struct.HeavilyDocumentedStruct.html"
90-
91-
assert-css: ("#top-doc-prose-title", {"color": "rgb(221, 221, 221)"})
92-
93-
assert-css: (".sidebar a", {"color": "rgb(253, 191, 53)"})
94-
assert-css: ("h1.fqn a", {"color": "rgb(221, 221, 221)"})
95-
96-
// We move the cursor over the "Implementations" title so the anchor is displayed.
97-
move-cursor-to: "h2#implementations"
98-
assert-css: ("h2#implementations a.anchor", {"color": "rgb(221, 221, 221)"})
99-
100-
// Same thing with the impl block title.
101-
move-cursor-to: "#impl-HeavilyDocumentedStruct"
102-
assert-css: ("#impl-HeavilyDocumentedStruct a.anchor", {"color": "rgb(221, 221, 221)"})
103-
104-
assert-css: ("#title-for-struct-impl-item-doc", {"margin-left": "0px"})
105-
106-
//
107-
// We do the same checks with the ayu theme now.
108-
//
109-
local-storage: {"rustdoc-theme": "ayu", "rustdoc-use-system-theme": "false"}
110-
goto: "file://" + |DOC_PATH| + "/staged_api/struct.Foo.html"
11171

112-
assert-css: ("#toggle-all-docs", {"color": "rgb(197, 197, 197)"})
113-
assert-css: (".fqn a:nth-of-type(1)", {"color": "rgb(255, 255, 255)"})
114-
assert-css: (".fqn a:nth-of-type(2)", {"color": "rgb(255, 160, 165)"})
115-
assert-css: (
116-
".rightside .srclink",
117-
{"color": "rgb(57, 175, 215)", "text-decoration": "none solid rgb(57, 175, 215)"},
118-
ALL,
72+
call-function: (
73+
"check-colors",
74+
(
75+
"ayu", // theme
76+
"rgb(197, 197, 197)", // main color
77+
"rgb(255, 255, 255)", // title color
78+
"rgb(255, 255, 255)", // fqn color
79+
"rgb(255, 160, 165)", // fqn type color
80+
"rgb(57, 175, 215)", // src link
81+
"rgb(83, 177, 219)", // sidebar link
82+
),
11983
)
120-
compare-elements-css: (".rightside .srclink", ".rightside.srclink", ["color", "text-decoration"])
121-
compare-elements-css: (".main-heading .srclink", ".rightside.srclink", ["color", "text-decoration"])
122-
123-
move-cursor-to: ".main-heading .srclink"
124-
assert-css: (
125-
".main-heading .srclink",
126-
{"color": "rgb(57, 175, 215)", "text-decoration": "underline solid rgb(57, 175, 215)"},
127-
)
128-
move-cursor-to: ".impl-items .rightside .srclink"
129-
assert-css: (
130-
".impl-items .rightside .srclink",
131-
{"color": "rgb(57, 175, 215)", "text-decoration": "none solid rgb(57, 175, 215)"},
84+
call-function: (
85+
"check-colors",
86+
(
87+
"dark", // theme
88+
"rgb(221, 221, 221)", // main color
89+
"rgb(221, 221, 221)", // title color
90+
"rgb(221, 221, 221)", // fqn color
91+
"rgb(45, 191, 184)", // fqn type color
92+
"rgb(210, 153, 29)", // src link
93+
"rgb(253, 191, 53)", // sidebar link
94+
),
13295
)
133-
move-cursor-to: ".impl-items .rightside.srclink"
134-
assert-css: (
135-
".impl-items .rightside.srclink",
136-
{"color": "rgb(57, 175, 215)", "text-decoration": "none solid rgb(57, 175, 215)"},
96+
call-function: (
97+
"check-colors",
98+
(
99+
"light", // theme
100+
"rgb(0, 0, 0)", // main color
101+
"rgb(0, 0, 0)", // title color
102+
"rgb(0, 0, 0)", // fqn color
103+
"rgb(173, 55, 138)", // fqn type color
104+
"rgb(56, 115, 173)", // src link
105+
"rgb(53, 109, 164)", // sidebar link
106+
),
137107
)
138-
139-
goto: "file://" + |DOC_PATH| + "/test_docs/struct.HeavilyDocumentedStruct.html"
140-
141-
assert-css: ("#top-doc-prose-title", {"color": "rgb(255, 255, 255)"})
142-
143-
assert-css: (".sidebar a", {"color": "rgb(83, 177, 219)"})
144-
assert-css: ("h1.fqn a", {"color": "rgb(255, 255, 255)"})
145-
146-
// We move the cursor over the "Implementations" title so the anchor is displayed.
147-
move-cursor-to: "h2#implementations"
148-
assert-css: ("h2#implementations a.anchor", {"color": "rgb(197, 197, 197)"})
149-
150-
// Same thing with the impl block title.
151-
move-cursor-to: "#impl-HeavilyDocumentedStruct"
152-
assert-css: ("#impl-HeavilyDocumentedStruct a.anchor", {"color": "rgb(197, 197, 197)"})
153-
154-
assert-css: ("#title-for-struct-impl-item-doc", {"margin-left": "0px"})

0 commit comments

Comments
 (0)