summaryrefslogtreecommitdiffstats
path: root/src/test/rustdoc-gui/source-code-page.goml
blob: 581f826a3d94d13625923bd6eb7a06316bb4a779 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Checks that the interactions with the source code pages are working as expected.
goto: file://|DOC_PATH|/src/test_docs/lib.rs.html
// Check that we can click on the line number.
click: ".line-numbers > span:nth-child(4)" // This is the span for line 4.
// Ensure that the page URL was updated.
assert-document-property: ({"URL": "lib.rs.html#4"}, ENDS_WITH)
assert-attribute: ("//*[@id='4']", {"class": "line-highlighted"})
// We now check that the good spans are highlighted
goto: file://|DOC_PATH|/src/test_docs/lib.rs.html#4-6
assert-attribute-false: (".line-numbers > span:nth-child(3)", {"class": "line-highlighted"})
assert-attribute: (".line-numbers > span:nth-child(4)", {"class": "line-highlighted"})
assert-attribute: (".line-numbers > span:nth-child(5)", {"class": "line-highlighted"})
assert-attribute: (".line-numbers > span:nth-child(6)", {"class": "line-highlighted"})
assert-attribute-false: (".line-numbers > span:nth-child(7)", {"class": "line-highlighted"})
// This is to ensure that the content is correctly align with the line numbers.
compare-elements-position: ("//*[@id='1']", ".rust > code > span", ("y"))

// Assert that the line numbers text is aligned to the right.
assert-css: (".line-numbers", {"text-align": "right"})

// Now let's check that clicking on something else than the line number doesn't
// do anything (and certainly not add a `#NaN` to the URL!).
show-text: true
goto: file://|DOC_PATH|/src/test_docs/lib.rs.html
// We use this assert-position to know where we will click.
assert-position: ("//*[@id='1']", {"x": 104, "y": 103})
// We click on the left of the "1" span but still in the "line-number" `<pre>`.
click: (103, 103)
assert-document-property: ({"URL": "/lib.rs.html"}, ENDS_WITH)

// Checking the source code sidebar.

// First we "open" it.
click: "#sidebar-toggle"
assert: ".source-sidebar-expanded"

// We check that the first entry of the sidebar is collapsed
assert-property: ("#source-sidebar details:first-of-type", {"open": "false"})
assert-text: ("#source-sidebar details:first-of-type > summary", "implementors")
// We now click on it.
click: "#source-sidebar details:first-of-type > summary"
assert-property: ("#source-sidebar details:first-of-type", {"open": "true"})

// And now we collapse it again.
click: "#source-sidebar details:first-of-type > summary"
assert-property: ("#source-sidebar details:first-of-type", {"open": "false"})

// Check the spacing.
assert-css: ("#source-sidebar > details.dir-entry", {"padding-left": "4px"})