Skip to content

Commit

Permalink
Add GUI test for new "sans serif fonts" setting
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Dec 4, 2024
1 parent 973847c commit 62bfdcb
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 4 deletions.
31 changes: 31 additions & 0 deletions tests/rustdoc-gui/font-serif-change.goml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Ensures that the font serif change is working as expected.
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"

// By default, it should be the serif fonts.
store-value: (serif_font, '"Source Serif 4", NanumBarunGothic, serif')
store-value: (serif_code_font, '"Source Code Pro", monospace')
assert-css: ("body", {"font-family": |serif_font|})
assert-css: ("p code", {"font-family": |serif_code_font|})

// We now switch to the sans serif font
click: "#settings-menu"
wait-for: "#sans-serif-fonts"
click: "#sans-serif-fonts"

store-value: (font, '"Fira Sans", sans-serif')
store-value: (code_font, '"Fira Mono", monospace')
assert-css: ("body", {"font-family": |font|})
assert-css: ("p code", {"font-family": |code_font|})

// Reloading the page to ensure it is loaded correctly.
reload:
assert-css: ("body", {"font-family": |font|})
assert-css: ("p code", {"font-family": |code_font|})

// We switch back to the serif font
click: "#settings-menu"
wait-for: "#sans-serif-fonts"
click: "#sans-serif-fonts"

assert-css: ("body", {"font-family": |serif_font|})
assert-css: ("p code", {"font-family": |serif_code_font|})
8 changes: 4 additions & 4 deletions tests/rustdoc-gui/settings.goml
Original file line number Diff line number Diff line change
Expand Up @@ -257,15 +257,15 @@ assert-text: ("#preferred-light-theme .setting-radio-name", "Preferred light the
// We now check that clicking on the toggles' text is like clicking on the checkbox.
// To test it, we use the "Disable keyboard shortcuts".
set-local-storage: {"rustdoc-disable-shortcuts": "false"}
click: ".setting-line:last-child .setting-check span"
click: "#disable-shortcuts"
assert-local-storage: {"rustdoc-disable-shortcuts": "true"}

// We now check that focusing a toggle and pressing Space is like clicking on it.
assert-local-storage: {"rustdoc-disable-shortcuts": "true"}
focus: ".setting-line:last-child .setting-check input"
focus: "#disable-shortcuts"
press-key: "Space"
assert-local-storage: {"rustdoc-disable-shortcuts": "false"}
focus: ".setting-line:last-child .setting-check input"
focus: "#disable-shortcuts"
press-key: "Space"
assert-local-storage: {"rustdoc-disable-shortcuts": "true"}

Expand All @@ -276,7 +276,7 @@ assert-false: "#help-button .popover"
wait-for-css: ("#settings-menu .popover", {"display": "block"})

// Now turn keyboard shortcuts back on, and see if they work.
click: ".setting-line:last-child .setting-check span"
click: "#disable-shortcuts"
assert-local-storage: {"rustdoc-disable-shortcuts": "false"}
press-key: "Escape"
press-key: "?"
Expand Down

0 comments on commit 62bfdcb

Please sign in to comment.