Skip to content

Commit 78f9fad

Browse files
Clean up code-color and headers-color rustdoc GUI tests
1 parent e0f8e60 commit 78f9fad

File tree

2 files changed

+78
-131
lines changed

2 files changed

+78
-131
lines changed

Diff for: src/test/rustdoc-gui/code-color.goml

+15-21
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,20 @@
55
goto: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html"
66
// If the text isn't displayed, the browser doesn't compute color style correctly...
77
show-text: true
8-
// Set the theme to dark.
9-
local-storage: {"rustdoc-theme": "dark", "rustdoc-preferred-dark-theme": "dark", "rustdoc-use-system-theme": "false"}
10-
// We reload the page so the local storage settings are being used.
11-
reload:
128

13-
assert-css: (".docblock pre > code", {"color": "rgb(221, 221, 221)"}, ALL)
14-
assert-css: (".docblock > p > code", {"color": "rgb(221, 221, 221)"}, ALL)
9+
define-function: (
10+
"check-colors",
11+
(theme, doc_code_color, doc_inline_code_color),
12+
[
13+
// Set the theme.
14+
("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}),
15+
// We reload the page so the local storage settings are being used.
16+
("reload"),
17+
("assert-css", (".docblock pre > code", {"color": |doc_code_color|}, ALL)),
18+
("assert-css", (".docblock > p > code", {"color": |doc_inline_code_color|}, ALL)),
19+
],
20+
)
1521

16-
// Set the theme to ayu.
17-
local-storage: {"rustdoc-theme": "ayu", "rustdoc-preferred-dark-theme": "ayu", "rustdoc-use-system-theme": "false"}
18-
// We reload the page so the local storage settings are being used.
19-
reload:
20-
21-
assert-css: (".docblock pre > code", {"color": "rgb(230, 225, 207)"}, ALL)
22-
assert-css: (".docblock > p > code", {"color": "rgb(255, 180, 84)"}, ALL)
23-
24-
// Set the theme to light.
25-
local-storage: {"rustdoc-theme": "light", "rustdoc-use-system-theme": "false"}
26-
// We reload the page so the local storage settings are being used.
27-
reload:
28-
29-
assert-css: (".docblock pre > code", {"color": "rgb(0, 0, 0)"}, ALL)
30-
assert-css: (".docblock > p > code", {"color": "rgb(0, 0, 0)"}, ALL)
22+
call-function: ("check-colors", ("ayu", "rgb(230, 225, 207)", "rgb(255, 180, 84)"))
23+
call-function: ("check-colors", ("dark", "rgb(221, 221, 221)", "rgb(221, 221, 221)"))
24+
call-function: ("check-colors", ("light", "rgb(0, 0, 0)", "rgb(0, 0, 0)"))

Diff for: src/test/rustdoc-gui/headers-color.goml

+63-110
Original file line numberDiff line numberDiff line change
@@ -1,117 +1,70 @@
11
// This test check for headers text and background colors for the different themes.
2-
goto: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html"
32

4-
// This is needed so that the text color is computed.
5-
show-text: true
6-
7-
// Ayu theme
8-
local-storage: {
9-
"rustdoc-theme": "ayu",
10-
"rustdoc-preferred-dark-theme": "ayu",
11-
"rustdoc-use-system-theme": "false",
12-
}
13-
reload:
14-
15-
assert-css: (
16-
".impl",
17-
{"color": "rgb(197, 197, 197)", "background-color": "rgba(0, 0, 0, 0)"},
18-
ALL,
19-
)
20-
assert-css: (
21-
".impl .code-header",
22-
{"color": "rgb(230, 225, 207)", "background-color": "rgba(0, 0, 0, 0)"},
23-
ALL,
3+
define-function: (
4+
"check-colors",
5+
(theme, color, code_header_color, focus_background_color, headings_color),
6+
[
7+
("goto", "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html"),
8+
// This is needed so that the text color is computed.
9+
("show-text", true),
10+
("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}),
11+
("reload"),
12+
("assert-css", (
13+
".impl",
14+
{"color": |color|, "background-color": "rgba(0, 0, 0, 0)"},
15+
ALL,
16+
)),
17+
("assert-css", (
18+
".impl .code-header",
19+
{"color": |code_header_color|, "background-color": "rgba(0, 0, 0, 0)"},
20+
ALL,
21+
)),
22+
("goto", "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html#impl-Foo"),
23+
("assert-css", (
24+
"#impl-Foo",
25+
{"color": |color|, "background-color": |focus_background_color|},
26+
)),
27+
("goto", "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html#method.must_use"),
28+
("assert-css", (
29+
"#method\.must_use",
30+
{"color": |color|, "background-color": |focus_background_color|},
31+
ALL,
32+
)),
33+
("goto", "file://" + |DOC_PATH| + "/test_docs/index.html"),
34+
("assert-css", (".small-section-header a", {"color": |color|}, ALL)),
35+
("goto", "file://" + |DOC_PATH| + "/test_docs/struct.HeavilyDocumentedStruct.html"),
36+
// We select headings (h2, h3, h...).
37+
("assert-css", (".docblock > :not(p) > a", {"color": |headings_color|}, ALL)),
38+
],
2439
)
2540

26-
goto: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html#impl-Foo"
27-
assert-css: (
28-
"#impl-Foo",
29-
{"color": "rgb(197, 197, 197)", "background-color": "rgba(255, 236, 164, 0.06)"},
41+
call-function: (
42+
"check-colors",
43+
{
44+
"theme": "ayu",
45+
"color": "rgb(197, 197, 197)",
46+
"code_header_color": "rgb(230, 225, 207)",
47+
"focus_background_color": "rgba(255, 236, 164, 0.06)",
48+
"headings_color": "rgb(57, 175, 215)",
49+
},
3050
)
31-
32-
goto: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html#method.must_use"
33-
assert-css: (
34-
"#method\.must_use",
35-
{"color": "rgb(197, 197, 197)", "background-color": "rgba(255, 236, 164, 0.06)"},
36-
ALL,
51+
call-function: (
52+
"check-colors",
53+
{
54+
"theme": "dark",
55+
"color": "rgb(221, 221, 221)",
56+
"code_header_color": "rgb(221, 221, 221)",
57+
"focus_background_color": "rgb(73, 74, 61)",
58+
"headings_color": "rgb(210, 153, 29)",
59+
},
3760
)
38-
39-
goto: "file://" + |DOC_PATH| + "/test_docs/index.html"
40-
assert-css: (".small-section-header a", {"color": "rgb(197, 197, 197)"}, ALL)
41-
42-
goto: "file://" + |DOC_PATH| + "/test_docs/struct.HeavilyDocumentedStruct.html"
43-
// We select headings (h2, h3, h...).
44-
assert-css: (".docblock > :not(p) > a", {"color": "rgb(57, 175, 215)"}, ALL)
45-
46-
// Dark theme
47-
local-storage: {
48-
"rustdoc-theme": "dark",
49-
"rustdoc-preferred-dark-theme": "dark",
50-
"rustdoc-use-system-theme": "false",
51-
}
52-
goto: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html"
53-
54-
assert-css: (
55-
".impl",
56-
{"color": "rgb(221, 221, 221)", "background-color": "rgba(0, 0, 0, 0)"},
57-
ALL,
58-
)
59-
assert-css: (
60-
".impl .code-header",
61-
{"color": "rgb(221, 221, 221)", "background-color": "rgba(0, 0, 0, 0)"},
62-
ALL,
63-
)
64-
65-
goto: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html#impl-Foo"
66-
assert-css: (
67-
"#impl-Foo",
68-
{"color": "rgb(221, 221, 221)", "background-color": "rgb(73, 74, 61)"},
69-
)
70-
71-
goto: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html#method.must_use"
72-
assert-css: (
73-
"#method\.must_use",
74-
{"color": "rgb(221, 221, 221)", "background-color": "rgb(73, 74, 61)"},
75-
ALL,
61+
call-function: (
62+
"check-colors",
63+
{
64+
"theme": "light",
65+
"color": "rgb(0, 0, 0)",
66+
"code_header_color": "rgb(0, 0, 0)",
67+
"focus_background_color": "rgb(253, 255, 211)",
68+
"headings_color": "rgb(56, 115, 173)",
69+
},
7670
)
77-
78-
goto: "file://" + |DOC_PATH| + "/test_docs/index.html"
79-
assert-css: (".small-section-header a", {"color": "rgb(221, 221, 221)"}, ALL)
80-
81-
goto: "file://" + |DOC_PATH| + "/test_docs/struct.HeavilyDocumentedStruct.html"
82-
// We select headings (h2, h3, h...).
83-
assert-css: (".docblock > :not(p) > a", {"color": "rgb(210, 153, 29)"}, ALL)
84-
85-
// Light theme
86-
local-storage: {"rustdoc-theme": "light", "rustdoc-use-system-theme": "false"}
87-
reload:
88-
89-
goto: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html"
90-
91-
assert-css: (
92-
".impl",
93-
{"color": "rgb(0, 0, 0)", "background-color": "rgba(0, 0, 0, 0)"},
94-
ALL,
95-
)
96-
assert-css: (
97-
".impl .code-header",
98-
{"color": "rgb(0, 0, 0)", "background-color": "rgba(0, 0, 0, 0)"},
99-
ALL,
100-
)
101-
102-
goto: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html#impl-Foo"
103-
assert-css: ("#impl-Foo", {"color": "rgb(0, 0, 0)", "background-color": "rgb(253, 255, 211)"})
104-
105-
goto: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html#method.must_use"
106-
assert-css: (
107-
"#method\.must_use",
108-
{"color": "rgb(0, 0, 0)", "background-color": "rgb(253, 255, 211)"},
109-
ALL,
110-
)
111-
112-
goto: "file://" + |DOC_PATH| + "/test_docs/index.html"
113-
assert-css: (".small-section-header a", {"color": "rgb(0, 0, 0)"}, ALL)
114-
115-
goto: "file://" + |DOC_PATH| + "/test_docs/struct.HeavilyDocumentedStruct.html"
116-
// We select headings (h2, h3, h...).
117-
assert-css: (".docblock > :not(p) > a", {"color": "rgb(56, 115, 173)"}, ALL)

0 commit comments

Comments
 (0)