Skip to content

Commit

Permalink
Update rustdoc GUI tests
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Aug 30, 2024
1 parent 0d156f2 commit 5b75f8a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
1 change: 1 addition & 0 deletions tests/rustdoc-gui/scrape-examples-button-focus.goml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
go-to: "file://" + |DOC_PATH| + "/scrape_examples/fn.test.html"

// The next/prev buttons vertically scroll the code viewport between examples
move-cursor-to: ".scraped-example-list > .scraped-example"
store-property: (".scraped-example-list > .scraped-example pre", {"scrollTop": initialScrollTop})
focus: ".scraped-example-list > .scraped-example .next"
press-key: "Enter"
Expand Down
8 changes: 4 additions & 4 deletions tests/rustdoc-gui/scrape-examples-color.goml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ define-function: (
block {
call-function: ("switch-theme", {"theme": |theme|})
wait-for: ".more-examples-toggle"
assert-css: (".scraped-example .example-wrap .rust span.highlight:not(.focus)", {
assert-css: (".scraped-example .rust span.highlight:not(.focus)", {
"background-color": |highlight|,
}, ALL)
assert-css: (".scraped-example .example-wrap .rust span.highlight.focus", {
assert-css: (".scraped-example .rust span.highlight.focus", {
"background-color": |highlight_focus|,
}, ALL)

Expand Down Expand Up @@ -67,11 +67,11 @@ define-function: (
[theme, background_color_start, background_color_end],
block {
call-function: ("switch-theme", {"theme": |theme|})
assert-css: (".scraped-example:not(.expanded) .code-wrapper::before", {
assert-css: (".scraped-example:not(.expanded)::before", {
"background-image": "linear-gradient(" + |background_color_start| + ", " +
|background_color_end| + ")",
})
assert-css: (".scraped-example:not(.expanded) .code-wrapper::after", {
assert-css: (".scraped-example:not(.expanded)::after", {
"background-image": "linear-gradient(to top, " + |background_color_start| + ", " +
|background_color_end| + ")",
})
Expand Down
20 changes: 10 additions & 10 deletions tests/rustdoc-gui/scrape-examples-layout.goml
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,33 @@ go-to: "file://" + |DOC_PATH| + "/scrape_examples/fn.test_many.html"

// Check that it's not zero.
assert-property-false: (
".more-scraped-examples .scraped-example .code-wrapper .src-line-numbers",
".more-scraped-examples .scraped-example .src-line-numbers",
{"clientWidth": "0"}
)

// Check that examples with very long lines have the same width as ones that don't.
store-property: (
".more-scraped-examples .scraped-example:nth-child(2) .code-wrapper .src-line-numbers",
".more-scraped-examples .scraped-example:nth-child(2) .src-line-numbers",
{"clientWidth": clientWidth},
)

assert-property: (
".more-scraped-examples .scraped-example:nth-child(3) .code-wrapper .src-line-numbers",
".more-scraped-examples .scraped-example:nth-child(3) .src-line-numbers",
{"clientWidth": |clientWidth|}
)

assert-property: (
".more-scraped-examples .scraped-example:nth-child(4) .code-wrapper .src-line-numbers",
".more-scraped-examples .scraped-example:nth-child(4) .src-line-numbers",
{"clientWidth": |clientWidth|}
)

assert-property: (
".more-scraped-examples .scraped-example:nth-child(5) .code-wrapper .src-line-numbers",
".more-scraped-examples .scraped-example:nth-child(5) .src-line-numbers",
{"clientWidth": |clientWidth|}
)

assert-property: (
".more-scraped-examples .scraped-example:nth-child(6) .code-wrapper .src-line-numbers",
".more-scraped-examples .scraped-example:nth-child(6) .src-line-numbers",
{"clientWidth": |clientWidth|}
)

Expand All @@ -39,10 +39,10 @@ assert-property: (
store-value: (offset_y, 4)

// First with desktop
assert-position: (".scraped-example .code-wrapper", {"y": 226})
assert-position: (".scraped-example .code-wrapper .prev", {"y": 226 + |offset_y|})
assert-position: (".scraped-example", {"y": 226})
assert-position: (".scraped-example .prev", {"y": 226 + |offset_y|})

// Then with mobile
set-window-size: (600, 600)
assert-position: (".scraped-example .code-wrapper", {"y": 308})
assert-position: (".scraped-example .code-wrapper .prev", {"y": 308 + |offset_y|})
assert-position: (".scraped-example", {"y": 284})
assert-position: (".scraped-example .prev", {"y": 284 + |offset_y|})

0 comments on commit 5b75f8a

Please sign in to comment.