]> git.lizzy.rs Git - rust.git/blob - src/test/rustdoc-gui/notable-trait.goml
Rollup merge of #104137 - StackDoubleFlow:err-lsc-unsupported, r=bjorn3
[rust.git] / src / test / 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     [
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
204 // Check that clicking outside works.
205 click: "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']"
206 assert-count: ("//*[@class='notable popover']", 1)
207 click: ".search-input"
208 assert-count: ("//*[@class='notable popover']", 0)
209
210 // Check that pressing tab over and over works.
211 click: "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']"
212 move-cursor-to: "//*[@class='notable popover']"
213 assert-count: ("//*[@class='notable popover']", 1)
214 press-key: "Tab"
215 press-key: "Tab"
216 press-key: "Tab"
217 press-key: "Tab"
218 press-key: "Tab"
219 press-key: "Tab"
220 press-key: "Tab"
221 assert-count: ("//*[@class='notable popover']", 0)