diff options
Diffstat (limited to 'tests/rustdoc-gui')
| -rw-r--r-- | tests/rustdoc-gui/basic-code.goml | 6 | ||||
| -rw-r--r-- | tests/rustdoc-gui/docblock-code-block-line-number.goml | 66 | ||||
| -rw-r--r-- | tests/rustdoc-gui/jump-to-def-background.goml | 2 | ||||
| -rw-r--r-- | tests/rustdoc-gui/scrape-examples-button-focus.goml | 60 | ||||
| -rw-r--r-- | tests/rustdoc-gui/scrape-examples-layout.goml | 47 | ||||
| -rw-r--r-- | tests/rustdoc-gui/sidebar-foreign-impl-sort.goml | 15 | ||||
| -rw-r--r-- | tests/rustdoc-gui/source-anchor-scroll.goml | 6 | ||||
| -rw-r--r-- | tests/rustdoc-gui/source-code-page-code-scroll.goml | 4 | ||||
| -rw-r--r-- | tests/rustdoc-gui/source-code-page.goml | 38 | ||||
| -rw-r--r-- | tests/rustdoc-gui/src/test_docs/lib.rs | 18 |
10 files changed, 118 insertions, 144 deletions
diff --git a/tests/rustdoc-gui/basic-code.goml b/tests/rustdoc-gui/basic-code.goml deleted file mode 100644 index 22ac5316184..00000000000 --- a/tests/rustdoc-gui/basic-code.goml +++ /dev/null @@ -1,6 +0,0 @@ -// Small test to ensure the "src-line-numbers" element is only present once on -// the page. -go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" -click: "a.src" -wait-for: ".src-line-numbers" -assert-count: (".src-line-numbers", 1) diff --git a/tests/rustdoc-gui/docblock-code-block-line-number.goml b/tests/rustdoc-gui/docblock-code-block-line-number.goml index 3c16626336e..032746a6bdf 100644 --- a/tests/rustdoc-gui/docblock-code-block-line-number.goml +++ b/tests/rustdoc-gui/docblock-code-block-line-number.goml @@ -112,28 +112,6 @@ wait-for: "pre.example-line-numbers" go-to: "file://" + |DOC_PATH| + "/scrape_examples/fn.test_many.html" assert-css: ( - ".scraped-example .src-line-numbers > pre", - { - // There should not be a radius on the right of the line numbers. - "border-top-left-radius": "6px", - "border-bottom-left-radius": "6px", - "border-top-right-radius": "0px", - "border-bottom-right-radius": "0px", - }, - ALL, -) -assert-css: ( - ".scraped-example .src-line-numbers", - { - // There should not be a radius on the right of the line numbers. - "border-top-left-radius": "6px", - "border-bottom-left-radius": "6px", - "border-top-right-radius": "0px", - "border-bottom-right-radius": "0px", - }, - ALL, -) -assert-css: ( ".scraped-example .rust", { // There should not be a radius on the left of the code. @@ -149,23 +127,15 @@ define-function: ( "check-padding", [path, padding_bottom], block { - assert-css: (|path| + " .src-line-numbers", { + assert-css: (|path| + " span[data-nosnippet]", { "padding-top": "0px", "padding-bottom": "0px", - "padding-left": "0px", - "padding-right": "0px", - }, ALL) - assert-css: (|path| + " .src-line-numbers > pre", { - "padding-top": "14px", - "padding-bottom": |padding_bottom|, - "padding-left": "0px", - "padding-right": "0px", - }, ALL) - assert-css: (|path| + " .src-line-numbers > pre > span", { - "padding-top": "0px", - "padding-bottom": "0px", - "padding-left": "8px", - "padding-right": "8px", + "padding-left": "4px", + "padding-right": "4px", + "margin-right": "20px", + "margin-left": "0px", + "margin-top": "0px", + "margin-bottom": "0px", }, ALL) }, ) @@ -196,13 +166,13 @@ define-function: ("check-line-numbers-existence", [], block { wait-for-local-storage-false: {"rustdoc-line-numbers": "true" } assert-false: ".example-line-numbers" // Line numbers should still be there. - assert: ".src-line-numbers" + assert-css: ("[data-nosnippet]", { "display": "inline-block"}) // Now disabling the setting. click: "input#line-numbers" wait-for-local-storage: {"rustdoc-line-numbers": "true" } assert-false: ".example-line-numbers" // Line numbers should still be there. - assert: ".src-line-numbers" + assert-css: ("[data-nosnippet]", { "display": "inline-block"}) // Closing settings menu. click: "#settings-menu" wait-for-css: ("#settings", {"display": "none"}) @@ -214,18 +184,16 @@ call-function: ("check-line-numbers-existence", {}) // Now checking the line numbers in the source code page. click: ".src" -assert-css: (".src-line-numbers", { - "padding-top": "20px", - "padding-bottom": "20px", - "padding-left": "4px", - "padding-right": "0px", -}) -assert-css: (".src-line-numbers > a", { +assert-css: ("a[data-nosnippet]", { "padding-top": "0px", "padding-bottom": "0px", - "padding-left": "8px", - "padding-right": "8px", -}) + "padding-left": "4px", + "padding-right": "4px", + "margin-top": "0px", + "margin-bottom": "0px", + "margin-left": "0px", + "margin-right": "20px", +}, ALL) // Checking that turning off the line numbers setting won't remove line numbers. call-function: ("check-line-numbers-existence", {}) diff --git a/tests/rustdoc-gui/jump-to-def-background.goml b/tests/rustdoc-gui/jump-to-def-background.goml index 71320360740..de5ea6c9b0b 100644 --- a/tests/rustdoc-gui/jump-to-def-background.goml +++ b/tests/rustdoc-gui/jump-to-def-background.goml @@ -8,7 +8,7 @@ define-function: ( block { call-function: ("switch-theme", {"theme": |theme|}) assert-css: ( - "body.src .example-wrap pre.rust a", + "body.src .example-wrap pre.rust a:not([data-nosnippet])", {"background-color": |background_color|}, ALL, ) diff --git a/tests/rustdoc-gui/scrape-examples-button-focus.goml b/tests/rustdoc-gui/scrape-examples-button-focus.goml index 83ed6a219b2..12246a37661 100644 --- a/tests/rustdoc-gui/scrape-examples-button-focus.goml +++ b/tests/rustdoc-gui/scrape-examples-button-focus.goml @@ -4,52 +4,44 @@ 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 .src-line-numbers", { - "scrollTop": initialScrollTop, -}) +wait-for: ".scraped-example-list > .scraped-example .next" +store-value: (initialScrollTop, 250) assert-property: (".scraped-example-list > .scraped-example .rust", { "scrollTop": |initialScrollTop|, -}) +}, NEAR) focus: ".scraped-example-list > .scraped-example .next" press-key: "Enter" -assert-property-false: (".scraped-example-list > .scraped-example .src-line-numbers", { - "scrollTop": |initialScrollTop| -}, NEAR) assert-property-false: (".scraped-example-list > .scraped-example .rust", { "scrollTop": |initialScrollTop| }, NEAR) focus: ".scraped-example-list > .scraped-example .prev" press-key: "Enter" -assert-property: (".scraped-example-list > .scraped-example .src-line-numbers", { - "scrollTop": |initialScrollTop| -}, NEAR) assert-property: (".scraped-example-list > .scraped-example .rust", { "scrollTop": |initialScrollTop| }, NEAR) -// The expand button increases the scrollHeight of the minimized code viewport -store-property: (".scraped-example-list > .scraped-example pre", {"offsetHeight": smallOffsetHeight}) -assert-property: (".scraped-example-list > .scraped-example .src-line-numbers", { - "scrollHeight": |smallOffsetHeight| -}, NEAR) -assert-property: (".scraped-example-list > .scraped-example .rust", { - "scrollHeight": |smallOffsetHeight| -}, NEAR) -focus: ".scraped-example-list > .scraped-example .expand" -press-key: "Enter" -assert-property-false: (".scraped-example-list > .scraped-example .src-line-numbers", { - "offsetHeight": |smallOffsetHeight| -}, NEAR) -assert-property-false: (".scraped-example-list > .scraped-example .rust", { - "offsetHeight": |smallOffsetHeight| -}, NEAR) -store-property: (".scraped-example-list > .scraped-example .src-line-numbers", { - "offsetHeight": fullOffsetHeight, +// Make sure all the buttons are the same size +store-property: (".scraped-example-list > .scraped-example .prev", { + "offsetWidth": buttonWidth, + "offsetHeight": buttonHeight, }) -assert-property: (".scraped-example-list > .scraped-example .rust", { - "offsetHeight": |fullOffsetHeight|, - "scrollHeight": |fullOffsetHeight|, +assert-property: (".scraped-example-list > .scraped-example .prev", { + "offsetWidth": |buttonWidth|, + "offsetHeight": |buttonHeight|, + "title": "Previous usage", +}) +assert-property: (".scraped-example-list > .scraped-example .next", { + "offsetWidth": |buttonWidth|, + "offsetHeight": |buttonHeight|, + "title": "Next usage", +}) +assert-property: (".scraped-example-list > .scraped-example .expand", { + "offsetWidth": |buttonWidth|, + "offsetHeight": |buttonHeight|, + "title": "Show all", +}) +assert-property: (".scraped-example-list > .scraped-example .copy-button", { + "offsetWidth": |buttonWidth|, + "offsetHeight": |buttonHeight|, + "title": "Copy code to clipboard", }) -assert-property: (".scraped-example-list > .scraped-example .src-line-numbers", { - "scrollHeight": |fullOffsetHeight| -}, NEAR) diff --git a/tests/rustdoc-gui/scrape-examples-layout.goml b/tests/rustdoc-gui/scrape-examples-layout.goml index 5187ac486b0..85a3b2a6287 100644 --- a/tests/rustdoc-gui/scrape-examples-layout.goml +++ b/tests/rustdoc-gui/scrape-examples-layout.goml @@ -3,35 +3,38 @@ go-to: "file://" + |DOC_PATH| + "/scrape_examples/fn.test_many.html" set-window-size: (1000, 1000) +// We move the mouse over the scraped example for the prev button to be generated. +move-cursor-to: ".scraped-example" + // Check that it's not zero. assert-property-false: ( - ".more-scraped-examples .scraped-example .src-line-numbers", + ".more-scraped-examples .scraped-example span[data-nosnippet]", {"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) .src-line-numbers", + ".more-scraped-examples .scraped-example:nth-child(2) span[data-nosnippet]", {"clientWidth": clientWidth}, ) assert-property: ( - ".more-scraped-examples .scraped-example:nth-child(3) .src-line-numbers", + ".more-scraped-examples .scraped-example:nth-child(3) span[data-nosnippet]", {"clientWidth": |clientWidth|} ) assert-property: ( - ".more-scraped-examples .scraped-example:nth-child(4) .src-line-numbers", + ".more-scraped-examples .scraped-example:nth-child(4) span[data-nosnippet]", {"clientWidth": |clientWidth|} ) assert-property: ( - ".more-scraped-examples .scraped-example:nth-child(5) .src-line-numbers", + ".more-scraped-examples .scraped-example:nth-child(5) span[data-nosnippet]", {"clientWidth": |clientWidth|} ) assert-property: ( - ".more-scraped-examples .scraped-example:nth-child(6) .src-line-numbers", + ".more-scraped-examples .scraped-example:nth-child(6) span[data-nosnippet]", {"clientWidth": |clientWidth|} ) @@ -55,25 +58,6 @@ assert-size: (".more-scraped-examples .scraped-example .example-wrap", { "width": |width|, }) -// Check that the expand button works and also that line number aligns with code. -move-cursor-to: ".scraped-example .rust" -click: ".scraped-example .button-holder .expand" -wait-for: ".scraped-example.expanded" -// They should have the same y position. -compare-elements-position: ( - ".scraped-example.expanded .src-line-numbers pre span", - ".scraped-example.expanded .rust code", - ["y"], -) -// And they should have the same height. -compare-elements-size: ( - ".scraped-example.expanded .src-line-numbers", - ".scraped-example.expanded .rust", - ["height"], -) -// Collapse code again. -click: ".scraped-example .button-holder .expand" - // Check that for both mobile and desktop sizes, the buttons in scraped examples are displayed // correctly. @@ -98,7 +82,7 @@ define-function: ( [], block { // Title should be above the code. - store-position: (".scraped-example .example-wrap .src-line-numbers", {"x": x, "y": y}) + store-position: (".scraped-example .example-wrap", {"x": x, "y": y}) store-size: (".scraped-example .scraped-example-title", { "height": title_height }) assert-position: (".scraped-example .scraped-example-title", { @@ -107,10 +91,13 @@ define-function: ( }) // Line numbers should be right beside the code. - compare-elements-position: ( - ".scraped-example .example-wrap .src-line-numbers", - ".scraped-example .example-wrap .rust", - ["y"], + compare-elements-position-near: ( + ".scraped-example .example-wrap span[data-nosnippet]", + // On the first line, the code starts with `fn main` so we have a keyword. + ".scraped-example .example-wrap .rust span.kw", + // They're not exactly the same size but since they're on the same line, + // it's kinda the same. + {"y": 2}, ) } ) diff --git a/tests/rustdoc-gui/sidebar-foreign-impl-sort.goml b/tests/rustdoc-gui/sidebar-foreign-impl-sort.goml new file mode 100644 index 00000000000..f09f0971351 --- /dev/null +++ b/tests/rustdoc-gui/sidebar-foreign-impl-sort.goml @@ -0,0 +1,15 @@ +// Checks sidebar resizing close the Settings popover +go-to: "file://" + |DOC_PATH| + "/test_docs/SidebarSort/trait.Sort.html#foreign-impls" + +// Check that the sidebar contains the expected foreign implementations +assert-text: (".sidebar-elems section ul > li:nth-child(1)", "&'a str") +assert-text: (".sidebar-elems section ul > li:nth-child(2)", "AtomicBool") +assert-text: (".sidebar-elems section ul > li:nth-child(3)", "AtomicU8") +assert-text: (".sidebar-elems section ul > li:nth-child(4)", "AtomicU16") +assert-text: (".sidebar-elems section ul > li:nth-child(5)", "AtomicU32") +assert-text: (".sidebar-elems section ul > li:nth-child(6)", "Cell<u8>") +assert-text: (".sidebar-elems section ul > li:nth-child(7)", "Cell<u16>") +assert-text: (".sidebar-elems section ul > li:nth-child(8)", "u8") +assert-text: (".sidebar-elems section ul > li:nth-child(9)", "u16") +assert-text: (".sidebar-elems section ul > li:nth-child(10)", "u32") +assert-text: (".sidebar-elems section ul > li:nth-child(11)", "usize") diff --git a/tests/rustdoc-gui/source-anchor-scroll.goml b/tests/rustdoc-gui/source-anchor-scroll.goml index 4ad65bbbd61..c005af1e7a1 100644 --- a/tests/rustdoc-gui/source-anchor-scroll.goml +++ b/tests/rustdoc-gui/source-anchor-scroll.goml @@ -8,13 +8,13 @@ set-window-size: (600, 800) assert-property: ("html", {"scrollTop": "0"}) click: '//a[text() = "barbar" and @href="#5-7"]' -assert-property: ("html", {"scrollTop": "208"}) +assert-property: ("html", {"scrollTop": "206"}) click: '//a[text() = "bar" and @href="#28-36"]' assert-property: ("html", {"scrollTop": "239"}) click: '//a[normalize-space() = "sub_fn" and @href="#2-4"]' -assert-property: ("html", {"scrollTop": "136"}) +assert-property: ("html", {"scrollTop": "134"}) // We now check that clicking on lines doesn't change the scroll // Extra information: the "sub_fn" function header is on line 1. click: '//*[@id="6"]' -assert-property: ("html", {"scrollTop": "136"}) +assert-property: ("html", {"scrollTop": "134"}) diff --git a/tests/rustdoc-gui/source-code-page-code-scroll.goml b/tests/rustdoc-gui/source-code-page-code-scroll.goml index 60012db6c8c..c15a9ae7983 100644 --- a/tests/rustdoc-gui/source-code-page-code-scroll.goml +++ b/tests/rustdoc-gui/source-code-page-code-scroll.goml @@ -2,7 +2,7 @@ go-to: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html" set-window-size: (800, 1000) // "scrollWidth" should be superior than "clientWidth". -assert-property: ("body", {"scrollWidth": 1776, "clientWidth": 800}) +assert-property: ("body", {"scrollWidth": 1780, "clientWidth": 800}) // Both properties should be equal (ie, no scroll on the code block). -assert-property: (".example-wrap .rust", {"scrollWidth": 1662, "clientWidth": 1662}) +assert-property: (".example-wrap .rust", {"scrollWidth": 1715, "clientWidth": 1715}) diff --git a/tests/rustdoc-gui/source-code-page.goml b/tests/rustdoc-gui/source-code-page.goml index afb19462521..aa5a16aac70 100644 --- a/tests/rustdoc-gui/source-code-page.goml +++ b/tests/rustdoc-gui/source-code-page.goml @@ -3,7 +3,7 @@ include: "utils.goml" go-to: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html" show-text: true // Check that we can click on the line number. -click: ".src-line-numbers > a:nth-child(4)" // This is the anchor for line 4. +click: "//a[@data-nosnippet and text()='4']" // This is the anchor 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"}) @@ -14,11 +14,11 @@ assert-attribute: ("//*[@id='4']", {"class": "line-highlighted"}) assert-css: ("//*[@id='4']", {"border-right-width": "0px"}) // We now check that the good anchors are highlighted go-to: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html#4-6" -assert-attribute-false: (".src-line-numbers > a:nth-child(3)", {"class": "line-highlighted"}) -assert-attribute: (".src-line-numbers > a:nth-child(4)", {"class": "line-highlighted"}) -assert-attribute: (".src-line-numbers > a:nth-child(5)", {"class": "line-highlighted"}) -assert-attribute: (".src-line-numbers > a:nth-child(6)", {"class": "line-highlighted"}) -assert-attribute-false: (".src-line-numbers > a:nth-child(7)", {"class": "line-highlighted"}) +assert-attribute-false: ("//a[@data-nosnippet and text()='3']", {"class": "line-highlighted"}) +assert-attribute: ("//a[@data-nosnippet and text()='4']", {"class": "line-highlighted"}) +assert-attribute: ("//a[@data-nosnippet and text()='5']", {"class": "line-highlighted"}) +assert-attribute: ("//a[@data-nosnippet and text()='6']", {"class": "line-highlighted"}) +assert-attribute-false: ("//a[@data-nosnippet and text()='7']", {"class": "line-highlighted"}) define-function: ( "check-colors", @@ -26,12 +26,12 @@ define-function: ( block { call-function: ("switch-theme", {"theme": |theme|}) assert-css: ( - ".src-line-numbers > a:not(.line-highlighted)", + "a[data-nosnippet]:not(.line-highlighted)", {"color": |color|, "background-color": |background_color|}, ALL, ) assert-css: ( - ".src-line-numbers > a.line-highlighted", + "a[data-nosnippet].line-highlighted", {"color": |highlight_color|, "background-color": |highlight_background_color|}, ALL, ) @@ -61,37 +61,37 @@ call-function: ("check-colors", { }) // This is to ensure that the content is correctly align with the line numbers. -compare-elements-position: ("//*[@id='1']", ".rust > code > span", ["y"]) +compare-elements-position-near: ("//*[@id='1']", ".rust > code > span", {"y": 2}) // Check the `href` property so that users can treat anchors as links. -assert-property: (".src-line-numbers > a:nth-child(1)", { +assert-property: ("//a[@data-nosnippet and text()='1']", { "href": |DOC_PATH| + "/src/test_docs/lib.rs.html#1" }, ENDS_WITH) -assert-property: (".src-line-numbers > a:nth-child(2)", { +assert-property: ("//a[@data-nosnippet and text()='2']", { "href": |DOC_PATH| + "/src/test_docs/lib.rs.html#2" }, ENDS_WITH) -assert-property: (".src-line-numbers > a:nth-child(3)", { +assert-property: ("//a[@data-nosnippet and text()='3']", { "href": |DOC_PATH| + "/src/test_docs/lib.rs.html#3" }, ENDS_WITH) -assert-property: (".src-line-numbers > a:nth-child(4)", { +assert-property: ("//a[@data-nosnippet and text()='4']", { "href": |DOC_PATH| + "/src/test_docs/lib.rs.html#4" }, ENDS_WITH) -assert-property: (".src-line-numbers > a:nth-child(5)", { +assert-property: ("//a[@data-nosnippet and text()='5']", { "href": |DOC_PATH| + "/src/test_docs/lib.rs.html#5" }, ENDS_WITH) -assert-property: (".src-line-numbers > a:nth-child(6)", { +assert-property: ("//a[@data-nosnippet and text()='6']", { "href": |DOC_PATH| + "/src/test_docs/lib.rs.html#6" }, ENDS_WITH) // Assert that the line numbers text is aligned to the right. -assert-css: (".src-line-numbers", {"text-align": "right"}) +assert-css: ("a[data-nosnippet]", {"text-align": "right"}, ALL) // 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!). go-to: "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": 88, "y": 171}) -// We click on the left of the "1" anchor but still in the "src-line-number" `<pre>`. -click: (163, 77) +assert-position: ("//*[@id='1']", {"x": 81, "y": 169}) +// We click on the left of the "1" anchor but still in the `a[data-nosnippet]`. +click: (77, 163) assert-document-property: ({"URL": "/lib.rs.html"}, ENDS_WITH) // Checking the source code sidebar. diff --git a/tests/rustdoc-gui/src/test_docs/lib.rs b/tests/rustdoc-gui/src/test_docs/lib.rs index 1a9ffbe8898..f9c20ab22b8 100644 --- a/tests/rustdoc-gui/src/test_docs/lib.rs +++ b/tests/rustdoc-gui/src/test_docs/lib.rs @@ -713,3 +713,21 @@ pub trait ItemsTrait { /// blablala fn bar(); } + +pub mod SidebarSort { + use std::cell::Cell; + use std::sync::atomic::*; + pub trait Sort {} + + impl Sort for u32 {} + impl Sort for u8 {} + impl Sort for u16 {} + impl Sort for usize {} + impl Sort for AtomicU32 {} + impl Sort for AtomicU16 {} + impl Sort for AtomicU8 {} + impl Sort for AtomicBool {} + impl Sort for Cell<u16> {} + impl Sort for Cell<u8> {} + impl<'a> Sort for &'a str {} +} |
