]> git.lizzy.rs Git - rust.git/blob - src/test/rustdoc-gui/search-result-color.goml
Rollup merge of #105661 - lcnr:evaluate-new, r=compiler-errors
[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     "#titles > button > div.count",
71     {"color": "rgb(136, 136, 136)"},
72     ALL,
73 )
74 assert-css: (
75     "//*[@class='desc'][text()='Just a normal struct.']",
76     {"color": "rgb(197, 197, 197)"},
77 )
78 assert-css: (
79     "//*[@class='result-name']/*[text()='test_docs::']",
80     {"color": "rgb(0, 150, 207)"},
81 )
82
83 // Checking the color of the bottom border.
84 assert-css: (
85     ".search-results > a",
86     {"border-bottom-color": "rgba(170, 170, 170, 0.2)"}
87 )
88
89 // Checking the color of "keyword" text.
90 assert-css: (
91     "//*[@class='result-name']//*[text()='(keyword)']",
92     {"color": "rgb(120, 135, 151)"},
93 )
94
95 store-value: (entry_color, "rgb(0, 150, 207)") // color of the search entry
96 store-value: (hover_entry_color, "rgb(255, 255, 255)") // color of the hovered/focused search entry
97 store-value: (background_color, "rgba(0, 0, 0, 0)") // background color
98 store-value: (hover_background_color, "rgb(60, 60, 60)") // hover background color
99
100 call-function: (
101     "check-result-color", (
102         "keyword", // item kind
103         "rgb(57, 175, 215)", // color of item kind
104         "rgb(57, 175, 215)", // color of hovered/focused item kind
105     ),
106 )
107 call-function: (
108     "check-result-color", (
109         "struct", // item kind
110         "rgb(255, 160, 165)", // color of item kind
111         "rgb(255, 160, 165)", // color of hovered/focused item kind
112     ),
113 )
114 call-function: (
115     "check-result-color", (
116         "associatedtype", // item kind
117         "rgb(57, 175, 215)", // color of item kind
118         "rgb(57, 175, 215)", // color of hovered/focused item kind
119     ),
120 )
121 call-function: (
122     "check-result-color", (
123         "tymethod", // item kind
124         "rgb(253, 214, 135)", // color of item kind
125         "rgb(253, 214, 135)", // color of hovered/focused item kind
126     ),
127 )
128 call-function: (
129     "check-result-color", (
130         "method", // item kind
131         "rgb(253, 214, 135)", // color of item kind
132         "rgb(253, 214, 135)", // color of hovered/focused item kind
133     ),
134 )
135 call-function: (
136     "check-result-color", (
137         "structfield", // item kind
138         "rgb(0, 150, 207)", // color of item kind
139         "rgb(255, 255, 255)", // color of hovered/focused item kind
140     ),
141 )
142 call-function: (
143     "check-result-color", (
144         "macro", // item kind
145         "rgb(163, 122, 204)", // color of item kind
146         "rgb(163, 122, 204)", // color of hovered/focused item kind
147     ),
148 )
149 call-function: (
150     "check-result-color", (
151         "fn", // item kind
152         "rgb(253, 214, 135)", // color of item kind
153         "rgb(253, 214, 135)", // color of hovered/focused item kind
154     ),
155 )
156
157 // Checking the `<a>` container.
158 move-cursor-to: ".search-input"
159 focus: ".search-input" // To ensure the `<a>` container isnt focus or hover.
160 assert-css: (
161     "//*[@class='result-name']/*[text()='test_docs::']/ancestor::a",
162     {"color": "rgb(0, 150, 207)", "background-color": "rgba(0, 0, 0, 0)"},
163     ALL,
164 )
165
166 // Checking color and background on hover.
167 move-cursor-to: "//*[@class='desc'][text()='Just a normal struct.']"
168 assert-css: (
169     "//*[@class='result-name']/*[text()='test_docs::']",
170     {"color": "rgb(255, 255, 255)"},
171 )
172 assert-css: (
173     "//*[@class='result-name']/*[text()='test_docs::']/ancestor::a",
174     {"color": "rgb(255, 255, 255)", "background-color": "rgb(60, 60, 60)"},
175 )
176
177 // Dark theme
178 local-storage: {
179     "rustdoc-theme": "dark",
180     "rustdoc-use-system-theme": "false",
181 }
182 reload:
183
184 // Waiting for the search results to appear...
185 wait-for: "#titles"
186 assert-css: (
187     "#titles > button > div.count",
188     {"color": "rgb(136, 136, 136)"},
189     ALL,
190 )
191 assert-css: (
192     "//*[@class='desc'][text()='Just a normal struct.']",
193     {"color": "rgb(221, 221, 221)"},
194 )
195 assert-css: (
196     "//*[@class='result-name']/*[text()='test_docs::']",
197     {"color": "rgb(221, 221, 221)"},
198 )
199
200 // Checking the color of the bottom border.
201 assert-css: (
202     ".search-results > a",
203     {"border-bottom-color": "rgba(170, 170, 170, 0.2)"}
204 )
205
206 // Checking the color for "keyword" text.
207 assert-css: (
208     "//*[@class='result-name']//*[text()='(keyword)']",
209     {"color": "rgb(221, 221, 221)"},
210 )
211
212 store-value: (entry_color, "rgb(221, 221, 221)") // color of the search entry
213 store-value: (hover_entry_color, "rgb(221, 221, 221)") // color of the hovered/focused search entry
214 store-value: (background_color, "rgba(0, 0, 0, 0)") // background color
215 store-value: (hover_background_color, "rgb(97, 97, 97)") // hover background color
216
217 call-function: (
218     "check-result-color", (
219         "keyword", // item kind
220         "rgb(210, 153, 29)", // color of item kind
221         "rgb(210, 153, 29)", // color of hovered/focused item kind
222     ),
223 )
224 call-function: (
225     "check-result-color", (
226         "struct", // item kind
227         "rgb(45, 191, 184)", // color of item kind
228         "rgb(45, 191, 184)", // color of hovered/focused item kind
229     ),
230 )
231 call-function: (
232     "check-result-color", (
233         "associatedtype", // item kind
234         "rgb(210, 153, 29)", // color of item kind
235         "rgb(210, 153, 29)", // color of hovered/focused item kind
236     ),
237 )
238 call-function: (
239     "check-result-color", (
240         "tymethod", // item kind
241         "rgb(43, 171, 99)", // color of item kind
242         "rgb(43, 171, 99)", // color of hovered/focused item kind
243     ),
244 )
245 call-function: (
246     "check-result-color", (
247         "method", // item kind
248         "rgb(43, 171, 99)", // color of item kind
249         "rgb(43, 171, 99)", // color of hovered/focused item kind
250     ),
251 )
252 call-function: (
253     "check-result-color", (
254         "structfield", // item kind
255         "rgb(221, 221, 221)", // color of item kind
256         "rgb(221, 221, 221)", // color of hovered/focused item kind
257     ),
258 )
259 call-function: (
260     "check-result-color", (
261         "macro", // item kind
262         "rgb(9, 189, 0)", // color of item kind
263         "rgb(9, 189, 0)", // color of hovered/focused item kind
264     ),
265 )
266 call-function: (
267     "check-result-color", (
268         "fn", // item kind
269         "rgb(43, 171, 99)", // color of item kind
270         "rgb(43, 171, 99)", // color of hovered/focused item kind
271     ),
272 )
273
274 // Checking the `<a>` container.
275 move-cursor-to: ".search-input"
276 focus: ".search-input" // To ensure the `<a>` container isnt focus or hover.
277 assert-css: (
278     "//*[@class='result-name']/*[text()='test_docs::']/ancestor::a",
279     {"color": "rgb(221, 221, 221)", "background-color": "rgba(0, 0, 0, 0)"},
280 )
281
282 // Light theme
283 local-storage: {"rustdoc-theme": "light", "rustdoc-use-system-theme": "false"}
284 reload:
285
286 // Waiting for the search results to appear...
287 wait-for: "#titles"
288 assert-css: (
289     "#titles > button > div.count",
290     {"color": "rgb(136, 136, 136)"},
291     ALL,
292 )
293 assert-css: (
294     "//*[@class='desc'][text()='Just a normal struct.']",
295     {"color": "rgb(0, 0, 0)"},
296 )
297 assert-css: (
298     "//*[@class='result-name']/*[text()='test_docs::']",
299     {"color": "rgb(0, 0, 0)"},
300 )
301
302 // Checking the color of the bottom border.
303 assert-css: (
304     ".search-results > a",
305     {"border-bottom-color": "rgba(170, 170, 170, 0.2)"}
306 )
307
308 // Checking the color for "keyword" text.
309 assert-css: (
310     "//*[@class='result-name']//*[text()='(keyword)']",
311     {"color": "rgb(0, 0, 0)"},
312 )
313
314 store-value: (entry_color, "rgb(0, 0, 0)") // color of the search entry
315 store-value: (hover_entry_color, "rgb(0, 0, 0)") // color of the hovered/focused search entry
316 store-value: (background_color, "rgba(0, 0, 0, 0)") // background color
317 store-value: (hover_background_color, "rgb(204, 204, 204)") // hover background color
318
319 call-function: (
320     "check-result-color", (
321         "keyword", // item kind
322         "rgb(56, 115, 173)", // color of item kind
323         "rgb(56, 115, 173)", // color of hovered/focused item kind
324     ),
325 )
326 call-function: (
327     "check-result-color", (
328         "struct", // item kind
329         "rgb(173, 55, 138)", // color of item kind
330         "rgb(173, 55, 138)", // color of hovered/focused item kind
331     ),
332 )
333 call-function: (
334     "check-result-color", (
335         "associatedtype", // item kind
336         "rgb(56, 115, 173)", // color of item kind
337         "rgb(56, 115, 173)", // color of hovered/focused item kind
338     ),
339 )
340 call-function: (
341     "check-result-color", (
342         "tymethod", // item kind
343         "rgb(173, 124, 55)", // color of item kind
344         "rgb(173, 124, 55)", // color of hovered/focused item kind
345     ),
346 )
347 call-function: (
348     "check-result-color", (
349         "method", // item kind
350         "rgb(173, 124, 55)", // color of item kind
351         "rgb(173, 124, 55)", // color of hovered/focused item kind
352     ),
353 )
354 call-function: (
355     "check-result-color", (
356         "structfield", // item kind
357         "rgb(0, 0, 0)", // color of item kind
358         "rgb(0, 0, 0)", // color of hovered/focused item kind
359     ),
360 )
361 call-function: (
362     "check-result-color", (
363         "macro", // item kind
364         "rgb(6, 128, 0)", // color of item kind
365         "rgb(6, 128, 0)", // color of hovered/focused item kind
366     ),
367 )
368 call-function: (
369     "check-result-color", (
370         "fn", // item kind
371         "rgb(173, 124, 55)", // color of item kind
372         "rgb(173, 124, 55)", // color of hovered/focused item kind
373     ),
374 )
375
376 // Checking the `<a>` container.
377 move-cursor-to: ".search-input"
378 focus: ".search-input" // To ensure the `<a>` container isnt focus or hover.
379 assert-css: (
380     "//*[@class='result-name']/*[text()='test_docs::']/ancestor::a",
381     {"color": "rgb(0, 0, 0)", "background-color": "rgba(0, 0, 0, 0)"},
382 )
383
384 // Check the alias.
385 goto: "file://" + |DOC_PATH| + "/test_docs/index.html"
386 // If the text isn't displayed, the browser doesn't compute color style correctly...
387 show-text: true
388
389 define-function: (
390     "check-alias",
391     (theme, alias, grey),
392     [
393         ("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}),
394         ("reload"),
395         ("write", (".search-input", "thisisanalias")),
396         // To be SURE that the search will be run.
397         ("press-key", 'Enter'),
398         // Waiting for the search results to appear...
399         ("wait-for", "#titles"),
400         // Checking that the colors for the alias element are the ones expected.
401         ("assert-css", (".result-name > .alias", {"color": |alias|})),
402         ("assert-css", (".result-name > .alias > .grey", {"color": |grey|})),
403         // Leave the search results to prevent reloading with an already filled search input.
404         ("press-key", "Escape"),
405     ],
406 )
407
408 call-function: ("check-alias", {
409     "theme": "ayu",
410     "alias": "rgb(197, 197, 197)",
411     "grey": "rgb(153, 153, 153)",
412 })
413 call-function: ("check-alias", {
414     "theme": "dark",
415     "alias": "rgb(255, 255, 255)",
416     "grey": "rgb(204, 204, 204)",
417 })
418 call-function: ("check-alias", {
419     "theme": "light",
420     "alias": "rgb(0, 0, 0)",
421     "grey": "rgb(153, 153, 153)",
422 })