Skip to content

Commit 40e3b6e

Browse files
Add GUI test for source code viewer scroll handling
1 parent c527502 commit 40e3b6e

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// We check that when the anchor changes and is output of the displayed content,
2+
// the page is scrolled to it.
3+
goto: file://|DOC_PATH|/src/link_to_definition/lib.rs.html
4+
5+
// We reduce the window size to make it easier to make an element "out of the page".
6+
size: (600, 800)
7+
// We check that the scroll is at the top first.
8+
assert-property: ("html", {"scrollTop": "0"})
9+
10+
click: '//a[text() = "barbar"]'
11+
assert-property: ("html", {"scrollTop": "125"})
12+
click: '//a[text() = "bar"]'
13+
assert-property: ("html", {"scrollTop": "166"})
14+
click: '//a[text() = "sub_fn"]'
15+
assert-property: ("html", {"scrollTop": "53"})
16+
17+
// We now check that clicking on lines doesn't change the scroll
18+
// Extra information: the "sub_fn" function header is on line 1.
19+
click: '//*[@id="6"]'
20+
assert-property: ("html", {"scrollTop": "53"})
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,35 @@
1+
pub fn sub_fn() {
2+
barbar();
3+
}
4+
fn barbar() {
5+
bar(vec![], vec![], vec![], vec![], Bar { a: "a".into(), b: 0 });
6+
}
7+
18
pub struct Bar {
29
pub a: String,
310
pub b: u32,
411
}
512

613
pub fn foo(_b: &Bar) {}
14+
15+
// The goal now is to add
16+
// a lot of lines so
17+
// that the next content
18+
// will be out of the screen
19+
// to allow us to test that
20+
// if the anchor changes to
21+
// something outside of the
22+
// current view, it'll
23+
// scroll to it as expected.
24+
25+
// More filling content.
26+
27+
pub fn bar(
28+
_a: Vec<String>,
29+
_b: Vec<String>,
30+
_c: Vec<String>,
31+
_d: Vec<String>,
32+
_e: Bar,
33+
) {
34+
sub_fn();
35+
}

0 commit comments

Comments
 (0)