Skip to content

Commit 9b789a6

Browse files
Add GUI regression test for scraped examples title position on mobile
1 parent 096bf4e commit 9b789a6

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

tests/rustdoc-gui/scrape-examples-layout.goml

+35
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Check that the line number column has the correct layout.
22
go-to: "file://" + |DOC_PATH| + "/scrape_examples/fn.test_many.html"
33

4+
set-window-size: (1000, 1000)
5+
46
// Check that it's not zero.
57
assert-property-false: (
68
".more-scraped-examples .scraped-example .src-line-numbers",
@@ -33,6 +35,18 @@ assert-property: (
3335
{"clientWidth": |clientWidth|}
3436
)
3537

38+
// The "title" should be located at the right bottom corner of the code example.
39+
store-position: (".example-wrap.scraped-example", {"x": x, "y": y})
40+
store-size: (".example-wrap.scraped-example", {"width": width, "height": height})
41+
store-size: (".example-wrap.scraped-example .scraped-example-title", {
42+
"width": title_width,
43+
"height": title_height,
44+
})
45+
assert-position: (".example-wrap.scraped-example .scraped-example-title", {
46+
"x": |x| + |width| - |title_width| - 5,
47+
"y": |y| + |height| - |title_height| - 8,
48+
})
49+
3650
// Check that for both mobile and desktop sizes, the buttons in scraped examples are displayed
3751
// correctly.
3852

@@ -46,3 +60,24 @@ assert-position: (".scraped-example .prev", {"y": 226 + |offset_y|})
4660
set-window-size: (600, 600)
4761
assert-position: (".scraped-example", {"y": 284})
4862
assert-position: (".scraped-example .prev", {"y": 284 + |offset_y|})
63+
64+
define-function: (
65+
"check_title_position",
66+
[],
67+
block {
68+
store-position: (".example-wrap.scraped-example .src-line-numbers", {"x": x, "y": y})
69+
store-size: (".example-wrap.scraped-example .scraped-example-title", { "height": title_height })
70+
71+
assert-position: (".example-wrap.scraped-example .scraped-example-title", {
72+
"x": |x|, // same X position.
73+
"y": |y| - |title_height|,
74+
})
75+
}
76+
)
77+
78+
// Check that the title is now above the code.
79+
call-function: ("check_title_position", {})
80+
81+
// Then with small mobile
82+
set-window-size: (300, 300)
83+
call-function: ("check_title_position", {})

0 commit comments

Comments
 (0)