Skip to content

Commit 71e824d

Browse files
Add tests for source line numbers colors
1 parent 0185be2 commit 71e824d

File tree

1 file changed

+43
-1
lines changed

1 file changed

+43
-1
lines changed

src/test/rustdoc-gui/source-code-page.goml

+43-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Checks that the interactions with the source code pages are working as expected.
22
goto: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html"
3+
show-text: true
34
// Check that we can click on the line number.
45
click: ".src-line-numbers > span:nth-child(4)" // This is the span for line 4.
56
// Ensure that the page URL was updated.
@@ -12,6 +13,48 @@ assert-attribute: (".src-line-numbers > span:nth-child(4)", {"class": "line-high
1213
assert-attribute: (".src-line-numbers > span:nth-child(5)", {"class": "line-highlighted"})
1314
assert-attribute: (".src-line-numbers > span:nth-child(6)", {"class": "line-highlighted"})
1415
assert-attribute-false: (".src-line-numbers > span:nth-child(7)", {"class": "line-highlighted"})
16+
17+
define-function: (
18+
"check-colors",
19+
(theme, color, background_color, highlight_color, highlight_background_color),
20+
[
21+
("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}),
22+
("reload"),
23+
("assert-css", (
24+
".src-line-numbers > span:not(.line-highlighted)",
25+
{"color": |color|, "background-color": |background_color|},
26+
ALL,
27+
)),
28+
("assert-css", (
29+
".src-line-numbers > span.line-highlighted",
30+
{"color": |highlight_color|, "background-color": |highlight_background_color|},
31+
ALL,
32+
)),
33+
],
34+
)
35+
36+
call-function: ("check-colors", {
37+
"theme": "ayu",
38+
"color": "rgb(92, 103, 115)",
39+
"background_color": "rgba(0, 0, 0, 0)",
40+
"highlight_color": "rgb(112, 128, 144)",
41+
"highlight_background_color": "rgba(255, 236, 164, 0.06)",
42+
})
43+
call-function: ("check-colors", {
44+
"theme": "dark",
45+
"color": "rgb(59, 145, 226)",
46+
"background_color": "rgba(0, 0, 0, 0)",
47+
"highlight_color": "rgb(59, 145, 226)",
48+
"highlight_background_color": "rgb(10, 4, 47)",
49+
})
50+
call-function: ("check-colors", {
51+
"theme": "light",
52+
"color": "rgb(198, 126, 45)",
53+
"background_color": "rgba(0, 0, 0, 0)",
54+
"highlight_color": "rgb(198, 126, 45)",
55+
"highlight_background_color": "rgb(253, 255, 211)",
56+
})
57+
1558
// This is to ensure that the content is correctly align with the line numbers.
1659
compare-elements-position: ("//*[@id='1']", ".rust > code > span", ("y"))
1760

@@ -20,7 +63,6 @@ assert-css: (".src-line-numbers", {"text-align": "right"})
2063

2164
// Now let's check that clicking on something else than the line number doesn't
2265
// do anything (and certainly not add a `#NaN` to the URL!).
23-
show-text: true
2466
goto: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html"
2567
// We use this assert-position to know where we will click.
2668
assert-position: ("//*[@id='1']", {"x": 104, "y": 112})

0 commit comments

Comments
 (0)