diff options
Diffstat (limited to '')
-rw-r--r-- | tests/rustdoc-gui/README.md | 34 | ||||
-rw-r--r-- | tests/rustdoc-gui/anchor-navigable.goml (renamed from src/test/rustdoc-gui/anchor-navigable.goml) | 0 | ||||
-rw-r--r-- | tests/rustdoc-gui/anchors.goml | 109 | ||||
-rw-r--r-- | tests/rustdoc-gui/auto-hide-trait-implementations.goml (renamed from src/test/rustdoc-gui/auto-hide-trait-implementations.goml) | 0 | ||||
-rw-r--r-- | tests/rustdoc-gui/basic-code.goml | 6 | ||||
-rw-r--r-- | tests/rustdoc-gui/check-code-blocks-margin.goml (renamed from src/test/rustdoc-gui/check-code-blocks-margin.goml) | 0 | ||||
-rw-r--r-- | tests/rustdoc-gui/check-stab-in-docblock.goml (renamed from src/test/rustdoc-gui/check-stab-in-docblock.goml) | 0 | ||||
-rw-r--r-- | tests/rustdoc-gui/check_info_sign_position.goml (renamed from src/test/rustdoc-gui/check_info_sign_position.goml) | 0 | ||||
-rw-r--r-- | tests/rustdoc-gui/code-blocks-overflow.goml (renamed from src/test/rustdoc-gui/code-blocks-overflow.goml) | 0 | ||||
-rw-r--r-- | tests/rustdoc-gui/code-color.goml | 24 | ||||
-rw-r--r-- | tests/rustdoc-gui/code-sidebar-toggle.goml (renamed from src/test/rustdoc-gui/code-sidebar-toggle.goml) | 4 | ||||
-rw-r--r-- | tests/rustdoc-gui/code-tags.goml (renamed from src/test/rustdoc-gui/code-tags.goml) | 10 | ||||
-rw-r--r-- | tests/rustdoc-gui/codeblock-sub.goml | 5 | ||||
-rw-r--r-- | tests/rustdoc-gui/codeblock-tooltip.goml (renamed from src/test/rustdoc-gui/codeblock-tooltip.goml) | 89 | ||||
-rw-r--r-- | tests/rustdoc-gui/cursor.goml (renamed from src/test/rustdoc-gui/cursor.goml) | 6 | ||||
-rw-r--r-- | tests/rustdoc-gui/default-settings.goml (renamed from src/test/rustdoc-gui/default-settings.goml) | 0 | ||||
-rw-r--r-- | tests/rustdoc-gui/docblock-big-code-mobile.goml | 13 | ||||
-rw-r--r-- | tests/rustdoc-gui/docblock-code-block-line-number.goml | 71 | ||||
-rw-r--r-- | tests/rustdoc-gui/docblock-details.goml (renamed from src/test/rustdoc-gui/docblock-details.goml) | 0 | ||||
-rw-r--r-- | tests/rustdoc-gui/docblock-table-overflow.goml (renamed from src/test/rustdoc-gui/docblock-table-overflow.goml) | 0 | ||||
-rw-r--r-- | tests/rustdoc-gui/docblock-table.goml | 52 | ||||
-rw-r--r-- | tests/rustdoc-gui/duplicate-macro-reexport.goml (renamed from src/test/rustdoc-gui/duplicate-macro-reexport.goml) | 0 | ||||
-rw-r--r-- | tests/rustdoc-gui/enum-variants.goml (renamed from src/test/rustdoc-gui/enum-variants.goml) | 0 | ||||
-rw-r--r-- | tests/rustdoc-gui/escape-key.goml (renamed from src/test/rustdoc-gui/escape-key.goml) | 2 | ||||
-rw-r--r-- | tests/rustdoc-gui/font-weight.goml (renamed from src/test/rustdoc-gui/font-weight.goml) | 6 | ||||
-rw-r--r-- | tests/rustdoc-gui/hash-item-expansion.goml (renamed from src/test/rustdoc-gui/hash-item-expansion.goml) | 0 | ||||
-rw-r--r-- | tests/rustdoc-gui/headers-color.goml | 70 | ||||
-rw-r--r-- | tests/rustdoc-gui/headings.goml (renamed from src/test/rustdoc-gui/headings.goml) | 54 | ||||
-rw-r--r-- | tests/rustdoc-gui/help-page.goml (renamed from src/test/rustdoc-gui/help-page.goml) | 24 | ||||
-rw-r--r-- | tests/rustdoc-gui/highlight-colors.goml | 94 | ||||
-rw-r--r-- | tests/rustdoc-gui/huge-collection-of-constants.goml (renamed from src/test/rustdoc-gui/huge-collection-of-constants.goml) | 0 | ||||
-rw-r--r-- | tests/rustdoc-gui/huge-logo.goml (renamed from src/test/rustdoc-gui/huge-logo.goml) | 0 | ||||
-rw-r--r-- | tests/rustdoc-gui/impl-default-expansion.goml (renamed from src/test/rustdoc-gui/impl-default-expansion.goml) | 0 | ||||
-rw-r--r-- | tests/rustdoc-gui/impl-doc.goml | 9 | ||||
-rw-r--r-- | tests/rustdoc-gui/implementors.goml (renamed from src/test/rustdoc-gui/implementors.goml) | 6 | ||||
-rw-r--r-- | tests/rustdoc-gui/item-decl-colors.goml | 80 | ||||
-rw-r--r-- | tests/rustdoc-gui/item-info-alignment.goml (renamed from src/test/rustdoc-gui/item-info-alignment.goml) | 0 | ||||
-rw-r--r-- | tests/rustdoc-gui/item-info-overflow.goml (renamed from src/test/rustdoc-gui/item-info-overflow.goml) | 0 | ||||
-rw-r--r-- | tests/rustdoc-gui/item-info.goml (renamed from src/test/rustdoc-gui/item-info.goml) | 0 | ||||
-rw-r--r-- | tests/rustdoc-gui/item-summary-table.goml (renamed from src/test/rustdoc-gui/item-summary-table.goml) | 0 | ||||
-rw-r--r-- | tests/rustdoc-gui/javascript-disabled.goml (renamed from src/test/rustdoc-gui/javascript-disabled.goml) | 0 | ||||
-rw-r--r-- | tests/rustdoc-gui/jump-to-def-background.goml (renamed from src/test/rustdoc-gui/jump-to-def-background.goml) | 12 | ||||
-rw-r--r-- | tests/rustdoc-gui/label-next-to-symbol.goml (renamed from src/test/rustdoc-gui/label-next-to-symbol.goml) | 0 | ||||
-rw-r--r-- | tests/rustdoc-gui/links-color.goml | 98 | ||||
-rw-r--r-- | tests/rustdoc-gui/list_code_block.goml (renamed from src/test/rustdoc-gui/list_code_block.goml) | 2 | ||||
-rw-r--r-- | tests/rustdoc-gui/method-margins.goml | 18 | ||||
-rw-r--r-- | tests/rustdoc-gui/mobile.goml (renamed from src/test/rustdoc-gui/mobile.goml) | 6 | ||||
-rw-r--r-- | tests/rustdoc-gui/module-items-font.goml (renamed from src/test/rustdoc-gui/module-items-font.goml) | 0 | ||||
-rw-r--r-- | tests/rustdoc-gui/no-docblock.goml (renamed from src/test/rustdoc-gui/no-docblock.goml) | 0 | ||||
-rw-r--r-- | tests/rustdoc-gui/notable-trait.goml (renamed from src/test/rustdoc-gui/notable-trait.goml) | 32 | ||||
-rw-r--r-- | tests/rustdoc-gui/overflow-tooltip-information.goml (renamed from src/test/rustdoc-gui/overflow-tooltip-information.goml) | 0 | ||||
-rw-r--r-- | tests/rustdoc-gui/pocket-menu.goml (renamed from src/test/rustdoc-gui/pocket-menu.goml) | 0 | ||||
-rw-r--r-- | tests/rustdoc-gui/run-on-hover.goml (renamed from src/test/rustdoc-gui/run-on-hover.goml) | 22 | ||||
-rw-r--r-- | tests/rustdoc-gui/rust-logo.goml | 58 | ||||
-rw-r--r-- | tests/rustdoc-gui/scrape-examples-button-focus.goml (renamed from src/test/rustdoc-gui/scrape-examples-button-focus.goml) | 12 | ||||
-rw-r--r-- | tests/rustdoc-gui/scrape-examples-color.goml | 60 | ||||
-rw-r--r-- | tests/rustdoc-gui/scrape-examples-fonts.goml (renamed from src/test/rustdoc-gui/scrape-examples-fonts.goml) | 1 | ||||
-rw-r--r-- | tests/rustdoc-gui/scrape-examples-layout.goml | 49 | ||||
-rw-r--r-- | tests/rustdoc-gui/scrape-examples-toggle.goml | 51 | ||||
-rw-r--r-- | tests/rustdoc-gui/search-filter.goml (renamed from src/test/rustdoc-gui/search-filter.goml) | 8 | ||||
-rw-r--r-- | tests/rustdoc-gui/search-form-elements.goml (renamed from src/test/rustdoc-gui/search-form-elements.goml) | 0 | ||||
-rw-r--r-- | tests/rustdoc-gui/search-input-mobile.goml (renamed from src/test/rustdoc-gui/search-input-mobile.goml) | 0 | ||||
-rw-r--r-- | tests/rustdoc-gui/search-keyboard.goml (renamed from src/test/rustdoc-gui/search-keyboard.goml) | 2 | ||||
-rw-r--r-- | tests/rustdoc-gui/search-no-result.goml | 36 | ||||
-rw-r--r-- | tests/rustdoc-gui/search-reexport.goml (renamed from src/test/rustdoc-gui/search-reexport.goml) | 0 | ||||
-rw-r--r-- | tests/rustdoc-gui/search-result-color.goml (renamed from src/test/rustdoc-gui/search-result-color.goml) | 112 | ||||
-rw-r--r-- | tests/rustdoc-gui/search-result-description.goml (renamed from src/test/rustdoc-gui/search-result-description.goml) | 2 | ||||
-rw-r--r-- | tests/rustdoc-gui/search-result-display.goml (renamed from src/test/rustdoc-gui/search-result-display.goml) | 22 | ||||
-rw-r--r-- | tests/rustdoc-gui/search-result-go-to-first.goml (renamed from src/test/rustdoc-gui/search-result-go-to-first.goml) | 8 | ||||
-rw-r--r-- | tests/rustdoc-gui/search-result-keyword.goml (renamed from src/test/rustdoc-gui/search-result-keyword.goml) | 2 | ||||
-rw-r--r-- | tests/rustdoc-gui/search-tab-change-title-fn-sig.goml | 74 | ||||
-rw-r--r-- | tests/rustdoc-gui/search-tab.goml | 76 | ||||
-rw-r--r-- | tests/rustdoc-gui/settings.goml (renamed from src/test/rustdoc-gui/settings.goml) | 57 | ||||
-rw-r--r-- | tests/rustdoc-gui/shortcuts.goml (renamed from src/test/rustdoc-gui/shortcuts.goml) | 0 | ||||
-rw-r--r-- | tests/rustdoc-gui/sidebar-links-color.goml (renamed from src/test/rustdoc-gui/sidebar-links-color.goml) | 78 | ||||
-rw-r--r-- | tests/rustdoc-gui/sidebar-macro-reexport.goml (renamed from src/test/rustdoc-gui/sidebar-macro-reexport.goml) | 0 | ||||
-rw-r--r-- | tests/rustdoc-gui/sidebar-mobile-scroll.goml (renamed from src/test/rustdoc-gui/sidebar-mobile-scroll.goml) | 0 | ||||
-rw-r--r-- | tests/rustdoc-gui/sidebar-mobile.goml (renamed from src/test/rustdoc-gui/sidebar-mobile.goml) | 14 | ||||
-rw-r--r-- | tests/rustdoc-gui/sidebar-source-code-display.goml | 215 | ||||
-rw-r--r-- | tests/rustdoc-gui/sidebar-source-code.goml | 90 | ||||
-rw-r--r-- | tests/rustdoc-gui/sidebar.goml (renamed from src/test/rustdoc-gui/sidebar.goml) | 46 | ||||
-rw-r--r-- | tests/rustdoc-gui/source-anchor-scroll.goml (renamed from src/test/rustdoc-gui/source-anchor-scroll.goml) | 0 | ||||
-rw-r--r-- | tests/rustdoc-gui/source-code-page.goml | 218 | ||||
-rw-r--r-- | tests/rustdoc-gui/src-font-size.goml (renamed from src/test/rustdoc-gui/src-font-size.goml) | 0 | ||||
-rw-r--r-- | tests/rustdoc-gui/src/huge_logo/Cargo.lock (renamed from src/test/rustdoc-gui/src/huge_logo/Cargo.lock) | 0 | ||||
-rw-r--r-- | tests/rustdoc-gui/src/huge_logo/Cargo.toml (renamed from src/test/rustdoc-gui/src/huge_logo/Cargo.toml) | 0 | ||||
-rw-r--r-- | tests/rustdoc-gui/src/huge_logo/src/lib.rs (renamed from src/test/rustdoc-gui/src/huge_logo/src/lib.rs) | 0 | ||||
-rw-r--r-- | tests/rustdoc-gui/src/lib2/Cargo.lock | 22 | ||||
-rw-r--r-- | tests/rustdoc-gui/src/lib2/Cargo.toml | 11 | ||||
-rw-r--r-- | tests/rustdoc-gui/src/lib2/another_folder/mod.rs (renamed from src/test/rustdoc-gui/src/lib2/another_folder/mod.rs) | 0 | ||||
-rw-r--r-- | tests/rustdoc-gui/src/lib2/another_folder/sub_mod/mod.rs (renamed from src/test/rustdoc-gui/src/lib2/another_folder/sub_mod/mod.rs) | 0 | ||||
-rw-r--r-- | tests/rustdoc-gui/src/lib2/another_mod/mod.rs (renamed from src/test/rustdoc-gui/src/lib2/another_mod/mod.rs) | 0 | ||||
-rw-r--r-- | tests/rustdoc-gui/src/lib2/http/Cargo.toml | 7 | ||||
-rw-r--r-- | tests/rustdoc-gui/src/lib2/http/lib.rs | 1 | ||||
-rw-r--r-- | tests/rustdoc-gui/src/lib2/implementors/Cargo.lock (renamed from src/test/rustdoc-gui/src/lib2/implementors/Cargo.lock) | 0 | ||||
-rw-r--r-- | tests/rustdoc-gui/src/lib2/implementors/Cargo.toml | 10 | ||||
-rw-r--r-- | tests/rustdoc-gui/src/lib2/implementors/lib.rs | 22 | ||||
-rw-r--r-- | tests/rustdoc-gui/src/lib2/lib.rs | 343 | ||||
-rw-r--r-- | tests/rustdoc-gui/src/link_to_definition/Cargo.lock (renamed from src/test/rustdoc-gui/src/link_to_definition/Cargo.lock) | 0 | ||||
-rw-r--r-- | tests/rustdoc-gui/src/link_to_definition/Cargo.toml (renamed from src/test/rustdoc-gui/src/link_to_definition/Cargo.toml) | 0 | ||||
-rw-r--r-- | tests/rustdoc-gui/src/link_to_definition/lib.rs (renamed from src/test/rustdoc-gui/src/link_to_definition/lib.rs) | 0 | ||||
-rw-r--r-- | tests/rustdoc-gui/src/scrape_examples/Cargo.lock (renamed from src/test/rustdoc-gui/src/scrape_examples/Cargo.lock) | 0 | ||||
-rw-r--r-- | tests/rustdoc-gui/src/scrape_examples/Cargo.toml (renamed from src/test/rustdoc-gui/src/scrape_examples/Cargo.toml) | 0 | ||||
-rw-r--r-- | tests/rustdoc-gui/src/scrape_examples/examples/check-many-1.rs | 13 | ||||
-rw-r--r-- | tests/rustdoc-gui/src/scrape_examples/examples/check-many-2.rs | 13 | ||||
-rw-r--r-- | tests/rustdoc-gui/src/scrape_examples/examples/check-many-3.rs | 13 | ||||
-rw-r--r-- | tests/rustdoc-gui/src/scrape_examples/examples/check-many-4.rs | 13 | ||||
-rw-r--r-- | tests/rustdoc-gui/src/scrape_examples/examples/check-many-5.rs | 13 | ||||
-rw-r--r-- | tests/rustdoc-gui/src/scrape_examples/examples/check-many-6.rs | 13 | ||||
-rw-r--r-- | tests/rustdoc-gui/src/scrape_examples/examples/check-many-7.rs | 13 | ||||
-rw-r--r-- | tests/rustdoc-gui/src/scrape_examples/examples/check.rs (renamed from src/test/rustdoc-gui/src/scrape_examples/examples/check.rs) | 0 | ||||
-rw-r--r-- | tests/rustdoc-gui/src/scrape_examples/src/lib.rs (renamed from src/test/rustdoc-gui/src/scrape_examples/src/lib.rs) | 0 | ||||
-rw-r--r-- | tests/rustdoc-gui/src/settings/.cargo/config.toml (renamed from src/test/rustdoc-gui/src/settings/.cargo/config.toml) | 0 | ||||
-rw-r--r-- | tests/rustdoc-gui/src/settings/Cargo.lock (renamed from src/test/rustdoc-gui/src/settings/Cargo.lock) | 0 | ||||
-rw-r--r-- | tests/rustdoc-gui/src/settings/Cargo.toml (renamed from src/test/rustdoc-gui/src/settings/Cargo.toml) | 0 | ||||
-rw-r--r-- | tests/rustdoc-gui/src/settings/lib.rs (renamed from src/test/rustdoc-gui/src/settings/lib.rs) | 0 | ||||
-rw-r--r-- | tests/rustdoc-gui/src/staged_api/Cargo.lock (renamed from src/test/rustdoc-gui/src/staged_api/Cargo.lock) | 0 | ||||
-rw-r--r-- | tests/rustdoc-gui/src/staged_api/Cargo.toml (renamed from src/test/rustdoc-gui/src/staged_api/Cargo.toml) | 0 | ||||
-rw-r--r-- | tests/rustdoc-gui/src/staged_api/lib.rs (renamed from src/test/rustdoc-gui/src/staged_api/lib.rs) | 0 | ||||
-rw-r--r-- | tests/rustdoc-gui/src/test_docs/Cargo.lock (renamed from src/test/rustdoc-gui/src/test_docs/Cargo.lock) | 0 | ||||
-rw-r--r-- | tests/rustdoc-gui/src/test_docs/Cargo.toml (renamed from src/test/rustdoc-gui/src/test_docs/Cargo.toml) | 0 | ||||
-rw-r--r-- | tests/rustdoc-gui/src/test_docs/build.rs (renamed from src/test/rustdoc-gui/src/test_docs/build.rs) | 0 | ||||
-rw-r--r-- | tests/rustdoc-gui/src/test_docs/lib.rs | 476 | ||||
-rw-r--r-- | tests/rustdoc-gui/src/test_docs/macros.rs (renamed from src/test/rustdoc-gui/src/test_docs/macros.rs) | 0 | ||||
-rw-r--r-- | tests/rustdoc-gui/stab-badge.goml | 41 | ||||
-rw-r--r-- | tests/rustdoc-gui/struct-fields.goml | 5 | ||||
-rw-r--r-- | tests/rustdoc-gui/target.goml (renamed from src/test/rustdoc-gui/target.goml) | 12 | ||||
-rw-r--r-- | tests/rustdoc-gui/theme-change.goml (renamed from src/test/rustdoc-gui/theme-change.goml) | 0 | ||||
-rw-r--r-- | tests/rustdoc-gui/theme-in-history.goml (renamed from src/test/rustdoc-gui/theme-in-history.goml) | 0 | ||||
-rw-r--r-- | tests/rustdoc-gui/toggle-click-deadspace.goml | 15 | ||||
-rw-r--r-- | tests/rustdoc-gui/toggle-docs-mobile.goml (renamed from src/test/rustdoc-gui/toggle-docs-mobile.goml) | 0 | ||||
-rw-r--r-- | tests/rustdoc-gui/toggle-docs.goml | 75 | ||||
-rw-r--r-- | tests/rustdoc-gui/toggle-implementors.goml (renamed from src/test/rustdoc-gui/toggle-implementors.goml) | 0 | ||||
-rw-r--r-- | tests/rustdoc-gui/toggled-open-implementations.goml (renamed from src/test/rustdoc-gui/toggled-open-implementations.goml) | 2 | ||||
-rw-r--r-- | tests/rustdoc-gui/trait-sidebar-item-order.goml (renamed from src/test/rustdoc-gui/trait-sidebar-item-order.goml) | 0 | ||||
-rw-r--r-- | tests/rustdoc-gui/type-declation-overflow.goml (renamed from src/test/rustdoc-gui/type-declation-overflow.goml) | 16 | ||||
-rw-r--r-- | tests/rustdoc-gui/unsafe-fn.goml (renamed from src/test/rustdoc-gui/unsafe-fn.goml) | 10 | ||||
-rw-r--r-- | tests/rustdoc-gui/where-whitespace.goml (renamed from src/test/rustdoc-gui/where-whitespace.goml) | 0 |
138 files changed, 3132 insertions, 276 deletions
diff --git a/tests/rustdoc-gui/README.md b/tests/rustdoc-gui/README.md new file mode 100644 index 000000000..1126a72ab --- /dev/null +++ b/tests/rustdoc-gui/README.md @@ -0,0 +1,34 @@ +The tests present here are used to test the generated HTML from rustdoc. The +goal is to prevent unsound/unexpected GUI changes. + +This is using the [browser-ui-test] framework to do so. It works as follows: + +It wraps [puppeteer] to send commands to a web browser in order to navigate and +test what's being currently displayed in the web page. + +You can find more information and its documentation in its [repository][browser-ui-test]. + +If you need to have more information on the tests run, you can use `--test-args`: + +```bash +$ ./x.py test tests/rustdoc-gui --stage 1 --test-args --debug +``` + +If you don't want to run in headless mode (helpful to debug sometimes), you can use +`--no-headless`: + +```bash +$ ./x.py test tests/rustdoc-gui --stage 1 --test-args --no-headless +``` + +To see the supported options, use `--help`. + +Important to be noted: if the chromium instance crashes when you run it, you might need to +use `--no-sandbox` to make it work: + +```bash +$ ./x.py test tests/rustdoc-gui --stage 1 --test-args --no-sandbox +``` + +[browser-ui-test]: https://github.com/GuillaumeGomez/browser-UI-test/ +[puppeteer]: https://pptr.dev/ diff --git a/src/test/rustdoc-gui/anchor-navigable.goml b/tests/rustdoc-gui/anchor-navigable.goml index 9d5c55a1e..9d5c55a1e 100644 --- a/src/test/rustdoc-gui/anchor-navigable.goml +++ b/tests/rustdoc-gui/anchor-navigable.goml diff --git a/tests/rustdoc-gui/anchors.goml b/tests/rustdoc-gui/anchors.goml new file mode 100644 index 000000000..85cb72274 --- /dev/null +++ b/tests/rustdoc-gui/anchors.goml @@ -0,0 +1,109 @@ +// This test is to ensure that the anchors (`§`) have the expected color and position. + +define-function: ( + "check-colors", + (theme, main_color, title_color, main_heading_color, main_heading_type_color, src_link_color, sidebar_link_color), + block { + goto: "file://" + |DOC_PATH| + "/staged_api/struct.Foo.html" + // This is needed to ensure that the text color is computed. + show-text: true + + // 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": |main_color|}) + assert-css: (".main-heading h1 a:nth-of-type(1)", {"color": |main_heading_color|}) + assert-css: (".main-heading a:nth-of-type(2)", {"color": |main_heading_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: ( + ".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|}, + ) + + 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: ("#top-doc-prose-title", {"color": |title_color|}) + + assert-css: (".sidebar a", {"color": |sidebar_link_color|}) + assert-css: (".main-heading h1 a", {"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": |main_color|}) + + // 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)", + "main_heading_color": "rgb(255, 255, 255)", + "main_heading_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)", + "main_heading_color": "rgb(221, 221, 221)", + "main_heading_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)", + "main_heading_color": "rgb(0, 0, 0)", + "main_heading_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/tests/rustdoc-gui/auto-hide-trait-implementations.goml index 0a619c352..0a619c352 100644 --- a/src/test/rustdoc-gui/auto-hide-trait-implementations.goml +++ b/tests/rustdoc-gui/auto-hide-trait-implementations.goml diff --git a/tests/rustdoc-gui/basic-code.goml b/tests/rustdoc-gui/basic-code.goml new file mode 100644 index 000000000..971c2f948 --- /dev/null +++ b/tests/rustdoc-gui/basic-code.goml @@ -0,0 +1,6 @@ +// Small test to ensure the "src-line-numbers" element is only present once on +// the page. +goto: "file://" + |DOC_PATH| + "/test_docs/index.html" +click: ".srclink" +wait-for: ".src-line-numbers" +assert-count: (".src-line-numbers", 1) diff --git a/src/test/rustdoc-gui/check-code-blocks-margin.goml b/tests/rustdoc-gui/check-code-blocks-margin.goml index c2cec0020..c2cec0020 100644 --- a/src/test/rustdoc-gui/check-code-blocks-margin.goml +++ b/tests/rustdoc-gui/check-code-blocks-margin.goml diff --git a/src/test/rustdoc-gui/check-stab-in-docblock.goml b/tests/rustdoc-gui/check-stab-in-docblock.goml index 266fa9997..266fa9997 100644 --- a/src/test/rustdoc-gui/check-stab-in-docblock.goml +++ b/tests/rustdoc-gui/check-stab-in-docblock.goml diff --git a/src/test/rustdoc-gui/check_info_sign_position.goml b/tests/rustdoc-gui/check_info_sign_position.goml index f36e73fc5..f36e73fc5 100644 --- a/src/test/rustdoc-gui/check_info_sign_position.goml +++ b/tests/rustdoc-gui/check_info_sign_position.goml diff --git a/src/test/rustdoc-gui/code-blocks-overflow.goml b/tests/rustdoc-gui/code-blocks-overflow.goml index fbf0e890b..fbf0e890b 100644 --- a/src/test/rustdoc-gui/code-blocks-overflow.goml +++ b/tests/rustdoc-gui/code-blocks-overflow.goml diff --git a/tests/rustdoc-gui/code-color.goml b/tests/rustdoc-gui/code-color.goml new file mode 100644 index 000000000..cb550a457 --- /dev/null +++ b/tests/rustdoc-gui/code-color.goml @@ -0,0 +1,24 @@ +// The ayu theme has a different color for the "<code>" tags in the doc blocks. We need to +// check that the rule isn't applied on other "<code>" elements. +// +// While we're at it, we also check it for the other themes. +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 + +define-function: ( + "check-colors", + (theme, doc_code_color, doc_inline_code_color), + block { + // 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) + }, +) + +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/tests/rustdoc-gui/code-sidebar-toggle.goml index 00a0ea1e1..df665bd46 100644 --- a/src/test/rustdoc-gui/code-sidebar-toggle.goml +++ b/tests/rustdoc-gui/code-sidebar-toggle.goml @@ -1,7 +1,7 @@ // This test checks that the source code pages sidebar toggle is working as expected. goto: "file://" + |DOC_PATH| + "/test_docs/index.html" click: ".srclink" -wait-for: "#sidebar-toggle" -click: "#sidebar-toggle" +wait-for: "#src-sidebar-toggle" +click: "#src-sidebar-toggle" fail: true assert-css: ("#source-sidebar", { "left": "-300px" }) diff --git a/src/test/rustdoc-gui/code-tags.goml b/tests/rustdoc-gui/code-tags.goml index 94c1a6525..8561f537f 100644 --- a/src/test/rustdoc-gui/code-tags.goml +++ b/tests/rustdoc-gui/code-tags.goml @@ -9,16 +9,16 @@ size: (1080, 600) // Check that their content is inside <pre><code> assert-count: (".example-wrap pre > code", 4) // Check that function signature is inside <pre><code> -assert: "pre.rust.fn > code" +assert: ".item-decl pre.rust > code" goto: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html" -assert: "pre.rust.struct > code" +assert: ".item-decl pre.rust > code" goto: "file://" + |DOC_PATH| + "/test_docs/enum.AnEnum.html" -assert: "pre.rust.enum > code" +assert: ".item-decl pre.rust > code" goto: "file://" + |DOC_PATH| + "/test_docs/trait.AnotherOne.html" -assert: "pre.rust.trait > code" +assert: ".item-decl pre.rust > code" goto: "file://" + |DOC_PATH| + "/test_docs/type.SomeType.html" -assert: "pre.rust.typedef > code" +assert: ".item-decl pre.rust > code" diff --git a/tests/rustdoc-gui/codeblock-sub.goml b/tests/rustdoc-gui/codeblock-sub.goml new file mode 100644 index 000000000..cbd314d27 --- /dev/null +++ b/tests/rustdoc-gui/codeblock-sub.goml @@ -0,0 +1,5 @@ +// Test that code blocks nested within <sub> do not have a line height of 0. +goto: "file://" + |DOC_PATH| + "/test_docs/codeblock_sub/index.html" + +store-property: (codeblock_sub_1, "#codeblock-sub-1", "offsetHeight") +assert-property-false: ("#codeblock-sub-3", { "offsetHeight": |codeblock_sub_1| }) diff --git a/src/test/rustdoc-gui/codeblock-tooltip.goml b/tests/rustdoc-gui/codeblock-tooltip.goml index 4d923be3e..a3ef4e77b 100644 --- a/src/test/rustdoc-gui/codeblock-tooltip.goml +++ b/tests/rustdoc-gui/codeblock-tooltip.goml @@ -5,131 +5,128 @@ show-text: true define-function: ( "check-colors", (theme, background, color, border), - [ + block { // Setting the theme. - ("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}), - ("reload"), + local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} + reload: // compile_fail block - ("assert-css", ( + assert-css: ( ".docblock .example-wrap.compile_fail .tooltip", {"color": "rgba(255, 0, 0, 0.5)"}, - )), - ("assert-css", ( + ) + 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"), + move-cursor-to: ".docblock .example-wrap.compile_fail .tooltip" - ("assert-css", ( + assert-css: ( ".docblock .example-wrap.compile_fail .tooltip", {"color": "rgb(255, 0, 0)"}, - )), - ("assert-css", ( + ) + assert-css: ( ".docblock .example-wrap.compile_fail", {"border-left": "2px solid rgb(255, 0, 0)"}, - )), - ("assert-css", ( + ) + assert-css: ( ".docblock .example-wrap.compile_fail .tooltip::after", { "content": '"This example deliberately fails to compile"', - "text-align": "center", "padding": "5px 3px 3px", "background-color": |background|, "color": |color|, "border": "1px solid " + |border|, }, - )), - ("assert-css", ( + ) + assert-css: ( ".docblock .example-wrap.compile_fail .tooltip::before", { "border-width": "5px", "border-style": "solid", "border-color": "rgba(0, 0, 0, 0) " + |background| + " rgba(0, 0, 0, 0) rgba(0, 0, 0, 0)", }, - )), + ) // should_panic block - ("assert-css", ( + assert-css: ( ".docblock .example-wrap.should_panic .tooltip", {"color": "rgba(255, 0, 0, 0.5)"}, - )), - ("assert-css", ( + ) + 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"), + move-cursor-to: ".docblock .example-wrap.should_panic .tooltip" - ("assert-css", ( + assert-css: ( ".docblock .example-wrap.should_panic .tooltip", {"color": "rgb(255, 0, 0)"}, - )), - ("assert-css", ( + ) + assert-css: ( ".docblock .example-wrap.should_panic", {"border-left": "2px solid rgb(255, 0, 0)"}, - )), - ("assert-css", ( + ) + assert-css: ( ".docblock .example-wrap.should_panic .tooltip::after", { "content": '"This example panics"', - "text-align": "center", "padding": "5px 3px 3px", "background-color": |background|, "color": |color|, "border": "1px solid " + |border|, }, - )), - ("assert-css", ( + ) + assert-css: ( ".docblock .example-wrap.should_panic .tooltip::before", { "border-width": "5px", "border-style": "solid", "border-color": "rgba(0, 0, 0, 0) " + |background| + " rgba(0, 0, 0, 0) rgba(0, 0, 0, 0)", }, - )), + ) // ignore block - ("assert-css", ( + assert-css: ( ".docblock .example-wrap.ignore .tooltip", {"color": "rgba(255, 142, 0, 0.6)"}, - )), - ("assert-css", ( + ) + assert-css: ( ".docblock .example-wrap.ignore", {"border-left": "2px solid rgba(255, 142, 0, 0.6)"}, - )), + ) - ("move-cursor-to", ".docblock .example-wrap.ignore"), + move-cursor-to: ".docblock .example-wrap.ignore .tooltip" - ("assert-css", ( + assert-css: ( ".docblock .example-wrap.ignore .tooltip", {"color": "rgb(255, 142, 0)"}, - )), - ("assert-css", ( + ) + assert-css: ( ".docblock .example-wrap.ignore", {"border-left": "2px solid rgb(255, 142, 0)"}, - )), - ("assert-css", ( + ) + assert-css: ( ".docblock .example-wrap.ignore .tooltip::after", { "content": '"This example is not tested"', - "text-align": "center", "padding": "5px 3px 3px", "background-color": |background|, "color": |color|, "border": "1px solid " + |border|, }, - )), - ("assert-css", ( + ) + assert-css: ( ".docblock .example-wrap.ignore .tooltip::before", { "border-width": "5px", "border-style": "solid", "border-color": "rgba(0, 0, 0, 0) " + |background| + " rgba(0, 0, 0, 0) rgba(0, 0, 0, 0)", }, - )), - ], + ) + }, ) call-function: ("check-colors", { diff --git a/src/test/rustdoc-gui/cursor.goml b/tests/rustdoc-gui/cursor.goml index b2e91cb81..59b139797 100644 --- a/src/test/rustdoc-gui/cursor.goml +++ b/tests/rustdoc-gui/cursor.goml @@ -12,8 +12,8 @@ write: (".search-input", "Foo") // To be SURE that the search will be run. press-key: 'Enter' // Waiting for the search results to appear... -wait-for: "#titles" -assert-css: ("#titles > button", {"cursor": "pointer"}) +wait-for: "#search-tabs" +assert-css: ("#search-tabs > button", {"cursor": "pointer"}) // mobile sidebar toggle button size: (500, 700) @@ -21,4 +21,4 @@ assert-css: (".sidebar-menu-toggle", {"cursor": "pointer"}) // the sidebar toggle button on the source code pages goto: "file://" + |DOC_PATH| + "/src/lib2/lib.rs.html" -assert-css: ("#sidebar-toggle > button", {"cursor": "pointer"}) +assert-css: ("#src-sidebar-toggle > button", {"cursor": "pointer"}) diff --git a/src/test/rustdoc-gui/default-settings.goml b/tests/rustdoc-gui/default-settings.goml index ab27b001e..ab27b001e 100644 --- a/src/test/rustdoc-gui/default-settings.goml +++ b/tests/rustdoc-gui/default-settings.goml diff --git a/tests/rustdoc-gui/docblock-big-code-mobile.goml b/tests/rustdoc-gui/docblock-big-code-mobile.goml new file mode 100644 index 000000000..3ce921c2c --- /dev/null +++ b/tests/rustdoc-gui/docblock-big-code-mobile.goml @@ -0,0 +1,13 @@ +// If we have a long `<code>`, 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" +// 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 +// around 20px (which is the font size). +assert-property: (".docblock p > code", {"offsetHeight": "44"}) + +// Same check, but where the long code block is also a link +goto: "file://" + |DOC_PATH| + "/test_docs/long_code_block_link/index.html" +assert-property: (".docblock p > a > code", {"offsetHeight": "44"}) diff --git a/tests/rustdoc-gui/docblock-code-block-line-number.goml b/tests/rustdoc-gui/docblock-code-block-line-number.goml new file mode 100644 index 000000000..69bcf5339 --- /dev/null +++ b/tests/rustdoc-gui/docblock-code-block-line-number.goml @@ -0,0 +1,71 @@ +// Checks that the setting "line numbers" is working as expected. +goto: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html" + +// Otherwise, we can't check text color +show-text: true + +// We check that without this setting, there is no line number displayed. +assert-false: "pre.example-line-numbers" + +// Let's now check some CSS properties... +define-function: ( + "check-colors", + (theme, color), + block { + // We now set the setting to show the line numbers on code examples. + local-storage: { + "rustdoc-theme": |theme|, + "rustdoc-use-system-theme": "false", + "rustdoc-line-numbers": "true" + } + // We reload to make the line numbers appear and change theme. + reload: + // We wait for them to be added into the DOM by the JS... + wait-for: "pre.example-line-numbers" + // If the test didn't fail, it means that it was found! + assert-css: ( + "pre.example-line-numbers", + { + "color": |color|, + "margin": "0px", + "padding": "14px 8px", + "text-align": "right", + }, + ALL, + ) + }, +) +call-function: ("check-colors", { + "theme": "ayu", + "color": "rgb(92, 103, 115)", +}) +call-function: ("check-colors", { + "theme": "dark", + "color": "rgb(59, 145, 226)", +}) +call-function: ("check-colors", { + "theme": "light", + "color": "rgb(198, 126, 45)", +}) + +// The first code block has two lines so let's check its `<pre>` elements lists both of them. +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" +wait-for: 100 // wait-for-false does not exist +assert-false: "pre.example-line-numbers" +assert-local-storage: {"rustdoc-line-numbers": "false" } + +// Finally, turn it on again. +click: "input#line-numbers" +wait-for: "pre.example-line-numbers" +assert-local-storage: {"rustdoc-line-numbers": "true" } diff --git a/src/test/rustdoc-gui/docblock-details.goml b/tests/rustdoc-gui/docblock-details.goml index 9ae571efb..9ae571efb 100644 --- a/src/test/rustdoc-gui/docblock-details.goml +++ b/tests/rustdoc-gui/docblock-details.goml diff --git a/src/test/rustdoc-gui/docblock-table-overflow.goml b/tests/rustdoc-gui/docblock-table-overflow.goml index d8670089a..d8670089a 100644 --- a/src/test/rustdoc-gui/docblock-table-overflow.goml +++ b/tests/rustdoc-gui/docblock-table-overflow.goml diff --git a/tests/rustdoc-gui/docblock-table.goml b/tests/rustdoc-gui/docblock-table.goml new file mode 100644 index 000000000..3dcb8abd4 --- /dev/null +++ b/tests/rustdoc-gui/docblock-table.goml @@ -0,0 +1,52 @@ +// This test checks the appearance of the tables in the doc comments. +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"]) + +define-function: ( + "check-colors", + (theme, border_color, zebra_stripe_color), + block { + local-storage: {"rustdoc-use-system-theme": "false", "rustdoc-theme": |theme|} + reload: + assert-css: (".top-doc .docblock table tbody tr:nth-child(1)", { + "background-color": "rgba(0, 0, 0, 0)", + }) + assert-css: (".top-doc .docblock table tbody tr:nth-child(2)", { + "background-color": |zebra_stripe_color|, + }) + assert-css: (".top-doc .docblock table tbody tr:nth-child(3)", { + "background-color": "rgba(0, 0, 0, 0)", + }) + assert-css: (".top-doc .docblock table tbody tr:nth-child(4)", { + "background-color": |zebra_stripe_color|, + }) + assert-css: (".top-doc .docblock table td", { + "border-style": "solid", + "border-width": "1px", + "border-color": |border_color|, + }) + assert-css: (".top-doc .docblock table th", { + "border-style": "solid", + "border-width": "1px", + "border-color": |border_color|, + }) + } +) + +call-function: ("check-colors", { + "theme": "dark", + "border_color": "rgb(224, 224, 224)", + "zebra_stripe_color": "rgb(42, 42, 42)", +}) +call-function: ("check-colors", { + "theme": "ayu", + "border_color": "rgb(92, 103, 115)", + "zebra_stripe_color": "rgb(25, 31, 38)", +}) +call-function: ("check-colors", { + "theme": "light", + "border_color": "rgb(224, 224, 224)", + "zebra_stripe_color": "rgb(245, 245, 245)", +}) diff --git a/src/test/rustdoc-gui/duplicate-macro-reexport.goml b/tests/rustdoc-gui/duplicate-macro-reexport.goml index 496203c12..496203c12 100644 --- a/src/test/rustdoc-gui/duplicate-macro-reexport.goml +++ b/tests/rustdoc-gui/duplicate-macro-reexport.goml diff --git a/src/test/rustdoc-gui/enum-variants.goml b/tests/rustdoc-gui/enum-variants.goml index 8dfc49285..8dfc49285 100644 --- a/src/test/rustdoc-gui/enum-variants.goml +++ b/tests/rustdoc-gui/enum-variants.goml diff --git a/src/test/rustdoc-gui/escape-key.goml b/tests/rustdoc-gui/escape-key.goml index 78e9f2309..5d80d2496 100644 --- a/src/test/rustdoc-gui/escape-key.goml +++ b/tests/rustdoc-gui/escape-key.goml @@ -5,7 +5,7 @@ goto: "file://" + |DOC_PATH| + "/test_docs/index.html" write: (".search-input", "test") // To be SURE that the search will be run. press-key: 'Enter' -wait-for: "#search h1" // The search element is empty before the first search +wait-for: "#search h1" // The search element is empty before the first search // Check that the currently displayed element is search. wait-for: "#alternative-display #search" assert-attribute: ("#main-content", {"class": "content hidden"}) diff --git a/src/test/rustdoc-gui/font-weight.goml b/tests/rustdoc-gui/font-weight.goml index 8ba005b0c..fafb15631 100644 --- a/src/test/rustdoc-gui/font-weight.goml +++ b/tests/rustdoc-gui/font-weight.goml @@ -20,7 +20,7 @@ goto: "file://" + |DOC_PATH| + "/lib2/trait.Trait.html" // This is a complex selector, so here's how it works: // // * //*[@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 +// * /pre[@class='rust'] — selects immediate child with tag pre and class rust // * /code — selects immediate child with tag code // * /a[@class='constant'] — selects immediate child with tag a and class constant // * //text() — selects child that is text node @@ -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 '<a>' because intermediate tags could be added. assert-count: ( - "//*[@class='item-decl']/pre[@class='rust trait']/code/a[@class='constant']//text()/parent::*", + "//*[@class='item-decl']/pre[@class='rust']/code/a[@class='constant']//text()/parent::*", 1, ) assert-css: ( - "//*[@class='item-decl']/pre[@class='rust trait']/code/a[@class='constant']//text()/parent::*", + "//*[@class='item-decl']/pre[@class='rust']/code/a[@class='constant']//text()/parent::*", {"font-weight": "400"}, ) diff --git a/src/test/rustdoc-gui/hash-item-expansion.goml b/tests/rustdoc-gui/hash-item-expansion.goml index 3cf94f624..3cf94f624 100644 --- a/src/test/rustdoc-gui/hash-item-expansion.goml +++ b/tests/rustdoc-gui/hash-item-expansion.goml diff --git a/tests/rustdoc-gui/headers-color.goml b/tests/rustdoc-gui/headers-color.goml new file mode 100644 index 000000000..92cf050a5 --- /dev/null +++ b/tests/rustdoc-gui/headers-color.goml @@ -0,0 +1,70 @@ +// This test check for headers text and background colors for the different themes. + +define-function: ( + "check-colors", + (theme, color, code_header_color, focus_background_color, headings_color), + block { + 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) + }, +) + +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)", + }, +) +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)", + }, +) +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)", + }, +) diff --git a/src/test/rustdoc-gui/headings.goml b/tests/rustdoc-gui/headings.goml index 85e17ca95..e4ba5f124 100644 --- a/src/test/rustdoc-gui/headings.goml +++ b/tests/rustdoc-gui/headings.goml @@ -13,7 +13,7 @@ // 14px 0.875rem goto: "file://" + |DOC_PATH| + "/test_docs/struct.HeavilyDocumentedStruct.html" -assert-css: ("h1.fqn", {"font-size": "24px"}) +assert-css: (".main-heading h1", {"font-size": "24px"}) assert-css: ("h2#top-doc-prose-title", {"font-size": "22px"}) assert-css: ("h2#top-doc-prose-title", {"border-bottom-width": "1px"}) @@ -52,7 +52,7 @@ assert-css: ("h6#sub-sub-heading-for-struct-impl-item-doc", {"font-size": "14px" goto: "file://" + |DOC_PATH| + "/test_docs/enum.HeavilyDocumentedEnum.html" -assert-css: ("h1.fqn", {"font-size": "24px"}) +assert-css: (".main-heading h1", {"font-size": "24px"}) assert-css: ("h2#top-doc-prose-title", {"font-size": "22px"}) assert-css: ("h2#top-doc-prose-title", {"border-bottom-width": "1px"}) @@ -111,7 +111,7 @@ assert-css: ("//ul[@class='block mod']/preceding-sibling::h3", {"border-bottom-w goto: "file://" + |DOC_PATH| + "/test_docs/union.HeavilyDocumentedUnion.html" -assert-css: ("h1.fqn", {"font-size": "24px"}) +assert-css: (".main-heading h1", {"font-size": "24px"}) assert-css: ("h2#top-doc-prose-title", {"font-size": "22px"}) assert-css: ("h2#top-doc-prose-title", {"border-bottom-width": "1px"}) @@ -143,7 +143,7 @@ assert-css: ("h6#sub-heading-for-union-impl-item-doc", {"border-bottom-width": " goto: "file://" + |DOC_PATH| + "/test_docs/macro.heavily_documented_macro.html" -assert-css: ("h1.fqn", {"font-size": "24px"}) +assert-css: (".main-heading h1", {"font-size": "24px"}) assert-css: ("h2#top-doc-prose-title", {"font-size": "22px"}) assert-css: ("h2#top-doc-prose-title", {"border-bottom-width": "1px"}) @@ -157,38 +157,38 @@ 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", ( + block { + 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", ( + ) + assert-css: ( ".top-doc .docblock h3", {"color": |heading_color|, "border-bottom": "1px solid " + |heading_border_color|}, - )), - ("assert-css", ( + ) + assert-css: ( ".top-doc .docblock h4", {"color": |heading_color|, "border-bottom": "1px solid " + |heading_border_color|}, - )), - ("assert-css", ( + ) + assert-css: ( ".top-doc .docblock h5", {"color": |small_heading_color|, "border-bottom-width": "0px"}, - )), - ("assert-css", ( + ) + assert-css: ( "#implementations-list .docblock h4", {"color": |heading_color|, "border-bottom-width": "0px"}, - )), - ("assert-css", ( + ) + assert-css: ( "#implementations-list .docblock h5", {"color": |small_heading_color|, "border-bottom-width": "0px"}, - )), - ("assert-css", ( + ) + assert-css: ( "#implementations-list .docblock h6", {"color": |small_heading_color|, "border-bottom-width": "0px"}, - )), - ], + ) + }, ) call-function: ( "check-colors", @@ -221,11 +221,11 @@ call-function: ( define-function: ( "check-since-color", (theme), - [ - ("local-storage", {"rustdoc-theme": |theme|}), - ("reload"), - ("assert-css", (".since", {"color": "rgb(128, 128, 128)"}, ALL)), - ], + block { + local-storage: {"rustdoc-theme": |theme|} + reload: + assert-css: (".since", {"color": "rgb(128, 128, 128)"}, ALL) + }, ) goto: "file://" + |DOC_PATH| + "/staged_api/struct.Foo.html" diff --git a/src/test/rustdoc-gui/help-page.goml b/tests/rustdoc-gui/help-page.goml index 799ba851c..5f4c1ba2f 100644 --- a/src/test/rustdoc-gui/help-page.goml +++ b/tests/rustdoc-gui/help-page.goml @@ -18,18 +18,17 @@ show-text: true define-function: ( "check-colors", (theme, color, background, box_shadow), - [ + block { // Setting the theme. - ("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}), + local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} // We reload the page so the local storage settings are being used. - ("reload"), - ("assert-css", ("#help kbd", { + reload: + assert-css: ("#help kbd", { "color": |color|, "background-color": |background|, "box-shadow": |box_shadow| + " 0px -1px 0px 0px inset", - "cursor": "default", - }, ALL)), - ], + }, ALL) + }, ) call-function: ("check-colors", { @@ -40,7 +39,7 @@ call-function: ("check-colors", { }) call-function: ("check-colors", { "theme": "dark", - "color": "rgb(221, 221, 221)", + "color": "rgb(0, 0, 0)", "background": "rgb(250, 251, 252)", "box_shadow": "rgb(198, 203, 209)", }) @@ -62,3 +61,12 @@ click: "#help-button > a" assert-css: ("#help", {"display": "none"}) compare-elements-property-false: (".sub", "#help", ["offsetWidth"]) compare-elements-position-false: (".sub", "#help", ("x")) + +// This test ensures that the "the rustdoc book" anchor link within the help popover works. +goto: "file://" + |DOC_PATH| + "/test_docs/index.html" +size: (1000, 1000) // Popover only appears when the screen width is >700px. +assert-false: "#help" +click: "#help-button > a" +click: ".popover a[href='https://doc.rust-lang.org/rustdoc/']" +wait-for: 2000 +assert-document-property: {"URL": "https://doc.rust-lang.org/rustdoc/"} diff --git a/tests/rustdoc-gui/highlight-colors.goml b/tests/rustdoc-gui/highlight-colors.goml new file mode 100644 index 000000000..b182150a5 --- /dev/null +++ b/tests/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, + attr, + macro, + question_mark, + comment, + doc_comment, + ), + block { + 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 .attr", {"color": |attr|}, 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)", + "attr": "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)", + "attr": "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)", + "attr": "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/tests/rustdoc-gui/huge-collection-of-constants.goml index 3ccd33f1c..3ccd33f1c 100644 --- a/src/test/rustdoc-gui/huge-collection-of-constants.goml +++ b/tests/rustdoc-gui/huge-collection-of-constants.goml diff --git a/src/test/rustdoc-gui/huge-logo.goml b/tests/rustdoc-gui/huge-logo.goml index 01f06771c..01f06771c 100644 --- a/src/test/rustdoc-gui/huge-logo.goml +++ b/tests/rustdoc-gui/huge-logo.goml diff --git a/src/test/rustdoc-gui/impl-default-expansion.goml b/tests/rustdoc-gui/impl-default-expansion.goml index c3f9240cc..c3f9240cc 100644 --- a/src/test/rustdoc-gui/impl-default-expansion.goml +++ b/tests/rustdoc-gui/impl-default-expansion.goml diff --git a/tests/rustdoc-gui/impl-doc.goml b/tests/rustdoc-gui/impl-doc.goml new file mode 100644 index 000000000..6caffb9c3 --- /dev/null +++ b/tests/rustdoc-gui/impl-doc.goml @@ -0,0 +1,9 @@ +// A docblock on an impl must have a margin to separate it from the contents. +goto: "file://" + |DOC_PATH| + "/test_docs/struct.TypeWithImplDoc.html" + +// The text is about 24px tall, so if there's a margin, then their position will be >24px apart +compare-elements-position-near-false: ( + "#implementations-list > .implementors-toggle > .docblock > p", + "#implementations-list > .implementors-toggle > .impl-items", + {"y": 24} +) diff --git a/src/test/rustdoc-gui/implementors.goml b/tests/rustdoc-gui/implementors.goml index 4999283dc..997c0ed8f 100644 --- a/src/test/rustdoc-gui/implementors.goml +++ b/tests/rustdoc-gui/implementors.goml @@ -33,3 +33,9 @@ goto: "file://" + |DOC_PATH| + "/lib2/trait.TraitToReexport.html" assert-count: ("#implementors-list .impl", 1) goto: "file://" + |DOC_PATH| + "/implementors/trait.TraitToReexport.html" assert-count: ("#implementors-list .impl", 1) + +// Now check that the link is properly rewritten for a crate called `http`. +// An older version of rustdoc had a buggy check for absolute links. +goto: "file://" + |DOC_PATH| + "/http/trait.HttpTrait.html" +assert-count: ("#implementors-list .impl", 1) +assert-attribute: ("#implementors-list .impl a.trait", {"href": "../http/trait.HttpTrait.html"}) diff --git a/tests/rustdoc-gui/item-decl-colors.goml b/tests/rustdoc-gui/item-decl-colors.goml new file mode 100644 index 000000000..c58e3eb7c --- /dev/null +++ b/tests/rustdoc-gui/item-decl-colors.goml @@ -0,0 +1,80 @@ +// This test ensures that the color of the items in the type decl are working as expected. + +// We need to disable this check because `implementors/test_docs/trait.TraitWithoutGenerics.js` +// doesn't exist. +fail-on-request-error: false + +define-function: ( + "check-colors", + ( + theme, + attr_color, + trait_color, + struct_color, + enum_color, + primitive_color, + constant_color, + fn_color, + assoc_type_color, + ), + block { + 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 .fn", {"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/tests/rustdoc-gui/item-info-alignment.goml index 94b52f005..94b52f005 100644 --- a/src/test/rustdoc-gui/item-info-alignment.goml +++ b/tests/rustdoc-gui/item-info-alignment.goml diff --git a/src/test/rustdoc-gui/item-info-overflow.goml b/tests/rustdoc-gui/item-info-overflow.goml index 8ea14621c..8ea14621c 100644 --- a/src/test/rustdoc-gui/item-info-overflow.goml +++ b/tests/rustdoc-gui/item-info-overflow.goml diff --git a/src/test/rustdoc-gui/item-info.goml b/tests/rustdoc-gui/item-info.goml index 6780dfca6..6780dfca6 100644 --- a/src/test/rustdoc-gui/item-info.goml +++ b/tests/rustdoc-gui/item-info.goml diff --git a/src/test/rustdoc-gui/item-summary-table.goml b/tests/rustdoc-gui/item-summary-table.goml index 2a92e9da5..2a92e9da5 100644 --- a/src/test/rustdoc-gui/item-summary-table.goml +++ b/tests/rustdoc-gui/item-summary-table.goml diff --git a/src/test/rustdoc-gui/javascript-disabled.goml b/tests/rustdoc-gui/javascript-disabled.goml index edf179d0d..edf179d0d 100644 --- a/src/test/rustdoc-gui/javascript-disabled.goml +++ b/tests/rustdoc-gui/javascript-disabled.goml diff --git a/src/test/rustdoc-gui/jump-to-def-background.goml b/tests/rustdoc-gui/jump-to-def-background.goml index b65faf13d..8ee3ccf4a 100644 --- a/src/test/rustdoc-gui/jump-to-def-background.goml +++ b/tests/rustdoc-gui/jump-to-def-background.goml @@ -4,17 +4,17 @@ goto: "file://" + |DOC_PATH| + "/src/link_to_definition/lib.rs.html" define-function: ( "check-background-color", (theme, background_color), - [ + block { // Set the theme. - ("local-storage", { "rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false" }), + 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", ( + reload: + assert-css: ( "body.source .example-wrap pre.rust a", {"background-color": |background_color|}, ALL, - )), - ], + ) + }, ) call-function: ("check-background-color", ("ayu", "rgb(51, 51, 51)")) diff --git a/src/test/rustdoc-gui/label-next-to-symbol.goml b/tests/rustdoc-gui/label-next-to-symbol.goml index 05f8ddc71..05f8ddc71 100644 --- a/src/test/rustdoc-gui/label-next-to-symbol.goml +++ b/tests/rustdoc-gui/label-next-to-symbol.goml diff --git a/tests/rustdoc-gui/links-color.goml b/tests/rustdoc-gui/links-color.goml new file mode 100644 index 000000000..14f7d9935 --- /dev/null +++ b/tests/rustdoc-gui/links-color.goml @@ -0,0 +1,98 @@ +// 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 + +define-function: ( + "check-colors", + (theme, mod, macro, struct, enum, trait, fn, type, union, keyword, + sidebar, sidebar_current, sidebar_current_background), + block { + local-storage: { + "rustdoc-theme": |theme|, + "rustdoc-use-system-theme": "false", + } + reload: + // Checking results colors. + assert-css: (".item-table .mod", {"color": |mod|}, ALL) + assert-css: (".item-table .macro", {"color": |macro|}, ALL) + assert-css: (".item-table .struct", {"color": |struct|}, ALL) + assert-css: (".item-table .enum", {"color": |enum|}, ALL) + assert-css: (".item-table .trait", {"color": |trait|}, ALL) + assert-css: (".item-table .fn", {"color": |fn|}, ALL) + assert-css: (".item-table .type", {"color": |type|}, ALL) + assert-css: (".item-table .union", {"color": |union|}, ALL) + assert-css: (".item-table .keyword", {"color": |keyword|}, ALL) + // Checking sidebar elements. + assert-css: ( + ".sidebar-elems a:not(.current)", + {"color": |sidebar|, "background-color": "rgba(0, 0, 0, 0)", "font-weight": "400"}, + ALL, + ) + assert-css: ( + ".sidebar-elems a.current", + { + "color": |sidebar_current|, + "background-color": |sidebar_current_background|, + "font-weight": "500", + }, + ALL, + ) + }, +) + +call-function: ( + "check-colors", + { + "theme": "ayu", + "mod": "rgb(57, 175, 215)", + "macro": "rgb(163, 122, 204)", + "struct": "rgb(255, 160, 165)", + "enum": "rgb(255, 160, 165)", + "trait": "rgb(57, 175, 215)", + "fn": "rgb(253, 214, 135)", + "type": "rgb(255, 160, 165)", + "union": "rgb(255, 160, 165)", + "keyword": "rgb(57, 175, 215)", + "sidebar": "rgb(83, 177, 219)", + "sidebar_current": "rgb(255, 180, 76)", + "sidebar_current_background": "rgba(0, 0, 0, 0)", + }, +) +call-function: ( + "check-colors", + { + "theme": "dark", + "mod": "rgb(210, 153, 29)", + "macro": "rgb(9, 189, 0)", + "struct": "rgb(45, 191, 184)", + "enum": "rgb(45, 191, 184)", + "trait": "rgb(183, 140, 242)", + "fn": "rgb(43, 171, 99)", + "type": "rgb(45, 191, 184)", + "union": "rgb(45, 191, 184)", + "keyword": "rgb(210, 153, 29)", + "sidebar": "rgb(253, 191, 53)", + "sidebar_current": "rgb(253, 191, 53)", + "sidebar_current_background": "rgb(68, 68, 68)", + }, +) +call-function: ( + "check-colors", + { + "theme": "light", + "mod": "rgb(56, 115, 173)", + "macro": "rgb(6, 128, 0)", + "struct": "rgb(173, 55, 138)", + "enum": "rgb(173, 55, 138)", + "trait": "rgb(110, 79, 201)", + "fn": "rgb(173, 124, 55)", + "type": "rgb(173, 55, 138)", + "union": "rgb(173, 55, 138)", + "keyword": "rgb(56, 115, 173)", + "sidebar": "rgb(53, 109, 164)", + "sidebar_current": "rgb(53, 109, 164)", + "sidebar_current_background": "rgb(255, 255, 255)", + }, +) diff --git a/src/test/rustdoc-gui/list_code_block.goml b/tests/rustdoc-gui/list_code_block.goml index 3423a449d..c527cfbfc 100644 --- a/src/test/rustdoc-gui/list_code_block.goml +++ b/tests/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" -assert: ("pre.rust.fn") +assert: (".item-decl pre.rust") diff --git a/tests/rustdoc-gui/method-margins.goml b/tests/rustdoc-gui/method-margins.goml new file mode 100644 index 000000000..720268a9e --- /dev/null +++ b/tests/rustdoc-gui/method-margins.goml @@ -0,0 +1,18 @@ +// This test ensures that the margins on methods are coherent inside an impl block. +goto: "file://" + |DOC_PATH| + "/test_docs/trait_members/struct.HasTrait.html#impl-TraitMembers-for-HasTrait" + +assert-count: ("#trait-implementations-list > .toggle", 1) + +compare-elements-css: ( + // compare margin on type with margin on method + "#trait-implementations-list .impl-items > .toggle:nth-child(1) > summary", + "#trait-implementations-list .impl-items > .toggle:nth-child(2) > summary", + ["margin"] +) + +compare-elements-css: ( + // compare margin on type with margin on method + "#trait-implementations-list .impl-items > .toggle:nth-child(1)", + "#trait-implementations-list .impl-items > .toggle:nth-child(2)", + ["margin"] +) diff --git a/src/test/rustdoc-gui/mobile.goml b/tests/rustdoc-gui/mobile.goml index 704542a39..895864d89 100644 --- a/src/test/rustdoc-gui/mobile.goml +++ b/tests/rustdoc-gui/mobile.goml @@ -27,4 +27,8 @@ assert-css-false: (".content .out-of-band .since::before", { "content": "\"Since 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}) +// 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/tests/rustdoc-gui/module-items-font.goml index cd3676a98..cd3676a98 100644 --- a/src/test/rustdoc-gui/module-items-font.goml +++ b/tests/rustdoc-gui/module-items-font.goml diff --git a/src/test/rustdoc-gui/no-docblock.goml b/tests/rustdoc-gui/no-docblock.goml index 17a955064..17a955064 100644 --- a/src/test/rustdoc-gui/no-docblock.goml +++ b/tests/rustdoc-gui/no-docblock.goml diff --git a/src/test/rustdoc-gui/notable-trait.goml b/tests/rustdoc-gui/notable-trait.goml index 7d4bd27d4..b4fa7d0db 100644 --- a/src/test/rustdoc-gui/notable-trait.goml +++ b/tests/rustdoc-gui/notable-trait.goml @@ -123,40 +123,40 @@ assert-count: ("//*[@class='notable popover']", 0) define-function: ( "check-colors", (theme, header_color, content_color, type_color, trait_color), - [ - ("goto", "file://" + |DOC_PATH| + "/test_docs/struct.NotableStructWithLongName.html"), + block { + goto: "file://" + |DOC_PATH| + "/test_docs/struct.NotableStructWithLongName.html" // This is needed to ensure that the text color is computed. - ("show-text", true), + show-text: true // Setting the theme. - ("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}), + local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} // We reload the page so the local storage settings are being used. - ("reload"), + reload: - ("move-cursor-to", "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']"), - ("assert-count", (".notable.popover", 1)), + move-cursor-to: "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']" + assert-count: (".notable.popover", 1) - ("assert-css", ( + assert-css: ( ".notable.popover h3", {"color": |header_color|}, ALL, - )), - ("assert-css", ( + ) + assert-css: ( ".notable.popover pre", {"color": |content_color|}, ALL, - )), - ("assert-css", ( + ) + assert-css: ( ".notable.popover pre a.struct", {"color": |type_color|}, ALL, - )), - ("assert-css", ( + ) + assert-css: ( ".notable.popover pre a.trait", {"color": |trait_color|}, ALL, - )), - ] + ) + }, ) call-function: ( diff --git a/src/test/rustdoc-gui/overflow-tooltip-information.goml b/tests/rustdoc-gui/overflow-tooltip-information.goml index 09ad6cdd7..09ad6cdd7 100644 --- a/src/test/rustdoc-gui/overflow-tooltip-information.goml +++ b/tests/rustdoc-gui/overflow-tooltip-information.goml diff --git a/src/test/rustdoc-gui/pocket-menu.goml b/tests/rustdoc-gui/pocket-menu.goml index c3649dc7b..c3649dc7b 100644 --- a/src/test/rustdoc-gui/pocket-menu.goml +++ b/tests/rustdoc-gui/pocket-menu.goml diff --git a/src/test/rustdoc-gui/run-on-hover.goml b/tests/rustdoc-gui/run-on-hover.goml index 57d63049f..8dcb62c10 100644 --- a/src/test/rustdoc-gui/run-on-hover.goml +++ b/tests/rustdoc-gui/run-on-hover.goml @@ -8,27 +8,27 @@ show-text: true define-function: ( "check-run-button", (theme, color, background, hover_color, hover_background), - [ - ("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}), - ("reload"), - ("assert-css", (".test-arrow", {"visibility": "hidden"})), - ("move-cursor-to", ".example-wrap"), - ("assert-css", (".test-arrow", { + block { + local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} + reload: + assert-css: (".test-arrow", {"visibility": "hidden"}) + move-cursor-to: ".example-wrap" + assert-css: (".test-arrow", { "visibility": "visible", "color": |color|, "background-color": |background|, "font-size": "22px", "border-radius": "5px", - })), - ("move-cursor-to", ".test-arrow"), - ("assert-css", (".test-arrow:hover", { + }) + move-cursor-to: ".test-arrow" + assert-css: (".test-arrow:hover", { "visibility": "visible", "color": |hover_color|, "background-color": |hover_background|, "font-size": "22px", "border-radius": "5px", - })), - ], + }) + }, ) call-function: ("check-run-button", { diff --git a/tests/rustdoc-gui/rust-logo.goml b/tests/rustdoc-gui/rust-logo.goml new file mode 100644 index 000000000..2d15e8b96 --- /dev/null +++ b/tests/rustdoc-gui/rust-logo.goml @@ -0,0 +1,58 @@ +// This test ensures that the correct style is applied to the rust logo in the sidebar. +goto: "file://" + |DOC_PATH| + "/test_docs/index.html" + +define-function: ( + "check-logo", + (theme, filter), + block { + // 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|}) + // Now we check that the non-rust logos don't have a CSS filter set. + goto: "file://" + |DOC_PATH| + "/huge_logo/index.html" + // Changing theme on the new page (again...). + local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} + reload: + // Check there is no rust logo + assert-false: ".rust-logo" + // Check there is no filter. + assert-css: (".sidebar .logo-container img", {"filter": "none"}) + }, +) + +call-function: ( + "check-logo", + { + "theme": "ayu", + "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", + { + "theme": "dark", + "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", + { + "theme": "light", + "filter": "none", + }, +) diff --git a/src/test/rustdoc-gui/scrape-examples-button-focus.goml b/tests/rustdoc-gui/scrape-examples-button-focus.goml index bba518db0..1b5c3a0d2 100644 --- a/src/test/rustdoc-gui/scrape-examples-button-focus.goml +++ b/tests/rustdoc-gui/scrape-examples-button-focus.goml @@ -1,3 +1,5 @@ +// This test ensures that the scraped examples buttons are working as expecting +// when 'Enter' key is pressed when they're focused. goto: "file://" + |DOC_PATH| + "/scrape_examples/fn.test.html" // The next/prev buttons vertically scroll the code viewport between examples @@ -5,25 +7,25 @@ store-property: (initialScrollTop, ".scraped-example-list > .scraped-example pre focus: ".scraped-example-list > .scraped-example .next" press-key: "Enter" assert-property-false: (".scraped-example-list > .scraped-example pre", { - "scrollTop": |initialScrollTop| + "scrollTop": |initialScrollTop| }) focus: ".scraped-example-list > .scraped-example .prev" press-key: "Enter" assert-property: (".scraped-example-list > .scraped-example pre", { - "scrollTop": |initialScrollTop| + "scrollTop": |initialScrollTop| }) // The expand button increases the scrollHeight of the minimized code viewport store-property: (smallOffsetHeight, ".scraped-example-list > .scraped-example pre", "offsetHeight") assert-property-false: (".scraped-example-list > .scraped-example pre", { - "scrollHeight": |smallOffsetHeight| + "scrollHeight": |smallOffsetHeight| }) focus: ".scraped-example-list > .scraped-example .expand" press-key: "Enter" assert-property-false: (".scraped-example-list > .scraped-example pre", { - "offsetHeight": |smallOffsetHeight| + "offsetHeight": |smallOffsetHeight| }) store-property: (fullOffsetHeight, ".scraped-example-list > .scraped-example pre", "offsetHeight") assert-property: (".scraped-example-list > .scraped-example pre", { - "scrollHeight": |fullOffsetHeight| + "scrollHeight": |fullOffsetHeight| }) diff --git a/tests/rustdoc-gui/scrape-examples-color.goml b/tests/rustdoc-gui/scrape-examples-color.goml new file mode 100644 index 000000000..40f31b277 --- /dev/null +++ b/tests/rustdoc-gui/scrape-examples-color.goml @@ -0,0 +1,60 @@ +// Check that scrape example code blocks have the expected colors. +goto: "file://" + |DOC_PATH| + "/scrape_examples/fn.test_many.html" +show-text: true + +define-function: ( + "check-colors", + (theme, highlight, highlight_focus, help_border, help_color, help_hover_border, + help_hover_color), + block { + local-storage: { "rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false", } + reload: + wait-for: ".more-examples-toggle" + assert-css: (".scraped-example .example-wrap .rust span.highlight:not(.focus)", { + "background-color": |highlight|, + }, ALL) + assert-css: (".scraped-example .example-wrap .rust span.highlight.focus", { + "background-color": |highlight_focus|, + }, ALL) + + assert-css: (".scraped-example-list .scrape-help", { + "border-color": |help_border|, + "color": |help_color|, + }) + move-cursor-to: ".scraped-example-list .scrape-help" + assert-css: (".scraped-example-list .scrape-help:hover", { + "border-color": |help_hover_border|, + "color": |help_hover_color|, + }) + // Moving the cursor to another item to not break next runs. + move-cursor-to: ".search-input" + } +) + +call-function: ("check-colors", { + "theme": "ayu", + "highlight": "rgb(91, 59, 1)", + "highlight_focus": "rgb(124, 75, 15)", + "help_border": "rgb(170, 170, 170)", + "help_color": "rgb(238, 238, 238)", + "help_hover_border": "rgb(255, 255, 255)", + "help_hover_color": "rgb(255, 255, 255)", +}) +call-function: ("check-colors", { + "theme": "dark", + "highlight": "rgb(91, 59, 1)", + "highlight_focus": "rgb(124, 75, 15)", + "help_border": "rgb(170, 170, 170)", + "help_color": "rgb(238, 238, 238)", + "help_hover_border": "rgb(255, 255, 255)", + "help_hover_color": "rgb(255, 255, 255)", +}) +call-function: ("check-colors", { + "theme": "light", + "highlight": "rgb(252, 255, 214)", + "highlight_focus": "rgb(246, 253, 176)", + "help_border": "rgb(85, 85, 85)", + "help_color": "rgb(51, 51, 51)", + "help_hover_border": "rgb(0, 0, 0)", + "help_hover_color": "rgb(0, 0, 0)", +}) diff --git a/src/test/rustdoc-gui/scrape-examples-fonts.goml b/tests/rustdoc-gui/scrape-examples-fonts.goml index b7d7f4ccb..142f337cb 100644 --- a/src/test/rustdoc-gui/scrape-examples-fonts.goml +++ b/tests/rustdoc-gui/scrape-examples-fonts.goml @@ -1,3 +1,4 @@ +// This test ensures that the correct font is used in scraped examples. goto: "file://" + |DOC_PATH| + "/scrape_examples/fn.test_many.html" store-value: (font, '"Fira Sans", Arial, NanumBarunGothic, sans-serif') diff --git a/tests/rustdoc-gui/scrape-examples-layout.goml b/tests/rustdoc-gui/scrape-examples-layout.goml new file mode 100644 index 000000000..95102528e --- /dev/null +++ b/tests/rustdoc-gui/scrape-examples-layout.goml @@ -0,0 +1,49 @@ +// Check that the line number column has the correct layout. +goto: "file://" + |DOC_PATH| + "/scrape_examples/fn.test_many.html" + +// Check that it's not zero. +assert-property-false: ( + ".more-scraped-examples .scraped-example .code-wrapper .src-line-numbers", + {"clientWidth": "0"} +) + +// Check that examples with very long lines have the same width as ones that don't. +store-property: ( + clientWidth, + ".more-scraped-examples .scraped-example:nth-child(2) .code-wrapper .src-line-numbers", + "clientWidth" +) + +assert-property: ( + ".more-scraped-examples .scraped-example:nth-child(3) .code-wrapper .src-line-numbers", + {"clientWidth": |clientWidth|} +) + +assert-property: ( + ".more-scraped-examples .scraped-example:nth-child(4) .code-wrapper .src-line-numbers", + {"clientWidth": |clientWidth|} +) + +assert-property: ( + ".more-scraped-examples .scraped-example:nth-child(5) .code-wrapper .src-line-numbers", + {"clientWidth": |clientWidth|} +) + +assert-property: ( + ".more-scraped-examples .scraped-example:nth-child(6) .code-wrapper .src-line-numbers", + {"clientWidth": |clientWidth|} +) + +// Check that for both mobile and desktop sizes, the buttons in scraped examples are displayed +// correctly. + +store-value: (offset_y, 4) + +// First with desktop +assert-position: (".scraped-example .code-wrapper", {"y": 255}) +assert-position: (".scraped-example .code-wrapper .prev", {"y": 255 + |offset_y|}) + +// Then with mobile +size: (600, 600) +assert-position: (".scraped-example .code-wrapper", {"y": 314}) +assert-position: (".scraped-example .code-wrapper .prev", {"y": 314 + |offset_y|}) diff --git a/tests/rustdoc-gui/scrape-examples-toggle.goml b/tests/rustdoc-gui/scrape-examples-toggle.goml new file mode 100644 index 000000000..2d5df6a5d --- /dev/null +++ b/tests/rustdoc-gui/scrape-examples-toggle.goml @@ -0,0 +1,51 @@ +// This tests checks that the "scraped examples" toggle is working as expected. +goto: "file://" + |DOC_PATH| + "/scrape_examples/fn.test_many.html" + +// Checking the color of the toggle line. +show-text: true +define-function: ( + "check-color", + (theme, toggle_line_color, toggle_line_hover_color), + block { + local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} + reload: + + // Clicking "More examples..." will open additional examples + assert-attribute-false: (".more-examples-toggle", {"open": ""}) + click: ".more-examples-toggle" + assert-attribute: (".more-examples-toggle", {"open": ""}) + + assert-css: (".toggle-line-inner", {"background-color": |toggle_line_color|}, ALL) + move-cursor-to: ".toggle-line" + assert-css: ( + ".toggle-line:hover .toggle-line-inner", + {"background-color": |toggle_line_hover_color|}, + ) + // Moving cursor away from the toggle line to prevent disrupting next test. + move-cursor-to: ".search-input" + }, +) + +call-function: ("check-color", { + "theme": "ayu", + "toggle_line_color": "rgb(153, 153, 153)", + "toggle_line_hover_color": "rgb(197, 197, 197)", +}) +call-function: ("check-color", { + "theme": "dark", + "toggle_line_color": "rgb(153, 153, 153)", + "toggle_line_hover_color": "rgb(197, 197, 197)", +}) +call-function: ("check-color", { + "theme": "light", + "toggle_line_color": "rgb(204, 204, 204)", + "toggle_line_hover_color": "rgb(153, 153, 153)", +}) + +// Toggling all docs will close additional examples +click: "#toggle-all-docs" +assert-attribute-false: (".more-examples-toggle", {"open": ""}) + +// After re-opening the docs, the additional examples should stay closed +click: "#toggle-all-docs" +assert-attribute-false: (".more-examples-toggle", {"open": ""}) diff --git a/src/test/rustdoc-gui/search-filter.goml b/tests/rustdoc-gui/search-filter.goml index e0228694e..5bc6e87d6 100644 --- a/src/test/rustdoc-gui/search-filter.goml +++ b/tests/rustdoc-gui/search-filter.goml @@ -5,7 +5,7 @@ write: (".search-input", "test") // To be SURE that the search will be run. press-key: 'Enter' // Waiting for the search results to appear... -wait-for: "#titles" +wait-for: "#search-tabs" assert-text: ("#results .externcrate", "test_docs") wait-for: "#crate-search" @@ -15,9 +15,10 @@ click: "#crate-search" press-key: "ArrowDown" press-key: "ArrowDown" press-key: "ArrowDown" +press-key: "ArrowDown" press-key: "Enter" // Waiting for the search results to appear... -wait-for: "#titles" +wait-for: "#search-tabs" assert-document-property: ({"URL": "&filter-crate="}, CONTAINS) // We check that there is no more "test_docs" appearing. assert-false: "#results .externcrate" @@ -39,9 +40,10 @@ click: "#crate-search" press-key: "ArrowUp" press-key: "ArrowUp" press-key: "ArrowUp" +press-key: "ArrowUp" press-key: "Enter" // Waiting for the search results to appear... -wait-for: "#titles" +wait-for: "#search-tabs" assert-property: ("#crate-search", {"value": "all crates"}) // Checking that the URL parameter is taken into account for crate filtering. diff --git a/src/test/rustdoc-gui/search-form-elements.goml b/tests/rustdoc-gui/search-form-elements.goml index 542db348c..542db348c 100644 --- a/src/test/rustdoc-gui/search-form-elements.goml +++ b/tests/rustdoc-gui/search-form-elements.goml diff --git a/src/test/rustdoc-gui/search-input-mobile.goml b/tests/rustdoc-gui/search-input-mobile.goml index ce0cef77c..ce0cef77c 100644 --- a/src/test/rustdoc-gui/search-input-mobile.goml +++ b/tests/rustdoc-gui/search-input-mobile.goml diff --git a/src/test/rustdoc-gui/search-keyboard.goml b/tests/rustdoc-gui/search-keyboard.goml index be642fc49..ed975664c 100644 --- a/src/test/rustdoc-gui/search-keyboard.goml +++ b/tests/rustdoc-gui/search-keyboard.goml @@ -5,7 +5,7 @@ write: (".search-input", "Foo") // To be SURE that the search will be run. press-key: 'Enter' // Waiting for the search results to appear... -wait-for: "#titles" +wait-for: "#search-tabs" // Now use the keyboard commands to switch to the third result. press-key: "ArrowDown" diff --git a/tests/rustdoc-gui/search-no-result.goml b/tests/rustdoc-gui/search-no-result.goml new file mode 100644 index 000000000..b76a44fa9 --- /dev/null +++ b/tests/rustdoc-gui/search-no-result.goml @@ -0,0 +1,36 @@ +// The goal of this test is to check the color of the "no result" links. +goto: "file://" + |DOC_PATH| + "/lib2/index.html?search=sdkfskjfsdks" +show-text: true + +define-function: ( + "check-no-result", + (theme, link, link_hover), + block { + // Changing theme. + local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} + reload: + wait-for: "#results" + assert: ".search-failed.active" + assert-css: ("#results a", {"color": |link|}, ALL) + move-cursor-to: "#results a" + assert-css: ("#results a:hover", {"color": |link_hover|}) + // Moving the cursor to some other place to not create issues with next function run. + move-cursor-to: ".search-input" + }, +) + +call-function: ("check-no-result", { + "theme": "ayu", + "link": "rgb(57, 175, 215)", + "link_hover": "rgb(57, 175, 215)", +}) +call-function: ("check-no-result", { + "theme": "dark", + "link": "rgb(210, 153, 29)", + "link_hover": "rgb(210, 153, 29)", +}) +call-function: ("check-no-result", { + "theme": "light", + "link": "rgb(56, 115, 173)", + "link_hover": "rgb(56, 115, 173)", +}) diff --git a/src/test/rustdoc-gui/search-reexport.goml b/tests/rustdoc-gui/search-reexport.goml index dd19f03bd..dd19f03bd 100644 --- a/src/test/rustdoc-gui/search-reexport.goml +++ b/tests/rustdoc-gui/search-reexport.goml diff --git a/src/test/rustdoc-gui/search-result-color.goml b/tests/rustdoc-gui/search-result-color.goml index dde43b1c9..d6d54ec4b 100644 --- a/src/test/rustdoc-gui/search-result-color.goml +++ b/tests/rustdoc-gui/search-result-color.goml @@ -3,53 +3,32 @@ 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", + block { + assert-css: (".result-" + |result_kind| + " ." + |result_kind|, {"color": |color|}, ALL) + assert-css: ( ".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|}), - ), - ], + {"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" @@ -65,7 +44,12 @@ local-storage: { reload: // Waiting for the search results to appear... -wait-for: "#titles" +wait-for: "#search-tabs" +assert-css: ( + "#search-tabs > button > .count", + {"color": "rgb(136, 136, 136)"}, + ALL, +) assert-css: ( "//*[@class='desc'][text()='Just a normal struct.']", {"color": "rgb(197, 197, 197)"}, @@ -177,7 +161,12 @@ local-storage: { reload: // Waiting for the search results to appear... -wait-for: "#titles" +wait-for: "#search-tabs" +assert-css: ( + "#search-tabs > button > .count", + {"color": "rgb(136, 136, 136)"}, + ALL, +) assert-css: ( "//*[@class='desc'][text()='Just a normal struct.']", {"color": "rgb(221, 221, 221)"}, @@ -274,7 +263,12 @@ local-storage: {"rustdoc-theme": "light", "rustdoc-use-system-theme": "false"} reload: // Waiting for the search results to appear... -wait-for: "#titles" +wait-for: "#search-tabs" +assert-css: ( + "#search-tabs > button > .count", + {"color": "rgb(136, 136, 136)"}, + ALL, +) assert-css: ( "//*[@class='desc'][text()='Just a normal struct.']", {"color": "rgb(0, 0, 0)"}, @@ -374,20 +368,20 @@ show-text: true define-function: ( "check-alias", (theme, alias, grey), - [ - ("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}), - ("reload"), - ("write", (".search-input", "thisisanalias")), + block { + local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} + reload: + write: (".search-input", "thisisanalias") // To be SURE that the search will be run. - ("press-key", 'Enter'), + press-key: 'Enter' // Waiting for the search results to appear... - ("wait-for", "#titles"), + wait-for: "#search-tabs" // Checking that the colors for the alias element are the ones expected. - ("assert-css", (".result-name > .alias", {"color": |alias|})), - ("assert-css", (".result-name > .alias > .grey", {"color": |grey|})), + assert-css: (".result-name > .alias", {"color": |alias|}) + assert-css: (".result-name > .alias > .grey", {"color": |grey|}) // Leave the search results to prevent reloading with an already filled search input. - ("press-key", "Escape"), - ], + press-key: "Escape" + }, ) call-function: ("check-alias", { diff --git a/src/test/rustdoc-gui/search-result-description.goml b/tests/rustdoc-gui/search-result-description.goml index 53a335b63..9fa210804 100644 --- a/src/test/rustdoc-gui/search-result-description.goml +++ b/tests/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" // Waiting for the search results to appear... -wait-for: "#titles" +wait-for: "#search-tabs" assert-text: (".search-results .desc code", "format!") diff --git a/src/test/rustdoc-gui/search-result-display.goml b/tests/rustdoc-gui/search-result-display.goml index 13a5e4c71..43e608228 100644 --- a/src/test/rustdoc-gui/search-result-display.goml +++ b/tests/rustdoc-gui/search-result-display.goml @@ -42,17 +42,17 @@ show-text: true define-function: ( "check-filter", (theme, border, filter, hover_border, hover_filter), - [ - ("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}), - ("reload"), - ("wait-for", "#crate-search"), - ("assert-css", ("#crate-search", {"border": "1px solid " + |border|})), - ("assert-css", ("#crate-search-div::after", {"filter": |filter|})), - ("move-cursor-to", "#crate-search"), - ("assert-css", ("#crate-search", {"border": "1px solid " + |hover_border|})), - ("assert-css", ("#crate-search-div::after", {"filter": |hover_filter|})), - ("move-cursor-to", ".search-input"), - ], + block { + local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} + reload: + wait-for: "#crate-search" + assert-css: ("#crate-search", {"border": "1px solid " + |border|}) + assert-css: ("#crate-search-div::after", {"filter": |filter|}) + move-cursor-to: "#crate-search" + assert-css: ("#crate-search", {"border": "1px solid " + |hover_border|}) + assert-css: ("#crate-search-div::after", {"filter": |hover_filter|}) + move-cursor-to: ".search-input" + }, ) call-function: ("check-filter", { diff --git a/src/test/rustdoc-gui/search-result-go-to-first.goml b/tests/rustdoc-gui/search-result-go-to-first.goml index eeddf5ef6..f444baa6c 100644 --- a/src/test/rustdoc-gui/search-result-go-to-first.goml +++ b/tests/rustdoc-gui/search-result-go-to-first.goml @@ -3,17 +3,17 @@ // First, we check that the first page doesn't have the string we're looking for to ensure // that the feature is changing page as expected. goto: "file://" + |DOC_PATH| + "/test_docs/index.html" -assert-text-false: (".fqn", "Struct test_docs::Foo") +assert-text-false: (".main-heading h1", "Struct test_docs::Foo") // We now check that we land on the search result page if "go_to_first" isn't set. goto: "file://" + |DOC_PATH| + "/test_docs/index.html?search=struct%3AFoo" // Waiting for the search results to appear... -wait-for: "#titles" -assert-text-false: (".fqn", "Struct test_docs::Foo") +wait-for: "#search-tabs" +assert-text-false: (".main-heading h1", "Struct test_docs::Foo") // Ensure that the search results are displayed, not the "normal" content. assert-css: ("#main-content", {"display": "none"}) // Now we can check that the feature is working as expected! goto: "file://" + |DOC_PATH| + "/test_docs/index.html?search=struct%3AFoo&go_to_first=true" // Waiting for the page to load... -wait-for-text: (".fqn", "Struct test_docs::Foo") +wait-for-text: (".main-heading h1", "Struct test_docs::Foo") diff --git a/src/test/rustdoc-gui/search-result-keyword.goml b/tests/rustdoc-gui/search-result-keyword.goml index 66e63155a..8c3577d9f 100644 --- a/src/test/rustdoc-gui/search-result-keyword.goml +++ b/tests/rustdoc-gui/search-result-keyword.goml @@ -4,7 +4,7 @@ write: (".search-input", "CookieMonster") // To be SURE that the search will be run. press-key: 'Enter' // Waiting for the search results to appear... -wait-for: "#titles" +wait-for: "#search-tabs" // Note: The two next assert commands could be merged as one but readability would be // less good. // diff --git a/tests/rustdoc-gui/search-tab-change-title-fn-sig.goml b/tests/rustdoc-gui/search-tab-change-title-fn-sig.goml new file mode 100644 index 000000000..1433dc4d7 --- /dev/null +++ b/tests/rustdoc-gui/search-tab-change-title-fn-sig.goml @@ -0,0 +1,74 @@ +// Checks that the search tab results work correctly with function signature syntax +// First, try a search-by-name +goto: "file://" + |DOC_PATH| + "/test_docs/index.html" +write: (".search-input", "Foo") +// To be SURE that the search will be run. +press-key: 'Enter' +// Waiting for the search results to appear... +wait-for: "#search-tabs" +assert-attribute: ("#search-tabs > button:nth-of-type(1)", {"class": "selected"}) +assert-text: ("#search-tabs > button:nth-of-type(1)", "In Names", STARTS_WITH) +assert: "input.search-input:focus" +// Use left-right keys +press-key: "ArrowDown" +assert: "#results > .search-results.active > a:nth-of-type(1):focus" +press-key: "ArrowRight" +wait-for-attribute: ("#search-tabs > button:nth-of-type(2)", {"class": "selected"}) +press-key: "ArrowRight" +wait-for-attribute: ("#search-tabs > button:nth-of-type(3)", {"class": "selected"}) +press-key: "ArrowRight" +wait-for-attribute: ("#search-tabs > button:nth-of-type(1)", {"class": "selected"}) +press-key: "ArrowLeft" +wait-for-attribute: ("#search-tabs > button:nth-of-type(3)", {"class": "selected"}) + +// Now try search-by-return +goto: "file://" + |DOC_PATH| + "/test_docs/index.html" +write: (".search-input", "-> String") +// To be SURE that the search will be run. +press-key: 'Enter' +// Waiting for the search results to appear... +wait-for: "#search-tabs" +assert-attribute: ("#search-tabs > button:nth-of-type(1)", {"class": "selected"}) +assert-text: ("#search-tabs > button:nth-of-type(1)", "In Function Return Types", STARTS_WITH) +assert: "input.search-input:focus" +// Use left-right keys +press-key: "ArrowDown" +assert: "#results > .search-results.active > a:nth-of-type(1):focus" +press-key: "ArrowRight" +wait-for-attribute: ("#search-tabs > button:nth-of-type(1)", {"class": "selected"}) +press-key: "ArrowRight" +wait-for-attribute: ("#search-tabs > button:nth-of-type(1)", {"class": "selected"}) +press-key: "ArrowRight" +wait-for-attribute: ("#search-tabs > button:nth-of-type(1)", {"class": "selected"}) +press-key: "ArrowLeft" +wait-for-attribute: ("#search-tabs > button:nth-of-type(1)", {"class": "selected"}) + +// Try with a search-by-return with no results +goto: "file://" + |DOC_PATH| + "/test_docs/index.html" +write: (".search-input", "-> Something") +// To be SURE that the search will be run. +press-key: 'Enter' +// Waiting for the search results to appear... +wait-for: "#search-tabs" +assert-attribute: ("#search-tabs > button:nth-of-type(1)", {"class": "selected"}) +assert-text: ("#search-tabs > button:nth-of-type(1)", "In Function Return Types", STARTS_WITH) + +// Try with a search-by-parameter +goto: "file://" + |DOC_PATH| + "/test_docs/index.html" +write: (".search-input", "usize pattern") +// To be SURE that the search will be run. +press-key: 'Enter' +// Waiting for the search results to appear... +wait-for: "#search-tabs" +assert-attribute: ("#search-tabs > button:nth-of-type(1)", {"class": "selected"}) +assert-text: ("#search-tabs > button:nth-of-type(1)", "In Function Parameters", STARTS_WITH) + +// Try with a search-by-parameter-and-return +goto: "file://" + |DOC_PATH| + "/test_docs/index.html" +write: (".search-input", "pattern -> str") +// To be SURE that the search will be run. +press-key: 'Enter' +// Waiting for the search results to appear... +wait-for: "#search-tabs" +assert-attribute: ("#search-tabs > button:nth-of-type(1)", {"class": "selected"}) +assert-text: ("#search-tabs > button:nth-of-type(1)", "In Function Signatures", STARTS_WITH) diff --git a/tests/rustdoc-gui/search-tab.goml b/tests/rustdoc-gui/search-tab.goml new file mode 100644 index 000000000..36958f700 --- /dev/null +++ b/tests/rustdoc-gui/search-tab.goml @@ -0,0 +1,76 @@ +// Checking the colors of the search tab headers. +goto: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html?search=something" +show-text: true + +define-function: ( + "check-colors", + (theme, background, background_selected, background_hover, border_bottom, + border_bottom_selected, border_bottom_hover, border_top, border_top_selected, + border_top_hover), + block { + // Setting the theme. + local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} + reload: + + // These two commands are used to be sure the search will be run. + focus: ".search-input" + press-key: "Enter" + + wait-for: "#search-tabs" + assert-css: ("#search-tabs > button:not(.selected)", { + "background-color": |background|, + "border-bottom": |border_bottom|, + "border-top": |border_top|, + }) + assert-css: ("#search-tabs > button.selected", { + "background-color": |background_selected|, + "border-bottom": |border_bottom_selected|, + "border-top": |border_top_selected|, + }) + move-cursor-to: "#search-tabs > button:not(.selected)" + assert-css: ("#search-tabs > button:not(.selected):hover", { + "background-color": |background_hover|, + "border-bottom": |border_bottom_hover|, + "border-top": |border_top_hover|, + }) + // To prevent disrupting next run of this function. + move-cursor-to: ".search-input" + }, +) + +call-function: ("check-colors", { + "theme": "ayu", + "background": "rgba(0, 0, 0, 0)", + "background_selected": "rgb(20, 25, 32)", + "background_hover": "rgba(0, 0, 0, 0)", + "border_bottom": "0px none rgb(197, 197, 197)", + "border_bottom_selected": "1px solid rgb(255, 180, 76)", + "border_bottom_hover": "1px solid rgba(242, 151, 24, 0.3)", + "border_top": "0px none rgb(197, 197, 197)", + "border_top_selected": "0px none rgb(197, 197, 197)", + "border_top_hover": "0px none rgb(197, 197, 197)", +}) +call-function: ("check-colors", { + "theme": "dark", + "background": "rgb(37, 37, 37)", + "background_selected": "rgb(53, 53, 53)", + "background_hover": "rgb(53, 53, 53)", + "border_bottom": "0px none rgb(221, 221, 221)", + "border_bottom_selected": "0px none rgb(221, 221, 221)", + "border_bottom_hover": "0px none rgb(221, 221, 221)", + "border_top": "2px solid rgb(37, 37, 37)", + "border_top_selected": "2px solid rgb(0, 137, 255)", + "border_top_hover": "2px solid rgb(0, 137, 255)", +}) +call-function: ("check-colors", { + "theme": "light", + "background": "rgb(230, 230, 230)", + "background_selected": "rgb(255, 255, 255)", + "background_hover": "rgb(255, 255, 255)", + "border_bottom": "0px none rgb(0, 0, 0)", + "border_bottom_selected": "0px none rgb(0, 0, 0)", + "border_bottom_hover": "0px none rgb(0, 0, 0)", + "border_top": "2px solid rgb(230, 230, 230)", + "border_top_selected": "2px solid rgb(0, 137, 255)", + "border_top_hover": "2px solid rgb(0, 137, 255)", +}) diff --git a/src/test/rustdoc-gui/settings.goml b/tests/rustdoc-gui/settings.goml index fc3beaa53..419cc5eba 100644 --- a/src/test/rustdoc-gui/settings.goml +++ b/tests/rustdoc-gui/settings.goml @@ -8,6 +8,10 @@ assert-false: "#settings" click: "#settings-menu" wait-for: "#settings" assert-css: ("#settings", {"display": "block"}) + +// Store the line margin to compare with the settings.html later. +store-css: (setting_line_margin, ".setting-line", "margin") + // Let's close it by clicking on the same button. click: "#settings-menu" wait-for-css: ("#settings", {"display": "none"}) @@ -105,6 +109,33 @@ assert-css: ( "box-shadow": "rgb(33, 150, 243) 0px 0px 1px 1px", }, ) +// Now we check the setting-name for radio buttons is on a different line than the label. +compare-elements-position-near: ( + "#theme .setting-name", + "#theme .choices", + {"x": 1} +) +compare-elements-position-near-false: ( + "#theme .setting-name", + "#theme .choices", + {"y": 1} +) +// Now we check that the label positions are all on the same line. +compare-elements-position-near: ( + "#theme .choices #theme-light", + "#theme .choices #theme-dark", + {"y": 1} +) +compare-elements-position-near: ( + "#theme .choices #theme-dark", + "#theme .choices #theme-ayu", + {"y": 1} +) +compare-elements-position-near: ( + "#theme .choices #theme-ayu", + "#theme .choices #theme-system-preference", + {"y": 1} +) // First we check the "default" display for toggles. assert-css: ( @@ -159,7 +190,7 @@ assert-text: ("#preferred-light-theme .setting-name", "Preferred light theme") // We now check that clicking on the toggles' text is like clicking on the checkbox. // To test it, we use the "Disable keyboard shortcuts". local-storage: {"rustdoc-disable-shortcuts": "false"} -click: ".setting-line:last-child .toggle .label" +click: ".setting-line:last-child .settings-toggle .label" assert-local-storage: {"rustdoc-disable-shortcuts": "true"} // Make sure that "Disable keyboard shortcuts" actually took effect. @@ -169,13 +200,32 @@ assert-false: "#help-button .popover" wait-for-css: ("#settings-menu .popover", {"display": "block"}) // Now turn keyboard shortcuts back on, and see if they work. -click: ".setting-line:last-child .toggle .label" +click: ".setting-line:last-child .settings-toggle .label" assert-local-storage: {"rustdoc-disable-shortcuts": "false"} press-key: "Escape" press-key: "?" wait-for-css: ("#help-button .popover", {"display": "block"}) assert-css: ("#settings-menu .popover", {"display": "none"}) +// Now switch back to the settings popover, and make sure the keyboard +// shortcut works when a check box is selected. +click: "#settings-menu > a" +wait-for-css: ("#settings-menu .popover", {"display": "block"}) +focus: "#auto-hide-large-items" +press-key: "?" +wait-for-css: ("#settings-menu .popover", {"display": "none"}) +wait-for-css: ("#help-button .popover", {"display": "block"}) + +// Now switch back to the settings popover, and make sure the keyboard +// shortcut works when a check box is selected. +click: "#settings-menu > a" +wait-for-css: ("#settings-menu .popover", {"display": "block"}) +wait-for-css: ("#help-button .popover", {"display": "none"}) +focus: "#theme-system-preference" +press-key: "?" +wait-for-css: ("#settings-menu .popover", {"display": "none"}) +wait-for-css: ("#help-button .popover", {"display": "block"}) + // Now we go to the settings page to check that the CSS is loaded as expected. goto: "file://" + |DOC_PATH| + "/settings.html" wait-for: "#settings" @@ -184,6 +234,9 @@ assert-css: (".setting-line", {"position": "relative"}) assert-attribute-false: ("#settings", {"class": "popover"}, CONTAINS) compare-elements-position: (".sub form", "#settings", ("x")) +// Check that setting-line has the same margin in this mode as in the popover. +assert-css: (".setting-line", {"margin": |setting_line_margin|}) + // We now check the display with JS disabled. assert-false: "noscript section" javascript: false diff --git a/src/test/rustdoc-gui/shortcuts.goml b/tests/rustdoc-gui/shortcuts.goml index 9068680d6..9068680d6 100644 --- a/src/test/rustdoc-gui/shortcuts.goml +++ b/tests/rustdoc-gui/shortcuts.goml diff --git a/src/test/rustdoc-gui/sidebar-links-color.goml b/tests/rustdoc-gui/sidebar-links-color.goml index 7ef7ec90c..1d5fdb7a4 100644 --- a/src/test/rustdoc-gui/sidebar-links-color.goml +++ b/tests/rustdoc-gui/sidebar-links-color.goml @@ -12,80 +12,80 @@ define-function: ( trait_hover_background, fn, fn_hover, fn_hover_background, type, type_hover, type_hover_background, keyword, keyword_hover, keyword_hover_background, ), - [ - ("local-storage", { "rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false" }), - ("reload"), + block { + local-storage: { "rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false" } + reload: // Struct - ("assert-css", ( + assert-css: ( ".sidebar .block.struct a:not(.current)", {"color": |struct|, "background-color": "rgba(0, 0, 0, 0)"}, - )), - ("move-cursor-to", ".sidebar .block.struct a:not(.current)"), - ("assert-css", ( + ) + move-cursor-to: ".sidebar .block.struct a:not(.current)" + assert-css: ( ".sidebar .block.struct a:hover", {"color": |struct_hover|, "background-color": |struct_hover_background|}, - )), + ) // Enum - ("assert-css", ( + assert-css: ( ".sidebar .block.enum a", {"color": |enum|, "background-color": "rgba(0, 0, 0, 0)"}, - )), - ("move-cursor-to", ".sidebar .block.enum a"), - ("assert-css", ( + ) + move-cursor-to: ".sidebar .block.enum a" + assert-css: ( ".sidebar .block.enum a:hover", {"color": |enum_hover|, "background-color": |enum_hover_background|}, - )), + ) // Union - ("assert-css", ( + assert-css: ( ".sidebar .block.union a", {"color": |union|, "background-color": "rgba(0, 0, 0, 0)"}, - )), - ("move-cursor-to", ".sidebar .block.union a"), - ("assert-css", ( + ) + move-cursor-to: ".sidebar .block.union a" + assert-css: ( ".sidebar .block.union a:hover", {"color": |union_hover|, "background-color": |union_hover_background|}, - )), + ) // Trait - ("assert-css", ( + assert-css: ( ".sidebar .block.trait a", {"color": |trait|, "background-color": "rgba(0, 0, 0, 0)"}, - )), - ("move-cursor-to", ".sidebar .block.trait a"), - ("assert-css", ( + ) + move-cursor-to: ".sidebar .block.trait a" + assert-css: ( ".sidebar .block.trait a:hover", {"color": |trait_hover|, "background-color": |trait_hover_background|}, - )), + ) // Function - ("assert-css", ( + assert-css: ( ".sidebar .block.fn a", {"color": |fn|, "background-color": "rgba(0, 0, 0, 0)"}, - )), - ("move-cursor-to", ".sidebar .block.fn a"), - ("assert-css", ( + ) + move-cursor-to: ".sidebar .block.fn a" + assert-css: ( ".sidebar .block.fn a:hover", {"color": |fn_hover|, "background-color": |fn_hover_background|}, - )), + ) // Type definition - ("assert-css", ( + assert-css: ( ".sidebar .block.type a", {"color": |type|, "background-color": "rgba(0, 0, 0, 0)"}, - )), - ("move-cursor-to", ".sidebar .block.type a"), - ("assert-css", ( + ) + move-cursor-to: ".sidebar .block.type a" + assert-css: ( ".sidebar .block.type a:hover", {"color": |type_hover|, "background-color": |type_hover_background|}, - )), + ) // Keyword - ("assert-css", ( + assert-css: ( ".sidebar .block.keyword a", {"color": |keyword|, "background-color": "rgba(0, 0, 0, 0)"}, - )), - ("move-cursor-to", ".sidebar .block.keyword a"), - ("assert-css", ( + ) + move-cursor-to: ".sidebar .block.keyword a" + assert-css: ( ".sidebar .block.keyword a:hover", {"color": |keyword_hover|, "background-color": |keyword_hover_background|}, - )), - ] + ) + } ) call-function: ( diff --git a/src/test/rustdoc-gui/sidebar-macro-reexport.goml b/tests/rustdoc-gui/sidebar-macro-reexport.goml index b5c1b6a43..b5c1b6a43 100644 --- a/src/test/rustdoc-gui/sidebar-macro-reexport.goml +++ b/tests/rustdoc-gui/sidebar-macro-reexport.goml diff --git a/src/test/rustdoc-gui/sidebar-mobile-scroll.goml b/tests/rustdoc-gui/sidebar-mobile-scroll.goml index 2449269b1..2449269b1 100644 --- a/src/test/rustdoc-gui/sidebar-mobile-scroll.goml +++ b/tests/rustdoc-gui/sidebar-mobile-scroll.goml diff --git a/src/test/rustdoc-gui/sidebar-mobile.goml b/tests/rustdoc-gui/sidebar-mobile.goml index 38d01f7f6..d5f4b6196 100644 --- a/src/test/rustdoc-gui/sidebar-mobile.goml +++ b/tests/rustdoc-gui/sidebar-mobile.goml @@ -58,17 +58,17 @@ show-text: true define-function: ( "check-colors", (theme, color, background), - [ - ("local-storage", {"rustdoc-use-system-theme": "false", "rustdoc-theme": |theme|}), - ("reload"), + block { + local-storage: {"rustdoc-use-system-theme": "false", "rustdoc-theme": |theme|} + reload: // Open the sidebar menu. - ("click", ".sidebar-menu-toggle"), - ("assert-css", (".sidebar", { + click: ".sidebar-menu-toggle" + assert-css: (".sidebar", { "background-color": |background|, "color": |color|, - })), - ], + }) + }, ) call-function: ("check-colors", { diff --git a/tests/rustdoc-gui/sidebar-source-code-display.goml b/tests/rustdoc-gui/sidebar-source-code-display.goml new file mode 100644 index 000000000..f3eb8ff76 --- /dev/null +++ b/tests/rustdoc-gui/sidebar-source-code-display.goml @@ -0,0 +1,215 @@ +// This test ensures that the elements in the sidebar are displayed correctly. +javascript: false +goto: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html" +// Since the javascript is disabled, there shouldn't be a toggle. +assert-false: "#src-sidebar-toggle" +wait-for-css: (".sidebar", {"display": "none"}) + +// Let's retry with javascript enabled. +javascript: true +reload: +wait-for: "#src-sidebar-toggle" +assert-css: ("#src-sidebar-toggle", {"visibility": "visible"}) +assert-css: (".sidebar > *:not(#src-sidebar-toggle)", {"visibility": "hidden"}) +// Let's expand the sidebar now. +click: "#src-sidebar-toggle" +wait-for-css: ("#src-sidebar-toggle", {"visibility": "visible"}) + +// We now check that opening the sidebar and clicking a link will leave it open. +// The behavior here on desktop is different than the behavior on mobile, +// but since the sidebar doesn't fill the entire screen here, it makes sense to have the +// sidebar stay resident. +wait-for-css: (".sidebar", {"width": "300px"}) +assert-local-storage: {"rustdoc-source-sidebar-show": "true"} +click: ".sidebar a.selected" +goto: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html" +wait-for-css: (".sidebar", {"width": "300px"}) +assert-local-storage: {"rustdoc-source-sidebar-show": "true"} + +// Now we check the display of the sidebar items. +show-text: true + +define-function: ( + "check-colors", + ( + theme, color, color_hover, background, background_hover, background_toggle, + background_toggle_hover, + ), + block { + local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} + reload: + wait-for-css: ("#src-sidebar-toggle", {"visibility": "visible"}) + assert-css: ( + "#source-sidebar details[open] > .files a.selected", + {"color": |color_hover|, "background-color": |background|}, + ) + + // Without hover or focus. + assert-css: ("#src-sidebar-toggle > button", {"background-color": |background_toggle|}) + // With focus. + focus: "#src-sidebar-toggle > button" + assert-css: ( + "#src-sidebar-toggle > button:focus", + {"background-color": |background_toggle_hover|}, + ) + focus: ".search-input" + // With hover. + move-cursor-to: "#src-sidebar-toggle > button" + assert-css: ( + "#src-sidebar-toggle > button:hover", + {"background-color": |background_toggle_hover|}, + ) + + // Without hover or focus. + assert-css: ( + "#source-sidebar details[open] > .files a:not(.selected)", + {"color": |color|, "background-color": |background_toggle|}, + ) + // With focus. + focus: "#source-sidebar details[open] > .files a:not(.selected)" + wait-for-css: ( + "#source-sidebar details[open] > .files a:not(.selected):focus", + {"color": |color_hover|, "background-color": |background_hover|}, + ) + focus: ".search-input" + // With hover. + move-cursor-to: "#source-sidebar details[open] > .files a:not(.selected)" + assert-css: ( + "#source-sidebar details[open] > .files a:not(.selected):hover", + {"color": |color_hover|, "background-color": |background_hover|}, + ) + + // Without hover or focus. + assert-css: ( + "#source-sidebar .dir-entry summary", + {"color": |color|, "background-color": |background_toggle|}, + ) + // With focus. + focus: "#source-sidebar .dir-entry summary" + wait-for-css: ( + "#source-sidebar .dir-entry summary:focus", + {"color": |color_hover|, "background-color": |background_hover|}, + ) + focus: ".search-input" + // With hover. + move-cursor-to: "#source-sidebar .dir-entry summary" + assert-css: ( + "#source-sidebar .dir-entry summary:hover", + {"color": |color_hover|, "background-color": |background_hover|}, + ) + + // Without hover or focus. + assert-css: ( + "#source-sidebar details[open] > .folders > details > summary", + {"color": |color|, "background-color": |background_toggle|}, + ) + // With focus. + focus: "#source-sidebar details[open] > .folders > details > summary" + wait-for-css: ( + "#source-sidebar details[open] > .folders > details > summary:focus", + {"color": |color_hover|, "background-color": |background_hover|}, + ) + focus: ".search-input" + // With hover. + move-cursor-to: "#source-sidebar details[open] > .folders > details > summary" + assert-css: ( + "#source-sidebar details[open] > .folders > details > summary:hover", + {"color": |color_hover|, "background-color": |background_hover|}, + ) + }, +) + +call-function: ("check-colors", { + "theme": "light", + "color": "rgb(0, 0, 0)", + "color_hover": "rgb(0, 0, 0)", + "background": "rgb(255, 255, 255)", + "background_hover": "rgb(224, 224, 224)", + "background_toggle": "rgba(0, 0, 0, 0)", + "background_toggle_hover": "rgb(224, 224, 224)", +}) +call-function: ("check-colors", { + "theme": "dark", + "color": "rgb(221, 221, 221)", + "color_hover": "rgb(221, 221, 221)", + "background": "rgb(51, 51, 51)", + "background_hover": "rgb(68, 68, 68)", + "background_toggle": "rgba(0, 0, 0, 0)", + "background_toggle_hover": "rgb(103, 103, 103)", +}) +call-function: ("check-colors", { + "theme": "ayu", + "color": "rgb(197, 197, 197)", + "color_hover": "rgb(255, 180, 76)", + "background": "rgb(20, 25, 31)", + "background_hover": "rgb(20, 25, 31)", + "background_toggle": "rgba(0, 0, 0, 0)", + "background_toggle_hover": "rgba(70, 70, 70, 0.33)", +}) + +// Now checking on mobile devices. +size: (500, 700) +reload: +// Waiting for the sidebar to be displayed... +wait-for-css: ("#src-sidebar-toggle", {"visibility": "visible"}) + +// We now check it takes the full size of the display. +assert-property: ("body", {"clientWidth": "500", "clientHeight": "700"}) +assert-property: (".sidebar", {"clientWidth": "500", "clientHeight": "700"}) + +// We now check the display of the toggle once the sidebar is expanded. +assert-property: ("#src-sidebar-toggle", {"clientWidth": "500", "clientHeight": "39"}) +assert-css: ( + "#src-sidebar-toggle", + { + "border-top-width": "0px", + "border-right-width": "0px", + "border-left-width": "0px", + "border-bottom-width": "1px", + }, +) + +// We now check that the scroll position is kept when opening the sidebar. +click: "#src-sidebar-toggle" +wait-for-css: (".sidebar", {"left": "-1000px"}) +// We scroll to line 117 to change the scroll position. +scroll-to: '//*[@id="117"]' +assert-window-property: {"pageYOffset": "2542"} +// Expanding the sidebar... +click: "#src-sidebar-toggle" +wait-for-css: (".sidebar", {"left": "0px"}) +click: "#src-sidebar-toggle" +wait-for-css: (".sidebar", {"left": "-1000px"}) +// The "scrollTop" property should be the same. +assert-window-property: {"pageYOffset": "2542"} + +// We now check that the scroll position is restored if the window is resized. +size: (500, 700) +click: "#src-sidebar-toggle" +wait-for-css: ("#source-sidebar", {"visibility": "visible"}) +assert-window-property: {"pageYOffset": "0"} +size: (900, 900) +assert-window-property: {"pageYOffset": "2542"} +size: (500, 700) +click: "#src-sidebar-toggle" +wait-for-css: ("#source-sidebar", {"visibility": "hidden"}) + +// We now check that opening the sidebar and clicking a link will close it. +// The behavior here on mobile is different than the behavior on desktop, +// but common sense dictates that if you have a list of files that fills the entire screen, and +// you click one of them, you probably want to actually see the file's contents, and not just +// make it the current selection. +click: "#src-sidebar-toggle" +wait-for-css: ("#source-sidebar", {"visibility": "visible"}) +assert-local-storage: {"rustdoc-source-sidebar-show": "true"} +click: ".sidebar a.selected" +goto: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html" +wait-for-css: ("#source-sidebar", {"visibility": "hidden"}) +assert-local-storage: {"rustdoc-source-sidebar-show": "false"} +// Resize back to desktop size, to check that the sidebar doesn't spontaneously open. +size: (1000, 1000) +wait-for-css: ("#source-sidebar", {"visibility": "hidden"}) +assert-local-storage: {"rustdoc-source-sidebar-show": "false"} +click: "#src-sidebar-toggle" +wait-for-css: ("#source-sidebar", {"visibility": "visible"}) +assert-local-storage: {"rustdoc-source-sidebar-show": "true"} diff --git a/tests/rustdoc-gui/sidebar-source-code.goml b/tests/rustdoc-gui/sidebar-source-code.goml new file mode 100644 index 000000000..c8a29b58d --- /dev/null +++ b/tests/rustdoc-gui/sidebar-source-code.goml @@ -0,0 +1,90 @@ +// The goal of this test is to ensure that the sidebar is working as expected in the source +// code pages. +goto: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html" +show-text: true + +// First, check the sidebar colors. +define-function: ( + "check-colors", + (theme, color, background_color), + block { + local-storage: { + "rustdoc-theme": |theme|, + "rustdoc-use-system-theme": "false", + } + reload: + // Checking results colors. + assert-css: (".source .sidebar", { + "color": |color|, + "background-color": |background_color| + }, ALL) + }, +) + +call-function: ( + "check-colors", + { + "theme": "ayu", + "color": "rgb(197, 197, 197)", + "background_color": "rgb(20, 25, 31)", + } +) +call-function: ( + "check-colors", + { + "theme": "dark", + "color": "rgb(221, 221, 221)", + "background_color": "rgb(80, 80, 80)", + } +) +call-function: ( + "check-colors", + { + "theme": "light", + "color": "rgb(0, 0, 0)", + "background_color": "rgb(245, 245, 245)", + } +) + +// Next, desktop mode layout. +size: (1100, 800) +// We check that the sidebar isn't expanded and has the expected width. +assert-css: ("nav.sidebar", {"width": "50px"}) +// We now click on the button to expand the sidebar. +click: (10, 10) +// We wait for the sidebar to be expanded. +wait-for-css: (".source-sidebar-expanded nav.sidebar", {"width": "300px"}) +assert-css: (".source-sidebar-expanded nav.sidebar a", {"font-size": "14px"}) +// We collapse the sidebar. +click: (10, 10) +// We ensure that the class has been removed. +wait-for: "html:not(.expanded)" +assert: "nav.sidebar" + +// Checking that only the path to the current file is "open". +goto: "file://" + |DOC_PATH| + "/src/lib2/another_folder/sub_mod/mod.rs.html" +// First we expand the sidebar again. +click: (10, 10) +// We wait for the sidebar to be expanded. +wait-for-css: (".source-sidebar-expanded nav.sidebar", {"width": "300px"}) +assert: "//*[@class='dir-entry' and @open]/*[text()='lib2']" +assert: "//*[@class='dir-entry' and @open]/*[text()='another_folder']" +assert: "//*[@class='dir-entry' and @open]/*[text()='sub_mod']" +// Only "another_folder" should be "open" in "lib2". +assert: "//*[@class='dir-entry' and not(@open)]/*[text()='another_mod']" +// All other trees should be collapsed. +assert-count: ("//*[@id='source-sidebar']/details[not(text()='lib2') and not(@open)]", 8) + +// We now switch to mobile mode. +size: (600, 600) +wait-for-css: (".source-sidebar-expanded nav.sidebar", {"left": "0px"}) +// We collapse the sidebar. +click: (10, 10) +// We check that the sidebar has been moved off-screen. +assert-css: ("nav.sidebar", {"left": "-1000px"}) +// We ensure that the class has been removed. +assert-false: ".source-sidebar-expanded" +assert: "nav.sidebar" + +// Check that the topbar is not visible +assert-false: ".mobile-topbar" diff --git a/src/test/rustdoc-gui/sidebar.goml b/tests/rustdoc-gui/sidebar.goml index 5058630f4..9c742be05 100644 --- a/src/test/rustdoc-gui/sidebar.goml +++ b/tests/rustdoc-gui/sidebar.goml @@ -2,6 +2,50 @@ goto: "file://" + |DOC_PATH| + "/test_docs/index.html" assert-property: (".sidebar", {"clientWidth": "200"}) show-text: true + +// First, check the sidebar colors. +define-function: ( + "check-colors", + (theme, color, background_color), + block { + local-storage: { + "rustdoc-theme": |theme|, + "rustdoc-use-system-theme": "false", + } + reload: + // Checking results colors. + assert-css: (".sidebar", { + "color": |color|, + "background-color": |background_color| + }, ALL) + }, +) + +call-function: ( + "check-colors", + { + "theme": "ayu", + "color": "rgb(197, 197, 197)", + "background_color": "rgb(20, 25, 31)", + } +) +call-function: ( + "check-colors", + { + "theme": "dark", + "color": "rgb(221, 221, 221)", + "background_color": "rgb(80, 80, 80)", + } +) +call-function: ( + "check-colors", + { + "theme": "light", + "color": "rgb(0, 0, 0)", + "background_color": "rgb(245, 245, 245)", + } +) + local-storage: {"rustdoc-theme": "light"} // We reload the page so the local storage settings are being used. reload: @@ -104,4 +148,4 @@ assert-text: ("#toggle-all-docs", "[+]") assert-property: (".sidebar", {"clientWidth": "200"}) click: "#toggle-all-docs" assert-text: ("#toggle-all-docs", "[−]") -assert-property: (".sidebar", {"clientWidth": "200"})
\ No newline at end of file +assert-property: (".sidebar", {"clientWidth": "200"}) diff --git a/src/test/rustdoc-gui/source-anchor-scroll.goml b/tests/rustdoc-gui/source-anchor-scroll.goml index ddfe0c3d1..ddfe0c3d1 100644 --- a/src/test/rustdoc-gui/source-anchor-scroll.goml +++ b/tests/rustdoc-gui/source-anchor-scroll.goml diff --git a/tests/rustdoc-gui/source-code-page.goml b/tests/rustdoc-gui/source-code-page.goml new file mode 100644 index 000000000..7c35119e6 --- /dev/null +++ b/tests/rustdoc-gui/source-code-page.goml @@ -0,0 +1,218 @@ +// Checks that the interactions with the source code pages are working as expected. +goto: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html" +show-text: true +// Check that we can click on the line number. +click: ".src-line-numbers > a:nth-child(4)" // This is the anchor for line 4. +// Ensure that the page URL was updated. +assert-document-property: ({"URL": "lib.rs.html#4"}, ENDS_WITH) +assert-attribute: ("//*[@id='4']", {"class": "line-highlighted"}) +// Ensure that the default style, with the right border, isn't used. +assert-css: ("//*[@id='4']", {"border-right-width": "0px"}) +reload: +assert-attribute: ("//*[@id='4']", {"class": "line-highlighted"}) +assert-css: ("//*[@id='4']", {"border-right-width": "0px"}) +// We now check that the good anchors are highlighted +goto: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html#4-6" +assert-attribute-false: (".src-line-numbers > a:nth-child(3)", {"class": "line-highlighted"}) +assert-attribute: (".src-line-numbers > a:nth-child(4)", {"class": "line-highlighted"}) +assert-attribute: (".src-line-numbers > a:nth-child(5)", {"class": "line-highlighted"}) +assert-attribute: (".src-line-numbers > a:nth-child(6)", {"class": "line-highlighted"}) +assert-attribute-false: (".src-line-numbers > a:nth-child(7)", {"class": "line-highlighted"}) + +define-function: ( + "check-colors", + (theme, color, background_color, highlight_color, highlight_background_color), + block { + local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} + reload: + assert-css: ( + ".src-line-numbers > a:not(.line-highlighted)", + {"color": |color|, "background-color": |background_color|}, + ALL, + ) + assert-css: ( + ".src-line-numbers > a.line-highlighted", + {"color": |highlight_color|, "background-color": |highlight_background_color|}, + ALL, + ) + }, +) + +call-function: ("check-colors", { + "theme": "ayu", + "color": "rgb(92, 103, 115)", + "background_color": "rgba(0, 0, 0, 0)", + "highlight_color": "rgb(112, 128, 144)", + "highlight_background_color": "rgba(255, 236, 164, 0.06)", +}) +call-function: ("check-colors", { + "theme": "dark", + "color": "rgb(59, 145, 226)", + "background_color": "rgba(0, 0, 0, 0)", + "highlight_color": "rgb(59, 145, 226)", + "highlight_background_color": "rgb(10, 4, 47)", +}) +call-function: ("check-colors", { + "theme": "light", + "color": "rgb(198, 126, 45)", + "background_color": "rgba(0, 0, 0, 0)", + "highlight_color": "rgb(198, 126, 45)", + "highlight_background_color": "rgb(253, 255, 211)", +}) + +// This is to ensure that the content is correctly align with the line numbers. +compare-elements-position: ("//*[@id='1']", ".rust > code > span", ("y")) +// Check the `href` property so that users can treat anchors as links. +assert-property: (".src-line-numbers > a:nth-child(1)", { + "href": "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html#1" +}) +assert-property: (".src-line-numbers > a:nth-child(2)", { + "href": "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html#2" +}) +assert-property: (".src-line-numbers > a:nth-child(3)", { + "href": "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html#3" +}) +assert-property: (".src-line-numbers > a:nth-child(4)", { + "href": "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html#4" +}) +assert-property: (".src-line-numbers > a:nth-child(5)", { + "href": "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html#5" +}) +assert-property: (".src-line-numbers > a:nth-child(6)", { + "href": "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html#6" +}) + +// Assert that the line numbers text is aligned to the right. +assert-css: (".src-line-numbers", {"text-align": "right"}) + +// Now let's check that clicking on something else than the line number doesn't +// do anything (and certainly not add a `#NaN` to the URL!). +goto: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html" +// We use this assert-position to know where we will click. +assert-position: ("//*[@id='1']", {"x": 88, "y": 112}) +// We click on the left of the "1" anchor but still in the "src-line-number" `<pre>`. +click: (87, 103) +assert-document-property: ({"URL": "/lib.rs.html"}, ENDS_WITH) + +// Checking the source code sidebar. + +// First we "open" it. +click: "#src-sidebar-toggle" +assert: ".source-sidebar-expanded" + +// We check that the first entry of the sidebar is collapsed +assert-property: ("#source-sidebar details:first-of-type", {"open": "false"}) +assert-text: ("#source-sidebar details:first-of-type > summary", "http") +// We now click on it. +click: "#source-sidebar details:first-of-type > summary" +assert-property: ("#source-sidebar details:first-of-type", {"open": "true"}) + +// And now we collapse it again. +click: "#source-sidebar details:first-of-type > summary" +assert-property: ("#source-sidebar details:first-of-type", {"open": "false"}) + +// And open it again, since it'll be the reference we use to check positions. +click: "#source-sidebar details:first-of-type > summary" +assert-property: ("#source-sidebar details:first-of-type", {"open": "true"}) + +// Check the sidebar directory entries have a marker and spacing (desktop). +store-property: ( + link_height, + "#source-sidebar > details:first-of-type.dir-entry[open] > .files > a", + "offsetHeight" +) +define-function: ( + "check-sidebar-dir-entry", + (x, y), + block { + assert: "details:first-of-type.dir-entry[open] > summary::marker" + assert-css: ("#source-sidebar > details:first-of-type.dir-entry", {"padding-left": "4px"}) + // This check ensures that the summary is only one line. + assert-property: ( + "#source-sidebar > details:first-of-type.dir-entry[open] > summary", + {"offsetHeight": |link_height|} + ) + assert-position: ( + "#source-sidebar > details:first-of-type.dir-entry[open] > summary", + {"x": |x|, "y": |y|} + ) + assert-property: ( + "#source-sidebar > details:first-of-type.dir-entry[open] > .files > a", + {"offsetHeight": |link_height|} + ) + assert-position: ( + "#source-sidebar > details:first-of-type.dir-entry[open] > .files > a", + // left margin + {"x": |x| + 27, "y": |y| + |link_height|} + ) + } +) +store-property: ( + source_sidebar_title_height, + "#source-sidebar > .title", + "offsetHeight" +) +store-property: ( + source_sidebar_title_y, + "#source-sidebar > .title", + "offsetTop" +) +call-function: ("check-sidebar-dir-entry", { + "x": 0, + // border + margin = 6 + "y": |source_sidebar_title_y| + |source_sidebar_title_height| + 6, +}) + +// Check the search form +assert-css: ("nav.sub", {"flex-direction": "row"}) +// The goal of this test is to ensure the search input is perfectly centered +// between the top of the page and the top of the gray code block. +// To check this, we maintain the invariant: +// +// offsetTop[nav.sub form] = offsetTop[#main-content] - offsetHeight[nav.sub form] - offsetTop[nav.sub form] +assert-property: ("nav.sub form", {"offsetTop": 28, "offsetHeight": 34}) +assert-property: ("#main-content", {"offsetTop": 90}) +// 28 = 90 - 34 - 28 + +// Now do the same check on moderately-sized, tablet mobile. +size: (700, 700) +assert-css: ("nav.sub", {"flex-direction": "row"}) +assert-property: ("nav.sub form", {"offsetTop": 21, "offsetHeight": 34}) +assert-property: ("#main-content", {"offsetTop": 76}) +// 21 = 76 - 34 - 21 + +// Check the sidebar directory entries have a marker and spacing (tablet). +store-property: ( + source_sidebar_title_height, + "#source-sidebar > .title", + "offsetHeight" +) +store-property: ( + source_sidebar_title_y, + "#source-sidebar > .title", + "offsetTop" +) +call-function: ("check-sidebar-dir-entry", { + "x": 0, + "y": |source_sidebar_title_y| + |source_sidebar_title_height| + 6, +}) + +// Tiny, phone mobile gets a different display where the logo is stacked on top. +size: (450, 700) +assert-css: ("nav.sub", {"flex-direction": "column"}) + +// Check the sidebar directory entries have a marker and spacing (phone). +store-property: ( + source_sidebar_title_height, + "#source-sidebar > .title", + "offsetHeight" +) +store-property: ( + source_sidebar_title_y, + "#source-sidebar > .title", + "offsetTop" +) +call-function: ("check-sidebar-dir-entry", { + "x": 0, + "y": |source_sidebar_title_y| + |source_sidebar_title_height| + 6, +}) diff --git a/src/test/rustdoc-gui/src-font-size.goml b/tests/rustdoc-gui/src-font-size.goml index 9233f3744..9233f3744 100644 --- a/src/test/rustdoc-gui/src-font-size.goml +++ b/tests/rustdoc-gui/src-font-size.goml diff --git a/src/test/rustdoc-gui/src/huge_logo/Cargo.lock b/tests/rustdoc-gui/src/huge_logo/Cargo.lock index 142805750..142805750 100644 --- a/src/test/rustdoc-gui/src/huge_logo/Cargo.lock +++ b/tests/rustdoc-gui/src/huge_logo/Cargo.lock diff --git a/src/test/rustdoc-gui/src/huge_logo/Cargo.toml b/tests/rustdoc-gui/src/huge_logo/Cargo.toml index 3f10d09c8..3f10d09c8 100644 --- a/src/test/rustdoc-gui/src/huge_logo/Cargo.toml +++ b/tests/rustdoc-gui/src/huge_logo/Cargo.toml diff --git a/src/test/rustdoc-gui/src/huge_logo/src/lib.rs b/tests/rustdoc-gui/src/huge_logo/src/lib.rs index ec137fb9a..ec137fb9a 100644 --- a/src/test/rustdoc-gui/src/huge_logo/src/lib.rs +++ b/tests/rustdoc-gui/src/huge_logo/src/lib.rs diff --git a/tests/rustdoc-gui/src/lib2/Cargo.lock b/tests/rustdoc-gui/src/lib2/Cargo.lock new file mode 100644 index 000000000..425a3ae7e --- /dev/null +++ b/tests/rustdoc-gui/src/lib2/Cargo.lock @@ -0,0 +1,22 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "http" +version = "0.1.0" + +[[package]] +name = "implementors" +version = "0.1.0" +dependencies = [ + "http", +] + +[[package]] +name = "lib2" +version = "0.1.0" +dependencies = [ + "http", + "implementors", +] diff --git a/tests/rustdoc-gui/src/lib2/Cargo.toml b/tests/rustdoc-gui/src/lib2/Cargo.toml new file mode 100644 index 000000000..8bca77ff8 --- /dev/null +++ b/tests/rustdoc-gui/src/lib2/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "lib2" +version = "0.1.0" +edition = "2018" + +[lib] +path = "lib.rs" + +[dependencies] +implementors = { path = "./implementors" } +http = { path = "./http" } diff --git a/src/test/rustdoc-gui/src/lib2/another_folder/mod.rs b/tests/rustdoc-gui/src/lib2/another_folder/mod.rs index ec9a20859..ec9a20859 100644 --- a/src/test/rustdoc-gui/src/lib2/another_folder/mod.rs +++ b/tests/rustdoc-gui/src/lib2/another_folder/mod.rs diff --git a/src/test/rustdoc-gui/src/lib2/another_folder/sub_mod/mod.rs b/tests/rustdoc-gui/src/lib2/another_folder/sub_mod/mod.rs index f16722cf3..f16722cf3 100644 --- a/src/test/rustdoc-gui/src/lib2/another_folder/sub_mod/mod.rs +++ b/tests/rustdoc-gui/src/lib2/another_folder/sub_mod/mod.rs diff --git a/src/test/rustdoc-gui/src/lib2/another_mod/mod.rs b/tests/rustdoc-gui/src/lib2/another_mod/mod.rs index 9a4f007a2..9a4f007a2 100644 --- a/src/test/rustdoc-gui/src/lib2/another_mod/mod.rs +++ b/tests/rustdoc-gui/src/lib2/another_mod/mod.rs diff --git a/tests/rustdoc-gui/src/lib2/http/Cargo.toml b/tests/rustdoc-gui/src/lib2/http/Cargo.toml new file mode 100644 index 000000000..fa719efa5 --- /dev/null +++ b/tests/rustdoc-gui/src/lib2/http/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name = "http" +version = "0.1.0" +edition = "2018" + +[lib] +path = "lib.rs" diff --git a/tests/rustdoc-gui/src/lib2/http/lib.rs b/tests/rustdoc-gui/src/lib2/http/lib.rs new file mode 100644 index 000000000..204e07494 --- /dev/null +++ b/tests/rustdoc-gui/src/lib2/http/lib.rs @@ -0,0 +1 @@ +pub trait HttpTrait {} diff --git a/src/test/rustdoc-gui/src/lib2/implementors/Cargo.lock b/tests/rustdoc-gui/src/lib2/implementors/Cargo.lock index cad99a991..cad99a991 100644 --- a/src/test/rustdoc-gui/src/lib2/implementors/Cargo.lock +++ b/tests/rustdoc-gui/src/lib2/implementors/Cargo.lock diff --git a/tests/rustdoc-gui/src/lib2/implementors/Cargo.toml b/tests/rustdoc-gui/src/lib2/implementors/Cargo.toml new file mode 100644 index 000000000..9dafc43df --- /dev/null +++ b/tests/rustdoc-gui/src/lib2/implementors/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "implementors" +version = "0.1.0" +edition = "2018" + +[lib] +path = "lib.rs" + +[dependencies] +http = { path = "../http/" } diff --git a/tests/rustdoc-gui/src/lib2/implementors/lib.rs b/tests/rustdoc-gui/src/lib2/implementors/lib.rs new file mode 100644 index 000000000..2842ac50d --- /dev/null +++ b/tests/rustdoc-gui/src/lib2/implementors/lib.rs @@ -0,0 +1,22 @@ +pub trait Whatever { + type Foo; + + fn method() {} +} + +pub struct Struct; + +impl Whatever for Struct { + type Foo = u8; +} + +impl http::HttpTrait for Struct {} + +mod traits { + pub trait TraitToReexport { + fn method() {} + } +} + +#[doc(inline)] +pub use traits::TraitToReexport; diff --git a/tests/rustdoc-gui/src/lib2/lib.rs b/tests/rustdoc-gui/src/lib2/lib.rs new file mode 100644 index 000000000..34e67d9d2 --- /dev/null +++ b/tests/rustdoc-gui/src/lib2/lib.rs @@ -0,0 +1,343 @@ +// ignore-tidy-linelength + +#![feature(doc_cfg)] + +pub mod another_folder; +pub mod another_mod; + +pub mod module { + pub mod sub_module { + pub mod sub_sub_module { + pub fn foo() {} + } + pub fn bar() {} + } + pub fn whatever() {} +} + +pub fn foobar() {} + +pub type Alias = u32; + +#[doc(cfg(feature = "foo-method"))] +pub struct Foo { + pub x: Alias, +} + +impl Foo { + /// Some documentation + /// # A Heading + pub fn a_method(&self) {} +} + +#[doc(cfg(feature = "foo-method"))] +#[deprecated = "Whatever [`Foo::a_method`](#method.a_method)"] +pub trait Trait { + type X; + const Y: u32; + + #[deprecated = "Whatever [`Foo`](#tadam)"] + fn foo() {} + fn fooo(); +} + +impl Trait for Foo { + type X = u32; + const Y: u32 = 0; + + fn fooo() {} +} + +impl implementors::Whatever for Foo { + type Foo = u32; +} + +#[doc(inline)] +pub use implementors::TraitToReexport; + +pub struct StructToImplOnReexport; + +impl TraitToReexport for StructToImplOnReexport {} + +pub mod sub_mod { + /// ```txt + /// aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + /// ``` + /// + /// ``` + /// aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + /// ``` + pub struct Foo; +} + +pub mod long_trait { + use std::ops::DerefMut; + + pub trait ALongNameBecauseItHelpsTestingTheCurrentProblem: + DerefMut<Target = u32> + From<u128> + Send + Sync + AsRef<str> + 'static + { + } +} + +pub mod long_table { + /// | This::is::a::kinda::very::long::header::number::one | This::is::a::kinda::very::long::header::number::two | This::is::a::kinda::very::long::header::number::one | This::is::a::kinda::very::long::header::number::two | + /// | ----------- | ----------- | ----------- | ----------- | + /// | This::is::a::kinda::long::content::number::one | This::is::a::kinda::very::long::content::number::two | This::is::a::kinda::long::content::number::one | This::is::a::kinda::very::long::content::number::two | + /// + /// I wanna sqdkfnqds f dsqf qds f dsqf dsq f dsq f qds f qds f qds f dsqq f dsf sqdf dsq fds f dsq f dq f ds fq sd fqds f dsq f sqd fsq df sd fdsqfqsd fdsq f dsq f dsqfd s dfq + pub struct Foo; + + /// | This::is::a::kinda::very::long::header::number::one | This::is::a::kinda::very::long::header::number::two | This::is::a::kinda::very::long::header::number::one | This::is::a::kinda::very::long::header::number::two | + /// | ----------- | ----------- | ----------- | ----------- | + /// | This::is::a::kinda::long::content::number::one | This::is::a::kinda::very::long::content::number::two | This::is::a::kinda::long::content::number::one | This::is::a::kinda::very::long::content::number::two | + /// + /// I wanna sqdkfnqds f dsqf qds f dsqf dsq f dsq f qds f qds f qds f dsqq f dsf sqdf dsq fds f dsq f dq f ds fq sd fqds f dsq f sqd fsq df sd fdsqfqsd fdsq f dsq f dsqfd s dfq + impl Foo { + pub fn foo(&self) {} + } +} + +pub mod summary_table { + /// | header 1 | header 2 | + /// | -------- | -------- | + /// | content | content | + pub struct Foo; +} + +pub mod too_long { + pub type ReallyLongTypeNameLongLongLong = + Option<unsafe extern "C" fn(a: *const u8, b: *const u8) -> *const u8>; + + pub const ReallyLongTypeNameLongLongLongConstBecauseWhyNotAConstRightGigaGigaSupraLong: u32 = 0; + + /// This also has a really long doccomment. Lorem ipsum dolor sit amet, + /// consectetur adipiscing elit. Suspendisse id nibh malesuada, hendrerit + /// massa vel, tincidunt est. Nulla interdum, sem ac efficitur ornare, arcu + /// nunc dignissim nibh, at rutrum diam augue ac mauris. Fusce tincidunt et + /// ligula sed viverra. Aenean sed facilisis dui, non volutpat felis. In + /// vitae est dui. Donec felis nibh, blandit at nibh eu, tempor suscipit + /// nisl. Vestibulum ornare porta libero, eu faucibus purus iaculis ut. Ut + /// quis tincidunt nunc, in mollis purus. Nulla sed interdum quam. Nunc + /// vitae cursus ex. + pub struct SuperIncrediblyLongLongLongLongLongLongLongGigaGigaGigaMegaLongLongLongStructName { + pub a: u32, + } + + impl SuperIncrediblyLongLongLongLongLongLongLongGigaGigaGigaMegaLongLongLongStructName { + /// ``` + /// let x = SuperIncrediblyLongLongLongLongLongLongLongGigaGigaGigaMegaLongLongLongStructName { a: 0 }; + /// ``` + pub fn foo(&self) {} + } +} + +pub struct HasALongTraitWithParams {} + +pub trait LongTraitWithParamsBananaBananaBanana<T> {} + +impl LongTraitWithParamsBananaBananaBanana<usize> for HasALongTraitWithParams {} + +#[doc(cfg(any(target_os = "android", target_os = "linux", target_os = "emscripten", target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd", target_os = "openbsd")))] +pub struct LongItemInfo; + +pub trait SimpleTrait {} +pub struct LongItemInfo2; + +/// Some docs. +#[doc(cfg(any(target_os = "android", target_os = "linux", target_os = "emscripten", target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd", target_os = "openbsd")))] +impl SimpleTrait for LongItemInfo2 {} + +pub struct WhereWhitespace<T>; + +impl<T> WhereWhitespace<T> { + pub fn new<F>(f: F) -> Self + where + F: FnMut() -> i32, + {} +} + +impl<K, T> Whitespace<&K> for WhereWhitespace<T> +where + K: std::fmt::Debug, +{ + type Output = WhereWhitespace<T>; + fn index(&self, _key: &K) -> &Self::Output { + self + } +} + +pub trait Whitespace<Idx> +where + Idx: ?Sized, +{ + type Output; + fn index(&self, index: Idx) -> &Self::Output; +} + +pub struct ItemInfoAlignmentTest; + +impl ItemInfoAlignmentTest { + /// This method has docs + #[deprecated] + pub fn foo() {} + #[deprecated] + pub fn bar() {} +} + +pub mod scroll_traits { + use std::iter::*; + + /// Shamelessly (partially) copied from `std::iter::Iterator`. + /// It allows us to check that the scroll is working as expected on "hidden" items. + pub trait Iterator { + type Item; + + fn next(&mut self) -> Option<Self::Item>; + fn size_hint(&self) -> (usize, Option<usize>); + fn count(self) -> usize + where + Self: Sized; + fn last(self) -> Option<Self::Item> + where + Self: Sized; + fn advance_by(&mut self, n: usize) -> Result<(), usize>; + fn nth(&mut self, n: usize) -> Option<Self::Item>; + fn step_by(self, step: usize) -> StepBy<Self> + where + Self: Sized; + fn chain<U>(self, other: U) -> Chain<Self, U::IntoIter> + where + Self: Sized, + U: IntoIterator<Item = Self::Item>; + fn zip<U>(self, other: U) -> Zip<Self, U::IntoIter> + where + Self: Sized, + U: IntoIterator; + fn intersperse(self, separator: Self::Item) -> Intersperse<Self> + where + Self: Sized, + Self::Item: Clone; + fn intersperse_with<G>(self, separator: G) -> IntersperseWith<Self, G> + where + Self: Sized, + G: FnMut() -> Self::Item; + fn map<B, F>(self, f: F) -> Map<Self, F> + where + Self: Sized, + F: FnMut(Self::Item) -> B; + fn for_each<F>(self, f: F) + where + Self: Sized, + F: FnMut(Self::Item); + fn filter<P>(self, predicate: P) -> Filter<Self, P> + where + Self: Sized, + P: FnMut(&Self::Item) -> bool; + fn filter_map<B, F>(self, f: F) -> FilterMap<Self, F> + where + Self: Sized, + F: FnMut(Self::Item) -> Option<B>; + fn enumerate(self) -> Enumerate<Self> + where + Self: Sized; + fn peekable(self) -> Peekable<Self> + where + Self: Sized; + fn skip_while<P>(self, predicate: P) -> SkipWhile<Self, P> + where + Self: Sized, + P: FnMut(&Self::Item) -> bool; + fn take_while<P>(self, predicate: P) -> TakeWhile<Self, P> + where + Self: Sized, + P: FnMut(&Self::Item) -> bool; + fn map_while<B, P>(self, predicate: P) -> MapWhile<Self, P> + where + Self: Sized, + P: FnMut(Self::Item) -> Option<B>; + fn skip(self, n: usize) -> Skip<Self> + where + Self: Sized; + fn take(self, n: usize) -> Take<Self> + where + Self: Sized; + fn scan<St, B, F>(self, initial_state: St, f: F) -> Scan<Self, St, F> + where + Self: Sized, + F: FnMut(&mut St, Self::Item) -> Option<B>; + fn flat_map<U, F>(self, f: F) -> FlatMap<Self, U, F> + where + Self: Sized, + U: IntoIterator, + F: FnMut(Self::Item) -> U; + fn flatten(self) -> Flatten<Self> + where + Self: Sized, + Self::Item: IntoIterator; + fn fuse(self) -> Fuse<Self> + where + Self: Sized; + fn inspect<F>(self, f: F) -> Inspect<Self, F> + where + Self: Sized, + F: FnMut(&Self::Item); + fn by_ref(&mut self) -> &mut Self + where + Self: Sized; + fn collect<B: FromIterator<Self::Item>>(self) -> B + where + Self: Sized; + fn collect_into<E: Extend<Self::Item>>(self, collection: &mut E) -> &mut E + where + Self: Sized; + fn partition<B, F>(self, f: F) -> (B, B) + where + Self: Sized, + B: Default + Extend<Self::Item>, + F: FnMut(&Self::Item) -> bool; + fn partition_in_place<'a, T: 'a, P>(mut self, predicate: P) -> usize + where + Self: Sized + DoubleEndedIterator<Item = &'a mut T>, + P: FnMut(&T) -> bool; + fn is_partitioned<P>(mut self, mut predicate: P) -> bool + where + Self: Sized, + P: FnMut(Self::Item) -> bool; + fn fold<B, F>(mut self, init: B, mut f: F) -> B + where + Self: Sized, + F: FnMut(B, Self::Item) -> B; + fn reduce<F>(mut self, f: F) -> Option<Self::Item> + where + Self: Sized, + F: FnMut(Self::Item, Self::Item) -> Self::Item; + fn all<F>(&mut self, f: F) -> bool + where + Self: Sized, + F: FnMut(Self::Item) -> bool; + fn any<F>(&mut self, f: F) -> bool + where + Self: Sized, + F: FnMut(Self::Item) -> bool; + fn find<P>(&mut self, predicate: P) -> Option<Self::Item> + where + Self: Sized, + P: FnMut(&Self::Item) -> bool; + fn find_map<B, F>(&mut self, f: F) -> Option<B> + where + Self: Sized, + F: FnMut(Self::Item) -> Option<B>; + fn position<P>(&mut self, predicate: P) -> Option<usize> + where + Self: Sized, + P: FnMut(Self::Item) -> bool; + /// We will scroll to "string" to ensure it scrolls as expected. + fn this_is_a_method_with_a_long_name_returning_something() -> String; + } + + /// This one doesn't have hidden items (because there are too many) so we can also confirm that it + /// scrolls as expected. + pub trait TraitWithLongItemsName { + fn this_is_a_method_with_a_long_name_returning_something() -> String; + } +} diff --git a/src/test/rustdoc-gui/src/link_to_definition/Cargo.lock b/tests/rustdoc-gui/src/link_to_definition/Cargo.lock index e4b4e52d0..e4b4e52d0 100644 --- a/src/test/rustdoc-gui/src/link_to_definition/Cargo.lock +++ b/tests/rustdoc-gui/src/link_to_definition/Cargo.lock diff --git a/src/test/rustdoc-gui/src/link_to_definition/Cargo.toml b/tests/rustdoc-gui/src/link_to_definition/Cargo.toml index cdd294d74..cdd294d74 100644 --- a/src/test/rustdoc-gui/src/link_to_definition/Cargo.toml +++ b/tests/rustdoc-gui/src/link_to_definition/Cargo.toml diff --git a/src/test/rustdoc-gui/src/link_to_definition/lib.rs b/tests/rustdoc-gui/src/link_to_definition/lib.rs index 419a9ccee..419a9ccee 100644 --- a/src/test/rustdoc-gui/src/link_to_definition/lib.rs +++ b/tests/rustdoc-gui/src/link_to_definition/lib.rs diff --git a/src/test/rustdoc-gui/src/scrape_examples/Cargo.lock b/tests/rustdoc-gui/src/scrape_examples/Cargo.lock index 7cd6d0844..7cd6d0844 100644 --- a/src/test/rustdoc-gui/src/scrape_examples/Cargo.lock +++ b/tests/rustdoc-gui/src/scrape_examples/Cargo.lock diff --git a/src/test/rustdoc-gui/src/scrape_examples/Cargo.toml b/tests/rustdoc-gui/src/scrape_examples/Cargo.toml index aea9b657d..aea9b657d 100644 --- a/src/test/rustdoc-gui/src/scrape_examples/Cargo.toml +++ b/tests/rustdoc-gui/src/scrape_examples/Cargo.toml diff --git a/tests/rustdoc-gui/src/scrape_examples/examples/check-many-1.rs b/tests/rustdoc-gui/src/scrape_examples/examples/check-many-1.rs new file mode 100644 index 000000000..81a48ac50 --- /dev/null +++ b/tests/rustdoc-gui/src/scrape_examples/examples/check-many-1.rs @@ -0,0 +1,13 @@ +fn main() { + // all examples have same line count + scrape_examples::test_many(); + scrape_examples::test_many(); + scrape_examples::test_many(); + scrape_examples::test_many(); + scrape_examples::test_many(); + scrape_examples::test_many(); + scrape_examples::test_many(); + scrape_examples::test_many(); + scrape_examples::test_many(); + scrape_examples::test_many(); +} diff --git a/tests/rustdoc-gui/src/scrape_examples/examples/check-many-2.rs b/tests/rustdoc-gui/src/scrape_examples/examples/check-many-2.rs new file mode 100644 index 000000000..c9fdf68d3 --- /dev/null +++ b/tests/rustdoc-gui/src/scrape_examples/examples/check-many-2.rs @@ -0,0 +1,13 @@ +fn main() { + // ignore-tidy-linelength + scrape_examples::test_many(); /* Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. */ + scrape_examples::test_many(); /* Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. */ + scrape_examples::test_many(); /* Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. */ + scrape_examples::test_many(); /* Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. */ + scrape_examples::test_many(); /* Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. */ + scrape_examples::test_many(); /* Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. */ + scrape_examples::test_many(); /* Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. */ + scrape_examples::test_many(); /* Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. */ + scrape_examples::test_many(); /* Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. */ + scrape_examples::test_many(); /* Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. */ +} diff --git a/tests/rustdoc-gui/src/scrape_examples/examples/check-many-3.rs b/tests/rustdoc-gui/src/scrape_examples/examples/check-many-3.rs new file mode 100644 index 000000000..c9fdf68d3 --- /dev/null +++ b/tests/rustdoc-gui/src/scrape_examples/examples/check-many-3.rs @@ -0,0 +1,13 @@ +fn main() { + // ignore-tidy-linelength + scrape_examples::test_many(); /* Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. */ + scrape_examples::test_many(); /* Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. */ + scrape_examples::test_many(); /* Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. */ + scrape_examples::test_many(); /* Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. */ + scrape_examples::test_many(); /* Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. */ + scrape_examples::test_many(); /* Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. */ + scrape_examples::test_many(); /* Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. */ + scrape_examples::test_many(); /* Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. */ + scrape_examples::test_many(); /* Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. */ + scrape_examples::test_many(); /* Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. */ +} diff --git a/tests/rustdoc-gui/src/scrape_examples/examples/check-many-4.rs b/tests/rustdoc-gui/src/scrape_examples/examples/check-many-4.rs new file mode 100644 index 000000000..81a48ac50 --- /dev/null +++ b/tests/rustdoc-gui/src/scrape_examples/examples/check-many-4.rs @@ -0,0 +1,13 @@ +fn main() { + // all examples have same line count + scrape_examples::test_many(); + scrape_examples::test_many(); + scrape_examples::test_many(); + scrape_examples::test_many(); + scrape_examples::test_many(); + scrape_examples::test_many(); + scrape_examples::test_many(); + scrape_examples::test_many(); + scrape_examples::test_many(); + scrape_examples::test_many(); +} diff --git a/tests/rustdoc-gui/src/scrape_examples/examples/check-many-5.rs b/tests/rustdoc-gui/src/scrape_examples/examples/check-many-5.rs new file mode 100644 index 000000000..81a48ac50 --- /dev/null +++ b/tests/rustdoc-gui/src/scrape_examples/examples/check-many-5.rs @@ -0,0 +1,13 @@ +fn main() { + // all examples have same line count + scrape_examples::test_many(); + scrape_examples::test_many(); + scrape_examples::test_many(); + scrape_examples::test_many(); + scrape_examples::test_many(); + scrape_examples::test_many(); + scrape_examples::test_many(); + scrape_examples::test_many(); + scrape_examples::test_many(); + scrape_examples::test_many(); +} diff --git a/tests/rustdoc-gui/src/scrape_examples/examples/check-many-6.rs b/tests/rustdoc-gui/src/scrape_examples/examples/check-many-6.rs new file mode 100644 index 000000000..81a48ac50 --- /dev/null +++ b/tests/rustdoc-gui/src/scrape_examples/examples/check-many-6.rs @@ -0,0 +1,13 @@ +fn main() { + // all examples have same line count + scrape_examples::test_many(); + scrape_examples::test_many(); + scrape_examples::test_many(); + scrape_examples::test_many(); + scrape_examples::test_many(); + scrape_examples::test_many(); + scrape_examples::test_many(); + scrape_examples::test_many(); + scrape_examples::test_many(); + scrape_examples::test_many(); +} diff --git a/tests/rustdoc-gui/src/scrape_examples/examples/check-many-7.rs b/tests/rustdoc-gui/src/scrape_examples/examples/check-many-7.rs new file mode 100644 index 000000000..81a48ac50 --- /dev/null +++ b/tests/rustdoc-gui/src/scrape_examples/examples/check-many-7.rs @@ -0,0 +1,13 @@ +fn main() { + // all examples have same line count + scrape_examples::test_many(); + scrape_examples::test_many(); + scrape_examples::test_many(); + scrape_examples::test_many(); + scrape_examples::test_many(); + scrape_examples::test_many(); + scrape_examples::test_many(); + scrape_examples::test_many(); + scrape_examples::test_many(); + scrape_examples::test_many(); +} diff --git a/src/test/rustdoc-gui/src/scrape_examples/examples/check.rs b/tests/rustdoc-gui/src/scrape_examples/examples/check.rs index b3f682fe4..b3f682fe4 100644 --- a/src/test/rustdoc-gui/src/scrape_examples/examples/check.rs +++ b/tests/rustdoc-gui/src/scrape_examples/examples/check.rs diff --git a/src/test/rustdoc-gui/src/scrape_examples/src/lib.rs b/tests/rustdoc-gui/src/scrape_examples/src/lib.rs index 88b03cf26..88b03cf26 100644 --- a/src/test/rustdoc-gui/src/scrape_examples/src/lib.rs +++ b/tests/rustdoc-gui/src/scrape_examples/src/lib.rs diff --git a/src/test/rustdoc-gui/src/settings/.cargo/config.toml b/tests/rustdoc-gui/src/settings/.cargo/config.toml index bbb8d11a2..bbb8d11a2 100644 --- a/src/test/rustdoc-gui/src/settings/.cargo/config.toml +++ b/tests/rustdoc-gui/src/settings/.cargo/config.toml diff --git a/src/test/rustdoc-gui/src/settings/Cargo.lock b/tests/rustdoc-gui/src/settings/Cargo.lock index 6f0de1ac1..6f0de1ac1 100644 --- a/src/test/rustdoc-gui/src/settings/Cargo.lock +++ b/tests/rustdoc-gui/src/settings/Cargo.lock diff --git a/src/test/rustdoc-gui/src/settings/Cargo.toml b/tests/rustdoc-gui/src/settings/Cargo.toml index c8a211a47..c8a211a47 100644 --- a/src/test/rustdoc-gui/src/settings/Cargo.toml +++ b/tests/rustdoc-gui/src/settings/Cargo.toml diff --git a/src/test/rustdoc-gui/src/settings/lib.rs b/tests/rustdoc-gui/src/settings/lib.rs index b76b4321d..b76b4321d 100644 --- a/src/test/rustdoc-gui/src/settings/lib.rs +++ b/tests/rustdoc-gui/src/settings/lib.rs diff --git a/src/test/rustdoc-gui/src/staged_api/Cargo.lock b/tests/rustdoc-gui/src/staged_api/Cargo.lock index 6e8eba56c..6e8eba56c 100644 --- a/src/test/rustdoc-gui/src/staged_api/Cargo.lock +++ b/tests/rustdoc-gui/src/staged_api/Cargo.lock diff --git a/src/test/rustdoc-gui/src/staged_api/Cargo.toml b/tests/rustdoc-gui/src/staged_api/Cargo.toml index b231be6ee..b231be6ee 100644 --- a/src/test/rustdoc-gui/src/staged_api/Cargo.toml +++ b/tests/rustdoc-gui/src/staged_api/Cargo.toml diff --git a/src/test/rustdoc-gui/src/staged_api/lib.rs b/tests/rustdoc-gui/src/staged_api/lib.rs index 5934593a8..5934593a8 100644 --- a/src/test/rustdoc-gui/src/staged_api/lib.rs +++ b/tests/rustdoc-gui/src/staged_api/lib.rs diff --git a/src/test/rustdoc-gui/src/test_docs/Cargo.lock b/tests/rustdoc-gui/src/test_docs/Cargo.lock index 6b80f6e88..6b80f6e88 100644 --- a/src/test/rustdoc-gui/src/test_docs/Cargo.lock +++ b/tests/rustdoc-gui/src/test_docs/Cargo.lock diff --git a/src/test/rustdoc-gui/src/test_docs/Cargo.toml b/tests/rustdoc-gui/src/test_docs/Cargo.toml index 8be819b76..8be819b76 100644 --- a/src/test/rustdoc-gui/src/test_docs/Cargo.toml +++ b/tests/rustdoc-gui/src/test_docs/Cargo.toml diff --git a/src/test/rustdoc-gui/src/test_docs/build.rs b/tests/rustdoc-gui/src/test_docs/build.rs index 16c96ded9..16c96ded9 100644 --- a/src/test/rustdoc-gui/src/test_docs/build.rs +++ b/tests/rustdoc-gui/src/test_docs/build.rs diff --git a/tests/rustdoc-gui/src/test_docs/lib.rs b/tests/rustdoc-gui/src/test_docs/lib.rs new file mode 100644 index 000000000..512504396 --- /dev/null +++ b/tests/rustdoc-gui/src/test_docs/lib.rs @@ -0,0 +1,476 @@ +//! The point of this crate is to be able to have enough different "kinds" of +//! documentation generated so we can test each different features. +#![doc(html_playground_url="https://play.rust-lang.org/")] + +#![crate_name = "test_docs"] +#![feature(rustdoc_internals)] +#![feature(doc_cfg)] +#![feature(associated_type_defaults)] + +/*! +Enable the feature <span class="stab portability"><code>some-feature</code></span> to enjoy +this crate even more! +Enable the feature <span class="stab portability"><code>some-feature</code></span> to enjoy +this crate even more! +Enable the feature <span class="stab portability"><code>some-feature</code></span> to enjoy +this crate even more! + +Also, stop using `bar` as it's <span class="stab deprecated" title="">deprecated</span>. +Also, stop using `bar` as it's <span class="stab deprecated" title="">deprecated</span>. +Also, stop using `bar` as it's <span class="stab deprecated" title="">deprecated</span>. + +Finally, you can use `quz` only on <span class="stab portability"><code>Unix or x86-64</code> +</span>. +Finally, you can use `quz` only on <span class="stab portability"><code>Unix or x86-64</code> +</span>. +*/ + +use std::convert::AsRef; +use std::fmt; + +/// Basic function with some code examples: +/// +/// ``` +/// println!("nothing fancy"); +/// println!("but with two lines!"); +/// ``` +/// +/// A failing to compile one: +/// +/// ```compile_fail +/// println!("where did my argument {} go? :'("); +/// ``` +/// +/// An ignored one: +/// +/// ```ignore (it's a test) +/// Let's say I'm just some text will ya? +/// ``` +/// +/// A failing to run one: +/// +/// ```should_panic +/// panic!("tadam"); +/// ``` +/// +/// An inlined `code`! +pub fn foo() {} + +/// Just a normal struct. +pub struct Foo; + +impl Foo { + #[must_use] + pub fn must_use(&self) -> bool { + true + } +} + +impl AsRef<str> for Foo { + fn as_ref(&self) -> &str { + "hello" + } +} + +/// Just a normal enum. +/// +/// # title! +#[doc(alias = "ThisIsAnAlias")] +#[non_exhaustive] +pub enum WhoLetTheDogOut { + /// Woof! + Woof, + /// Meoooooooow... + Meow, +} + +/// Who doesn't love to wrap a `format!` call? +pub fn some_more_function<T: fmt::Debug>(t: &T) -> String { + format!("{:?}", t) +} + +/// Woohoo! A trait! +pub trait AnotherOne { + /// Some func 3. + fn func3(); + + /// Some func 1. + fn func1(); + + fn another(); + fn why_not(); + + /// Some func 2. + fn func2(); + + fn hello(); +} + +/// ```compile_fail +/// whatever +/// ``` +/// +/// Check for "i" signs in lists! +/// +/// 1. elem 1 +/// 2. test 1 +/// ```compile_fail +/// fn foo() {} +/// ``` +/// 3. elem 3 +/// 4. ```ignore (it's a test) +/// fn foo() {} +/// ``` +/// 5. elem 5 +/// +/// Final one: +/// +/// ```ignore (still a test) +/// let x = 12; +/// ``` +pub fn check_list_code_block() {} + +/// a thing with a label +#[deprecated(since = "1.0.0", note = "text why this deprecated")] +#[doc(cfg(unix))] +pub fn replaced_function() {} + +/// Some doc with `code`! +pub enum AnEnum { + WithVariants { and: usize, sub: usize, variants: usize }, +} + +#[doc(keyword = "CookieMonster")] +/// Some keyword. +pub mod keyword {} + +/// Just some type alias. +pub type SomeType = u32; + +pub mod huge_amount_of_consts { + include!(concat!(env!("OUT_DIR"), "/huge_amount_of_consts.rs")); +} + +/// Very long code text `hereIgoWithLongTextBecauseWhyNotAndWhyWouldntI`. +pub mod long_code_block {} + +/// Very long code text [`hereIgoWithLongTextBecauseWhyNotAndWhyWouldntI`][lnk]. +/// +/// [lnk]: crate::long_code_block_link +pub mod long_code_block_link {} + +#[macro_export] +macro_rules! repro { + () => {}; +} + +pub use crate::repro as repro2; + +/// # Top-doc Prose title +/// +/// Text below title. +/// +/// ## Top-doc Prose sub-heading +/// +/// Text below sub-heading. +/// +/// ### Top-doc Prose sub-sub-heading +/// +/// Text below sub-sub-heading +/// +/// #### You know the drill. +/// +/// More text. +pub struct HeavilyDocumentedStruct { + /// # Title for field + /// ## Sub-heading for field + pub nothing: (), +} + +/// # Title for struct impl doc +/// +/// Text below heading. +/// +/// ## Sub-heading for struct impl doc +/// +/// Text below sub-heading. +/// +/// ### Sub-sub-heading for struct impl doc +/// +/// Text below sub-sub-heading. +/// +impl HeavilyDocumentedStruct { + /// # Title for struct impl-item doc + /// Text below title. + /// ## Sub-heading for struct impl-item doc + /// Text below sub-heading. + /// ### Sub-sub-heading for struct impl-item doc + /// Text below sub-sub-heading. + pub fn do_nothing() {} +} + +/// # Top-doc Prose title +/// +/// Text below title. +/// +/// ## Top-doc Prose sub-heading +/// +/// Text below sub-heading. +/// +/// ### Top-doc Prose sub-sub-heading +/// +/// Text below sub-sub-heading +pub enum HeavilyDocumentedEnum { + /// # None prose title + /// ## None prose sub-heading + None, + /// # Wrapped prose title + /// ## Wrapped prose sub-heading + Wrapped( + /// # Wrapped.0 prose title + /// ## Wrapped.0 prose sub-heading + String, + String, + ), + Structy { + /// # Structy prose title + /// ## Structy prose sub-heading + alpha: String, + beta: String, + }, +} + +/// # Title for enum impl doc +/// +/// Text below heading. +/// +/// ## Sub-heading for enum impl doc +/// +/// Text below sub-heading. +/// +/// ### Sub-sub-heading for enum impl doc +/// +/// Text below sub-sub-heading. +/// +impl HeavilyDocumentedEnum { + /// # Title for enum impl-item doc + /// Text below title. + /// ## Sub-heading for enum impl-item doc + /// Text below sub-heading. + /// ### Sub-sub-heading for enum impl-item doc + /// Text below sub-sub-heading. + pub fn do_nothing() {} +} + +/// # Top-doc prose title +/// +/// Text below heading. +/// +/// ## Top-doc prose sub-heading +/// +/// Text below heading. +pub union HeavilyDocumentedUnion { + /// # Title for union variant + /// ## Sub-heading for union variant + pub nothing: (), + pub something: f32, +} + +/// # Title for union impl doc +/// ## Sub-heading for union impl doc +impl HeavilyDocumentedUnion { + /// # Title for union impl-item doc + /// ## Sub-heading for union impl-item doc + pub fn do_nothing() {} +} + +/// # Top-doc prose title +/// +/// Text below heading. +/// +/// ## Top-doc prose sub-heading +/// +/// Text below heading. +#[macro_export] +macro_rules! heavily_documented_macro { + () => {}; +} + +pub trait EmptyTrait1 {} +pub trait EmptyTrait2 {} +pub trait EmptyTrait3 {} + +pub struct HasEmptyTraits{} + +impl EmptyTrait1 for HasEmptyTraits {} +impl EmptyTrait2 for HasEmptyTraits {} +#[doc(cfg(feature = "some-feature"))] +impl EmptyTrait3 for HasEmptyTraits {} + +mod macros; +pub use macros::*; + +#[doc(alias = "AliasForTheStdReexport")] +pub use ::std as TheStdReexport; + +pub mod details { + /// We check the appearance of the `<details>`/`<summary>` in here. + /// + /// ## Hello + /// + /// <details> + /// <summary><h4>I'm a summary</h4></summary> + /// <div>I'm the content of the details!</div> + /// </details> + pub struct Details; + + impl Details { + /// We check the appearance of the `<details>`/`<summary>` in here. + /// + /// ## Hello + /// + /// <details> + /// <summary><h4>I'm a summary</h4></summary> + /// <div>I'm the content of the details!</div> + /// </details> + pub fn method() {} + } +} + +pub mod doc_block_table { + + pub trait DocBlockTableTrait { + fn func(); + } + + /// Struct doc. + /// + /// | header1 | header2 | + /// |--------------------------|--------------------------| + /// | Lorem Ipsum, Lorem Ipsum | Lorem Ipsum, Lorem Ipsum | + /// | Lorem Ipsum, Lorem Ipsum | Lorem Ipsum, Lorem Ipsum | + /// | Lorem Ipsum, Lorem Ipsum | Lorem Ipsum, Lorem Ipsum | + /// | Lorem Ipsum, Lorem Ipsum | Lorem Ipsum, Lorem Ipsum | + pub struct DocBlockTable {} + + impl DocBlockTableTrait for DocBlockTable { + /// Trait impl func doc for struct. + /// + /// | header1 | header2 | + /// |--------------------------|--------------------------| + /// | Lorem Ipsum, Lorem Ipsum | Lorem Ipsum, Lorem Ipsum | + fn func() { + println!(); + } + } + +} + +pub struct NotableStructWithLongName<R>(R); + +impl<R: std::io::Read> NotableStructWithLongName<R> { + pub fn create_an_iterator_from_read(r: R) -> NotableStructWithLongName<R> { Self(r) } +} + +impl<R: std::io::Read> std::iter::Iterator for NotableStructWithLongName<R> { + type Item = (); + + fn next(&mut self) -> Option<Self::Item> { () } +} + +pub trait TraitWithNoDocblocks { + fn first_fn(&self); + fn second_fn(&self); +} + +pub struct TypeWithNoDocblocks; + +impl TypeWithNoDocblocks { + fn x() -> Option<Self> { + Some(Self) + } + fn y() -> Option<u32> { + // code comment + let t = Self::x()?; + Some(0) + } +} + +impl TypeWithNoDocblocks { + pub fn first_fn(&self) {} + pub fn second_fn<'a>(&'a self) { + let x = 12; + let y = "a"; + let z = false; + } +} + +pub unsafe fn unsafe_fn() {} + +pub fn safe_fn() {} + +#[repr(C)] +pub struct WithGenerics<T: TraitWithNoDocblocks, S = String, E = WhoLetTheDogOut, P = i8> { + s: S, + t: T, + e: E, + p: P, +} + +pub struct StructWithPublicUndocumentedFields { + pub first: u32, + pub second: u32, +} + +pub const CONST: u8 = 0; + +pub trait TraitWithoutGenerics { + const C: u8 = CONST; + type T = SomeType; + + fn foo(); +} + +pub mod trait_members { + pub trait TraitMembers { + /// Some type + type Type; + /// Some function + fn function(); + /// Some other function + fn function2(); + } + pub struct HasTrait; + impl TraitMembers for HasTrait { + type Type = u8; + fn function() {} + fn function2() {} + } +} + +pub struct TypeWithImplDoc; + +/// impl doc +impl TypeWithImplDoc { + /// fn doc + pub fn test_fn() {} +} + +/// <sub id="codeblock-sub-1"> +/// +/// ``` +/// one +/// ``` +/// +/// </sub> +/// +/// <sub id="codeblock-sub-3"> +/// +/// ``` +/// one +/// two +/// three +/// ``` +/// +/// </sub> +pub mod codeblock_sub {} diff --git a/src/test/rustdoc-gui/src/test_docs/macros.rs b/tests/rustdoc-gui/src/test_docs/macros.rs index 07b2b9792..07b2b9792 100644 --- a/src/test/rustdoc-gui/src/test_docs/macros.rs +++ b/tests/rustdoc-gui/src/test_docs/macros.rs diff --git a/tests/rustdoc-gui/stab-badge.goml b/tests/rustdoc-gui/stab-badge.goml new file mode 100644 index 000000000..50ba1ba62 --- /dev/null +++ b/tests/rustdoc-gui/stab-badge.goml @@ -0,0 +1,41 @@ +// All stability badges should have rounded corners and colored backgrounds. +goto: "file://" + |DOC_PATH| + "/test_docs/index.html" +show-text: true +define-function: ( + "check-badge", + (theme, background, color), + block { + local-storage: {"rustdoc-use-system-theme": "false", "rustdoc-theme": |theme|} + goto: "file://" + |DOC_PATH| + "/test_docs/index.html" + assert: ".docblock .stab" + assert: ".item-table .stab" + assert-css: (".stab", { + "border-radius": "3px", + "color": |color|, + "background-color": |background|, + }) + goto: "file://" + |DOC_PATH| + "/test_docs/fn.replaced_function.html" + assert: (".item-info .stab") + assert-css: (".stab", { + "border-radius": "3px", + "color": |color|, + "background-color": |background|, + }) + }, +) + +call-function: ("check-badge", { + "theme": "ayu", + "color": "rgb(197, 197, 197)", + "background": "rgb(49, 69, 89)", +}) +call-function: ("check-badge", { + "theme": "dark", + "color": "rgb(221, 221, 221)", + "background": "rgb(49, 69, 89)", +}) +call-function: ("check-badge", { + "theme": "light", + "color": "rgb(0, 0, 0)", + "background": "rgb(255, 245, 214)", +}) diff --git a/tests/rustdoc-gui/struct-fields.goml b/tests/rustdoc-gui/struct-fields.goml new file mode 100644 index 000000000..fa3e16cb8 --- /dev/null +++ b/tests/rustdoc-gui/struct-fields.goml @@ -0,0 +1,5 @@ +// This test ensures that each field is on its own line (In other words, they have display: block). +goto: "file://" + |DOC_PATH| + "/test_docs/struct.StructWithPublicUndocumentedFields.html" + +store-property: (first_top, "//*[@id='structfield.first']", "offsetTop") +assert-property-false: ("//*[@id='structfield.second']", { "offsetTop": |first_top| }) diff --git a/src/test/rustdoc-gui/target.goml b/tests/rustdoc-gui/target.goml index 3e5c30dc7..ca393ee58 100644 --- a/src/test/rustdoc-gui/target.goml +++ b/tests/rustdoc-gui/target.goml @@ -8,14 +8,14 @@ assert: "#method\.a_method:target" define-function: ( "check-style", (theme, background, border), - [ - ("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}), - ("reload"), - ("assert-css", ("#method\.a_method:target", { + block { + local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} + reload: + assert-css: ("#method\.a_method:target", { "background-color": |background|, "border-right": "3px solid " + |border|, - })), - ], + }) + }, ) call-function: ("check-style", { diff --git a/src/test/rustdoc-gui/theme-change.goml b/tests/rustdoc-gui/theme-change.goml index cc47f1f45..cc47f1f45 100644 --- a/src/test/rustdoc-gui/theme-change.goml +++ b/tests/rustdoc-gui/theme-change.goml diff --git a/src/test/rustdoc-gui/theme-in-history.goml b/tests/rustdoc-gui/theme-in-history.goml index 10508e86a..10508e86a 100644 --- a/src/test/rustdoc-gui/theme-in-history.goml +++ b/tests/rustdoc-gui/theme-in-history.goml diff --git a/tests/rustdoc-gui/toggle-click-deadspace.goml b/tests/rustdoc-gui/toggle-click-deadspace.goml new file mode 100644 index 000000000..ac346f25b --- /dev/null +++ b/tests/rustdoc-gui/toggle-click-deadspace.goml @@ -0,0 +1,15 @@ +// This test ensures that clicking on a method summary, but not on the "[-]", +// doesn't toggle the <details>. +goto: "file://" + |DOC_PATH| + "/lib2/struct.Foo.html" +assert-attribute: (".impl-items .toggle", {"open": ""}) +click: "h4.code-header" // This is the position of "pub" in "pub fn a_method" +assert-attribute: (".impl-items .toggle", {"open": ""}) +click-with-offset: ( + ".impl-items .toggle summary", + {"x": -24, "y": 8}, // This is the position of "[-]" next to that pub fn. +) +assert-attribute-false: (".impl-items .toggle", {"open": ""}) + +// Click the "Trait" part of "impl Trait" and verify it navigates. +click: "#impl-Trait-for-Foo h3 a:first-of-type" +assert-text: (".main-heading h1", "Trait lib2::Trait") diff --git a/src/test/rustdoc-gui/toggle-docs-mobile.goml b/tests/rustdoc-gui/toggle-docs-mobile.goml index 6ce24a81b..6ce24a81b 100644 --- a/src/test/rustdoc-gui/toggle-docs-mobile.goml +++ b/tests/rustdoc-gui/toggle-docs-mobile.goml diff --git a/tests/rustdoc-gui/toggle-docs.goml b/tests/rustdoc-gui/toggle-docs.goml new file mode 100644 index 000000000..c9d236e9b --- /dev/null +++ b/tests/rustdoc-gui/toggle-docs.goml @@ -0,0 +1,75 @@ +// Checks that the documentation toggles have the correct position, style and work as expected. +goto: "file://" + |DOC_PATH| + "/test_docs/index.html" +assert-attribute: ("#main-content > details.top-doc", {"open": ""}) +assert-text: ("#toggle-all-docs", "[−]") +click: "#toggle-all-docs" +wait-for: 50 +// This is now collapsed so there shouldn't be the "open" attribute on details. +assert-attribute-false: ("#main-content > details.top-doc", {"open": ""}) +assert-text: ("#toggle-all-docs", "[+]") +assert-css: ( + "#main-content > details.top-doc > summary", + {"font-family": '"Fira Sans", Arial, NanumBarunGothic, sans-serif'}, +) +click: "#toggle-all-docs" +// Not collapsed anymore so the "open" attribute should be back. +wait-for-attribute: ("#main-content > details.top-doc", {"open": ""}) +assert-text: ("#toggle-all-docs", "[−]") + +// Check that it works on non-module pages as well. +goto: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html" +// We first check that everything is visible. +assert-text: ("#toggle-all-docs", "[−]") +assert-attribute: ("#implementations-list details.toggle", {"open": ""}, ALL) +assert-attribute: ("#trait-implementations-list details.toggle", {"open": ""}, ALL) +assert-attribute-false: ( + "#blanket-implementations-list > details.toggle", + {"open": ""}, + ALL, +) + +// We collapse them all. +click: "#toggle-all-docs" +wait-for-text: ("#toggle-all-docs", "[+]") +// We check that all <details> are collapsed (except for the impl block ones). +assert-attribute-false: ("details.toggle:not(.implementors-toggle)", {"open": ""}, ALL) +assert-attribute: ("#implementations-list > details.implementors-toggle", {"open": ""}) +// We now check that the other impl blocks are collapsed. +assert-attribute-false: ( + "#blanket-implementations-list > details.toggle.implementors-toggle", + {"open": ""}, + ALL, +) +// We open them all again. +click: "#toggle-all-docs" +wait-for-text: ("#toggle-all-docs", "[−]") +assert-attribute: ("details.toggle", {"open": ""}, ALL) + +// Checking the toggles style. +show-text: true +define-function: ( + "check-color", + (theme, filter), + block { + // 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: ("details.toggle > summary::before", { + "opacity": "0.5", + "filter": |filter|, + }, ALL) + move-cursor-to: "details.toggle summary" + assert-css: ("details.toggle > summary:hover::before", { + "opacity": "1", + "filter": |filter|, + }) + // moving the cursor somewhere else to not mess with next function calls. + move-cursor-to: ".search-input" + }, +) + +call-function: ("check-color", {"theme": "ayu", "filter": "invert(1)"}) +call-function: ("check-color", {"theme": "dark", "filter": "invert(1)"}) +call-function: ("check-color", {"theme": "light", "filter": "none"}) diff --git a/src/test/rustdoc-gui/toggle-implementors.goml b/tests/rustdoc-gui/toggle-implementors.goml index 8ff5b91af..8ff5b91af 100644 --- a/src/test/rustdoc-gui/toggle-implementors.goml +++ b/tests/rustdoc-gui/toggle-implementors.goml diff --git a/src/test/rustdoc-gui/toggled-open-implementations.goml b/tests/rustdoc-gui/toggled-open-implementations.goml index e4d59b5d7..000293b55 100644 --- a/src/test/rustdoc-gui/toggled-open-implementations.goml +++ b/tests/rustdoc-gui/toggled-open-implementations.goml @@ -2,4 +2,4 @@ // has all the implementations toggled open by default, so users can // find method names in those implementations with Ctrl-F. goto: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html" -assert-attribute: (".rustdoc-toggle.implementors-toggle", {"open": ""}) +assert-attribute: (".toggle.implementors-toggle", {"open": ""}) diff --git a/src/test/rustdoc-gui/trait-sidebar-item-order.goml b/tests/rustdoc-gui/trait-sidebar-item-order.goml index e5d023544..e5d023544 100644 --- a/src/test/rustdoc-gui/trait-sidebar-item-order.goml +++ b/tests/rustdoc-gui/trait-sidebar-item-order.goml diff --git a/src/test/rustdoc-gui/type-declation-overflow.goml b/tests/rustdoc-gui/type-declation-overflow.goml index c014eb52e..644429c01 100644 --- a/src/test/rustdoc-gui/type-declation-overflow.goml +++ b/tests/rustdoc-gui/type-declation-overflow.goml @@ -1,3 +1,4 @@ +// ignore-tidy-linelength // This test ensures that the items declaration content overflow is handled inside the <pre> directly. // We need to disable this check because @@ -58,3 +59,18 @@ goto: "file://" + |DOC_PATH| + "/lib2/too_long/struct.SuperIncrediblyLongLongLon compare-elements-position-false: (".main-heading h1", ".main-heading .out-of-band", ("y")) goto: "file://" + |DOC_PATH| + "/lib2/index.html" compare-elements-position-false: (".main-heading h1", ".main-heading .out-of-band", ("y")) + +// Now we will check that the scrolling is working. +// First on an item with "hidden methods". +goto: "file://" + |DOC_PATH| + "/lib2/scroll_traits/trait.Iterator.html" + +click: ".item-decl .type-contents-toggle" +assert-property: (".item-decl > pre", {"scrollLeft": 0}) +scroll-to: "//*[@class='item-decl']//details/a[text()='String']" +assert-property-false: (".item-decl > pre", {"scrollLeft": 0}) + +// Then on an item without "hidden methods". +goto: "file://" + |DOC_PATH| + "/lib2/scroll_traits/trait.TraitWithLongItemsName.html" +assert-property: (".item-decl > pre", {"scrollLeft": 0}) +scroll-to: "//*[@class='item-decl']//code/a[text()='String']" +assert-property-false: (".item-decl > pre", {"scrollLeft": 0}) diff --git a/src/test/rustdoc-gui/unsafe-fn.goml b/tests/rustdoc-gui/unsafe-fn.goml index 5e43b85fc..d3a672ddd 100644 --- a/src/test/rustdoc-gui/unsafe-fn.goml +++ b/tests/rustdoc-gui/unsafe-fn.goml @@ -14,13 +14,13 @@ define-function: ( // `theme` is the theme being tested. // `color` is the expected color of the `<sup>` element. (theme, color), - [ + block { // Set the theme. - ("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}), + 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", (".item-left sup", {"color": |color|})), - ], + reload: + assert-css: (".item-left sup", {"color": |color|}) + }, ) call-function: ("sup-check", ("dark", "rgb(221, 221, 221)")) diff --git a/src/test/rustdoc-gui/where-whitespace.goml b/tests/rustdoc-gui/where-whitespace.goml index 41596a9bc..41596a9bc 100644 --- a/src/test/rustdoc-gui/where-whitespace.goml +++ b/tests/rustdoc-gui/where-whitespace.goml |