From 9855a3844bbe96d03f18541bdee3e325c35c8a34 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 15 Jul 2024 18:10:50 +0200 Subject: [PATCH] Add tests for new toggle on deref blocks --- tests/rustdoc-gui/deref-block.goml | 30 ++++++++++++++++++++++++++++++ tests/rustdoc-gui/src/lib2/lib.rs | 10 ++++++++++ 2 files changed, 40 insertions(+) create mode 100644 tests/rustdoc-gui/deref-block.goml diff --git a/tests/rustdoc-gui/deref-block.goml b/tests/rustdoc-gui/deref-block.goml new file mode 100644 index 00000000000..24f612f8a6f --- /dev/null +++ b/tests/rustdoc-gui/deref-block.goml @@ -0,0 +1,30 @@ +// This test ensures that several clickable items actually have the pointer cursor. +go-to: "file://" + |DOC_PATH| + "/lib2/struct.Derefer.html" + +assert-text: (".big-toggle summary", "Methods from Deref§") +// We ensure it doesn't go over `§`. +assert-css: (".big-toggle summary::before", { + "left": "-34px", + "top": "9px", +}) +// It should NOT have the same X or Y position as the other toggles. +compare-elements-position-false: ( + ".big-toggle summary::before", + ".method-toggle summary::before", + ["x", "y"], +) + +// We now check that if we're in mobile mode, it gets back to its original X position. +set-window-size: (600, 600) +assert-css: (".big-toggle summary::before", { + "left": "-11px", + "top": "9px", +}) +// It should have the same X position as the other toggles. +compare-elements-position: (".big-toggle summary::before", ".method-toggle summary::before", ["x"]) +// But still shouldn't have the same Y position. +compare-elements-position-false: ( + ".big-toggle summary::before", + ".method-toggle summary::before", + ["y"], +) diff --git a/tests/rustdoc-gui/src/lib2/lib.rs b/tests/rustdoc-gui/src/lib2/lib.rs index b467b044052..fafb8f3b59b 100644 --- a/tests/rustdoc-gui/src/lib2/lib.rs +++ b/tests/rustdoc-gui/src/lib2/lib.rs @@ -355,3 +355,13 @@ pub trait TraitWithLongItemsName { fn this_is_a_method_with_a_long_name_returning_something() -> String; } } + +pub struct Derefer(String); + +impl std::ops::Deref for Derefer { + type Target = str; + + fn deref(&self) -> &Self::Target { + &self.0 + } +}