]> git.lizzy.rs Git - rust.git/blob - tests/rustdoc-gui/notable-trait.goml
Rollup merge of #107777 - compiler-errors:derive_const-actually-derive-const, r=fee1...
[rust.git] / tests / rustdoc-gui / notable-trait.goml
1 // This test checks the position of the `i` for the notable traits.
2 goto: "file://" + |DOC_PATH| + "/test_docs/struct.NotableStructWithLongName.html"
3 show-text: true
4 // We start with a wide screen.
5 size: (1100, 600)
6 // Checking they have the same y position.
7 compare-elements-position: (
8     "//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']",
9     "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']",
10     ("y"),
11 )
12 // Checking they don't have the same x position.
13 compare-elements-position-false: (
14     "//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']",
15     "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']",
16     ("x"),
17 )
18 // The `i` should be *after* the type.
19 assert-position: (
20     "//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']",
21     {"x": 677},
22 )
23 assert-position: (
24     "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']",
25     {"x": 955},
26 )
27 // The tooltip should be below the `i`
28 // Also, clicking the tooltip should bring its text into the DOM
29 assert-count: ("//*[@class='notable popover']", 0)
30 click: "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']"
31 assert-count: ("//*[@class='notable popover']", 1)
32 compare-elements-position-near: (
33     "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']",
34     "//*[@class='notable popover']",
35     {"y": 30}
36 )
37 compare-elements-position-false: (
38     "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']",
39     "//*[@class='notable popover']",
40     ("x")
41 )
42 click: "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']"
43 move-cursor-to: "//h1"
44 assert-count: ("//*[@class='notable popover']", 0)
45
46 // Now only the `i` should be on the next line.
47 size: (1055, 600)
48 compare-elements-position-false: (
49     "//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']",
50     "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']",
51     ("y", "x"),
52 )
53
54 // Now both the `i` and the struct name should be on the next line.
55 size: (980, 600)
56 // Checking they have the same y position.
57 compare-elements-position: (
58     "//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']",
59     "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']",
60     ("y"),
61 )
62 // Checking they don't have the same x position.
63 compare-elements-position-false: (
64     "//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']",
65     "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']",
66     ("x"),
67 )
68 // The `i` should be *after* the type.
69 assert-position: (
70     "//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']",
71     {"x": 245},
72 )
73 assert-position: (
74     "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']",
75     {"x": 523},
76 )
77
78 // Checking on mobile now.
79 size: (650, 600)
80 // Checking they have the same y position.
81 compare-elements-position: (
82     "//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']",
83     "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']",
84     ("y"),
85 )
86 // Checking they don't have the same x position.
87 compare-elements-position-false: (
88     "//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']",
89     "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']",
90     ("x"),
91 )
92 // The `i` should be *after* the type.
93 assert-position: (
94     "//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']",
95     {"x": 15},
96 )
97 assert-position: (
98     "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']",
99     {"x": 293},
100 )
101 // The tooltip should STILL be below `i`
102 click: "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']"
103 assert-count: ("//*[@class='notable popover']", 1)
104 compare-elements-position-near: (
105     "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']",
106     "//*[@class='notable popover']",
107     {"y": 30}
108 )
109 compare-elements-position-false: (
110     "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']",
111     "//*[@class='notable popover']",
112     ("x")
113 )
114 assert-position: (
115     "//*[@class='notable popover']",
116     {"x": 0}
117 )
118 click: "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']"
119 move-cursor-to: "//h1"
120 assert-count: ("//*[@class='notable popover']", 0)
121
122 // Now check the colors.
123 define-function: (
124     "check-colors",
125     (theme, header_color, content_color, type_color, trait_color),
126     block {
127         goto: "file://" + |DOC_PATH| + "/test_docs/struct.NotableStructWithLongName.html"
128         // This is needed to ensure that the text color is computed.
129         show-text: true
130
131         // Setting the theme.
132         local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}
133         // We reload the page so the local storage settings are being used.
134         reload:
135
136         move-cursor-to: "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']"
137         assert-count: (".notable.popover", 1)
138
139         assert-css: (
140              ".notable.popover h3",
141              {"color": |header_color|},
142              ALL,
143         )
144         assert-css: (
145              ".notable.popover pre",
146              {"color": |content_color|},
147              ALL,
148         )
149         assert-css: (
150              ".notable.popover pre a.struct",
151              {"color": |type_color|},
152              ALL,
153         )
154         assert-css: (
155              ".notable.popover pre a.trait",
156              {"color": |trait_color|},
157              ALL,
158         )
159     },
160 )
161
162 call-function: (
163     "check-colors",
164     {
165         "theme": "ayu",
166         "content_color": "rgb(230, 225, 207)",
167         "header_color": "rgb(255, 255, 255)",
168         "type_color": "rgb(255, 160, 165)",
169         "trait_color": "rgb(57, 175, 215)",
170     },
171 )
172
173 call-function: (
174     "check-colors",
175     {
176         "theme": "dark",
177         "content_color": "rgb(221, 221, 221)",
178         "header_color": "rgb(221, 221, 221)",
179         "type_color": "rgb(45, 191, 184)",
180         "trait_color": "rgb(183, 140, 242)",
181     },
182 )
183
184 call-function: (
185     "check-colors",
186     {
187         "theme": "light",
188         "content_color": "rgb(0, 0, 0)",
189         "header_color": "rgb(0, 0, 0)",
190         "type_color": "rgb(173, 55, 138)",
191         "trait_color": "rgb(110, 79, 201)",
192     },
193 )
194
195 reload:
196
197 // Check that pressing escape works
198 click: "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']"
199 move-cursor-to: "//*[@class='notable popover']"
200 assert-count: ("//*[@class='notable popover']", 1)
201 press-key: "Escape"
202 assert-count: ("//*[@class='notable popover']", 0)
203 assert: "#method\.create_an_iterator_from_read .notable-traits:focus"
204
205 // Check that clicking outside works.
206 click: "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']"
207 assert-count: ("//*[@class='notable popover']", 1)
208 click: ".search-input"
209 assert-count: ("//*[@class='notable popover']", 0)
210 assert-false: "#method\.create_an_iterator_from_read .notable-traits:focus"
211
212 // Check that pressing tab over and over works.
213 click: "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']"
214 move-cursor-to: "//*[@class='notable popover']"
215 assert-count: ("//*[@class='notable popover']", 1)
216 press-key: "Tab"
217 press-key: "Tab"
218 press-key: "Tab"
219 press-key: "Tab"
220 press-key: "Tab"
221 press-key: "Tab"
222 press-key: "Tab"
223 assert-count: ("//*[@class='notable popover']", 0)
224 assert: "#method\.create_an_iterator_from_read .notable-traits:focus"
225
226 // Now we check that the focus isn't given back to the wrong item when opening
227 // another popover.
228 store-window-property: (scroll, "scrollY")
229 click: "#method\.create_an_iterator_from_read .fn"
230 // We ensure that the scroll position changed.
231 assert-window-property-false: {"scrollY": |scroll|}
232 // Store the new position.
233 store-window-property: (scroll, "scrollY")
234 click: "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']"
235 wait-for: "//*[@class='notable popover']"
236 click: "#settings-menu a"
237 click: ".search-input"
238 // We ensure we didn't come back to the previous focused item.
239 assert-window-property-false: {"scrollY": |scroll|}
240
241 // Same but with Escape handling.
242 store-window-property: (scroll, "scrollY")
243 click: "#method\.create_an_iterator_from_read .fn"
244 // We ensure that the scroll position changed.
245 assert-window-property-false: {"scrollY": |scroll|}
246 // Store the new position.
247 store-window-property: (scroll, "scrollY")
248 click: "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']"
249 wait-for: "//*[@class='notable popover']"
250 click: "#settings-menu a"
251 press-key: "Escape"
252 // We ensure we didn't come back to the previous focused item.
253 assert-window-property-false: {"scrollY": |scroll|}
254
255 // Opening the mobile sidebar should close the popover.
256 size: (650, 600)
257 click: "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']"
258 assert-count: ("//*[@class='notable popover']", 1)
259 click: ".sidebar-menu-toggle"
260 assert: "//*[@class='sidebar shown']"
261 assert-count: ("//*[@class='notable popover']", 0)
262 assert-false: "#method\.create_an_iterator_from_read .notable-traits:focus"
263 // Clicking a notable popover should close the sidebar.
264 click: "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']"
265 assert-count: ("//*[@class='notable popover']", 1)
266 assert-false: "//*[@class='sidebar shown']"
267
268 // Also check the focus handling for the help button.
269 size: (1100, 600)
270 reload:
271 assert-count: ("//*[@class='notable popover']", 0)
272 click: "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']"
273 assert-count: ("//*[@class='notable popover']", 1)
274 click: "#help-button a"
275 assert-count: ("//*[@class='notable popover']", 0)
276 assert-false: "#method\.create_an_iterator_from_read .notable-traits:focus"