Skip to content

Commit 0433639

Browse files
Use functions more in rustdoc GUI tests
1 parent ea7ada9 commit 0433639

17 files changed

Lines changed: 78 additions & 104 deletions

tests/rustdoc-gui/code-color.goml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,3 @@ call-function: ("check-colors", {
2222
"doc_code_color": "#e6e1cf",
2323
"doc_inline_code_color": "#ffb454",
2424
})
25-
call-function: ("check-colors", {
26-
"theme": "dark",
27-
"doc_code_color": "#ddd",
28-
"doc_inline_code_color": "#ddd",
29-
})
30-
call-function: ("check-colors", {
31-
"theme": "light",
32-
"doc_code_color": "black",
33-
"doc_inline_code_color": "black",
34-
})

tests/rustdoc-gui/copy-code.goml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Checks that the "copy code" button is not triggering JS error and its display
22
// isn't broken.
3+
include: "utils.goml"
34
go-to: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html"
45

56
define-function: (
@@ -47,15 +48,15 @@ assert: |copy_height| > 0 && |copy_width| > 0
4748

4849
// First we ensure that the clipboard is empty.
4950
assert-clipboard: ""
51+
5052
// We make the line numbers appear.
51-
click: "rustdoc-toolbar .settings-menu"
52-
wait-for-css: ("#settings", {"display": "block"})
53-
// We make the line numbers appear.
53+
call-function: ("open-settings-menu", {})
5454
click: "#line-numbers"
5555
wait-for-local-storage: {"rustdoc-line-numbers": "true" }
56+
5657
// We close the settings menu.
57-
click: "rustdoc-toolbar .settings-menu"
58-
wait-for-css-false: ("#settings", {"display": "block"})
58+
call-function: ("close-settings-menu", {})
59+
5960
// We ensure that there are actually line numbers generated in the DOM.
6061
assert-text: (".example-wrap pre.rust code span[data-nosnippet]", "1")
6162
// We make the copy button appear.

tests/rustdoc-gui/font-serif-change.goml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// Ensures that the font serif change is working as expected.
2+
include: "utils.goml"
23
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
34

45
// By default, it should be the serif fonts.
@@ -8,8 +9,7 @@ assert-css: ("body", {"font-family": |serif_font|})
89
assert-css: ("p code", {"font-family": |serif_code_font|})
910

1011
// We now switch to the sans serif font
11-
click: "main .settings-menu"
12-
wait-for: "#sans-serif-fonts"
12+
call-function: ("open-settings-menu", {})
1313
click: "#sans-serif-fonts"
1414

1515
store-value: (font, '"Fira Sans", sans-serif')
@@ -23,8 +23,7 @@ assert-css: ("body", {"font-family": |font|})
2323
assert-css: ("p code", {"font-family": |code_font|})
2424

2525
// We switch back to the serif font
26-
click: "main .settings-menu"
27-
wait-for: "#sans-serif-fonts"
26+
call-function: ("open-settings-menu", {})
2827
click: "#sans-serif-fonts"
2928

3029
assert-css: ("body", {"font-family": |serif_font|})

tests/rustdoc-gui/notable-trait.goml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,15 @@ call-function: ("check-notable-tooltip-position", {
8282
"i_x": 528,
8383
})
8484

85+
go-to: "file://" + |DOC_PATH| + "/test_docs/struct.NotableStructWithLongName.html"
86+
// This is needed to ensure that the text color is computed.
87+
show-text: true
88+
8589
// Now check the colors.
8690
define-function: (
8791
"check-colors",
8892
[theme, header_color, content_color, type_color, trait_color, link_color],
8993
block {
90-
go-to: "file://" + |DOC_PATH| + "/test_docs/struct.NotableStructWithLongName.html"
91-
// This is needed to ensure that the text color is computed.
92-
show-text: true
93-
9494
call-function: ("switch-theme", {"theme": |theme|})
9595

9696
assert-css: (
@@ -251,7 +251,6 @@ reload:
251251
assert-count: ("//*[@class='tooltip popover']", 0)
252252
click: "//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']"
253253
assert-count: ("//*[@class='tooltip popover']", 1)
254-
click: "rustdoc-toolbar .settings-menu a"
255-
wait-for: "#settings"
254+
call-function: ("open-settings-menu", {})
256255
assert-count: ("//*[@class='tooltip popover']", 0)
257256
assert-false: "#method\.create_an_iterator_from_read .tooltip:focus"

tests/rustdoc-gui/search-filter.goml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,17 +70,15 @@ assert-css: ("#crate-search", {
7070
})
7171

7272
// We now check the dark theme.
73-
click: "rustdoc-toolbar .settings-menu"
74-
wait-for: "#settings"
75-
click: "#theme-dark"
73+
call-function: ("switch-theme", {"theme": "dark"})
7674
wait-for-css: ("#crate-search", {
7775
"border": "1px solid #e0e0e0",
7876
"color": "#ddd",
7977
"background-color": "#353535",
8078
})
8179

8280
// And finally we check the ayu theme.
83-
click: "#theme-ayu"
81+
call-function: ("switch-theme", {"theme": "ayu"})
8482
wait-for-css: ("#crate-search", {
8583
"border": "1px solid #5c6773",
8684
"color": "#c5c5c5",

tests/rustdoc-gui/setting-auto-hide-content-large-items.goml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// This test ensures that the "Auto-hide item contents for large items" setting is working as
22
// expected.
33

4+
include: "utils.goml"
5+
46
// We need to disable this check because `trait.impl/test_docs/trait.Iterator.js` doesn't exist.
57
fail-on-request-error: false
68

@@ -9,8 +11,7 @@ define-function: (
911
[storage_value, setting_attribute_value, toggle_attribute_value],
1012
block {
1113
assert-local-storage: {"rustdoc-auto-hide-large-items": |storage_value|}
12-
click: "rustdoc-toolbar .settings-menu"
13-
wait-for: "#settings"
14+
call-function: ("open-settings-menu", {})
1415
assert-property: ("#auto-hide-large-items", {"checked": |setting_attribute_value|})
1516
assert-attribute: (".item-decl .type-contents-toggle", {"open": |toggle_attribute_value|})
1617
}

tests/rustdoc-gui/setting-auto-hide-item-methods-docs.goml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
// This test ensures that the "Auto-hide item methods' documentation" setting is working as
22
// expected.
33

4+
include: "utils.goml"
5+
46
define-function: (
57
"check-setting",
68
[storage_value, setting_attribute_value, toggle_attribute_value],
79
block {
810
assert-local-storage: {"rustdoc-auto-hide-method-docs": |storage_value|}
9-
click: "rustdoc-toolbar .settings-menu"
10-
wait-for: "#settings"
11+
call-function: ("open-settings-menu", {})
1112
assert-property: ("#auto-hide-method-docs", {"checked": |setting_attribute_value|})
1213
assert-attribute: (".toggle.method-toggle", {"open": |toggle_attribute_value|})
1314
}

tests/rustdoc-gui/setting-auto-hide-trait-implementations.goml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
// Checks that the setting "auto hide trait implementations" is working as expected.
22

3+
include: "utils.goml"
4+
35
define-function: (
46
"check-setting",
57
[storage_value, setting_attribute_value, toggle_attribute_value],
68
block {
79
assert-local-storage: {"rustdoc-auto-hide-trait-implementations": |storage_value|}
8-
click: "rustdoc-toolbar .settings-menu"
9-
wait-for: "#settings"
10+
call-function: ("open-settings-menu", {})
1011
assert-property: ("#auto-hide-trait-implementations", {"checked": |setting_attribute_value|})
1112
assert-attribute: ("#trait-implementations-list > details", {"open": |toggle_attribute_value|}, ALL)
1213
}

tests/rustdoc-gui/setting-go-to-only-result.goml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
// Checks that the setting "Directly go to item in search if there is only one result " is working as expected.
1+
// Checks that the setting "Directly go to item in search if there is only one result " is working
2+
// as expected.
3+
4+
include: "utils.goml"
25

36
define-function: (
47
"check-setting",
58
[storage_value, setting_attribute_value],
69
block {
710
assert-local-storage: {"rustdoc-go-to-only-result": |storage_value|}
8-
click: "rustdoc-toolbar .settings-menu"
9-
wait-for: "#settings"
11+
call-function: ("open-settings-menu", {})
1012
assert-property: ("#go-to-only-result", {"checked": |setting_attribute_value|})
1113
}
1214
)
@@ -25,8 +27,7 @@ wait-for: "#search"
2527
assert-document-property: ({"URL": "/lib2/index.html"}, CONTAINS)
2628

2729
// Now we change its value.
28-
click: "rustdoc-toolbar .settings-menu"
29-
wait-for: "#settings"
30+
call-function: ("open-settings-menu", {})
3031
click: "#go-to-only-result"
3132
assert-local-storage: {"rustdoc-go-to-only-result": "true"}
3233

tests/rustdoc-gui/settings.goml

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
11
// This test ensures that the settings menu display is working as expected and that
22
// the settings page is also rendered as expected.
3+
include: "utils.goml"
34
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
45
show-text: true // needed when we check for colors below.
56
// First, we check that the settings page doesn't exist.
67
assert-false: "#settings"
7-
// We now click on the settings button.
8-
click: "rustdoc-toolbar .settings-menu"
9-
wait-for: "#settings"
8+
call-function: ("open-settings-menu", {})
109
assert-css: ("#settings", {"display": "block"})
1110

1211
// Store the line margin to compare with the settings.html later.
1312
store-css: (".setting-line", {"margin": setting_line_margin})
1413

1514
// Let's close it by clicking on the same button.
16-
click: "rustdoc-toolbar .settings-menu"
17-
wait-for-css: ("#settings", {"display": "none"})
15+
call-function: ("close-settings-menu", {})
1816

1917
// Let's check that pressing "ESCAPE" is closing it.
2018
click: "rustdoc-toolbar .settings-menu"
@@ -28,8 +26,7 @@ write: "test"
2826
// To be SURE that the search will be run.
2927
press-key: 'Enter'
3028
wait-for: "#alternative-display #search"
31-
click: "rustdoc-toolbar .settings-menu"
32-
wait-for-css: ("#settings", {"display": "block"})
29+
call-function: ("open-settings-menu", {})
3330
// Ensure that the search is still displayed.
3431
wait-for: "#alternative-display #search"
3532
assert: "#main-content.hidden"
@@ -41,8 +38,7 @@ set-local-storage: {"rustdoc-theme": "dark", "rustdoc-use-system-theme": "false"
4138
// We reload the page so the local storage settings are being used.
4239
reload:
4340

44-
click: "rustdoc-toolbar .settings-menu"
45-
wait-for: "#settings"
41+
call-function: ("open-settings-menu", {})
4642

4743
// We check that the "Use system theme" is disabled.
4844
assert-property: ("#theme-system-preference", {"checked": "false"})

0 commit comments

Comments
 (0)