]> git.lizzy.rs Git - rust.git/blob - src/test/rustdoc-gui/search-result-color.goml
Rollup merge of #103382 - compiler-errors:anon-apit-lt-region-ice, r=cjgillot
[rust.git] / src / test / rustdoc-gui / search-result-color.goml
1 // The goal of this test is to ensure the color of the text is the one expected.
2
3 define-function: (
4     "check-result-color",
5     (result_kind, color, hover_color),
6     [
7         (
8             "assert-css",
9             (".result-" + |result_kind| + " ." + |result_kind|, {"color": |color|}, ALL),
10         ),
11         (
12             "assert-css",
13             (
14                 ".result-" + |result_kind|,
15                 {"color": |entry_color|, "background-color": |background_color|},
16             ),
17         ),
18         (
19             "move-cursor-to",
20             ".result-" + |result_kind|,
21         ),
22         (
23             "assert-css",
24             (
25                 ".result-" + |result_kind| + ":hover",
26                 {"color": |hover_entry_color|, "background-color": |hover_background_color|},
27             ),
28         ),
29         (
30             "assert-css",
31             (".result-" + |result_kind| + ":hover ." + |result_kind|, {"color": |hover_color|}),
32         ),
33         (
34             "move-cursor-to",
35             ".search-input",
36         ),
37         (
38             "focus",
39             ".result-" + |result_kind|,
40         ),
41         (
42             "assert-css",
43             (
44                 ".result-" + |result_kind| + ":focus",
45                 {"color": |hover_entry_color|, "background-color": |hover_background_color|},
46             ),
47         ),
48         (
49             "assert-css",
50             (".result-" + |result_kind| + ":focus ." + |result_kind|, {"color": |hover_color|}),
51         ),
52     ],
53 )
54
55 goto: "file://" + |DOC_PATH| + "/test_docs/index.html?search=coo"
56
57 // This is needed so that the text color is computed.
58 show-text: true
59
60 // Ayu theme
61 local-storage: {
62     "rustdoc-theme": "ayu",
63     "rustdoc-use-system-theme": "false",
64 }
65 reload:
66
67 // Waiting for the search results to appear...
68 wait-for: "#titles"
69 assert-css: (
70     "//*[@class='desc']//*[text()='Just a normal struct.']",
71     {"color": "rgb(197, 197, 197)"},
72 )
73 assert-css: (
74     "//*[@class='result-name']/*[text()='test_docs::']",
75     {"color": "rgb(0, 150, 207)"},
76 )
77
78 // Checking the color of "keyword" text.
79 assert-css: (
80     "//*[@class='result-name']//*[text()='(keyword)']",
81     {"color": "rgb(120, 135, 151)"},
82 )
83
84 store-value: (entry_color, "rgb(0, 150, 207)") // color of the search entry
85 store-value: (hover_entry_color, "rgb(255, 255, 255)") // color of the hovered/focused search entry
86 store-value: (background_color, "rgba(0, 0, 0, 0)") // background color
87 store-value: (hover_background_color, "rgb(60, 60, 60)") // hover background color
88
89 call-function: (
90     "check-result-color", (
91         "keyword", // item kind
92         "rgb(57, 175, 215)", // color of item kind
93         "rgb(57, 175, 215)", // color of hovered/focused item kind
94     ),
95 )
96 call-function: (
97     "check-result-color", (
98         "struct", // item kind
99         "rgb(255, 160, 165)", // color of item kind
100         "rgb(255, 160, 165)", // color of hovered/focused item kind
101     ),
102 )
103 call-function: (
104     "check-result-color", (
105         "associatedtype", // item kind
106         "rgb(57, 175, 215)", // color of item kind
107         "rgb(57, 175, 215)", // color of hovered/focused item kind
108     ),
109 )
110 call-function: (
111     "check-result-color", (
112         "tymethod", // item kind
113         "rgb(253, 214, 135)", // color of item kind
114         "rgb(253, 214, 135)", // color of hovered/focused item kind
115     ),
116 )
117 call-function: (
118     "check-result-color", (
119         "method", // item kind
120         "rgb(253, 214, 135)", // color of item kind
121         "rgb(253, 214, 135)", // color of hovered/focused item kind
122     ),
123 )
124 call-function: (
125     "check-result-color", (
126         "structfield", // item kind
127         "rgb(0, 150, 207)", // color of item kind
128         "rgb(255, 255, 255)", // color of hovered/focused item kind
129     ),
130 )
131 call-function: (
132     "check-result-color", (
133         "macro", // item kind
134         "rgb(163, 122, 204)", // color of item kind
135         "rgb(163, 122, 204)", // color of hovered/focused item kind
136     ),
137 )
138 call-function: (
139     "check-result-color", (
140         "fn", // item kind
141         "rgb(253, 214, 135)", // color of item kind
142         "rgb(253, 214, 135)", // color of hovered/focused item kind
143     ),
144 )
145
146 // Checking the `<a>` container.
147 move-cursor-to: ".search-input"
148 focus: ".search-input" // To ensure the `<a>` container isnt focus or hover.
149 assert-css: (
150     "//*[@class='result-name']/*[text()='test_docs::']/ancestor::a",
151     {"color": "rgb(0, 150, 207)", "background-color": "rgba(0, 0, 0, 0)"},
152     ALL,
153 )
154
155 // Checking color and background on hover.
156 move-cursor-to: "//*[@class='desc']//*[text()='Just a normal struct.']"
157 assert-css: (
158     "//*[@class='result-name']/*[text()='test_docs::']",
159     {"color": "rgb(255, 255, 255)"},
160 )
161 assert-css: (
162     "//*[@class='result-name']/*[text()='test_docs::']/ancestor::a",
163     {"color": "rgb(255, 255, 255)", "background-color": "rgb(60, 60, 60)"},
164 )
165
166 // Dark theme
167 local-storage: {
168     "rustdoc-theme": "dark",
169     "rustdoc-use-system-theme": "false",
170 }
171 reload:
172
173 // Waiting for the search results to appear...
174 wait-for: "#titles"
175 assert-css: (
176     "//*[@class='desc']//*[text()='Just a normal struct.']",
177     {"color": "rgb(221, 221, 221)"},
178 )
179 assert-css: (
180     "//*[@class='result-name']/*[text()='test_docs::']",
181     {"color": "rgb(221, 221, 221)"},
182 )
183
184 // Checking the color for "keyword" text.
185 assert-css: (
186     "//*[@class='result-name']//*[text()='(keyword)']",
187     {"color": "rgb(221, 221, 221)"},
188 )
189
190 store-value: (entry_color, "rgb(221, 221, 221)") // color of the search entry
191 store-value: (hover_entry_color, "rgb(221, 221, 221)") // color of the hovered/focused search entry
192 store-value: (background_color, "rgba(0, 0, 0, 0)") // background color
193 store-value: (hover_background_color, "rgb(97, 97, 97)") // hover background color
194
195 call-function: (
196     "check-result-color", (
197         "keyword", // item kind
198         "rgb(210, 153, 29)", // color of item kind
199         "rgb(210, 153, 29)", // color of hovered/focused item kind
200     ),
201 )
202 call-function: (
203     "check-result-color", (
204         "struct", // item kind
205         "rgb(45, 191, 184)", // color of item kind
206         "rgb(45, 191, 184)", // color of hovered/focused item kind
207     ),
208 )
209 call-function: (
210     "check-result-color", (
211         "associatedtype", // item kind
212         "rgb(210, 153, 29)", // color of item kind
213         "rgb(210, 153, 29)", // color of hovered/focused item kind
214     ),
215 )
216 call-function: (
217     "check-result-color", (
218         "tymethod", // item kind
219         "rgb(43, 171, 99)", // color of item kind
220         "rgb(43, 171, 99)", // color of hovered/focused item kind
221     ),
222 )
223 call-function: (
224     "check-result-color", (
225         "method", // item kind
226         "rgb(43, 171, 99)", // color of item kind
227         "rgb(43, 171, 99)", // color of hovered/focused item kind
228     ),
229 )
230 call-function: (
231     "check-result-color", (
232         "structfield", // item kind
233         "rgb(221, 221, 221)", // color of item kind
234         "rgb(221, 221, 221)", // color of hovered/focused item kind
235     ),
236 )
237 call-function: (
238     "check-result-color", (
239         "macro", // item kind
240         "rgb(9, 189, 0)", // color of item kind
241         "rgb(9, 189, 0)", // color of hovered/focused item kind
242     ),
243 )
244 call-function: (
245     "check-result-color", (
246         "fn", // item kind
247         "rgb(43, 171, 99)", // color of item kind
248         "rgb(43, 171, 99)", // color of hovered/focused item kind
249     ),
250 )
251
252 // Checking the `<a>` container.
253 move-cursor-to: ".search-input"
254 focus: ".search-input" // To ensure the `<a>` container isnt focus or hover.
255 assert-css: (
256     "//*[@class='result-name']/*[text()='test_docs::']/ancestor::a",
257     {"color": "rgb(221, 221, 221)", "background-color": "rgba(0, 0, 0, 0)"},
258 )
259
260 // Light theme
261 local-storage: {"rustdoc-theme": "light", "rustdoc-use-system-theme": "false"}
262 reload:
263
264 // Waiting for the search results to appear...
265 wait-for: "#titles"
266 assert-css: (
267     "//*[@class='desc']//*[text()='Just a normal struct.']",
268     {"color": "rgb(0, 0, 0)"},
269 )
270 assert-css: (
271     "//*[@class='result-name']/*[text()='test_docs::']",
272     {"color": "rgb(0, 0, 0)"},
273 )
274
275 // Checking the color for "keyword" text.
276 assert-css: (
277     "//*[@class='result-name']//*[text()='(keyword)']",
278     {"color": "rgb(0, 0, 0)"},
279 )
280
281 store-value: (entry_color, "rgb(0, 0, 0)") // color of the search entry
282 store-value: (hover_entry_color, "rgb(0, 0, 0)") // color of the hovered/focused search entry
283 store-value: (background_color, "rgba(0, 0, 0, 0)") // background color
284 store-value: (hover_background_color, "rgb(204, 204, 204)") // hover background color
285
286 call-function: (
287     "check-result-color", (
288         "keyword", // item kind
289         "rgb(56, 115, 173)", // color of item kind
290         "rgb(56, 115, 173)", // color of hovered/focused item kind
291     ),
292 )
293 call-function: (
294     "check-result-color", (
295         "struct", // item kind
296         "rgb(173, 55, 138)", // color of item kind
297         "rgb(173, 55, 138)", // color of hovered/focused item kind
298     ),
299 )
300 call-function: (
301     "check-result-color", (
302         "associatedtype", // item kind
303         "rgb(56, 115, 173)", // color of item kind
304         "rgb(56, 115, 173)", // color of hovered/focused item kind
305     ),
306 )
307 call-function: (
308     "check-result-color", (
309         "tymethod", // item kind
310         "rgb(173, 124, 55)", // color of item kind
311         "rgb(173, 124, 55)", // color of hovered/focused item kind
312     ),
313 )
314 call-function: (
315     "check-result-color", (
316         "method", // item kind
317         "rgb(173, 124, 55)", // color of item kind
318         "rgb(173, 124, 55)", // color of hovered/focused item kind
319     ),
320 )
321 call-function: (
322     "check-result-color", (
323         "structfield", // item kind
324         "rgb(0, 0, 0)", // color of item kind
325         "rgb(0, 0, 0)", // color of hovered/focused item kind
326     ),
327 )
328 call-function: (
329     "check-result-color", (
330         "macro", // item kind
331         "rgb(6, 128, 0)", // color of item kind
332         "rgb(6, 128, 0)", // color of hovered/focused item kind
333     ),
334 )
335 call-function: (
336     "check-result-color", (
337         "fn", // item kind
338         "rgb(173, 124, 55)", // color of item kind
339         "rgb(173, 124, 55)", // color of hovered/focused item kind
340     ),
341 )
342
343 // Checking the `<a>` container.
344 move-cursor-to: ".search-input"
345 focus: ".search-input" // To ensure the `<a>` container isnt focus or hover.
346 assert-css: (
347     "//*[@class='result-name']/*[text()='test_docs::']/ancestor::a",
348     {"color": "rgb(0, 0, 0)", "background-color": "rgba(0, 0, 0, 0)"},
349 )
350
351 // Check the alias more specifically in the dark theme.
352 goto: "file://" + |DOC_PATH| + "/test_docs/index.html"
353 // We set the theme so we're sure that the correct values will be used, whatever the computer
354 // this test is running on.
355 local-storage: {
356     "rustdoc-theme": "dark",
357     "rustdoc-use-system-theme": "false",
358 }
359 // If the text isn't displayed, the browser doesn't compute color style correctly...
360 show-text: true
361 // We reload the page so the local storage settings are being used.
362 reload:
363 write: (".search-input", "thisisanalias")
364 // To be SURE that the search will be run.
365 press-key: 'Enter'
366 // Waiting for the search results to appear...
367 wait-for: "#titles"
368 // Checking that the colors for the alias element are the ones expected.
369 assert-css: (".result-name > .alias", {"color": "rgb(255, 255, 255)"})
370 assert-css: (".result-name > .alias > .grey", {"color": "rgb(204, 204, 204)"})