From 94a0819fe3a0d679c3042a77bfe6a2afc505daea Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:11:28 +0200 Subject: Adding upstream version 1.66.0+dfsg1. Signed-off-by: Daniel Baumann --- src/test/rustdoc-gui/anchor-navigable.goml | 4 +- src/test/rustdoc-gui/anchors.goml | 121 +++++++-- .../auto-hide-trait-implementations.goml | 2 +- src/test/rustdoc-gui/basic-code.goml | 4 +- src/test/rustdoc-gui/basic.goml | 4 +- src/test/rustdoc-gui/check-code-blocks-margin.goml | 6 +- src/test/rustdoc-gui/check-stab-in-docblock.goml | 27 ++ src/test/rustdoc-gui/check_info_sign_position.goml | 12 +- src/test/rustdoc-gui/code-blocks-overflow.goml | 4 +- src/test/rustdoc-gui/code-color.goml | 38 ++- src/test/rustdoc-gui/code-sidebar-toggle.goml | 2 +- src/test/rustdoc-gui/code-tags.goml | 14 +- src/test/rustdoc-gui/codeblock-tooltip.goml | 80 ++++++ src/test/rustdoc-gui/default-settings.goml | 2 +- src/test/rustdoc-gui/docblock-big-code-mobile.goml | 2 +- .../docblock-code-block-line-number.goml | 27 +- src/test/rustdoc-gui/docblock-details.goml | 15 +- src/test/rustdoc-gui/docblock-table-overflow.goml | 10 +- src/test/rustdoc-gui/docblock-table.goml | 4 + src/test/rustdoc-gui/duplicate-macro-reexport.goml | 2 +- src/test/rustdoc-gui/escape-key.goml | 2 +- src/test/rustdoc-gui/font-weight.goml | 20 +- src/test/rustdoc-gui/hash-item-expansion.goml | 2 +- src/test/rustdoc-gui/headers-color.goml | 173 +++++-------- src/test/rustdoc-gui/headings.goml | 198 +++++++------- src/test/rustdoc-gui/help-page.goml | 24 ++ src/test/rustdoc-gui/highlight-colors.goml | 94 +++++++ .../rustdoc-gui/huge-collection-of-constants.goml | 2 +- src/test/rustdoc-gui/impl-default-expansion.goml | 2 +- src/test/rustdoc-gui/implementors.goml | 16 +- src/test/rustdoc-gui/item-decl-colors.goml | 74 ++++++ src/test/rustdoc-gui/item-info-alignment.goml | 10 + src/test/rustdoc-gui/item-info-overflow.goml | 10 +- src/test/rustdoc-gui/item-info.goml | 8 +- src/test/rustdoc-gui/item-summary-table.goml | 4 +- src/test/rustdoc-gui/javascript-disabled.goml | 2 +- src/test/rustdoc-gui/jump-to-def-background.goml | 57 ++-- src/test/rustdoc-gui/label-next-to-symbol.goml | 28 +- src/test/rustdoc-gui/links-color.goml | 85 ++++++ src/test/rustdoc-gui/list_code_block.goml | 4 +- src/test/rustdoc-gui/mobile.goml | 6 +- src/test/rustdoc-gui/module-items-font.goml | 2 +- src/test/rustdoc-gui/no-docblock.goml | 8 + src/test/rustdoc-gui/notable-trait.goml | 128 +++++++++ .../rustdoc-gui/overflow-tooltip-information.goml | 4 +- src/test/rustdoc-gui/pocket-menu.goml | 6 +- src/test/rustdoc-gui/run-on-hover.goml | 2 +- src/test/rustdoc-gui/rust-logo.goml | 100 ++----- src/test/rustdoc-gui/search-filter.goml | 22 +- src/test/rustdoc-gui/search-form-elements.goml | 263 +++++++++++++++++++ src/test/rustdoc-gui/search-input-mobile.goml | 2 +- src/test/rustdoc-gui/search-input.goml | 23 -- src/test/rustdoc-gui/search-reexport.goml | 2 +- src/test/rustdoc-gui/search-result-color.goml | 288 ++++++++++++++++++++- .../rustdoc-gui/search-result-description.goml | 2 +- src/test/rustdoc-gui/search-result-display.goml | 33 +-- .../rustdoc-gui/search-result-go-to-first.goml | 12 +- src/test/rustdoc-gui/search-result-keyword.goml | 2 +- .../search-tab-change-title-fn-sig.goml | 10 +- src/test/rustdoc-gui/settings.goml | 15 +- src/test/rustdoc-gui/shortcuts.goml | 20 +- src/test/rustdoc-gui/sidebar-links-color.goml | 233 +++++++++++++++++ src/test/rustdoc-gui/sidebar-macro-reexport.goml | 4 +- src/test/rustdoc-gui/sidebar-mobile-scroll.goml | 31 +++ src/test/rustdoc-gui/sidebar-mobile.goml | 18 +- .../rustdoc-gui/sidebar-source-code-display.goml | 40 +-- src/test/rustdoc-gui/sidebar-source-code.goml | 6 +- src/test/rustdoc-gui/sidebar.goml | 73 ++++-- src/test/rustdoc-gui/source-anchor-scroll.goml | 4 +- src/test/rustdoc-gui/source-code-page.goml | 90 ++++++- src/test/rustdoc-gui/src-font-size.goml | 10 +- src/test/rustdoc-gui/src/lib2/lib.rs | 40 +++ src/test/rustdoc-gui/src/staged_api/Cargo.toml | 3 +- src/test/rustdoc-gui/src/staged_api/lib.rs | 2 + src/test/rustdoc-gui/src/test_docs/lib.rs | 123 +++++++++ src/test/rustdoc-gui/theme-change.goml | 4 +- src/test/rustdoc-gui/theme-in-history.goml | 4 +- src/test/rustdoc-gui/toggle-click-deadspace.goml | 9 +- src/test/rustdoc-gui/toggle-docs-mobile.goml | 2 +- src/test/rustdoc-gui/toggle-docs.goml | 4 +- src/test/rustdoc-gui/toggle-implementors.goml | 2 +- .../rustdoc-gui/toggled-open-implementations.goml | 2 +- src/test/rustdoc-gui/trait-sidebar-item-order.goml | 2 +- src/test/rustdoc-gui/type-declation-overflow.goml | 20 +- src/test/rustdoc-gui/unsafe-fn.goml | 28 ++ src/test/rustdoc-gui/where-whitespace.goml | 27 ++ 86 files changed, 2262 insertions(+), 664 deletions(-) create mode 100644 src/test/rustdoc-gui/check-stab-in-docblock.goml create mode 100644 src/test/rustdoc-gui/codeblock-tooltip.goml create mode 100644 src/test/rustdoc-gui/docblock-table.goml create mode 100644 src/test/rustdoc-gui/help-page.goml create mode 100644 src/test/rustdoc-gui/highlight-colors.goml create mode 100644 src/test/rustdoc-gui/item-decl-colors.goml create mode 100644 src/test/rustdoc-gui/item-info-alignment.goml create mode 100644 src/test/rustdoc-gui/links-color.goml create mode 100644 src/test/rustdoc-gui/no-docblock.goml create mode 100644 src/test/rustdoc-gui/notable-trait.goml create mode 100644 src/test/rustdoc-gui/search-form-elements.goml delete mode 100644 src/test/rustdoc-gui/search-input.goml create mode 100644 src/test/rustdoc-gui/sidebar-links-color.goml create mode 100644 src/test/rustdoc-gui/sidebar-mobile-scroll.goml create mode 100644 src/test/rustdoc-gui/unsafe-fn.goml create mode 100644 src/test/rustdoc-gui/where-whitespace.goml (limited to 'src/test/rustdoc-gui') diff --git a/src/test/rustdoc-gui/anchor-navigable.goml b/src/test/rustdoc-gui/anchor-navigable.goml index 424c31223..9d5c55a1e 100644 --- a/src/test/rustdoc-gui/anchor-navigable.goml +++ b/src/test/rustdoc-gui/anchor-navigable.goml @@ -4,8 +4,8 @@ // anchor and the `impl Foo`. If there were a gap, this would cause an annoying // problem: you hover `impl Foo` to see the anchor, then when you move your // mouse to the left, the anchor disappears before you reach it. -goto: file://|DOC_PATH|/test_docs/struct.Foo.html +goto: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html" // We check that ".item-info" is bigger than its content. move-cursor-to: ".impl" -assert-property: (".impl > a.anchor", {"offsetWidth": "9"}) +assert-property: (".impl > a.anchor", {"offsetWidth": "8"}) assert-css: (".impl > a.anchor", {"left": "-8px"}) diff --git a/src/test/rustdoc-gui/anchors.goml b/src/test/rustdoc-gui/anchors.goml index 84b8bbd1b..fb8e288fa 100644 --- a/src/test/rustdoc-gui/anchors.goml +++ b/src/test/rustdoc-gui/anchors.goml @@ -1,34 +1,107 @@ // This test is to ensure that the anchors (`§`) have the expected color and position. -goto: file://|DOC_PATH|/test_docs/struct.HeavilyDocumentedStruct.html -show-text: true -// This is needed to ensure that the text color is computed. -show-text: true +define-function: ( + "check-colors", + (theme, main_color, title_color, fqn_color, fqn_type_color, src_link_color, sidebar_link_color), + [ + ("goto", "file://" + |DOC_PATH| + "/staged_api/struct.Foo.html"), + // This is needed to ensure that the text color is computed. + ("show-text", true), -// Set the theme to light. -local-storage: {"rustdoc-theme": "light", "rustdoc-use-system-theme": "false"} -// We reload the page so the local storage settings are being used. -reload: + // 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: ("#toggle-all-docs", {"color": "rgb(0, 0, 0)"}) -assert-css: (".fqn .in-band a:nth-of-type(1)", {"color": "rgb(0, 0, 0)"}) -assert-css: (".fqn .in-band a:nth-of-type(2)", {"color": "rgb(173, 55, 138)"}) -assert-css: (".srclink", {"color": "rgb(56, 115, 173)"}) + ("assert-css", ("#toggle-all-docs", {"color": |main_color|})), + ("assert-css", (".fqn a:nth-of-type(1)", {"color": |fqn_color|})), + ("assert-css", (".fqn a:nth-of-type(2)", {"color": |fqn_type_color|})), + ("assert-css", ( + ".rightside .srclink", + {"color": |src_link_color|, "text-decoration": "none solid " + |src_link_color|}, + ALL, + )), + ( + "compare-elements-css", + (".rightside .srclink", ".rightside.srclink", ["color", "text-decoration"]), + ), + ( + "compare-elements-css", + (".main-heading .srclink", ".rightside.srclink", ["color", "text-decoration"]), + ), -move-cursor-to: ".main-heading .srclink" -assert-css: (".srclink", {"text-decoration": "underline solid rgb(56, 115, 173)"}) + ("move-cursor-to", ".main-heading .srclink"), + ("assert-css", ( + ".main-heading .srclink", + {"color": |src_link_color|, "text-decoration": "underline solid " + |src_link_color|}, + )), + ("move-cursor-to", ".impl-items .rightside .srclink"), + ("assert-css", ( + ".impl-items .rightside .srclink", + {"color": |src_link_color|, "text-decoration": "none solid " + |src_link_color|}, + )), + ("move-cursor-to", ".impl-items .rightside.srclink"), + ("assert-css", ( + ".impl-items .rightside.srclink", + {"color": |src_link_color|, "text-decoration": "none solid " + |src_link_color|}, + )), -assert-css: ("#top-doc-prose-title", {"color": "rgb(0, 0, 0)"}) + ("goto", "file://" + |DOC_PATH| + "/test_docs/struct.HeavilyDocumentedStruct.html"), + // Since we changed page, we need to set the theme again. + ("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: (".sidebar a", {"color": "rgb(53, 109, 164)"}) -assert-css: (".in-band a", {"color": "rgb(0, 0, 0)"}) + ("assert-css", ("#top-doc-prose-title", {"color": |title_color|})), -// We move the cursor over the "Implementations" title so the anchor is displayed. -move-cursor-to: "h2#implementations" -assert-css: ("h2#implementations a.anchor", {"color": "rgb(0, 0, 0)"}) + ("assert-css", (".sidebar a", {"color": |sidebar_link_color|})), + ("assert-css", ("h1.fqn a", {"color": |title_color|})), -// Same thing with the impl block title. -move-cursor-to: "#impl-HeavilyDocumentedStruct" -assert-css: ("#impl-HeavilyDocumentedStruct a.anchor", {"color": "rgb(0, 0, 0)"}) + // We move the cursor over the "Implementations" title so the anchor is displayed. + ("move-cursor-to", "h2#implementations"), + ("assert-css", ("h2#implementations a.anchor", {"color": |main_color|})), -assert-css: ("#title-for-struct-impl-item-doc", {"margin-left": "0px"}) + // Same thing with the impl block title. + ("move-cursor-to", "#impl-HeavilyDocumentedStruct"), + ("assert-css", ("#impl-HeavilyDocumentedStruct a.anchor", {"color": |main_color|})), + + ("assert-css", ("#title-for-struct-impl-item-doc", {"margin-left": "0px"})), + ], +) + +call-function: ( + "check-colors", + { + "theme": "ayu", + "main_color": "rgb(197, 197, 197)", + "title_color": "rgb(255, 255, 255)", + "fqn_color": "rgb(255, 255, 255)", + "fqn_type_color": "rgb(255, 160, 165)", + "src_link_color": "rgb(57, 175, 215)", + "sidebar_link_color": "rgb(83, 177, 219)", + }, +) +call-function: ( + "check-colors", + { + "theme": "dark", + "main_color": "rgb(221, 221, 221)", + "title_color": "rgb(221, 221, 221)", + "fqn_color": "rgb(221, 221, 221)", + "fqn_type_color": "rgb(45, 191, 184)", + "src_link_color": "rgb(210, 153, 29)", + "sidebar_link_color": "rgb(253, 191, 53)", + }, +) +call-function: ( + "check-colors", + { + "theme": "light", + "main_color": "rgb(0, 0, 0)", + "title_color": "rgb(0, 0, 0)", + "fqn_color": "rgb(0, 0, 0)", + "fqn_type_color": "rgb(173, 55, 138)", + "src_link_color": "rgb(56, 115, 173)", + "sidebar_link_color": "rgb(53, 109, 164)", + }, +) diff --git a/src/test/rustdoc-gui/auto-hide-trait-implementations.goml b/src/test/rustdoc-gui/auto-hide-trait-implementations.goml index 7b1358fed..0a619c352 100644 --- a/src/test/rustdoc-gui/auto-hide-trait-implementations.goml +++ b/src/test/rustdoc-gui/auto-hide-trait-implementations.goml @@ -1,5 +1,5 @@ // Checks that the setting "auto hide trait implementations" is working as expected. -goto: file://|DOC_PATH|/test_docs/struct.Foo.html +goto: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html" // By default, the trait implementations are not collapsed. assert-attribute: ("#trait-implementations-list > details", {"open": ""}, ALL) diff --git a/src/test/rustdoc-gui/basic-code.goml b/src/test/rustdoc-gui/basic-code.goml index 27deb2c98..f4ba5a128 100644 --- a/src/test/rustdoc-gui/basic-code.goml +++ b/src/test/rustdoc-gui/basic-code.goml @@ -1,3 +1,3 @@ -goto: file://|DOC_PATH|/test_docs/index.html +goto: "file://" + |DOC_PATH| + "/test_docs/index.html" click: ".srclink" -assert-count: (".line-numbers", 1) +assert-count: (".src-line-numbers", 1) diff --git a/src/test/rustdoc-gui/basic.goml b/src/test/rustdoc-gui/basic.goml index 239e51a91..60292835b 100644 --- a/src/test/rustdoc-gui/basic.goml +++ b/src/test/rustdoc-gui/basic.goml @@ -1,4 +1,4 @@ -goto: file://|DOC_PATH|/test_docs/index.html +goto: "file://" + |DOC_PATH| + "/test_docs/index.html" assert: ("#functions") -goto: ./struct.Foo.html +goto: "./struct.Foo.html" assert: ("div.item-decl") diff --git a/src/test/rustdoc-gui/check-code-blocks-margin.goml b/src/test/rustdoc-gui/check-code-blocks-margin.goml index f6266eba7..c2cec0020 100644 --- a/src/test/rustdoc-gui/check-code-blocks-margin.goml +++ b/src/test/rustdoc-gui/check-code-blocks-margin.goml @@ -1,6 +1,6 @@ // This test ensures that the docblock elements have the appropriate left margin. -goto: file://|DOC_PATH|/test_docs/fn.foo.html +goto: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html" // The top docblock elements shouldn't have left margin... -assert-css: ("#main-content .docblock.item-decl", {"margin-left": "0px"}) +assert-css: ("#main-content .item-decl", {"margin-left": "0px"}) // ... but all the others should! -assert-css: ("#main-content .docblock:not(.item-decl)", {"margin-left": "24px"}) +assert-css: ("#main-content .docblock", {"margin-left": "24px"}) diff --git a/src/test/rustdoc-gui/check-stab-in-docblock.goml b/src/test/rustdoc-gui/check-stab-in-docblock.goml new file mode 100644 index 000000000..266fa9997 --- /dev/null +++ b/src/test/rustdoc-gui/check-stab-in-docblock.goml @@ -0,0 +1,27 @@ +// This test checks that using `.stab` attributes in `.docblock` elements doesn't +// create scrollable paragraphs. +goto: "file://" + |DOC_PATH| + "/test_docs/index.html" +// Needs the text to be display to check for scrollable content. +show-text: true +size: (786, 600) +// Confirms that there 3 paragraphs. +assert-count: (".top-doc .docblock p", 3) +// Checking that there is no scrollable content. +store-property: (clientHeight, ".top-doc .docblock p:nth-of-type(1)", "clientHeight") +store-property: (clientWidth, ".top-doc .docblock p:nth-of-type(1)", "clientWidth") +assert-property: ( + ".top-doc .docblock p:nth-of-type(1)", + {"scrollHeight": |clientHeight|, "scrollWidth": |clientWidth|}, +) +store-property: (clientHeight, ".top-doc .docblock p:nth-of-type(2)", "clientHeight") +store-property: (clientWidth, ".top-doc .docblock p:nth-of-type(2)", "clientWidth") +assert-property: ( + ".top-doc .docblock p:nth-of-type(2)", + {"scrollHeight": |clientHeight|, "scrollWidth": |clientWidth|}, +) +store-property: (clientHeight, ".top-doc .docblock p:nth-of-type(3)", "clientHeight") +store-property: (clientWidth, ".top-doc .docblock p:nth-of-type(3)", "clientWidth") +assert-property: ( + ".top-doc .docblock p:nth-of-type(3)", + {"scrollHeight": |clientHeight|, "scrollWidth": |clientWidth|}, +) diff --git a/src/test/rustdoc-gui/check_info_sign_position.goml b/src/test/rustdoc-gui/check_info_sign_position.goml index 3bed7a0a0..f36e73fc5 100644 --- a/src/test/rustdoc-gui/check_info_sign_position.goml +++ b/src/test/rustdoc-gui/check_info_sign_position.goml @@ -1,11 +1,11 @@ // This test checks the position of the information on the code blocks (like // `compile_fail` or `ignore`). -goto: file://|DOC_PATH|/test_docs/index.html -goto: ./fn.check_list_code_block.html +goto: "file://" + |DOC_PATH| + "/test_docs/index.html" +goto: "./fn.check_list_code_block.html" // If the codeblock is the first element of the docblock, the information tooltip must have // have some top margin to avoid going over the toggle (the "[+]"). -assert-css: (".docblock > .information > .compile_fail", { "margin-top": "16px" }) +assert-css: (".docblock > .example-wrap.compile_fail .tooltip", { "margin-top": "16px" }) // Checks that the other codeblocks don't have this top margin. -assert-css: ("ol > li > .information > .compile_fail", { "margin-top": "0px" }) -assert-css: ("ol > li > .information > .ignore", { "margin-top": "0px" }) -assert-css: (".docblock > .information > .ignore", { "margin-top": "0px" }) +assert-css: ("ol > li > .example-wrap.compile_fail .tooltip", { "margin-top": "0px" }) +assert-css: ("ol > li > .example-wrap.ignore .tooltip", { "margin-top": "0px" }) +assert-css: (".docblock > .example-wrap.ignore .tooltip", { "margin-top": "0px" }) diff --git a/src/test/rustdoc-gui/code-blocks-overflow.goml b/src/test/rustdoc-gui/code-blocks-overflow.goml index f93f3f0ae..fbf0e890b 100644 --- a/src/test/rustdoc-gui/code-blocks-overflow.goml +++ b/src/test/rustdoc-gui/code-blocks-overflow.goml @@ -1,8 +1,8 @@ // This test ensures that codeblocks content don't overflow. -goto: file://|DOC_PATH|/lib2/sub_mod/struct.Foo.html +goto: "file://" + |DOC_PATH| + "/lib2/sub_mod/struct.Foo.html" size: (1080, 600) // There should be two codeblocks: a rust one and a non-rust one. assert-count: (".docblock > .example-wrap", 2) assert: ".docblock > .example-wrap > .language-txt" assert: ".docblock > .example-wrap > .rust-example-rendered" -assert-css: (".docblock > .example-wrap > pre", {"width": "785.25px", "overflow-x": "auto"}, ALL) +assert-css: (".docblock > .example-wrap > pre", {"width": "796px", "overflow-x": "auto"}, ALL) diff --git a/src/test/rustdoc-gui/code-color.goml b/src/test/rustdoc-gui/code-color.goml index 2f95bfb6b..118f04ad6 100644 --- a/src/test/rustdoc-gui/code-color.goml +++ b/src/test/rustdoc-gui/code-color.goml @@ -2,29 +2,23 @@ // check that the rule isn't applied on other "" elements. // // While we're at it, we also check it for the other themes. -goto: file://|DOC_PATH|/test_docs/fn.foo.html +goto: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html" // If the text isn't displayed, the browser doesn't compute color style correctly... show-text: true -// Set the theme to dark. -local-storage: {"rustdoc-theme": "dark", "rustdoc-preferred-dark-theme": "dark", "rustdoc-use-system-theme": "false"} -// We reload the page so the local storage settings are being used. -reload: -assert-css: (".docblock pre > code", {"color": "rgb(221, 221, 221)"}, ALL) -assert-css: (".docblock > p > code", {"color": "rgb(221, 221, 221)"}, ALL) +define-function: ( + "check-colors", + (theme, doc_code_color, doc_inline_code_color), + [ + // Set 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", (".docblock pre > code", {"color": |doc_code_color|}, ALL)), + ("assert-css", (".docblock > p > code", {"color": |doc_inline_code_color|}, ALL)), + ], +) -// Set the theme to ayu. -local-storage: {"rustdoc-theme": "ayu", "rustdoc-preferred-dark-theme": "ayu", "rustdoc-use-system-theme": "false"} -// We reload the page so the local storage settings are being used. -reload: - -assert-css: (".docblock pre > code", {"color": "rgb(230, 225, 207)"}, ALL) -assert-css: (".docblock > p > code", {"color": "rgb(255, 180, 84)"}, ALL) - -// Set the theme to light. -local-storage: {"rustdoc-theme": "light", "rustdoc-use-system-theme": "false"} -// We reload the page so the local storage settings are being used. -reload: - -assert-css: (".docblock pre > code", {"color": "rgb(0, 0, 0)"}, ALL) -assert-css: (".docblock > p > code", {"color": "rgb(0, 0, 0)"}, ALL) +call-function: ("check-colors", ("ayu", "rgb(230, 225, 207)", "rgb(255, 180, 84)")) +call-function: ("check-colors", ("dark", "rgb(221, 221, 221)", "rgb(221, 221, 221)")) +call-function: ("check-colors", ("light", "rgb(0, 0, 0)", "rgb(0, 0, 0)")) diff --git a/src/test/rustdoc-gui/code-sidebar-toggle.goml b/src/test/rustdoc-gui/code-sidebar-toggle.goml index 867db0569..00a0ea1e1 100644 --- a/src/test/rustdoc-gui/code-sidebar-toggle.goml +++ b/src/test/rustdoc-gui/code-sidebar-toggle.goml @@ -1,5 +1,5 @@ // This test checks that the source code pages sidebar toggle is working as expected. -goto: file://|DOC_PATH|/test_docs/index.html +goto: "file://" + |DOC_PATH| + "/test_docs/index.html" click: ".srclink" wait-for: "#sidebar-toggle" click: "#sidebar-toggle" diff --git a/src/test/rustdoc-gui/code-tags.goml b/src/test/rustdoc-gui/code-tags.goml index 200569a28..837a2c1d5 100644 --- a/src/test/rustdoc-gui/code-tags.goml +++ b/src/test/rustdoc-gui/code-tags.goml @@ -1,20 +1,20 @@ // This test ensures that items and documentation code blocks are wrapped in

