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