]> git.lizzy.rs Git - rust.git/blob - tests/rustdoc-gui/anchors.goml
Rollup merge of #106779 - RReverser:patch-2, r=Mark-Simulacrum
[rust.git] / tests / rustdoc-gui / anchors.goml
1 // This test is to ensure that the anchors (`ยง`) have the expected color and position.
2
3 define-function: (
4     "check-colors",
5     (theme, main_color, title_color, main_heading_color, main_heading_type_color, src_link_color, sidebar_link_color),
6     block {
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: (".main-heading h1 a:nth-of-type(1)", {"color": |main_heading_color|})
18         assert-css: (".main-heading a:nth-of-type(2)", {"color": |main_heading_type_color|})
19         assert-css: (
20              ".rightside .srclink",
21              {"color": |src_link_color|, "text-decoration": "none solid " + |src_link_color|},
22              ALL,
23         )
24         compare-elements-css: (
25             ".rightside .srclink",
26             ".rightside.srclink",
27             ["color", "text-decoration"],
28         )
29         compare-elements-css: (
30             ".main-heading .srclink",
31             ".rightside.srclink",
32             ["color", "text-decoration"],
33         )
34
35         move-cursor-to: ".main-heading .srclink"
36         assert-css: (
37              ".main-heading .srclink",
38              {"color": |src_link_color|, "text-decoration": "underline solid " + |src_link_color|},
39         )
40         move-cursor-to: ".impl-items .rightside .srclink"
41         assert-css: (
42              ".impl-items .rightside .srclink",
43              {"color": |src_link_color|, "text-decoration": "none solid " + |src_link_color|},
44         )
45         move-cursor-to: ".impl-items .rightside.srclink"
46         assert-css: (
47              ".impl-items .rightside.srclink",
48              {"color": |src_link_color|, "text-decoration": "none solid " + |src_link_color|},
49         )
50
51         goto: "file://" + |DOC_PATH| + "/test_docs/struct.HeavilyDocumentedStruct.html"
52         // Since we changed page, we need to set the theme again.
53         local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}
54         // We reload the page so the local storage settings are being used.
55         reload:
56
57         assert-css: ("#top-doc-prose-title", {"color": |title_color|})
58
59         assert-css: (".sidebar a", {"color": |sidebar_link_color|})
60         assert-css: (".main-heading h1 a", {"color": |title_color|})
61
62         // We move the cursor over the "Implementations" title so the anchor is displayed.
63         move-cursor-to: "h2#implementations"
64         assert-css: ("h2#implementations a.anchor", {"color": |main_color|})
65
66         // Same thing with the impl block title.
67         move-cursor-to: "#impl-HeavilyDocumentedStruct"
68         assert-css: ("#impl-HeavilyDocumentedStruct a.anchor", {"color": |main_color|})
69
70         assert-css: ("#title-for-struct-impl-item-doc", {"margin-left": "0px"})
71     },
72 )
73
74 call-function: (
75     "check-colors",
76     {
77         "theme": "ayu",
78         "main_color": "rgb(197, 197, 197)",
79         "title_color": "rgb(255, 255, 255)",
80         "main_heading_color": "rgb(255, 255, 255)",
81         "main_heading_type_color": "rgb(255, 160, 165)",
82         "src_link_color": "rgb(57, 175, 215)",
83         "sidebar_link_color": "rgb(83, 177, 219)",
84     },
85 )
86 call-function: (
87     "check-colors",
88     {
89         "theme": "dark",
90         "main_color": "rgb(221, 221, 221)",
91         "title_color": "rgb(221, 221, 221)",
92         "main_heading_color": "rgb(221, 221, 221)",
93         "main_heading_type_color": "rgb(45, 191, 184)",
94         "src_link_color": "rgb(210, 153, 29)",
95         "sidebar_link_color": "rgb(253, 191, 53)",
96     },
97 )
98 call-function: (
99     "check-colors",
100     {
101         "theme": "light",
102         "main_color": "rgb(0, 0, 0)",
103         "title_color": "rgb(0, 0, 0)",
104         "main_heading_color": "rgb(0, 0, 0)",
105         "main_heading_type_color": "rgb(173, 55, 138)",
106         "src_link_color": "rgb(56, 115, 173)",
107         "sidebar_link_color": "rgb(53, 109, 164)",
108     },
109 )