-goto: file://|DOC_PATH|/test_docs/fn.foo.html
+goto: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html"
 size: (1080, 600)
-// There should be three doc codeblocks
+// There should be four doc codeblocks.
 // Check that their content is inside 

-assert-count: (".example-wrap pre > code", 3)
+assert-count: (".example-wrap pre > code", 4)
 // Check that function signature is inside 

 assert: "pre.rust.fn > code"
 
-goto: file://|DOC_PATH|/test_docs/struct.Foo.html
+goto: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html"
 assert: "pre.rust.struct > code"
 
-goto: file://|DOC_PATH|/test_docs/enum.AnEnum.html
+goto: "file://" + |DOC_PATH| + "/test_docs/enum.AnEnum.html"
 assert: "pre.rust.enum > code"
 
-goto: file://|DOC_PATH|/test_docs/trait.AnotherOne.html
+goto: "file://" + |DOC_PATH| + "/test_docs/trait.AnotherOne.html"
 assert: "pre.rust.trait > code"
 
-goto: file://|DOC_PATH|/test_docs/type.SomeType.html
+goto: "file://" + |DOC_PATH| + "/test_docs/type.SomeType.html"
 assert: "pre.rust.typedef > code"
diff --git a/src/test/rustdoc-gui/codeblock-tooltip.goml b/src/test/rustdoc-gui/codeblock-tooltip.goml
new file mode 100644
index 000000000..8e681a2a0
--- /dev/null
+++ b/src/test/rustdoc-gui/codeblock-tooltip.goml
@@ -0,0 +1,80 @@
+// Checking the colors of the codeblocks tooltips.
+goto: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html"
+show-text: true
+
+define-function: (
+    "check-colors",
+    (theme),
+    [
+        // Setting the theme.
+        ("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}),
+        ("reload"),
+
+        // compile_fail block
+        ("assert-css", (
+            ".docblock .example-wrap.compile_fail .tooltip",
+            {"color": "rgba(255, 0, 0, 0.5)"},
+        )),
+        ("assert-css", (
+            ".docblock .example-wrap.compile_fail",
+            {"border-left": "2px solid rgba(255, 0, 0, 0.5)"},
+        )),
+
+        ("move-cursor-to", ".docblock .example-wrap.compile_fail"),
+
+        ("assert-css", (
+            ".docblock .example-wrap.compile_fail .tooltip",
+            {"color": "rgb(255, 0, 0)"},
+        )),
+        ("assert-css", (
+            ".docblock .example-wrap.compile_fail",
+            {"border-left": "2px solid rgb(255, 0, 0)"},
+        )),
+
+        // should_panic block
+        ("assert-css", (
+            ".docblock .example-wrap.should_panic .tooltip",
+            {"color": "rgba(255, 0, 0, 0.5)"},
+        )),
+        ("assert-css", (
+            ".docblock .example-wrap.should_panic",
+            {"border-left": "2px solid rgba(255, 0, 0, 0.5)"},
+        )),
+
+        ("move-cursor-to", ".docblock .example-wrap.should_panic"),
+
+        ("assert-css", (
+            ".docblock .example-wrap.should_panic .tooltip",
+            {"color": "rgb(255, 0, 0)"},
+        )),
+        ("assert-css", (
+            ".docblock .example-wrap.should_panic",
+            {"border-left": "2px solid rgb(255, 0, 0)"},
+        )),
+
+        // ignore block
+        ("assert-css", (
+            ".docblock .example-wrap.ignore .tooltip",
+            {"color": "rgba(255, 142, 0, 0.6)"},
+        )),
+        ("assert-css", (
+            ".docblock .example-wrap.ignore",
+            {"border-left": "2px solid rgba(255, 142, 0, 0.6)"},
+        )),
+
+        ("move-cursor-to", ".docblock .example-wrap.ignore"),
+
+        ("assert-css", (
+            ".docblock .example-wrap.ignore .tooltip",
+            {"color": "rgb(255, 142, 0)"},
+        )),
+        ("assert-css", (
+            ".docblock .example-wrap.ignore",
+            {"border-left": "2px solid rgb(255, 142, 0)"},
+        )),
+    ],
+)
+
+call-function: ("check-colors", ("ayu"))
+call-function: ("check-colors", ("dark"))
+call-function: ("check-colors", ("light"))
diff --git a/src/test/rustdoc-gui/default-settings.goml b/src/test/rustdoc-gui/default-settings.goml
index 90f0b087a..ab27b001e 100644
--- a/src/test/rustdoc-gui/default-settings.goml
+++ b/src/test/rustdoc-gui/default-settings.goml
@@ -2,7 +2,7 @@
 //
 // The "settings" crate uses "ayu" as default setting, which is what we will
 // check.
-goto: file://|DOC_PATH|/settings/index.html
+goto: "file://" + |DOC_PATH| + "/settings/index.html"
 // Wait a bit to be sure the default theme is applied.
 // If the theme isn't applied, the command will time out.
 wait-for-css: ("body", {"background-color": "rgb(15, 20, 25)"})
diff --git a/src/test/rustdoc-gui/docblock-big-code-mobile.goml b/src/test/rustdoc-gui/docblock-big-code-mobile.goml
index 02f79f1fc..9f8df44d7 100644
--- a/src/test/rustdoc-gui/docblock-big-code-mobile.goml
+++ b/src/test/rustdoc-gui/docblock-big-code-mobile.goml
@@ -1,7 +1,7 @@
 // If we have a long ``, we need to ensure that it'll be fully displayed on mobile, meaning
 // that it'll be on two lines.
 emulate: "iPhone 8" // it has the following size: (375, 667)
-goto: file://|DOC_PATH|/test_docs/long_code_block/index.html
+goto: "file://" + |DOC_PATH| + "/test_docs/long_code_block/index.html"
 // We now check that the block is on two lines:
 show-text: true // We need to enable text draw to be able to have the "real" size
 // Little explanations for this test: if the text wasn't displayed on two lines, it would take
diff --git a/src/test/rustdoc-gui/docblock-code-block-line-number.goml b/src/test/rustdoc-gui/docblock-code-block-line-number.goml
index baf9651c4..911ee34be 100644
--- a/src/test/rustdoc-gui/docblock-code-block-line-number.goml
+++ b/src/test/rustdoc-gui/docblock-code-block-line-number.goml
@@ -1,8 +1,8 @@
 // Checks that the setting "line numbers" is working as expected.
-goto: file://|DOC_PATH|/test_docs/fn.foo.html
+goto: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html"
 
 // We check that without this setting, there is no line number displayed.
-assert-false: "pre.line-number"
+assert-false: "pre.example-line-numbers"
 
 // We now set the setting to show the line numbers on code examples.
 local-storage: {"rustdoc-line-numbers": "true" }
@@ -10,13 +10,30 @@ local-storage: {"rustdoc-line-numbers": "true" }
 reload:
 
 // We wait for them to be added into the DOM by the JS...
-wait-for: "pre.line-number"
+wait-for: "pre.example-line-numbers"
 // If the test didn't fail, it means that it was found!
 // Let's now check some CSS properties...
-assert-css: ("pre.line-number", {
+assert-css: ("pre.example-line-numbers", {
     "margin": "0px",
     "padding": "13px 8px",
     "text-align": "right",
 })
 // The first code block has two lines so let's check its `
` elements lists both of them.
-assert-text: ("pre.line-number", "1\n2")
+assert-text: ("pre.example-line-numbers", "1\n2")
+
+// Now, try changing the setting dynamically. We'll turn it off, using the settings menu,
+// and make sure it goes away.
+
+// First, open the settings menu.
+click: "#settings-menu"
+wait-for: "#settings"
+assert-css: ("#settings", {"display": "block"})
+
+// Then, click the toggle button.
+click: "input#line-numbers + .slider"
+wait-for: 100 // wait-for-false does not exist
+assert-false: "pre.example-line-numbers"
+
+// Finally, turn it on again.
+click: "input#line-numbers + .slider"
+wait-for: "pre.example-line-numbers"
diff --git a/src/test/rustdoc-gui/docblock-details.goml b/src/test/rustdoc-gui/docblock-details.goml
index f6287ade2..9ae571efb 100644
--- a/src/test/rustdoc-gui/docblock-details.goml
+++ b/src/test/rustdoc-gui/docblock-details.goml
@@ -1,5 +1,5 @@
 // This ensures that the `
`/`` elements are displayed as expected. -goto: file://|DOC_PATH|/test_docs/details/struct.Details.html +goto: "file://" + |DOC_PATH| + "/test_docs/details/struct.Details.html" show-text: true local-storage: {"rustdoc-theme": "dark", "rustdoc-use-system-theme": "false"} reload: @@ -14,10 +14,21 @@ assert-css: ( // We now check that the `` doesn't have a bottom border and has the correct display. assert-css: ( ".top-doc .docblock summary h4", - {"border-bottom": "0px none rgb(210, 210, 210)"}, + {"border-bottom-width": "0px"}, ) // This allows to ensure that summary is on one line only! assert-property: (".top-doc .docblock summary h4", {"offsetHeight": "33"}) assert-css: (".top-doc .docblock summary h4", {"margin-top": "15px", "margin-bottom": "5px"}) // So `33 + 15 + 5` == `53` assert-property: (".top-doc .docblock summary", {"offsetHeight": "53"}) + +// We now check the `` on a method. +assert-css: ( + ".method-toggle .docblock summary h4", + {"border-bottom-width": "0px"}, +) +// This allows to ensure that summary is on one line only! +assert-property: (".method-toggle .docblock summary h4", {"offsetHeight": "30"}) +assert-css: (".method-toggle .docblock summary h4", {"margin-top": "15px", "margin-bottom": "5px"}) +// So `30 + 15 + 5` == `50` +assert-property: (".method-toggle .docblock summary", {"offsetHeight": "50"}) diff --git a/src/test/rustdoc-gui/docblock-table-overflow.goml b/src/test/rustdoc-gui/docblock-table-overflow.goml index af76d2ea4..d8670089a 100644 --- a/src/test/rustdoc-gui/docblock-table-overflow.goml +++ b/src/test/rustdoc-gui/docblock-table-overflow.goml @@ -1,12 +1,12 @@ // This test ensures that the type declaration content overflow is handled inside the
 directly.
-goto: file://|DOC_PATH|/lib2/long_table/struct.Foo.html
+goto: "file://" + |DOC_PATH| + "/lib2/long_table/struct.Foo.html"
 // We set a fixed size so there is no chance of "random" resize.
 size: (1100, 800)
 // Logically, the ".docblock" and the "

" should have the same scroll width. compare-elements-property: (".top-doc .docblock", ".top-doc .docblock > p", ["scrollWidth"]) -assert-property: (".top-doc .docblock", {"scrollWidth": "801"}) +assert-property: (".top-doc .docblock", {"scrollWidth": "816"}) // However, since there is overflow in the , its scroll width is bigger. -assert-property: (".top-doc .docblock table", {"scrollWidth": "1573"}) +assert-property: (".top-doc .docblock table", {"scrollWidth": "1572"}) // Checking it works on other doc blocks as well... @@ -16,6 +16,6 @@ compare-elements-property: ( "#implementations-list > details .docblock > p", ["scrollWidth"], ) -assert-property: ("#implementations-list > details .docblock", {"scrollWidth": "801"}) +assert-property: ("#implementations-list > details .docblock", {"scrollWidth": "816"}) // However, since there is overflow in the
, its scroll width is bigger. -assert-property: ("#implementations-list > details .docblock table", {"scrollWidth": "1573"}) +assert-property: ("#implementations-list > details .docblock table", {"scrollWidth": "1572"}) diff --git a/src/test/rustdoc-gui/docblock-table.goml b/src/test/rustdoc-gui/docblock-table.goml new file mode 100644 index 000000000..4e316ce0b --- /dev/null +++ b/src/test/rustdoc-gui/docblock-table.goml @@ -0,0 +1,4 @@ +goto: "file://" + |DOC_PATH| + "/test_docs/doc_block_table/struct.DocBlockTable.html#method.func" + +compare-elements-css: (".impl-items .docblock table th", ".top-doc .docblock table th", ["border"]) +compare-elements-css: (".impl-items .docblock table td", ".top-doc .docblock table td", ["border"]) diff --git a/src/test/rustdoc-gui/duplicate-macro-reexport.goml b/src/test/rustdoc-gui/duplicate-macro-reexport.goml index 9ea599062..496203c12 100644 --- a/src/test/rustdoc-gui/duplicate-macro-reexport.goml +++ b/src/test/rustdoc-gui/duplicate-macro-reexport.goml @@ -1,5 +1,5 @@ // This test ensures that there is no macro duplicates in the sidebar. -goto: file://|DOC_PATH|/test_docs/macro.a.html +goto: "file://" + |DOC_PATH| + "/test_docs/macro.a.html" // Waiting for the elements in the sidebar to be rendered. wait-for: ".sidebar-elems .macro" // Check there is only one macro named "a" listed in the sidebar. diff --git a/src/test/rustdoc-gui/escape-key.goml b/src/test/rustdoc-gui/escape-key.goml index a5afb037d..78e9f2309 100644 --- a/src/test/rustdoc-gui/escape-key.goml +++ b/src/test/rustdoc-gui/escape-key.goml @@ -1,6 +1,6 @@ // This test ensures that the "Escape" shortcut is handled correctly based on the // current content displayed. -goto: file://|DOC_PATH|/test_docs/index.html +goto: "file://" + |DOC_PATH| + "/test_docs/index.html" // First, we check that the search results are hidden when the Escape key is pressed. write: (".search-input", "test") // To be SURE that the search will be run. diff --git a/src/test/rustdoc-gui/font-weight.goml b/src/test/rustdoc-gui/font-weight.goml index 5f29fde66..8ba005b0c 100644 --- a/src/test/rustdoc-gui/font-weight.goml +++ b/src/test/rustdoc-gui/font-weight.goml @@ -1,6 +1,6 @@ // This test checks that the font weight is correctly applied. -goto: file://|DOC_PATH|/lib2/struct.Foo.html -assert-css: ("//*[@class='docblock item-decl']//a[text()='Alias']", {"font-weight": "400"}) +goto: "file://" + |DOC_PATH| + "/lib2/struct.Foo.html" +assert-css: ("//*[@class='item-decl']//a[text()='Alias']", {"font-weight": "400"}) assert-css: ( "//*[@class='structfield small-section-header']//a[text()='Alias']", {"font-weight": "400"}, @@ -9,17 +9,17 @@ assert-css: ("#method\.a_method > .code-header", {"font-weight": "600"}) assert-css: ("#associatedtype\.X > .code-header", {"font-weight": "600"}) assert-css: ("#associatedconstant\.Y > .code-header", {"font-weight": "600"}) -goto: file://|DOC_PATH|/test_docs/type.SomeType.html +goto: "file://" + |DOC_PATH| + "/test_docs/type.SomeType.html" assert-css: (".top-doc .docblock p", {"font-weight": "400"}, ALL) -goto: file://|DOC_PATH|/test_docs/struct.Foo.html -assert-css: (".impl-items .method", {"font-weight": "600"}, ALL) +goto: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html" +assert-css: (".impl-items .method > .code-header", {"font-weight": "600"}, ALL) -goto: file://|DOC_PATH|/lib2/trait.Trait.html +goto: "file://" + |DOC_PATH| + "/lib2/trait.Trait.html" // This is a complex selector, so here's how it works: // -// * //*[@class='docblock item-decl'] — selects element of any tag with classes docblock and item-decl +// * //*[@class='item-decl'] — selects element of any tag with classes docblock and item-decl // * /pre[@class='rust trait'] — selects immediate child with tag pre and classes rust and trait // * /code — selects immediate child with tag code // * /a[@class='constant'] — selects immediate child with tag a and class constant @@ -29,11 +29,11 @@ goto: file://|DOC_PATH|/lib2/trait.Trait.html // This uses '/parent::*' as a proxy for the style of the text node. // We can't just select the '' because intermediate tags could be added. assert-count: ( - "//*[@class='docblock item-decl']/pre[@class='rust trait']/code/a[@class='constant']//text()/parent::*", + "//*[@class='item-decl']/pre[@class='rust trait']/code/a[@class='constant']//text()/parent::*", 1, ) assert-css: ( - "//*[@class='docblock item-decl']/pre[@class='rust trait']/code/a[@class='constant']//text()/parent::*", + "//*[@class='item-decl']/pre[@class='rust trait']/code/a[@class='constant']//text()/parent::*", {"font-weight": "400"}, ) @@ -41,4 +41,4 @@ assert-count: (".methods .associatedtype", 1) assert-css: (".methods .associatedtype", {"font-weight": "600"}) assert-count: (".methods .constant", 1) assert-css: (".methods .constant", {"font-weight": "600"}) -assert-css: (".methods .method", {"font-weight": "600"}) +assert-css: (".methods .method > .code-header", {"font-weight": "600"}) diff --git a/src/test/rustdoc-gui/hash-item-expansion.goml b/src/test/rustdoc-gui/hash-item-expansion.goml index 861f69283..3cf94f624 100644 --- a/src/test/rustdoc-gui/hash-item-expansion.goml +++ b/src/test/rustdoc-gui/hash-item-expansion.goml @@ -1,5 +1,5 @@ // This test ensures that the element corresponding to the hash is displayed. -goto: file://|DOC_PATH|/test_docs/struct.Foo.html#method.borrow +goto: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html#method.borrow" // In the blanket implementations list, "Borrow" is the second one, hence the ":nth(2)". assert-attribute: ("#blanket-implementations-list > details:nth-child(2)", {"open": ""}) // We first check that the impl block is open by default. diff --git a/src/test/rustdoc-gui/headers-color.goml b/src/test/rustdoc-gui/headers-color.goml index a47a9c8a1..c80a49c52 100644 --- a/src/test/rustdoc-gui/headers-color.goml +++ b/src/test/rustdoc-gui/headers-color.goml @@ -1,117 +1,70 @@ // This test check for headers text and background colors for the different themes. -goto: file://|DOC_PATH|/test_docs/struct.Foo.html -// This is needed so that the text color is computed. -show-text: true - -// Ayu theme -local-storage: { - "rustdoc-theme": "ayu", - "rustdoc-preferred-dark-theme": "ayu", - "rustdoc-use-system-theme": "false", -} -reload: - -assert-css: ( - ".impl", - {"color": "rgb(197, 197, 197)", "background-color": "rgba(0, 0, 0, 0)"}, - ALL, -) -assert-css: ( - ".impl .code-header", - {"color": "rgb(230, 225, 207)", "background-color": "rgb(15, 20, 25)"}, - ALL, +define-function: ( + "check-colors", + (theme, color, code_header_color, focus_background_color, headings_color), + [ + ("goto", "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html"), + // This is needed so that the text color is computed. + ("show-text", true), + ("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}), + ("reload"), + ("assert-css", ( + ".impl", + {"color": |color|, "background-color": "rgba(0, 0, 0, 0)"}, + ALL, + )), + ("assert-css", ( + ".impl .code-header", + {"color": |code_header_color|, "background-color": "rgba(0, 0, 0, 0)"}, + ALL, + )), + ("goto", "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html#impl-Foo"), + ("assert-css", ( + "#impl-Foo", + {"color": |color|, "background-color": |focus_background_color|}, + )), + ("goto", "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html#method.must_use"), + ("assert-css", ( + "#method\.must_use", + {"color": |color|, "background-color": |focus_background_color|}, + ALL, + )), + ("goto", "file://" + |DOC_PATH| + "/test_docs/index.html"), + ("assert-css", (".small-section-header a", {"color": |color|}, ALL)), + ("goto", "file://" + |DOC_PATH| + "/test_docs/struct.HeavilyDocumentedStruct.html"), + // We select headings (h2, h3, h...). + ("assert-css", (".docblock > :not(p) > a", {"color": |headings_color|}, ALL)), + ], ) -goto: file://|DOC_PATH|/test_docs/struct.Foo.html#impl-Foo -assert-css: ( - "#impl-Foo", - {"color": "rgb(197, 197, 197)", "background-color": "rgba(255, 236, 164, 0.06)"}, +call-function: ( + "check-colors", + { + "theme": "ayu", + "color": "rgb(197, 197, 197)", + "code_header_color": "rgb(230, 225, 207)", + "focus_background_color": "rgba(255, 236, 164, 0.06)", + "headings_color": "rgb(57, 175, 215)", + }, ) - -goto: file://|DOC_PATH|/test_docs/struct.Foo.html#method.must_use -assert-css: ( - "#method\.must_use", - {"color": "rgb(197, 197, 197)", "background-color": "rgba(255, 236, 164, 0.06)"}, - ALL, +call-function: ( + "check-colors", + { + "theme": "dark", + "color": "rgb(221, 221, 221)", + "code_header_color": "rgb(221, 221, 221)", + "focus_background_color": "rgb(73, 74, 61)", + "headings_color": "rgb(210, 153, 29)", + }, ) - -goto: file://|DOC_PATH|/test_docs/index.html -assert-css: (".small-section-header a", {"color": "rgb(197, 197, 197)"}, ALL) - -goto: file://|DOC_PATH|/test_docs/struct.HeavilyDocumentedStruct.html -// We select headings (h2, h3, h...). -assert-css: (".docblock > :not(p) > a", {"color": "rgb(57, 175, 215)"}, ALL) - -// Dark theme -local-storage: { - "rustdoc-theme": "dark", - "rustdoc-preferred-dark-theme": "dark", - "rustdoc-use-system-theme": "false", -} -goto: file://|DOC_PATH|/test_docs/struct.Foo.html - -assert-css: ( - ".impl", - {"color": "rgb(221, 221, 221)", "background-color": "rgba(0, 0, 0, 0)"}, - ALL, -) -assert-css: ( - ".impl .code-header", - {"color": "rgb(221, 221, 221)", "background-color": "rgb(53, 53, 53)"}, - ALL, -) - -goto: file://|DOC_PATH|/test_docs/struct.Foo.html#impl-Foo -assert-css: ( - "#impl-Foo", - {"color": "rgb(221, 221, 221)", "background-color": "rgb(73, 74, 61)"}, -) - -goto: file://|DOC_PATH|/test_docs/struct.Foo.html#method.must_use -assert-css: ( - "#method\.must_use", - {"color": "rgb(221, 221, 221)", "background-color": "rgb(73, 74, 61)"}, - ALL, +call-function: ( + "check-colors", + { + "theme": "light", + "color": "rgb(0, 0, 0)", + "code_header_color": "rgb(0, 0, 0)", + "focus_background_color": "rgb(253, 255, 211)", + "headings_color": "rgb(56, 115, 173)", + }, ) - -goto: file://|DOC_PATH|/test_docs/index.html -assert-css: (".small-section-header a", {"color": "rgb(221, 221, 221)"}, ALL) - -goto: file://|DOC_PATH|/test_docs/struct.HeavilyDocumentedStruct.html -// We select headings (h2, h3, h...). -assert-css: (".docblock > :not(p) > a", {"color": "rgb(210, 153, 29)"}, ALL) - -// Light theme -local-storage: {"rustdoc-theme": "light", "rustdoc-use-system-theme": "false"} -reload: - -goto: file://|DOC_PATH|/test_docs/struct.Foo.html - -assert-css: ( - ".impl", - {"color": "rgb(0, 0, 0)", "background-color": "rgba(0, 0, 0, 0)"}, - ALL, -) -assert-css: ( - ".impl .code-header", - {"color": "rgb(0, 0, 0)", "background-color": "rgb(255, 255, 255)"}, - ALL, -) - -goto: file://|DOC_PATH|/test_docs/struct.Foo.html#impl-Foo -assert-css: ("#impl-Foo", {"color": "rgb(0, 0, 0)", "background-color": "rgb(253, 255, 211)"}) - -goto: file://|DOC_PATH|/test_docs/struct.Foo.html#method.must_use -assert-css: ( - "#method\.must_use", - {"color": "rgb(0, 0, 0)", "background-color": "rgb(253, 255, 211)"}, - ALL, -) - -goto: file://|DOC_PATH|/test_docs/index.html -assert-css: (".small-section-header a", {"color": "rgb(0, 0, 0)"}, ALL) - -goto: file://|DOC_PATH|/test_docs/struct.HeavilyDocumentedStruct.html -// We select headings (h2, h3, h...). -assert-css: (".docblock > :not(p) > a", {"color": "rgb(56, 115, 173)"}, ALL) diff --git a/src/test/rustdoc-gui/headings.goml b/src/test/rustdoc-gui/headings.goml index 8c2c3df15..85e17ca95 100644 --- a/src/test/rustdoc-gui/headings.goml +++ b/src/test/rustdoc-gui/headings.goml @@ -11,7 +11,7 @@ // 18px 1.125em // 16px 1rem // 14px 0.875rem -goto: file://|DOC_PATH|/test_docs/struct.HeavilyDocumentedStruct.html +goto: "file://" + |DOC_PATH| + "/test_docs/struct.HeavilyDocumentedStruct.html" assert-css: ("h1.fqn", {"font-size": "24px"}) @@ -50,7 +50,7 @@ assert-css: ("h6#sub-heading-for-struct-impl-item-doc", {"font-size": "14px"}) assert-css: ("h6#sub-heading-for-struct-impl-item-doc", {"border-bottom-width": "0px"}) assert-css: ("h6#sub-sub-heading-for-struct-impl-item-doc", {"font-size": "14px"}) -goto: file://|DOC_PATH|/test_docs/enum.HeavilyDocumentedEnum.html +goto: "file://" + |DOC_PATH| + "/test_docs/enum.HeavilyDocumentedEnum.html" assert-css: ("h1.fqn", {"font-size": "24px"}) @@ -106,10 +106,10 @@ assert-css: ("h6#sub-heading-for-enum-impl-item-doc", {"border-bottom-width": "0 assert-css: ("h6#sub-sub-heading-for-enum-impl-item-doc", {"font-size": "14px"}) assert-css: ("h6#sub-sub-heading-for-enum-impl-item-doc", {"border-bottom-width": "0px"}) -assert-text: (".sidebar .mod h3", "Modules") -assert-css: (".sidebar .mod h3", {"border-bottom-width": "0px"}, ALL) +assert-text: ("//ul[@class='block mod']/preceding-sibling::h3", "Modules") +assert-css: ("//ul[@class='block mod']/preceding-sibling::h3", {"border-bottom-width": "0px"}, ALL) -goto: file://|DOC_PATH|/test_docs/union.HeavilyDocumentedUnion.html +goto: "file://" + |DOC_PATH| + "/test_docs/union.HeavilyDocumentedUnion.html" assert-css: ("h1.fqn", {"font-size": "24px"}) @@ -141,7 +141,7 @@ assert-css: ("h5#title-for-union-impl-item-doc", {"border-bottom-width": "0px"}) assert-css: ("h6#sub-heading-for-union-impl-item-doc", {"font-size": "14px"}) assert-css: ("h6#sub-heading-for-union-impl-item-doc", {"border-bottom-width": "0px"}) -goto: file://|DOC_PATH|/test_docs/macro.heavily_documented_macro.html +goto: "file://" + |DOC_PATH| + "/test_docs/macro.heavily_documented_macro.html" assert-css: ("h1.fqn", {"font-size": "24px"}) @@ -150,109 +150,85 @@ assert-css: ("h2#top-doc-prose-title", {"border-bottom-width": "1px"}) assert-css: ("h3#top-doc-prose-sub-heading", {"font-size": "20px"}) assert-css: ("h3#top-doc-prose-sub-heading", {"border-bottom-width": "1px"}) -// Checking colors now. +// Needed to check colors show-text: true -local-storage: {"rustdoc-theme": "light", "rustdoc-use-system-theme": "false"} -goto: file://|DOC_PATH|/test_docs/struct.HeavilyDocumentedStruct.html -assert-css: ( - ".top-doc .docblock h2", - {"color": "rgb(0, 0, 0)", "border-bottom": "1px solid rgb(221, 221, 221)"}, -) -assert-css: ( - ".top-doc .docblock h3", - {"color": "rgb(0, 0, 0)", "border-bottom": "1px solid rgb(221, 221, 221)"}, -) -assert-css: ( - ".top-doc .docblock h4", - {"color": "rgb(0, 0, 0)", "border-bottom": "1px solid rgb(221, 221, 221)"}, -) -assert-css: ( - ".top-doc .docblock h5", - {"color": "rgb(0, 0, 0)", "border-bottom": "0px none rgb(221, 221, 221)"}, -) -assert-css: ( - "#implementations-list .docblock h4", - {"color": "rgb(0, 0, 0)", "border-bottom": "0px none rgb(221, 221, 221)"}, -) -assert-css: ( - "#implementations-list .docblock h5", - {"color": "rgb(0, 0, 0)", "border-bottom": "0px none rgb(221, 221, 221)"}, -) -assert-css: ( - "#implementations-list .docblock h6", - {"color": "rgb(0, 0, 0)", "border-bottom": "0px none rgb(221, 221, 221)"}, -) - -local-storage: {"rustdoc-theme": "dark"} -reload: -assert-css: ( - ".top-doc .docblock h2", - {"color": "rgb(221, 221, 221)", "border-bottom": "1px solid rgb(210, 210, 210)"}, -) -assert-css: ( - ".top-doc .docblock h3", - {"color": "rgb(221, 221, 221)", "border-bottom": "1px solid rgb(210, 210, 210)"}, -) -assert-css: ( - ".top-doc .docblock h4", - {"color": "rgb(221, 221, 221)", "border-bottom": "1px solid rgb(210, 210, 210)"}, -) -assert-css: ( - ".top-doc .docblock h5", - {"color": "rgb(221, 221, 221)", "border-bottom": "0px none rgb(210, 210, 210)"}, -) -assert-css: ( - "#implementations-list .docblock h4", - {"color": "rgb(221, 221, 221)", "border-bottom": "0px none rgb(210, 210, 210)"}, -) -assert-css: ( - "#implementations-list .docblock h5", - {"color": "rgb(221, 221, 221)", "border-bottom": "0px none rgb(210, 210, 210)"}, -) -assert-css: ( - "#implementations-list .docblock h6", - {"color": "rgb(221, 221, 221)", "border-bottom": "0px none rgb(210, 210, 210)"}, -) - -local-storage: {"rustdoc-theme": "ayu"} -reload: -assert-css: ( - ".top-doc .docblock h2", - {"color": "rgb(255, 255, 255)", "border-bottom": "1px solid rgb(92, 103, 115)"}, -) -assert-css: ( - ".top-doc .docblock h2", - {"color": "rgb(255, 255, 255)", "border-bottom": "1px solid rgb(92, 103, 115)"}, -) -assert-css: ( - ".top-doc .docblock h4", - {"color": "rgb(255, 255, 255)", "border-bottom": "1px solid rgb(92, 103, 115)"}, -) -assert-css: ( - ".top-doc .docblock h5", - {"color": "rgb(197, 197, 197)", "border-bottom": "0px none rgb(92, 103, 115)"}, -) -assert-css: ( - "#implementations-list .docblock h4", - {"color": "rgb(255, 255, 255)", "border-bottom": "0px none rgb(92, 103, 115)"}, -) -assert-css: ( - "#implementations-list .docblock h5", - {"color": "rgb(197, 197, 197)", "border-bottom": "0px none rgb(92, 103, 115)"}, -) -assert-css: ( - "#implementations-list .docblock h6", - {"color": "rgb(197, 197, 197)", "border-bottom": "0px none rgb(92, 103, 115)"}, -) - -local-storage: {"rustdoc-theme": "light"} -goto: file://|DOC_PATH|/staged_api/struct.Foo.html -assert-css: (".since", {"color": "rgb(128, 128, 128)"}) - -local-storage: {"rustdoc-theme": "dark"} -reload: -assert-css: (".since", {"color": "rgb(128, 128, 128)"}) - -local-storage: {"rustdoc-theme": "ayu"} -reload: -assert-css: (".since", {"color": "rgb(128, 128, 128)"}) +goto: "file://" + |DOC_PATH| + "/test_docs/struct.HeavilyDocumentedStruct.html" + +define-function: ( + "check-colors", + (theme, heading_color, small_heading_color, heading_border_color), + [ + ("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}), + ("reload"), + ("assert-css", ( + ".top-doc .docblock h2", + {"color": |heading_color|, "border-bottom": "1px solid " + |heading_border_color|}, + )), + ("assert-css", ( + ".top-doc .docblock h3", + {"color": |heading_color|, "border-bottom": "1px solid " + |heading_border_color|}, + )), + ("assert-css", ( + ".top-doc .docblock h4", + {"color": |heading_color|, "border-bottom": "1px solid " + |heading_border_color|}, + )), + ("assert-css", ( + ".top-doc .docblock h5", + {"color": |small_heading_color|, "border-bottom-width": "0px"}, + )), + ("assert-css", ( + "#implementations-list .docblock h4", + {"color": |heading_color|, "border-bottom-width": "0px"}, + )), + ("assert-css", ( + "#implementations-list .docblock h5", + {"color": |small_heading_color|, "border-bottom-width": "0px"}, + )), + ("assert-css", ( + "#implementations-list .docblock h6", + {"color": |small_heading_color|, "border-bottom-width": "0px"}, + )), + ], +) +call-function: ( + "check-colors", + { + "theme": "ayu", + "heading_color": "rgb(255, 255, 255)", + "small_heading_color": "rgb(197, 197, 197)", + "heading_border_color": "rgb(92, 103, 115)", + }, +) +call-function: ( + "check-colors", + { + "theme": "dark", + "heading_color": "rgb(221, 221, 221)", + "small_heading_color": "rgb(221, 221, 221)", + "heading_border_color": "rgb(210, 210, 210)", + }, +) +call-function: ( + "check-colors", + { + "theme": "light", + "heading_color": "rgb(0, 0, 0)", + "small_heading_color": "rgb(0, 0, 0)", + "heading_border_color": "rgb(221, 221, 221)", + }, +) + +define-function: ( + "check-since-color", + (theme), + [ + ("local-storage", {"rustdoc-theme": |theme|}), + ("reload"), + ("assert-css", (".since", {"color": "rgb(128, 128, 128)"}, ALL)), + ], +) + +goto: "file://" + |DOC_PATH| + "/staged_api/struct.Foo.html" +call-function: ("check-since-color", ("ayu")) +call-function: ("check-since-color", ("dark")) +call-function: ("check-since-color", ("light")) diff --git a/src/test/rustdoc-gui/help-page.goml b/src/test/rustdoc-gui/help-page.goml new file mode 100644 index 000000000..521e14748 --- /dev/null +++ b/src/test/rustdoc-gui/help-page.goml @@ -0,0 +1,24 @@ +// This test ensures that opening the help page in its own tab works. +goto: "file://" + |DOC_PATH| + "/help.html" +size: (1000, 1000) // Try desktop size first. +wait-for: "#help" +assert-css: ("#help", {"display": "block"}) +click: "#help-button > a" +assert-css: ("#help", {"display": "block"}) +compare-elements-property: (".sub", "#help", ["offsetWidth"]) +compare-elements-position: (".sub", "#help", ("x")) +size: (500, 1000) // Try mobile next. +assert-css: ("#help", {"display": "block"}) +compare-elements-property: (".sub", "#help", ["offsetWidth"]) +compare-elements-position: (".sub", "#help", ("x")) + +// 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. +assert-false: "#help" +click: "#help-button > a" +assert-css: ("#help", {"display": "block"}) +click: "#help-button > a" +assert-css: ("#help", {"display": "none"}) +compare-elements-property-false: (".sub", "#help", ["offsetWidth"]) +compare-elements-position-false: (".sub", "#help", ("x")) diff --git a/src/test/rustdoc-gui/highlight-colors.goml b/src/test/rustdoc-gui/highlight-colors.goml new file mode 100644 index 000000000..51693314e --- /dev/null +++ b/src/test/rustdoc-gui/highlight-colors.goml @@ -0,0 +1,94 @@ +// This test checks the highlight colors in the source code pages. +goto: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html" +show-text: true + +define-function: ( + "check-colors", + ( + theme, + kw, + kw2, + prelude_ty, + prelude_val, + lifetime, + number, + string, + bool_val, + self, + attribute, + macro, + question_mark, + comment, + doc_comment, + ), + [ + ("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}), + ("reload"), + ("assert-css", ("pre.rust .kw", {"color": |kw|}, ALL)), + ("assert-css", ("pre.rust .kw-2", {"color": |kw2|}, ALL)), + ("assert-css", ("pre.rust .prelude-ty", {"color": |prelude_ty|}, ALL)), + ("assert-css", ("pre.rust .prelude-val", {"color": |prelude_val|}, ALL)), + ("assert-css", ("pre.rust .lifetime", {"color": |lifetime|}, ALL)), + ("assert-css", ("pre.rust .number", {"color": |number|}, ALL)), + ("assert-css", ("pre.rust .string", {"color": |string|}, ALL)), + ("assert-css", ("pre.rust .bool-val", {"color": |bool_val|}, ALL)), + ("assert-css", ("pre.rust .self", {"color": |self|}, ALL)), + ("assert-css", ("pre.rust .attribute", {"color": |attribute|}, ALL)), + ("assert-css", ("pre.rust .macro", {"color": |macro|}, ALL)), + ("assert-css", ("pre.rust .question-mark", {"color": |question_mark|}, ALL)), + ("assert-css", ("pre.rust .comment", {"color": |comment|}, ALL)), + ("assert-css", ("pre.rust .doccomment", {"color": |doc_comment|}, ALL)), + ], +) + +call-function: ("check-colors", { + "theme": "ayu", + "kw": "rgb(255, 119, 51)", + "kw2": "rgb(255, 119, 51)", + "prelude_ty": "rgb(105, 242, 223)", + "prelude_val": "rgb(255, 119, 51)", + "lifetime": "rgb(255, 119, 51)", + "number": "rgb(184, 204, 82)", + "string": "rgb(184, 204, 82)", + "bool_val": "rgb(255, 119, 51)", + "self": "rgb(54, 163, 217)", + "attribute": "rgb(230, 225, 207)", + "macro": "rgb(163, 122, 204)", + "question_mark": "rgb(255, 144, 17)", + "comment": "rgb(120, 135, 151)", + "doc_comment": "rgb(161, 172, 136)", +}) +call-function: ("check-colors", { + "theme": "dark", + "kw": "rgb(171, 138, 193)", + "kw2": "rgb(118, 154, 203)", + "prelude_ty": "rgb(118, 154, 203)", + "prelude_val": "rgb(238, 104, 104)", + "lifetime": "rgb(217, 127, 38)", + "number": "rgb(131, 163, 0)", + "string": "rgb(131, 163, 0)", + "bool_val": "rgb(238, 104, 104)", + "self": "rgb(238, 104, 104)", + "attribute": "rgb(238, 104, 104)", + "macro": "rgb(62, 153, 159)", + "question_mark": "rgb(255, 144, 17)", + "comment": "rgb(141, 141, 139)", + "doc_comment": "rgb(140, 163, 117)", +}) +call-function: ("check-colors", { + "theme": "light", + "kw": "rgb(137, 89, 168)", + "kw2": "rgb(66, 113, 174)", + "prelude_ty": "rgb(66, 113, 174)", + "prelude_val": "rgb(200, 40, 41)", + "lifetime": "rgb(183, 101, 20)", + "number": "rgb(113, 140, 0)", + "string": "rgb(113, 140, 0)", + "bool_val": "rgb(200, 40, 41)", + "self": "rgb(200, 40, 41)", + "attribute": "rgb(200, 40, 41)", + "macro": "rgb(62, 153, 159)", + "question_mark": "rgb(255, 144, 17)", + "comment": "rgb(142, 144, 140)", + "doc_comment": "rgb(77, 77, 76)", +}) diff --git a/src/test/rustdoc-gui/huge-collection-of-constants.goml b/src/test/rustdoc-gui/huge-collection-of-constants.goml index 4f75b5841..3ccd33f1c 100644 --- a/src/test/rustdoc-gui/huge-collection-of-constants.goml +++ b/src/test/rustdoc-gui/huge-collection-of-constants.goml @@ -1,6 +1,6 @@ // Make sure that the last two entries are more than 12 pixels apart and not stacked on each other. -goto: file://|DOC_PATH|/test_docs/huge_amount_of_consts/index.html +goto: "file://" + |DOC_PATH| + "/test_docs/huge_amount_of_consts/index.html" compare-elements-position-near-false: ( "//*[@class='item-table']//div[last()-1]", diff --git a/src/test/rustdoc-gui/impl-default-expansion.goml b/src/test/rustdoc-gui/impl-default-expansion.goml index 6df2661e6..c3f9240cc 100644 --- a/src/test/rustdoc-gui/impl-default-expansion.goml +++ b/src/test/rustdoc-gui/impl-default-expansion.goml @@ -1,3 +1,3 @@ // This test ensures that the impl blocks are open by default. -goto: file://|DOC_PATH|/test_docs/struct.Foo.html +goto: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html" assert-attribute: ("#implementations-list details.implementors-toggle", {"open": ""}) diff --git a/src/test/rustdoc-gui/implementors.goml b/src/test/rustdoc-gui/implementors.goml index 666a6e125..4999283dc 100644 --- a/src/test/rustdoc-gui/implementors.goml +++ b/src/test/rustdoc-gui/implementors.goml @@ -1,6 +1,6 @@ // The goal of this test is to check that the external trait implementors, generated with JS, // have the same display than the "local" ones. -goto: file://|DOC_PATH|/implementors/trait.Whatever.html +goto: "file://" + |DOC_PATH| + "/implementors/trait.Whatever.html" assert: "#implementors-list" // There are supposed to be two implementors listed. assert-count: ("#implementors-list .impl", 2) @@ -8,28 +8,28 @@ assert-count: ("#implementors-list .impl", 2) assert: ("#implementors-list .impl:nth-child(1) > a.anchor") assert-attribute: ("#implementors-list .impl:nth-child(1)", {"id": "impl-Whatever-for-Struct"}) assert-attribute: ("#implementors-list .impl:nth-child(1) > a.anchor", {"href": "#impl-Whatever-for-Struct"}) -assert: "#implementors-list .impl:nth-child(1) > .code-header.in-band" +assert: "#implementors-list .impl:nth-child(1) > .code-header" assert: ("#implementors-list .impl:nth-child(2) > a.anchor") assert-attribute: ("#implementors-list .impl:nth-child(2)", {"id": "impl-Whatever-1"}) assert-attribute: ("#implementors-list .impl:nth-child(2) > a.anchor", {"href": "#impl-Whatever-1"}) -assert: "#implementors-list .impl:nth-child(2) > .code-header.in-band" +assert: "#implementors-list .impl:nth-child(2) > .code-header" -goto: file://|DOC_PATH|/test_docs/struct.HasEmptyTraits.html +goto: "file://" + |DOC_PATH| + "/test_docs/struct.HasEmptyTraits.html" compare-elements-position-near-false: ( "#impl-EmptyTrait1-for-HasEmptyTraits", "#impl-EmptyTrait2-for-HasEmptyTraits", - {"y": 30}, + {"y": 34}, ) compare-elements-position-near: ( "#impl-EmptyTrait3-for-HasEmptyTraits h3", "#impl-EmptyTrait3-for-HasEmptyTraits .item-info", - {"y": 30}, + {"y": 34}, ) // Now check that re-exports work correctly. // There should be exactly one impl shown on both of these pages. -goto: file://|DOC_PATH|/lib2/trait.TraitToReexport.html +goto: "file://" + |DOC_PATH| + "/lib2/trait.TraitToReexport.html" assert-count: ("#implementors-list .impl", 1) -goto: file://|DOC_PATH|/implementors/trait.TraitToReexport.html +goto: "file://" + |DOC_PATH| + "/implementors/trait.TraitToReexport.html" assert-count: ("#implementors-list .impl", 1) diff --git a/src/test/rustdoc-gui/item-decl-colors.goml b/src/test/rustdoc-gui/item-decl-colors.goml new file mode 100644 index 000000000..ce688287a --- /dev/null +++ b/src/test/rustdoc-gui/item-decl-colors.goml @@ -0,0 +1,74 @@ +// This test ensures that the color of the items in the type decl are working as expected. +define-function: ( + "check-colors", + ( + theme, + attr_color, + trait_color, + struct_color, + enum_color, + primitive_color, + constant_color, + fn_color, + assoc_type_color, + ), + [ + ("goto", "file://" + |DOC_PATH| + "/test_docs/struct.WithGenerics.html"), + ("show-text", true), + ("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}), + ("reload"), + ("assert-css", (".item-decl .code-attribute", {"color": |attr_color|}, ALL)), + ("assert-css", (".item-decl .trait", {"color": |trait_color|}, ALL)), + // We need to add `code` here because otherwise it would select the parent too. + ("assert-css", (".item-decl code .struct", {"color": |struct_color|}, ALL)), + ("assert-css", (".item-decl .enum", {"color": |enum_color|}, ALL)), + ("assert-css", (".item-decl .primitive", {"color": |primitive_color|}, ALL)), + ("goto", "file://" + |DOC_PATH| + "/test_docs/trait.TraitWithoutGenerics.html"), + ("assert-css", (".item-decl .constant", {"color": |constant_color|}, ALL)), + ("assert-css", (".item-decl .fnname", {"color": |fn_color|}, ALL)), + ("assert-css", (".item-decl .associatedtype", {"color": |assoc_type_color|}, ALL)), + ], +) + +call-function: ( + "check-colors", + { + "theme": "ayu", + "attr_color": "rgb(153, 153, 153)", + "trait_color": "rgb(57, 175, 215)", + "struct_color": "rgb(255, 160, 165)", + "enum_color": "rgb(255, 160, 165)", + "primitive_color": "rgb(255, 160, 165)", + "constant_color": "rgb(57, 175, 215)", + "fn_color": "rgb(253, 214, 135)", + "assoc_type_color": "rgb(57, 175, 215)", + }, +) +call-function: ( + "check-colors", + { + "theme": "dark", + "attr_color": "rgb(153, 153, 153)", + "trait_color": "rgb(183, 140, 242)", + "struct_color": "rgb(45, 191, 184)", + "enum_color": "rgb(45, 191, 184)", + "primitive_color": "rgb(45, 191, 184)", + "constant_color": "rgb(210, 153, 29)", + "fn_color": "rgb(43, 171, 99)", + "assoc_type_color": "rgb(210, 153, 29)", + }, +) +call-function: ( + "check-colors", + { + "theme": "light", + "attr_color": "rgb(153, 153, 153)", + "trait_color": "rgb(110, 79, 201)", + "struct_color": "rgb(173, 55, 138)", + "enum_color": "rgb(173, 55, 138)", + "primitive_color": "rgb(173, 55, 138)", + "constant_color": "rgb(56, 115, 173)", + "fn_color": "rgb(173, 124, 55)", + "assoc_type_color": "rgb(56, 115, 173)", + }, +) diff --git a/src/test/rustdoc-gui/item-info-alignment.goml b/src/test/rustdoc-gui/item-info-alignment.goml new file mode 100644 index 000000000..94b52f005 --- /dev/null +++ b/src/test/rustdoc-gui/item-info-alignment.goml @@ -0,0 +1,10 @@ +// This test ensures that the "item-info" looks about the same +// whether or not it's inside a toggle. +goto: "file://" + |DOC_PATH| + "/lib2/struct.ItemInfoAlignmentTest.html" + +// First, we try it in "desktop" mode. +size: (1200, 870) +compare-elements-position: (".impl-items > .item-info", "summary > .item-info", ("x")) +// Next, we try it in "mobile" mode (max-width: 700px). +size: (650, 650) +compare-elements-position: (".impl-items > .item-info", "summary > .item-info", ("x")) diff --git a/src/test/rustdoc-gui/item-info-overflow.goml b/src/test/rustdoc-gui/item-info-overflow.goml index b7095a3c5..8ea14621c 100644 --- a/src/test/rustdoc-gui/item-info-overflow.goml +++ b/src/test/rustdoc-gui/item-info-overflow.goml @@ -1,10 +1,10 @@ // This test ensures that the "item-info" elements don't overflow. -goto: file://|DOC_PATH|/lib2/struct.LongItemInfo.html +goto: "file://" + |DOC_PATH| + "/lib2/struct.LongItemInfo.html" // We set a fixed size so there is no chance of "random" resize. size: (1200, 870) // Logically, the "item-decl" and the "item-info" should have the same scroll width. -compare-elements-property: (".docblock.item-decl", ".item-info", ["scrollWidth"]) -assert-property: (".item-info", {"scrollWidth": "890"}) +compare-elements-property: (".item-decl", ".item-info", ["scrollWidth"]) +assert-property: (".item-info", {"scrollWidth": "940"}) // Just to be sure we're comparing the correct "item-info": assert-text: ( ".item-info", @@ -13,7 +13,7 @@ assert-text: ( ) // Checking the "item-info" on an impl block as well: -goto: file://|DOC_PATH|/lib2/struct.LongItemInfo2.html +goto: "file://" + |DOC_PATH| + "/lib2/struct.LongItemInfo2.html" compare-elements-property: ( "#impl-SimpleTrait-for-LongItemInfo2 .item-info", "#impl-SimpleTrait-for-LongItemInfo2 + .docblock", @@ -21,7 +21,7 @@ compare-elements-property: ( ) assert-property: ( "#impl-SimpleTrait-for-LongItemInfo2 .item-info", - {"scrollWidth": "866"}, + {"scrollWidth": "916"}, ) // Just to be sure we're comparing the correct "item-info": assert-text: ( diff --git a/src/test/rustdoc-gui/item-info.goml b/src/test/rustdoc-gui/item-info.goml index 50c45b76b..6780dfca6 100644 --- a/src/test/rustdoc-gui/item-info.goml +++ b/src/test/rustdoc-gui/item-info.goml @@ -1,15 +1,15 @@ // This test ensures a few things for item info elements. -goto: file://|DOC_PATH|/lib2/struct.Foo.html +goto: "file://" + |DOC_PATH| + "/lib2/struct.Foo.html" // Ensuring that the item information don't take 100% of the width if unnecessary. // We set a fixed size so there is no chance of "random" resize. size: (1100, 800) // We check that ".item-info" is bigger than its content. -assert-css: (".item-info", {"width": "790px"}) +assert-css: (".item-info", {"width": "840px"}) assert-css: (".item-info .stab", {"width": "289px"}) -assert-position: (".item-info .stab", {"x": 295}) +assert-position: (".item-info .stab", {"x": 245}) // Now we ensure that they're not rendered on the same line. -goto: file://|DOC_PATH|/lib2/trait.Trait.html +goto: "file://" + |DOC_PATH| + "/lib2/trait.Trait.html" // We first ensure that there are two item info on the trait. assert-count: ("#main-content > .item-info .stab", 2) // They should not have the same `y` position! diff --git a/src/test/rustdoc-gui/item-summary-table.goml b/src/test/rustdoc-gui/item-summary-table.goml index 6bf4e288c..2a92e9da5 100644 --- a/src/test/rustdoc-gui/item-summary-table.goml +++ b/src/test/rustdoc-gui/item-summary-table.goml @@ -1,6 +1,6 @@ // This test ensures that
elements aren't display in items summary. -goto: file://|DOC_PATH|/lib2/summary_table/index.html +goto: "file://" + |DOC_PATH| + "/lib2/summary_table/index.html" // We check that we picked the right item first. assert-text: (".item-table .item-left", "Foo") // Then we check that its summary is empty. -assert-text: (".item-table .item-right", "") +assert-false: ".item-table .item-right" diff --git a/src/test/rustdoc-gui/javascript-disabled.goml b/src/test/rustdoc-gui/javascript-disabled.goml index 1693f7b64..edf179d0d 100644 --- a/src/test/rustdoc-gui/javascript-disabled.goml +++ b/src/test/rustdoc-gui/javascript-disabled.goml @@ -2,5 +2,5 @@ // can't be used without JS. javascript: false -goto: file://|DOC_PATH|/test_docs/struct.Foo.html +goto: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html" assert-css: (".sub", {"display": "none"}) diff --git a/src/test/rustdoc-gui/jump-to-def-background.goml b/src/test/rustdoc-gui/jump-to-def-background.goml index d17400f5b..b65faf13d 100644 --- a/src/test/rustdoc-gui/jump-to-def-background.goml +++ b/src/test/rustdoc-gui/jump-to-def-background.goml @@ -1,43 +1,22 @@ // We check the background color on the jump to definition links in the source code page. -goto: file://|DOC_PATH|/src/link_to_definition/lib.rs.html +goto: "file://" + |DOC_PATH| + "/src/link_to_definition/lib.rs.html" -// Set the theme to dark. -local-storage: { - "rustdoc-theme": "dark", - "rustdoc-preferred-dark-theme": "dark", - "rustdoc-use-system-theme": "false", -} -// We reload the page so the local storage settings are being used. -reload: - -assert-css: ( - "body.source .example-wrap pre.rust a", - {"background-color": "rgb(51, 51, 51)"}, - ALL, -) - -// Set the theme to ayu. -local-storage: { - "rustdoc-theme": "ayu", - "rustdoc-preferred-dark-theme": "ayu", - "rustdoc-use-system-theme": "false", -} -// We reload the page so the local storage settings are being used. -reload: - -assert-css: ( - "body.source .example-wrap pre.rust a", - {"background-color": "rgb(51, 51, 51)"}, - ALL, +define-function: ( + "check-background-color", + (theme, background_color), + [ + // Set 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", ( + "body.source .example-wrap pre.rust a", + {"background-color": |background_color|}, + ALL, + )), + ], ) -// Set the theme to light. -local-storage: {"rustdoc-theme": "light", "rustdoc-use-system-theme": "false"} -// We reload the page so the local storage settings are being used. -reload: - -assert-css: ( - "body.source .example-wrap pre.rust a", - {"background-color": "rgb(238, 238, 238)"}, - ALL, -) +call-function: ("check-background-color", ("ayu", "rgb(51, 51, 51)")) +call-function: ("check-background-color", ("dark", "rgb(51, 51, 51)")) +call-function: ("check-background-color", ("light", "rgb(238, 238, 238)")) diff --git a/src/test/rustdoc-gui/label-next-to-symbol.goml b/src/test/rustdoc-gui/label-next-to-symbol.goml index ca3994a08..05f8ddc71 100644 --- a/src/test/rustdoc-gui/label-next-to-symbol.goml +++ b/src/test/rustdoc-gui/label-next-to-symbol.goml @@ -1,20 +1,20 @@ // These tests verify that labels like "UNIX" and "Deprecated" stay on the same line as their symbol. // It also verifies the staggered layout on mobile. -goto: file://|DOC_PATH|/test_docs/index.html +goto: "file://" + |DOC_PATH| + "/test_docs/index.html" // Desktop view size: (1080, 600) assert: (".stab.deprecated") assert: (".stab.portability") -// make sure that deprecated and portability are different colours +// make sure that deprecated and portability have the right colors assert-css: ( ".item-table .item-left .stab.deprecated", - { "background-color": "rgb(255, 196, 196)" }, + { "background-color": "rgb(255, 245, 214)" }, ) assert-css: ( ".item-table .item-left .stab.portability", - { "background-color": "rgb(243, 223, 255)" }, + { "background-color": "rgb(255, 245, 214)" }, ) // table like view @@ -31,15 +31,9 @@ compare-elements-position: ( ) // Ensure no wrap -compare-elements-position-near: ( - "//*[@class='item-left module-item']//a[text()='replaced_function']", - "//*[@class='item-right docblock-short']//p[text()='a thing with a label']", - {"y": 2}, -) -// compare parent elements compare-elements-position: ( "//*[@class='item-left module-item']//a[text()='replaced_function']/..", - "//*[@class='item-right docblock-short']//p[text()='a thing with a label']/..", + "//*[@class='item-right docblock-short'][text()='a thing with a label']", ("y"), ) @@ -51,7 +45,7 @@ assert-css: (".item-right.docblock-short", { "padding-left": "32px" }) compare-elements-position-near: ( "//*[@class='item-left module-item']//a[text()='replaced_function']", ".item-left .stab.deprecated", - {"y": 1}, + {"y": 2}, ) compare-elements-position: ( ".item-left .stab.deprecated", @@ -60,19 +54,13 @@ compare-elements-position: ( ) // Ensure wrap -compare-elements-position-near-false: ( - "//*[@class='item-left module-item']//a[text()='replaced_function']", - "//*[@class='item-right docblock-short']//p[text()='a thing with a label']", - {"y": 12}, -) -// compare parent elements compare-elements-position-false: ( "//*[@class='item-left module-item']//a[text()='replaced_function']/..", - "//*[@class='item-right docblock-short']//p[text()='a thing with a label']/..", + "//*[@class='item-right docblock-short'][text()='a thing with a label']", ("y"), ) compare-elements-position-false: ( ".item-left .stab.deprecated", - "//*[@class='item-right docblock-short']//p[text()='a thing with a label']", + "//*[@class='item-right docblock-short'][text()='a thing with a label']", ("y"), ) diff --git a/src/test/rustdoc-gui/links-color.goml b/src/test/rustdoc-gui/links-color.goml new file mode 100644 index 000000000..839629ad9 --- /dev/null +++ b/src/test/rustdoc-gui/links-color.goml @@ -0,0 +1,85 @@ +// This test checks links colors. +goto: "file://" + |DOC_PATH| + "/test_docs/index.html" + +// This is needed so that the text color is computed. +show-text: true + +// Ayu theme +local-storage: { + "rustdoc-theme": "ayu", + "rustdoc-use-system-theme": "false", +} +reload: + +assert-css: (".item-table .mod", {"color": "rgb(57, 175, 215)"}, ALL) +assert-css: (".item-table .macro", {"color": "rgb(163, 122, 204)"}, ALL) +assert-css: (".item-table .struct", {"color": "rgb(255, 160, 165)"}, ALL) +assert-css: (".item-table .enum", {"color": "rgb(255, 160, 165)"}, ALL) +assert-css: (".item-table .trait", {"color": "rgb(57, 175, 215)"}, ALL) +assert-css: (".item-table .fn", {"color": "rgb(253, 214, 135)"}, ALL) +assert-css: (".item-table .type", {"color": "rgb(255, 160, 165)"}, ALL) +assert-css: (".item-table .union", {"color": "rgb(255, 160, 165)"}, ALL) +assert-css: (".item-table .keyword", {"color": "rgb(57, 175, 215)"}, ALL) + +assert-css: ( + ".sidebar-elems a:not(.current)", + {"color": "rgb(83, 177, 219)", "background-color": "rgba(0, 0, 0, 0)", "font-weight": "400"}, + ALL, +) +assert-css: ( + ".sidebar-elems a.current", + {"color": "rgb(255, 180, 76)", "background-color": "rgba(0, 0, 0, 0)", "font-weight": "500"}, + ALL, +) + + +// Dark theme +local-storage: {"rustdoc-theme": "dark"} +reload: + +assert-css: (".item-table .mod", {"color": "rgb(210, 153, 29)"}, ALL) +assert-css: (".item-table .macro", {"color": "rgb(9, 189, 0)"}, ALL) +assert-css: (".item-table .struct", {"color": "rgb(45, 191, 184)"}, ALL) +assert-css: (".item-table .enum", {"color": "rgb(45, 191, 184)"}, ALL) +assert-css: (".item-table .trait", {"color": "rgb(183, 140, 242)"}, ALL) +assert-css: (".item-table .fn", {"color": "rgb(43, 171, 99)"}, ALL) +assert-css: (".item-table .type", {"color": "rgb(45, 191, 184)"}, ALL) +assert-css: (".item-table .union", {"color": "rgb(45, 191, 184)"}, ALL) +assert-css: (".item-table .keyword", {"color": "rgb(210, 153, 29)"}, ALL) + +assert-css: ( + ".sidebar-elems a:not(.current)", + {"color": "rgb(253, 191, 53)", "background-color": "rgba(0, 0, 0, 0)", "font-weight": "400"}, + ALL, +) +assert-css: ( + ".sidebar-elems a.current", + {"color": "rgb(253, 191, 53)", "background-color": "rgb(68, 68, 68)", "font-weight": "500"}, + ALL, +) + + +// Light theme +local-storage: {"rustdoc-theme": "light"} +reload: + +assert-css: (".item-table .mod", {"color": "rgb(56, 115, 173)"}, ALL) +assert-css: (".item-table .macro", {"color": "rgb(6, 128, 0)"}, ALL) +assert-css: (".item-table .struct", {"color": "rgb(173, 55, 138)"}, ALL) +assert-css: (".item-table .enum", {"color": "rgb(173, 55, 138)"}, ALL) +assert-css: (".item-table .trait", {"color": "rgb(110, 79, 201)"}, ALL) +assert-css: (".item-table .fn", {"color": "rgb(173, 124, 55)"}, ALL) +assert-css: (".item-table .type", {"color": "rgb(173, 55, 138)"}, ALL) +assert-css: (".item-table .union", {"color": "rgb(173, 55, 138)"}, ALL) +assert-css: (".item-table .keyword", {"color": "rgb(56, 115, 173)"}, ALL) + +assert-css: ( + ".sidebar-elems a:not(.current)", + {"color": "rgb(53, 109, 164)", "background-color": "rgba(0, 0, 0, 0)", "font-weight": "400"}, + ALL, +) +assert-css: ( + ".sidebar-elems a.current", + {"color": "rgb(53, 109, 164)", "background-color": "rgb(255, 255, 255)", "font-weight": "500"}, + ALL, +) diff --git a/src/test/rustdoc-gui/list_code_block.goml b/src/test/rustdoc-gui/list_code_block.goml index eba1a662b..3423a449d 100644 --- a/src/test/rustdoc-gui/list_code_block.goml +++ b/src/test/rustdoc-gui/list_code_block.goml @@ -1,4 +1,4 @@ // This test checks that code blocks in list are supported. -goto: file://|DOC_PATH|/test_docs/index.html -goto: ./fn.check_list_code_block.html +goto: "file://" + |DOC_PATH| + "/test_docs/index.html" +goto: "./fn.check_list_code_block.html" assert: ("pre.rust.fn") diff --git a/src/test/rustdoc-gui/mobile.goml b/src/test/rustdoc-gui/mobile.goml index 13b9b563d..704542a39 100644 --- a/src/test/rustdoc-gui/mobile.goml +++ b/src/test/rustdoc-gui/mobile.goml @@ -1,5 +1,5 @@ // Test various properties of the mobile UI -goto: file://|DOC_PATH|/staged_api/struct.Foo.html +goto: "file://" + |DOC_PATH| + "/staged_api/struct.Foo.html" size: (400, 600) font-size: 18 @@ -12,7 +12,7 @@ assert-css: (".main-heading", { "flex-direction": "column" }) -assert-property: (".mobile-topbar h2.location", {"offsetHeight": 36}) +assert-property: (".mobile-topbar h2", {"offsetHeight": 36}) // Note: We can't use assert-text here because the 'Since' is set by CSS and // is therefore not part of the DOM. @@ -24,7 +24,7 @@ assert-css-false: (".content .out-of-band .since::before", { "content": "\"Since // On the settings page, the theme buttons should not line-wrap. Instead, they should // all be placed as a group on a line below the setting name "Theme." -goto: file://|DOC_PATH|/settings.html +goto: "file://" + |DOC_PATH| + "/settings.html" size: (400, 600) // Ignored for now https://github.com/rust-lang/rust/issues/93784. // compare-elements-position-near-false: ("#preferred-light-theme .setting-name", "#preferred-light-theme .choice", {"y": 16}) diff --git a/src/test/rustdoc-gui/module-items-font.goml b/src/test/rustdoc-gui/module-items-font.goml index 758ee391a..cd3676a98 100644 --- a/src/test/rustdoc-gui/module-items-font.goml +++ b/src/test/rustdoc-gui/module-items-font.goml @@ -1,5 +1,5 @@ // This test checks that the correct font is used on module items (in index.html pages). -goto: file://|DOC_PATH|/test_docs/index.html +goto: "file://" + |DOC_PATH| + "/test_docs/index.html" assert-css: ( ".item-table .module-item a", {"font-family": '"Fira Sans", Arial, NanumBarunGothic, sans-serif'}, diff --git a/src/test/rustdoc-gui/no-docblock.goml b/src/test/rustdoc-gui/no-docblock.goml new file mode 100644 index 000000000..2366a60f5 --- /dev/null +++ b/src/test/rustdoc-gui/no-docblock.goml @@ -0,0 +1,8 @@ +// This test checks that there are margins applied to methods with no docblocks. +goto: "file://" + |DOC_PATH| + "/test_docs/trait.TraitWithNoDocblocks.html" +// Check that the two methods are more than 24px apart. +compare-elements-position-near-false: ("//*[@id='tymethod.first_fn']", "//*[@id='tymethod.second_fn']", {"y": 24}) + +goto: "file://" + |DOC_PATH| + "/test_docs/struct.TypeWithNoDocblocks.html" +// Check that the two methods are more than 24px apart. +compare-elements-position-near-false: ("//*[@id='method.first_fn']", "//*[@id='method.second_fn']", {"y": 24}) diff --git a/src/test/rustdoc-gui/notable-trait.goml b/src/test/rustdoc-gui/notable-trait.goml new file mode 100644 index 000000000..efe0cb15f --- /dev/null +++ b/src/test/rustdoc-gui/notable-trait.goml @@ -0,0 +1,128 @@ +// This test checks the position of the `i` for the notable traits. +goto: "file://" + |DOC_PATH| + "/test_docs/struct.NotableStructWithLongName.html" +show-text: true +// We start with a wide screen. +size: (1100, 600) +// Checking they have the same y position. +compare-elements-position: ( + "//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']", + "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']", + ("y"), +) +// Checking they don't have the same x position. +compare-elements-position-false: ( + "//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']", + "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']", + ("x"), +) +// The `i` should be *after* the type. +assert-position: ( + "//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']", + {"x": 677}, +) +assert-position: ( + "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']", + {"x": 951}, +) +// The tooltip should be beside the `i` +click: "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']" +compare-elements-position-near: ( + "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']", + "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits-tooltiptext force-tooltip']", + {"y": 2} +) +compare-elements-position-false: ( + "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']", + "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits-tooltiptext force-tooltip']", + ("x") +) +// The docblock should be flush with the border. +assert-css: ( + "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits-tooltiptext force-tooltip']/*[@class='docblock']", + {"margin-left": "0px"} +) + +// Now only the `i` should be on the next line. +size: (1055, 600) +compare-elements-position-false: ( + "//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']", + "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']", + ("y", "x"), +) + +// Now both the `i` and the struct name should be on the next line. +size: (980, 600) +// Checking they have the same y position. +compare-elements-position: ( + "//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']", + "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']", + ("y"), +) +// Checking they don't have the same x position. +compare-elements-position-false: ( + "//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']", + "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']", + ("x"), +) +// The `i` should be *after* the type. +assert-position: ( + "//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']", + {"x": 245}, +) +assert-position: ( + "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']", + {"x": 519}, +) + +// Checking on mobile now. +size: (650, 600) +// Checking they have the same y position. +compare-elements-position: ( + "//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']", + "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']", + ("y"), +) +// Checking they don't have the same x position. +compare-elements-position-false: ( + "//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']", + "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']", + ("x"), +) +// The `i` should be *after* the type. +assert-position: ( + "//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']", + {"x": 15}, +) +assert-position: ( + "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']", + {"x": 289}, +) +// The tooltip should be below `i` +compare-elements-position-near-false: ( + "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']", + "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits-tooltiptext force-tooltip']", + {"y": 2} +) +compare-elements-position-false: ( + "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']", + "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits-tooltiptext force-tooltip']", + ("x") +) +compare-elements-position-near: ( + "//*[@id='method.create_an_iterator_from_read']/parent::*", + "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits-tooltiptext force-tooltip']", + {"x": 5} +) +// The docblock should be flush with the border. +assert-css: ( + "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits-tooltiptext force-tooltip']/*[@class='docblock']", + {"margin-left": "0px"} +) + +// Checking on very small mobile. The `i` should be on its own line. +size: (365, 600) +compare-elements-position-false: ( + "//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']", + "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']", + ("y", "x"), +) diff --git a/src/test/rustdoc-gui/overflow-tooltip-information.goml b/src/test/rustdoc-gui/overflow-tooltip-information.goml index 7ef85a4c4..09ad6cdd7 100644 --- a/src/test/rustdoc-gui/overflow-tooltip-information.goml +++ b/src/test/rustdoc-gui/overflow-tooltip-information.goml @@ -1,8 +1,8 @@ // The goal of this test is to ensure that the tooltip `.information` class doesn't // have overflow and max-width CSS rules set because they create a bug in firefox on // mac. For more information: https://github.com/rust-lang/rust/issues/89185 -goto: file://|DOC_PATH|/test_docs/fn.foo.html -assert-css: (".docblock > .information", { +goto: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html" +assert-css: (".docblock > .example-wrap .tooltip", { "overflow-x": "visible", "max-width": "none" }, ALL) diff --git a/src/test/rustdoc-gui/pocket-menu.goml b/src/test/rustdoc-gui/pocket-menu.goml index 54f3790a7..fb63ea62a 100644 --- a/src/test/rustdoc-gui/pocket-menu.goml +++ b/src/test/rustdoc-gui/pocket-menu.goml @@ -1,5 +1,5 @@ // This test ensures that the "pocket menus" are working as expected. -goto: file://|DOC_PATH|/test_docs/index.html +goto: "file://" + |DOC_PATH| + "/test_docs/index.html" // First we check that the help menu doesn't exist yet. assert-false: "#help-button .popover" // Then we display the help menu. @@ -56,7 +56,7 @@ reload: click: "#help-button" assert-css: ( "#help-button .popover", - {"display": "block", "border-color": "rgb(210, 210, 210)"}, + {"display": "block", "border-color": "rgb(224, 224, 224)"}, ) compare-elements-css: ("#help-button .popover", "#help-button .top", ["border-color"]) compare-elements-css: ("#help-button .popover", "#help-button .bottom", ["border-color"]) @@ -71,7 +71,7 @@ reload: click: "#help-button" assert-css: ( "#help-button .popover", - {"display": "block", "border-color": "rgb(221, 221, 221)"}, + {"display": "block", "border-color": "rgb(224, 224, 224)"}, ) compare-elements-css: ("#help-button .popover", "#help-button .top", ["border-color"]) compare-elements-css: ("#help-button .popover", "#help-button .bottom", ["border-color"]) diff --git a/src/test/rustdoc-gui/run-on-hover.goml b/src/test/rustdoc-gui/run-on-hover.goml index b8efa8e30..6c785e1c4 100644 --- a/src/test/rustdoc-gui/run-on-hover.goml +++ b/src/test/rustdoc-gui/run-on-hover.goml @@ -1,7 +1,7 @@ // Example code blocks sometimes have a "Run" button to run them on the // Playground. That button is hidden until the user hovers over the code block. // This test checks that it is hidden, and that it shows on hover. -goto: file://|DOC_PATH|/test_docs/fn.foo.html +goto: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html" assert-css: (".test-arrow", {"visibility": "hidden"}) move-cursor-to: ".example-wrap" assert-css: (".test-arrow", {"visibility": "visible"}) diff --git a/src/test/rustdoc-gui/rust-logo.goml b/src/test/rustdoc-gui/rust-logo.goml index 4a9dcf735..6c8dc8594 100644 --- a/src/test/rustdoc-gui/rust-logo.goml +++ b/src/test/rustdoc-gui/rust-logo.goml @@ -1,78 +1,34 @@ // This test ensures that the correct style is applied to the rust logo in the sidebar. -goto: file://|DOC_PATH|/test_docs/index.html - -// First we start with the dark theme. -local-storage: { - "rustdoc-theme": "dark", - "rustdoc-preferred-dark-theme": "dark", - "rustdoc-use-system-theme": "false", -} -reload: - -assert-css: ( - ".rust-logo", - {"filter": "drop-shadow(rgb(255, 255, 255) 1px 0px 0px) drop-shadow(rgb(255, 255, 255) 0px 1px 0px) drop-shadow(rgb(255, 255, 255) -1px 0px 0px) drop-shadow(rgb(255, 255, 255) 0px -1px 0px)"}, -) - -// In the source view page now. -goto: file://|DOC_PATH|/src/test_docs/lib.rs.html - -local-storage: { - "rustdoc-theme": "dark", - "rustdoc-preferred-dark-theme": "dark", - "rustdoc-use-system-theme": "false", -} -reload: - -assert-css: ( - ".rust-logo", - {"filter": "drop-shadow(rgb(255, 255, 255) 1px 0px 0px) drop-shadow(rgb(255, 255, 255) 0px 1px 0px) drop-shadow(rgb(255, 255, 255) -1px 0px 0px) drop-shadow(rgb(255, 255, 255) 0px -1px 0px)"}, -) - -// Then with the ayu theme. -local-storage: { - "rustdoc-theme": "ayu", - "rustdoc-preferred-dark-theme": "ayu", - "rustdoc-use-system-theme": "false", -} -reload: - -assert-css: ( - ".rust-logo", - {"filter": "drop-shadow(rgb(255, 255, 255) 1px 0px 0px) drop-shadow(rgb(255, 255, 255) 0px 1px 0px) drop-shadow(rgb(255, 255, 255) -1px 0px 0px) drop-shadow(rgb(255, 255, 255) 0px -1px 0px)"}, +goto: "file://" + |DOC_PATH| + "/test_docs/index.html" + +define-function: ( + "check-logo", + (theme, filter), + [ + // Going to the doc page. + ("goto", "file://" + |DOC_PATH| + "/test_docs/index.html"), + // Changing theme. + ("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}), + ("reload"), + ("assert-css", (".rust-logo", {"filter": |filter|})), + // Going to the source code page. + ("goto", "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html"), + // Changing theme (since it's local files, the local storage works by folder). + ("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}), + ("reload"), + ("assert-css", (".rust-logo", {"filter": |filter|})), + ], ) -// In the source view page now. -goto: file://|DOC_PATH|/src/test_docs/lib.rs.html - -local-storage: { - "rustdoc-theme": "ayu", - "rustdoc-preferred-dark-theme": "ayu", - "rustdoc-use-system-theme": "false", -} -reload: - -assert-css: ( - ".rust-logo", - {"filter": "drop-shadow(rgb(255, 255, 255) 1px 0px 0px) drop-shadow(rgb(255, 255, 255) 0px 1px 0px) drop-shadow(rgb(255, 255, 255) -1px 0px 0px) drop-shadow(rgb(255, 255, 255) 0px -1px 0px)"}, +call-function: ( + "check-logo", + ("ayu", "drop-shadow(rgb(255, 255, 255) 1px 0px 0px) drop-shadow(rgb(255, 255, 255) 0px 1px 0px) drop-shadow(rgb(255, 255, 255) -1px 0px 0px) drop-shadow(rgb(255, 255, 255) 0px -1px 0px)"), ) - -// And finally with the light theme. -local-storage: {"rustdoc-theme": "light", "rustdoc-use-system-theme": "false"} -reload: - -assert-css: ( - ".rust-logo", - {"filter": "none"}, +call-function: ( + "check-logo", + ("dark", "drop-shadow(rgb(255, 255, 255) 1px 0px 0px) drop-shadow(rgb(255, 255, 255) 0px 1px 0px) drop-shadow(rgb(255, 255, 255) -1px 0px 0px) drop-shadow(rgb(255, 255, 255) 0px -1px 0px)"), ) - -// In the source view page now. -goto: file://|DOC_PATH|/src/test_docs/lib.rs.html - -local-storage: {"rustdoc-theme": "light", "rustdoc-use-system-theme": "false"} -reload: - -assert-css: ( - ".rust-logo", - {"filter": "none"}, +call-function: ( + "check-logo", + ("light", "none"), ) diff --git a/src/test/rustdoc-gui/search-filter.goml b/src/test/rustdoc-gui/search-filter.goml index d645e2370..27db816e6 100644 --- a/src/test/rustdoc-gui/search-filter.goml +++ b/src/test/rustdoc-gui/search-filter.goml @@ -1,5 +1,5 @@ // Checks that the crate search filtering is handled correctly and changes the results. -goto: file://|DOC_PATH|/test_docs/index.html +goto: "file://" + |DOC_PATH| + "/test_docs/index.html" show-text: true write: (".search-input", "test") // To be SURE that the search will be run. @@ -40,16 +40,16 @@ press-key: "ArrowUp" press-key: "Enter" // Waiting for the search results to appear... wait-for: "#titles" -assert-property: ("#crate-search", {"value": "All crates"}) +assert-property: ("#crate-search", {"value": "all crates"}) // Checking that the URL parameter is taken into account for crate filtering. -goto: file://|DOC_PATH|/test_docs/index.html?search=test&filter-crate=lib2 +goto: "file://" + |DOC_PATH| + "/test_docs/index.html?search=test&filter-crate=lib2" wait-for: "#crate-search" assert-property: ("#crate-search", {"value": "lib2"}) assert-false: "#results .externcrate" -// Checking that the text for the "title" is correct (the "All" comes from the ""). +assert-text: (".search-results-title", "Results in all crates", STARTS_WITH) // Checking the display of the crate filter. // We start with the light theme. @@ -69,15 +69,15 @@ click: "#settings-menu" wait-for: "#settings" click: "#theme-dark" wait-for-css: ("#crate-search", { - "border": "1px solid rgb(240, 240, 240)", - "color": "rgb(17, 17, 17)", - "background-color": "rgb(240, 240, 240)", + "border": "1px solid rgb(224, 224, 224)", + "color": "rgb(221, 221, 221)", + "background-color": "rgb(53, 53, 53)", }) // And finally we check the ayu theme. click: "#theme-ayu" wait-for-css: ("#crate-search", { - "border": "1px solid rgb(66, 76, 87)", - "color": "rgb(197, 197, 197)", - "background-color": "rgb(20, 25, 32)", + "border": "1px solid rgb(92, 103, 115)", + "color": "rgb(255, 255, 255)", + "background-color": "rgb(15, 20, 25)", }) diff --git a/src/test/rustdoc-gui/search-form-elements.goml b/src/test/rustdoc-gui/search-form-elements.goml new file mode 100644 index 000000000..542db348c --- /dev/null +++ b/src/test/rustdoc-gui/search-form-elements.goml @@ -0,0 +1,263 @@ +// This test ensures that the elements in ".search-form" have the expected display. +goto: "file://" + |DOC_PATH| + "/test_docs/index.html" +show-text: true + +// Ayu theme +local-storage: { + "rustdoc-theme": "ayu", + "rustdoc-use-system-theme": "false", +} +reload: + +assert-css: ( + ".search-input", + { + "border-color": "rgb(92, 103, 115)", + "background-color": "rgb(20, 25, 32)", + "color": "rgb(255, 255, 255)", + }, +) +focus: ".search-input" +// Nothing should change. +assert-css: ( + ".search-input", + { + "border-color": "rgb(92, 103, 115)", + "background-color": "rgb(20, 25, 32)", + "color": "rgb(255, 255, 255)", + }, +) + +assert-css: ( + "#help-button", + {"border-color": "rgb(197, 197, 197)"}, +) +assert-css: ( + "#help-button > a", + { + "color": "rgb(255, 255, 255)", + "border-color": "rgb(92, 103, 115)", + "background-color": "rgb(20, 25, 32)", + }, +) +move-cursor-to: "#help-button" +assert-css: ( + "#help-button:hover", + {"border-color": "rgb(197, 197, 197)"}, +) +// Only "border-color" should change. +assert-css: ( + "#help-button:hover > a", + { + "color": "rgb(255, 255, 255)", + "border-color": "rgb(224, 224, 224)", + "background-color": "rgb(20, 25, 32)", + }, +) +// Link color inside +click: "#help-button" +assert-css: ( + "#help a", + { + "color": "rgb(57, 175, 215)", + }, +) + +assert-css: ( + "#settings-menu", + {"border-color": "rgb(197, 197, 197)"}, +) +assert-css: ( + "#settings-menu > a", + { + "border-color": "rgb(92, 103, 115)", + "background-color": "rgb(20, 25, 32)", + }, +) +move-cursor-to: "#settings-menu" +assert-css: ( + "#settings-menu:hover", + {"border-color": "rgb(197, 197, 197)"}, +) +// Only "border-color" should change. +assert-css: ( + "#settings-menu:hover > a", + { + "border-color": "rgb(224, 224, 224)", + "background-color": "rgb(20, 25, 32)", + }, +) + +// Dark theme +local-storage: { + "rustdoc-theme": "dark", + "rustdoc-use-system-theme": "false", +} +reload: + +assert-css: ( + ".search-input", + { + "border-color": "rgb(224, 224, 224)", + "background-color": "rgb(240, 240, 240)", + "color": "rgb(17, 17, 17)", + }, +) +focus: ".search-input" +// Only "border-color" should change. +assert-css: ( + ".search-input", + { + "border-color": "rgb(0, 141, 253)", + "background-color": "rgb(240, 240, 240)", + "color": "rgb(17, 17, 17)", + }, +) + +assert-css: ( + "#help-button", + {"border-color": "rgb(221, 221, 221)"}, +) +assert-css: ( + "#help-button > a", + { + "color": "rgb(0, 0, 0)", + "border-color": "rgb(224, 224, 224)", + "background-color": "rgb(240, 240, 240)", + }, +) +move-cursor-to: "#help-button" +assert-css: ( + "#help-button:hover", + {"border-color": "rgb(221, 221, 221)"}, +) +// Only "border-color" should change. +assert-css: ( + "#help-button:hover > a", + { + "color": "rgb(0, 0, 0)", + "border-color": "rgb(255, 185, 0)", + "background-color": "rgb(240, 240, 240)", + }, +) +// Link color inside +click: "#help-button" +assert-css: ( + "#help a", + { + "color": "rgb(210, 153, 29)", + }, +) + +assert-css: ( + "#settings-menu", + {"border-color": "rgb(221, 221, 221)"}, +) +assert-css: ( + "#settings-menu > a", + { + "border-color": "rgb(224, 224, 224)", + "background-color": "rgb(240, 240, 240)", + }, +) +move-cursor-to: "#settings-menu" +assert-css: ( + "#settings-menu:hover", + {"border-color": "rgb(221, 221, 221)"}, +) +// Only "border-color" should change. +assert-css: ( + "#settings-menu:hover > a", + { + "color": "rgb(0, 0, 0)", + "border-color": "rgb(255, 185, 0)", + "background-color": "rgb(240, 240, 240)", + }, +) + +// Light theme +local-storage: { + "rustdoc-theme": "light", + "rustdoc-use-system-theme": "false", +} +reload: + +assert-css: ( + ".search-input", + { + "border-color": "rgb(224, 224, 224)", + "background-color": "rgb(255, 255, 255)", + "color": "rgb(0, 0, 0)", + }, +) +focus: ".search-input" +// Nothing should change. +assert-css: ( + ".search-input", + { + "border-color": "rgb(102, 175, 233)", + "background-color": "rgb(255, 255, 255)", + "color": "rgb(0, 0, 0)", + }, +) + +assert-css: ( + "#help-button", + {"border-color": "rgb(0, 0, 0)"}, +) +assert-css: ( + "#help-button > a", + { + "color": "rgb(0, 0, 0)", + "border-color": "rgb(224, 224, 224)", + "background-color": "rgb(255, 255, 255)", + }, +) +move-cursor-to: "#help-button" +assert-css: ( + "#help-button:hover", + {"border-color": "rgb(0, 0, 0)"}, +) +// Only "border-color" should change. +assert-css: ( + "#help-button:hover > a", + { + "color": "rgb(0, 0, 0)", + "border-color": "rgb(113, 113, 113)", + "background-color": "rgb(255, 255, 255)", + }, +) +// Link color inside +click: "#help-button" +assert-css: ( + "#help a", + { + "color": "rgb(56, 115, 173)", + }, +) + +assert-css: ( + "#settings-menu", + {"border-color": "rgb(0, 0, 0)"}, +) +assert-css: ( + "#settings-menu > a", + { + "border-color": "rgb(224, 224, 224)", + "background-color": "rgb(255, 255, 255)", + }, +) +move-cursor-to: "#settings-menu" +assert-css: ( + "#settings-menu:hover", + {"border-color": "rgb(0, 0, 0)"}, +) +// Only "border-color" should change. +assert-css: ( + "#settings-menu:hover > a", + { + "color": "rgb(0, 0, 0)", + "border-color": "rgb(113, 113, 113)", + "background-color": "rgb(255, 255, 255)", + }, +) diff --git a/src/test/rustdoc-gui/search-input-mobile.goml b/src/test/rustdoc-gui/search-input-mobile.goml index 5c95db70a..ce0cef77c 100644 --- a/src/test/rustdoc-gui/search-input-mobile.goml +++ b/src/test/rustdoc-gui/search-input-mobile.goml @@ -1,6 +1,6 @@ // Test to ensure that you can click on the search input, whatever the width. // The PR which fixed it is: https://github.com/rust-lang/rust/pull/81592 -goto: file://|DOC_PATH|/test_docs/index.html +goto: "file://" + |DOC_PATH| + "/test_docs/index.html" size: (463, 700) // We first check that the search input isn't already focused. assert-false: ("input.search-input:focus") diff --git a/src/test/rustdoc-gui/search-input.goml b/src/test/rustdoc-gui/search-input.goml deleted file mode 100644 index 44123b702..000000000 --- a/src/test/rustdoc-gui/search-input.goml +++ /dev/null @@ -1,23 +0,0 @@ -// Ensures that the search input border color changes on focus. -goto: file://|DOC_PATH|/test_docs/index.html -local-storage: {"rustdoc-use-system-theme": "false", "rustdoc-theme": "dark"} -reload: - -assert-css: (".search-input", {"border-color": "rgb(224, 224, 224)"}) -click: ".search-input" -focus: ".search-input" -assert-css: (".search-input", {"border-color": "rgb(0, 141, 253)"}) - -local-storage: {"rustdoc-theme": "light"} -reload: - -assert-css: (".search-input", {"border-color": "rgb(224, 224, 224)"}) -click: ".search-input" -assert-css: (".search-input", {"border-color": "rgb(102, 175, 233)"}) - -local-storage: {"rustdoc-theme": "ayu"} -reload: - -assert-css: (".search-input", {"border-color": "rgb(66, 76, 87)"}) -click: ".search-input" -assert-css: (".search-input", {"border-color": "rgb(66, 76, 87)"}) diff --git a/src/test/rustdoc-gui/search-reexport.goml b/src/test/rustdoc-gui/search-reexport.goml index 5ef890d47..dd19f03bd 100644 --- a/src/test/rustdoc-gui/search-reexport.goml +++ b/src/test/rustdoc-gui/search-reexport.goml @@ -1,6 +1,6 @@ // Checks that the reexports are present in the search index, can have // doc aliases and are highligted when their ID is the hash of the page. -goto: file://|DOC_PATH|/test_docs/index.html +goto: "file://" + |DOC_PATH| + "/test_docs/index.html" local-storage: {"rustdoc-theme": "dark", "rustdoc-use-system-theme": "false"} reload: // First we check that the reexport has the correct ID and no background color. diff --git a/src/test/rustdoc-gui/search-result-color.goml b/src/test/rustdoc-gui/search-result-color.goml index 9a49ae2c6..69bb30df9 100644 --- a/src/test/rustdoc-gui/search-result-color.goml +++ b/src/test/rustdoc-gui/search-result-color.goml @@ -1,5 +1,58 @@ // The goal of this test is to ensure the color of the text is the one expected. -goto: file://|DOC_PATH|/test_docs/index.html?search=coo + +define-function: ( + "check-result-color", + (result_kind, color, hover_color), + [ + ( + "assert-css", + (".result-" + |result_kind| + " ." + |result_kind|, {"color": |color|}, ALL), + ), + ( + "assert-css", + ( + ".result-" + |result_kind|, + {"color": |entry_color|, "background-color": |background_color|}, + ), + ), + ( + "move-cursor-to", + ".result-" + |result_kind|, + ), + ( + "assert-css", + ( + ".result-" + |result_kind| + ":hover", + {"color": |hover_entry_color|, "background-color": |hover_background_color|}, + ), + ), + ( + "assert-css", + (".result-" + |result_kind| + ":hover ." + |result_kind|, {"color": |hover_color|}), + ), + ( + "move-cursor-to", + ".search-input", + ), + ( + "focus", + ".result-" + |result_kind|, + ), + ( + "assert-css", + ( + ".result-" + |result_kind| + ":focus", + {"color": |hover_entry_color|, "background-color": |hover_background_color|}, + ), + ), + ( + "assert-css", + (".result-" + |result_kind| + ":focus ." + |result_kind|, {"color": |hover_color|}), + ), + ], +) + +goto: "file://" + |DOC_PATH| + "/test_docs/index.html?search=coo" // This is needed so that the text color is computed. show-text: true @@ -7,7 +60,6 @@ show-text: true // Ayu theme local-storage: { "rustdoc-theme": "ayu", - "rustdoc-preferred-dark-theme": "ayu", "rustdoc-use-system-theme": "false", } reload: @@ -23,16 +75,97 @@ assert-css: ( {"color": "rgb(0, 150, 207)"}, ) -// Checking the color for "keyword". +// Checking the color of "keyword" text. assert-css: ( "//*[@class='result-name']//*[text()='(keyword)']", {"color": "rgb(120, 135, 151)"}, ) +store-value: (entry_color, "rgb(0, 150, 207)") // color of the search entry +store-value: (hover_entry_color, "rgb(255, 255, 255)") // color of the hovered/focused search entry +store-value: (background_color, "rgba(0, 0, 0, 0)") // background color +store-value: (hover_background_color, "rgb(60, 60, 60)") // hover background color + +call-function: ( + "check-result-color", ( + "keyword", // item kind + "rgb(57, 175, 215)", // color of item kind + "rgb(57, 175, 215)", // color of hovered/focused item kind + ), +) +call-function: ( + "check-result-color", ( + "struct", // item kind + "rgb(255, 160, 165)", // color of item kind + "rgb(255, 160, 165)", // color of hovered/focused item kind + ), +) +call-function: ( + "check-result-color", ( + "associatedtype", // item kind + "rgb(57, 175, 215)", // color of item kind + "rgb(57, 175, 215)", // color of hovered/focused item kind + ), +) +call-function: ( + "check-result-color", ( + "tymethod", // item kind + "rgb(253, 214, 135)", // color of item kind + "rgb(253, 214, 135)", // color of hovered/focused item kind + ), +) +call-function: ( + "check-result-color", ( + "method", // item kind + "rgb(253, 214, 135)", // color of item kind + "rgb(253, 214, 135)", // color of hovered/focused item kind + ), +) +call-function: ( + "check-result-color", ( + "structfield", // item kind + "rgb(0, 150, 207)", // color of item kind + "rgb(255, 255, 255)", // color of hovered/focused item kind + ), +) +call-function: ( + "check-result-color", ( + "macro", // item kind + "rgb(163, 122, 204)", // color of item kind + "rgb(163, 122, 204)", // color of hovered/focused item kind + ), +) +call-function: ( + "check-result-color", ( + "fn", // item kind + "rgb(253, 214, 135)", // color of item kind + "rgb(253, 214, 135)", // color of hovered/focused item kind + ), +) + +// Checking the `` container. +move-cursor-to: ".search-input" +focus: ".search-input" // To ensure the `` container isnt focus or hover. +assert-css: ( + "//*[@class='result-name']/*[text()='test_docs::']/ancestor::a", + {"color": "rgb(0, 150, 207)", "background-color": "rgba(0, 0, 0, 0)"}, + ALL, +) + +// Checking color and background on hover. +move-cursor-to: "//*[@class='desc']//*[text()='Just a normal struct.']" +assert-css: ( + "//*[@class='result-name']/*[text()='test_docs::']", + {"color": "rgb(255, 255, 255)"}, +) +assert-css: ( + "//*[@class='result-name']/*[text()='test_docs::']/ancestor::a", + {"color": "rgb(255, 255, 255)", "background-color": "rgb(60, 60, 60)"}, +) + // Dark theme local-storage: { "rustdoc-theme": "dark", - "rustdoc-preferred-dark-theme": "dark", "rustdoc-use-system-theme": "false", } reload: @@ -48,12 +181,82 @@ assert-css: ( {"color": "rgb(221, 221, 221)"}, ) -// Checking the color for "keyword". +// Checking the color for "keyword" text. assert-css: ( "//*[@class='result-name']//*[text()='(keyword)']", {"color": "rgb(221, 221, 221)"}, ) +store-value: (entry_color, "rgb(221, 221, 221)") // color of the search entry +store-value: (hover_entry_color, "rgb(221, 221, 221)") // color of the hovered/focused search entry +store-value: (background_color, "rgba(0, 0, 0, 0)") // background color +store-value: (hover_background_color, "rgb(97, 97, 97)") // hover background color + +call-function: ( + "check-result-color", ( + "keyword", // item kind + "rgb(210, 153, 29)", // color of item kind + "rgb(210, 153, 29)", // color of hovered/focused item kind + ), +) +call-function: ( + "check-result-color", ( + "struct", // item kind + "rgb(45, 191, 184)", // color of item kind + "rgb(45, 191, 184)", // color of hovered/focused item kind + ), +) +call-function: ( + "check-result-color", ( + "associatedtype", // item kind + "rgb(210, 153, 29)", // color of item kind + "rgb(210, 153, 29)", // color of hovered/focused item kind + ), +) +call-function: ( + "check-result-color", ( + "tymethod", // item kind + "rgb(43, 171, 99)", // color of item kind + "rgb(43, 171, 99)", // color of hovered/focused item kind + ), +) +call-function: ( + "check-result-color", ( + "method", // item kind + "rgb(43, 171, 99)", // color of item kind + "rgb(43, 171, 99)", // color of hovered/focused item kind + ), +) +call-function: ( + "check-result-color", ( + "structfield", // item kind + "rgb(221, 221, 221)", // color of item kind + "rgb(221, 221, 221)", // color of hovered/focused item kind + ), +) +call-function: ( + "check-result-color", ( + "macro", // item kind + "rgb(9, 189, 0)", // color of item kind + "rgb(9, 189, 0)", // color of hovered/focused item kind + ), +) +call-function: ( + "check-result-color", ( + "fn", // item kind + "rgb(43, 171, 99)", // color of item kind + "rgb(43, 171, 99)", // color of hovered/focused item kind + ), +) + +// Checking the `` container. +move-cursor-to: ".search-input" +focus: ".search-input" // To ensure the `` container isnt focus or hover. +assert-css: ( + "//*[@class='result-name']/*[text()='test_docs::']/ancestor::a", + {"color": "rgb(221, 221, 221)", "background-color": "rgba(0, 0, 0, 0)"}, +) + // Light theme local-storage: {"rustdoc-theme": "light", "rustdoc-use-system-theme": "false"} reload: @@ -69,19 +272,88 @@ assert-css: ( {"color": "rgb(0, 0, 0)"}, ) -// Checking the color for "keyword". +// Checking the color for "keyword" text. assert-css: ( "//*[@class='result-name']//*[text()='(keyword)']", {"color": "rgb(0, 0, 0)"}, ) +store-value: (entry_color, "rgb(0, 0, 0)") // color of the search entry +store-value: (hover_entry_color, "rgb(0, 0, 0)") // color of the hovered/focused search entry +store-value: (background_color, "rgba(0, 0, 0, 0)") // background color +store-value: (hover_background_color, "rgb(204, 204, 204)") // hover background color + +call-function: ( + "check-result-color", ( + "keyword", // item kind + "rgb(56, 115, 173)", // color of item kind + "rgb(56, 115, 173)", // color of hovered/focused item kind + ), +) +call-function: ( + "check-result-color", ( + "struct", // item kind + "rgb(173, 55, 138)", // color of item kind + "rgb(173, 55, 138)", // color of hovered/focused item kind + ), +) +call-function: ( + "check-result-color", ( + "associatedtype", // item kind + "rgb(56, 115, 173)", // color of item kind + "rgb(56, 115, 173)", // color of hovered/focused item kind + ), +) +call-function: ( + "check-result-color", ( + "tymethod", // item kind + "rgb(173, 124, 55)", // color of item kind + "rgb(173, 124, 55)", // color of hovered/focused item kind + ), +) +call-function: ( + "check-result-color", ( + "method", // item kind + "rgb(173, 124, 55)", // color of item kind + "rgb(173, 124, 55)", // color of hovered/focused item kind + ), +) +call-function: ( + "check-result-color", ( + "structfield", // item kind + "rgb(0, 0, 0)", // color of item kind + "rgb(0, 0, 0)", // color of hovered/focused item kind + ), +) +call-function: ( + "check-result-color", ( + "macro", // item kind + "rgb(6, 128, 0)", // color of item kind + "rgb(6, 128, 0)", // color of hovered/focused item kind + ), +) +call-function: ( + "check-result-color", ( + "fn", // item kind + "rgb(173, 124, 55)", // color of item kind + "rgb(173, 124, 55)", // color of hovered/focused item kind + ), +) + +// Checking the `` container. +move-cursor-to: ".search-input" +focus: ".search-input" // To ensure the `` container isnt focus or hover. +assert-css: ( + "//*[@class='result-name']/*[text()='test_docs::']/ancestor::a", + {"color": "rgb(0, 0, 0)", "background-color": "rgba(0, 0, 0, 0)"}, +) + // Check the alias more specifically in the dark theme. -goto: file://|DOC_PATH|/test_docs/index.html +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-preferred-dark-theme": "dark", "rustdoc-use-system-theme": "false", } // If the text isn't displayed, the browser doesn't compute color style correctly... diff --git a/src/test/rustdoc-gui/search-result-description.goml b/src/test/rustdoc-gui/search-result-description.goml index d8cb6ee57..53a335b63 100644 --- a/src/test/rustdoc-gui/search-result-description.goml +++ b/src/test/rustdoc-gui/search-result-description.goml @@ -1,5 +1,5 @@ // This test is to ensure that the codeblocks are correctly rendered in the search results. -goto: file://|DOC_PATH|/test_docs/index.html?search=some_more_function +goto: "file://" + |DOC_PATH| + "/test_docs/index.html?search=some_more_function" // Waiting for the search results to appear... wait-for: "#titles" assert-text: (".search-results .desc code", "format!") diff --git a/src/test/rustdoc-gui/search-result-display.goml b/src/test/rustdoc-gui/search-result-display.goml index 8464ba7c2..053bfd8c9 100644 --- a/src/test/rustdoc-gui/search-result-display.goml +++ b/src/test/rustdoc-gui/search-result-display.goml @@ -1,29 +1,28 @@ // Checks that the search results have the expected width. -goto: file://|DOC_PATH|/test_docs/index.html +goto: "file://" + |DOC_PATH| + "/test_docs/index.html" size: (900, 1000) write: (".search-input", "test") // To be SURE that the search will be run. press-key: 'Enter' -wait-for: "#search-settings" +wait-for: "#crate-search" // The width is returned by "getComputedStyle" which returns the exact number instead of the // CSS rule which is "50%"... -assert-css: (".search-results div.desc", {"width": "295px"}) +assert-css: (".search-results div.desc", {"width": "318px"}) size: (600, 100) // As counter-intuitive as it may seem, in this width, the width is "100%", which is why // when computed it's larger. -assert-css: (".search-results div.desc", {"width": "570px"}) +assert-css: (".search-results div.desc", {"width": "566px"}) + +// The result set is all on one line. +assert-css: (".search-results .result-name > span", {"display": "inline"}) // Check that the crate filter `` isn't bigger than its container. +// Then we compare again to confirm the height didn't change. +assert-css: ("#crate-search", {"width": "527px"}) +assert-css: (".search-results-title", {"height": "44px", "width": "640px"}) +// And we check that the `