fork/rust

git clone https://git.julia.blue/fork/rust

borsAuto merge of #103046 - JanBeh:PR_clarify_cmp_terminology, r=workingjubilee3bcad65fbf6

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