diff options
Diffstat (limited to 'src/test/rustdoc-gui')
| -rw-r--r-- | src/test/rustdoc-gui/codeblock-tooltip.goml | 2 | ||||
| -rw-r--r-- | src/test/rustdoc-gui/cursor.goml | 24 | ||||
| -rw-r--r-- | src/test/rustdoc-gui/help-page.goml | 38 | ||||
| -rw-r--r-- | src/test/rustdoc-gui/scrape-examples-button-focus.goml | 14 | ||||
| -rw-r--r-- | src/test/rustdoc-gui/search-result-color.goml | 53 | ||||
| -rw-r--r-- | src/test/rustdoc-gui/search-result-display.goml | 3 | ||||
| -rw-r--r-- | src/test/rustdoc-gui/sidebar-source-code-display.goml | 44 | ||||
| -rw-r--r-- | src/test/rustdoc-gui/sidebar-source-code.goml | 2 | ||||
| -rw-r--r-- | src/test/rustdoc-gui/src/scrape_examples/Cargo.lock | 7 | ||||
| -rw-r--r-- | src/test/rustdoc-gui/src/scrape_examples/Cargo.toml | 8 | ||||
| -rw-r--r-- | src/test/rustdoc-gui/src/scrape_examples/examples/check.rs | 25 | ||||
| -rw-r--r-- | src/test/rustdoc-gui/src/scrape_examples/src/lib.rs | 7 | ||||
| -rw-r--r-- | src/test/rustdoc-gui/src/test_docs/lib.rs | 5 | ||||
| -rw-r--r-- | src/test/rustdoc-gui/struct-fields.goml | 5 |
14 files changed, 209 insertions, 28 deletions
diff --git a/src/test/rustdoc-gui/codeblock-tooltip.goml b/src/test/rustdoc-gui/codeblock-tooltip.goml index caa1ab8f31e..4d923be3e78 100644 --- a/src/test/rustdoc-gui/codeblock-tooltip.goml +++ b/src/test/rustdoc-gui/codeblock-tooltip.goml @@ -146,7 +146,7 @@ call-function: ("check-colors", { }) call-function: ("check-colors", { "theme": "light", - "background": "rgb(253, 255, 211)", + "background": "rgb(0, 0, 0)", "color": "rgb(255, 255, 255)", "border": "rgb(224, 224, 224)", }) diff --git a/src/test/rustdoc-gui/cursor.goml b/src/test/rustdoc-gui/cursor.goml new file mode 100644 index 00000000000..b2e91cb81fb --- /dev/null +++ b/src/test/rustdoc-gui/cursor.goml @@ -0,0 +1,24 @@ +// This test ensures that several clickable items actually have the pointer cursor. +goto: "file://" + |DOC_PATH| + "/lib2/struct.Foo.html" + +// the `[+]/[-]` button +assert-css: ("#toggle-all-docs", {"cursor": "pointer"}) + +// the button next to the path header +assert-css: ("#copy-path", {"cursor": "pointer"}) + +// the search tabs +write: (".search-input", "Foo") +// To be SURE that the search will be run. +press-key: 'Enter' +// Waiting for the search results to appear... +wait-for: "#titles" +assert-css: ("#titles > button", {"cursor": "pointer"}) + +// mobile sidebar toggle button +size: (500, 700) +assert-css: (".sidebar-menu-toggle", {"cursor": "pointer"}) + +// the sidebar toggle button on the source code pages +goto: "file://" + |DOC_PATH| + "/src/lib2/lib.rs.html" +assert-css: ("#sidebar-toggle > button", {"cursor": "pointer"}) diff --git a/src/test/rustdoc-gui/help-page.goml b/src/test/rustdoc-gui/help-page.goml index 392f17bfd47..799ba851c92 100644 --- a/src/test/rustdoc-gui/help-page.goml +++ b/src/test/rustdoc-gui/help-page.goml @@ -13,6 +13,44 @@ assert-css: ("#help", {"display": "block"}) compare-elements-property: (".sub", "#help", ["offsetWidth"]) compare-elements-position: (".sub", "#help", ("x")) +// Checking the color of the elements of the help menu. +show-text: true +define-function: ( + "check-colors", + (theme, color, background, box_shadow), + [ + // Setting the theme. + ("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}), + // We reload the page so the local storage settings are being used. + ("reload"), + ("assert-css", ("#help kbd", { + "color": |color|, + "background-color": |background|, + "box-shadow": |box_shadow| + " 0px -1px 0px 0px inset", + "cursor": "default", + }, ALL)), + ], +) + +call-function: ("check-colors", { + "theme": "ayu", + "color": "rgb(197, 197, 197)", + "background": "rgb(49, 69, 89)", + "box_shadow": "rgb(92, 103, 115)", +}) +call-function: ("check-colors", { + "theme": "dark", + "color": "rgb(221, 221, 221)", + "background": "rgb(250, 251, 252)", + "box_shadow": "rgb(198, 203, 209)", +}) +call-function: ("check-colors", { + "theme": "light", + "color": "rgb(0, 0, 0)", + "background": "rgb(250, 251, 252)", + "box_shadow": "rgb(198, 203, 209)", +}) + // This test ensures that opening the help popover without switching pages works. goto: "file://" + |DOC_PATH| + "/test_docs/index.html" size: (1000, 1000) // Only supported on desktop. diff --git a/src/test/rustdoc-gui/scrape-examples-button-focus.goml b/src/test/rustdoc-gui/scrape-examples-button-focus.goml new file mode 100644 index 00000000000..2a263a87a47 --- /dev/null +++ b/src/test/rustdoc-gui/scrape-examples-button-focus.goml @@ -0,0 +1,14 @@ +goto: "file://" + |DOC_PATH| + "/scrape_examples/fn.test.html" +store-property: (smallOffsetHeight, ".scraped-example-list > .scraped-example pre", "offsetHeight") +assert-property-false: (".scraped-example-list > .scraped-example pre", { + "scrollHeight": |smallOffsetHeight| +}) +focus: ".scraped-example-list > .scraped-example .expand" +press-key: "Enter" +assert-property-false: (".scraped-example-list > .scraped-example pre", { + "offsetHeight": |smallOffsetHeight| +}) +store-property: (fullOffsetHeight, ".scraped-example-list > .scraped-example pre", "offsetHeight") +assert-property: (".scraped-example-list > .scraped-example pre", { + "scrollHeight": |fullOffsetHeight| +}) diff --git a/src/test/rustdoc-gui/search-result-color.goml b/src/test/rustdoc-gui/search-result-color.goml index d437ad75970..dde43b1c980 100644 --- a/src/test/rustdoc-gui/search-result-color.goml +++ b/src/test/rustdoc-gui/search-result-color.goml @@ -366,23 +366,42 @@ assert-css: ( {"color": "rgb(0, 0, 0)", "background-color": "rgba(0, 0, 0, 0)"}, ) -// Check the alias more specifically in the dark theme. +// Check the alias. goto: "file://" + |DOC_PATH| + "/test_docs/index.html" -// We set the theme so we're sure that the correct values will be used, whatever the computer -// this test is running on. -local-storage: { - "rustdoc-theme": "dark", - "rustdoc-use-system-theme": "false", -} // If the text isn't displayed, the browser doesn't compute color style correctly... show-text: true -// We reload the page so the local storage settings are being used. -reload: -write: (".search-input", "thisisanalias") -// To be SURE that the search will be run. -press-key: 'Enter' -// Waiting for the search results to appear... -wait-for: "#titles" -// Checking that the colors for the alias element are the ones expected. -assert-css: (".result-name > .alias", {"color": "rgb(255, 255, 255)"}) -assert-css: (".result-name > .alias > .grey", {"color": "rgb(204, 204, 204)"}) + +define-function: ( + "check-alias", + (theme, alias, grey), + [ + ("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}), + ("reload"), + ("write", (".search-input", "thisisanalias")), + // To be SURE that the search will be run. + ("press-key", 'Enter'), + // Waiting for the search results to appear... + ("wait-for", "#titles"), + // Checking that the colors for the alias element are the ones expected. + ("assert-css", (".result-name > .alias", {"color": |alias|})), + ("assert-css", (".result-name > .alias > .grey", {"color": |grey|})), + // Leave the search results to prevent reloading with an already filled search input. + ("press-key", "Escape"), + ], +) + +call-function: ("check-alias", { + "theme": "ayu", + "alias": "rgb(197, 197, 197)", + "grey": "rgb(153, 153, 153)", +}) +call-function: ("check-alias", { + "theme": "dark", + "alias": "rgb(255, 255, 255)", + "grey": "rgb(204, 204, 204)", +}) +call-function: ("check-alias", { + "theme": "light", + "alias": "rgb(0, 0, 0)", + "grey": "rgb(153, 153, 153)", +}) diff --git a/src/test/rustdoc-gui/search-result-display.goml b/src/test/rustdoc-gui/search-result-display.goml index fa349c872ae..13a5e4c717b 100644 --- a/src/test/rustdoc-gui/search-result-display.goml +++ b/src/test/rustdoc-gui/search-result-display.goml @@ -22,7 +22,8 @@ size: (900, 900) // First we check the current width, height and position. assert-css: ("#crate-search", {"width": "223px"}) -assert-css: (".search-results-title", {"height": "44px", "width": "336px"}) +assert-css: (".search-results-title", {"height": "44px", "width": "640px"}) +assert-css: ("#search", {"width": "640px"}) // Then we update the text of one of the `<option>`. text: ( diff --git a/src/test/rustdoc-gui/sidebar-source-code-display.goml b/src/test/rustdoc-gui/sidebar-source-code-display.goml index abf8af77715..40ae4af81be 100644 --- a/src/test/rustdoc-gui/sidebar-source-code-display.goml +++ b/src/test/rustdoc-gui/sidebar-source-code-display.goml @@ -43,16 +43,24 @@ define-function: ( "#source-sidebar details[open] > .files a.selected", {"color": |color_hover|, "background-color": |background|}, )), + // Without hover or focus. ("assert-css", ("#sidebar-toggle > button", {"background-color": |background_toggle|})), // With focus. ("focus", "#sidebar-toggle > button"), - ("assert-css", ("#sidebar-toggle > button", {"background-color": |background_toggle_hover|})), + ("assert-css", ( + "#sidebar-toggle > button:focus", + {"background-color": |background_toggle_hover|}, + )), ("focus", ".search-input"), // With hover. ("move-cursor-to", "#sidebar-toggle > button"), - ("assert-css", ("#sidebar-toggle > button", {"background-color": |background_toggle_hover|})), - // Without hover. + ("assert-css", ( + "#sidebar-toggle > button:hover", + {"background-color": |background_toggle_hover|}, + )), + + // Without hover or focus. ("assert-css", ( "#source-sidebar details[open] > .files a:not(.selected)", {"color": |color|, "background-color": |background_toggle|}, @@ -60,17 +68,37 @@ define-function: ( // With focus. ("focus", "#source-sidebar details[open] > .files a:not(.selected)"), ("wait-for-css", ( - "#source-sidebar details[open] > .files a:not(.selected)", + "#source-sidebar details[open] > .files a:not(.selected):focus", {"color": |color_hover|, "background-color": |background_hover|}, )), ("focus", ".search-input"), // With hover. ("move-cursor-to", "#source-sidebar details[open] > .files a:not(.selected)"), ("assert-css", ( - "#source-sidebar details[open] > .files a:not(.selected)", + "#source-sidebar details[open] > .files a:not(.selected):hover", {"color": |color_hover|, "background-color": |background_hover|}, )), - // Without hover. + + // Without hover or focus. + ("assert-css", ( + "#source-sidebar .dir-entry summary", + {"color": |color|, "background-color": |background_toggle|}, + )), + // With focus. + ("focus", "#source-sidebar .dir-entry summary"), + ("wait-for-css", ( + "#source-sidebar .dir-entry summary:focus", + {"color": |color_hover|, "background-color": |background_hover|}, + )), + ("focus", ".search-input"), + // With hover. + ("move-cursor-to", "#source-sidebar .dir-entry summary"), + ("assert-css", ( + "#source-sidebar .dir-entry summary:hover", + {"color": |color_hover|, "background-color": |background_hover|}, + )), + + // Without hover or focus. ("assert-css", ( "#source-sidebar details[open] > .folders > details > summary", {"color": |color|, "background-color": |background_toggle|}, @@ -78,14 +106,14 @@ define-function: ( // With focus. ("focus", "#source-sidebar details[open] > .folders > details > summary"), ("wait-for-css", ( - "#source-sidebar details[open] > .folders > details > summary", + "#source-sidebar details[open] > .folders > details > summary:focus", {"color": |color_hover|, "background-color": |background_hover|}, )), ("focus", ".search-input"), // With hover. ("move-cursor-to", "#source-sidebar details[open] > .folders > details > summary"), ("assert-css", ( - "#source-sidebar details[open] > .folders > details > summary", + "#source-sidebar details[open] > .folders > details > summary:hover", {"color": |color_hover|, "background-color": |background_hover|}, )), ], diff --git a/src/test/rustdoc-gui/sidebar-source-code.goml b/src/test/rustdoc-gui/sidebar-source-code.goml index e9a987d52bb..36e4d555b8e 100644 --- a/src/test/rustdoc-gui/sidebar-source-code.goml +++ b/src/test/rustdoc-gui/sidebar-source-code.goml @@ -28,7 +28,7 @@ assert: "//*[@class='dir-entry' and @open]/*[text()='sub_mod']" // Only "another_folder" should be "open" in "lib2". assert: "//*[@class='dir-entry' and not(@open)]/*[text()='another_mod']" // All other trees should be collapsed. -assert-count: ("//*[@id='source-sidebar']/details[not(text()='lib2') and not(@open)]", 6) +assert-count: ("//*[@id='source-sidebar']/details[not(text()='lib2') and not(@open)]", 7) // We now switch to mobile mode. size: (600, 600) diff --git a/src/test/rustdoc-gui/src/scrape_examples/Cargo.lock b/src/test/rustdoc-gui/src/scrape_examples/Cargo.lock new file mode 100644 index 00000000000..7cd6d0844e4 --- /dev/null +++ b/src/test/rustdoc-gui/src/scrape_examples/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "scrape_examples" +version = "0.1.0" diff --git a/src/test/rustdoc-gui/src/scrape_examples/Cargo.toml b/src/test/rustdoc-gui/src/scrape_examples/Cargo.toml new file mode 100644 index 00000000000..aea9b657d30 --- /dev/null +++ b/src/test/rustdoc-gui/src/scrape_examples/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "scrape_examples" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/src/test/rustdoc-gui/src/scrape_examples/examples/check.rs b/src/test/rustdoc-gui/src/scrape_examples/examples/check.rs new file mode 100644 index 00000000000..3e69c6086ae --- /dev/null +++ b/src/test/rustdoc-gui/src/scrape_examples/examples/check.rs @@ -0,0 +1,25 @@ +fn main() { + for i in 0..9 { + println!("hello world!"); + println!("hello world!"); + println!("hello world!"); + println!("hello world!"); + println!("hello world!"); + println!("hello world!"); + println!("hello world!"); + println!("hello world!"); + println!("hello world!"); + } + scrape_examples::test(); + for i in 0..9 { + println!("hello world!"); + println!("hello world!"); + println!("hello world!"); + println!("hello world!"); + println!("hello world!"); + println!("hello world!"); + println!("hello world!"); + println!("hello world!"); + println!("hello world!"); + } +} diff --git a/src/test/rustdoc-gui/src/scrape_examples/src/lib.rs b/src/test/rustdoc-gui/src/scrape_examples/src/lib.rs new file mode 100644 index 00000000000..6412de2c03a --- /dev/null +++ b/src/test/rustdoc-gui/src/scrape_examples/src/lib.rs @@ -0,0 +1,7 @@ +/// # Examples +/// +/// ``` +/// test(); +/// test(); +/// ``` +pub fn test() {} diff --git a/src/test/rustdoc-gui/src/test_docs/lib.rs b/src/test/rustdoc-gui/src/test_docs/lib.rs index 8eea5ad01c0..dea154c9319 100644 --- a/src/test/rustdoc-gui/src/test_docs/lib.rs +++ b/src/test/rustdoc-gui/src/test_docs/lib.rs @@ -408,6 +408,11 @@ pub struct WithGenerics<T: TraitWithNoDocblocks, S = String, E = WhoLetTheDogOut p: P, } +pub struct StructWithPublicUndocumentedFields { + pub first: u32, + pub second: u32, +} + pub const CONST: u8 = 0; pub trait TraitWithoutGenerics { diff --git a/src/test/rustdoc-gui/struct-fields.goml b/src/test/rustdoc-gui/struct-fields.goml new file mode 100644 index 00000000000..3ec60b58cfd --- /dev/null +++ b/src/test/rustdoc-gui/struct-fields.goml @@ -0,0 +1,5 @@ +goto: "file://" + |DOC_PATH| + "/test_docs/struct.StructWithPublicUndocumentedFields.html" + +// Both fields must be on their own line. In other words, they have display: block. +store-property: (first_top, "//*[@id='structfield.first']", "offsetTop") +assert-property-false: ("//*[@id='structfield.second']", { "offsetTop": |first_top| }) |
