about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2025-01-24 15:36:52 +0100
committerGuillaume Gomez <guillaume1.gomez@gmail.com>2025-01-24 15:36:52 +0100
commitcaacb048303bfef39a2c89baccccad8e79e5a8d2 (patch)
treebd7a1de87c137722c68b942f59084a82849442a9
parent530f8bb3dbf90ff1dd65e6ef59f717cd6de66b12 (diff)
downloadrust-caacb048303bfef39a2c89baccccad8e79e5a8d2.tar.gz
rust-caacb048303bfef39a2c89baccccad8e79e5a8d2.zip
Add GUI regression test for indent of trait items on mobile
-rw-r--r--tests/rustdoc-gui/search-tab.goml2
-rw-r--r--tests/rustdoc-gui/src/test_docs/lib.rs22
-rw-r--r--tests/rustdoc-gui/toggle-docs-mobile.goml26
3 files changed, 49 insertions, 1 deletions
diff --git a/tests/rustdoc-gui/search-tab.goml b/tests/rustdoc-gui/search-tab.goml
index eea561e0c67..826e272e508 100644
--- a/tests/rustdoc-gui/search-tab.goml
+++ b/tests/rustdoc-gui/search-tab.goml
@@ -78,7 +78,7 @@ call-function: ("check-colors", {
 set-window-size: (851, 600)
 
 // Check the size and count in tabs
-assert-text: ("#search-tabs > button:nth-child(1) > .count", " (26) ")
+assert-text: ("#search-tabs > button:nth-child(1) > .count", " (27) ")
 assert-text: ("#search-tabs > button:nth-child(2) > .count", " (7)  ")
 assert-text: ("#search-tabs > button:nth-child(3) > .count", " (0)  ")
 store-property: ("#search-tabs > button:nth-child(1)", {"offsetWidth": buttonWidth})
diff --git a/tests/rustdoc-gui/src/test_docs/lib.rs b/tests/rustdoc-gui/src/test_docs/lib.rs
index dae13d9ac18..1a9ffbe8898 100644
--- a/tests/rustdoc-gui/src/test_docs/lib.rs
+++ b/tests/rustdoc-gui/src/test_docs/lib.rs
@@ -691,3 +691,25 @@ impl ImplDoc {
 impl ImplDoc {
     pub fn bar5() {}
 }
+
+pub trait ItemsTrait {
+    /// You want doc, here is doc!
+    ///
+    /// blablala
+    type F;
+
+    /// You want doc, here is doc!
+    ///
+    /// blablala
+    const X: u32;
+
+    /// You want doc, here is doc!
+    ///
+    /// blablala
+    fn foo() {}
+
+    /// You want doc, here is doc!
+    ///
+    /// blablala
+    fn bar();
+}
diff --git a/tests/rustdoc-gui/toggle-docs-mobile.goml b/tests/rustdoc-gui/toggle-docs-mobile.goml
index be12e4c19b3..6a40ba83b84 100644
--- a/tests/rustdoc-gui/toggle-docs-mobile.goml
+++ b/tests/rustdoc-gui/toggle-docs-mobile.goml
@@ -31,3 +31,29 @@ assert-attribute: (".top-doc", {"open": ""})
 // To ensure that the toggle isn't over the text, we check that the toggle isn't clicked.
 click: (3, 270)
 assert-attribute: (".top-doc", {"open": ""})
+
+// Same check on trait items.
+fail-on-request-error: false // To prevent downloads errors on "trait.impl/test_docs/trait.ItemsTrait.js"
+go-to: "file://" + |DOC_PATH| + "/test_docs/trait.ItemsTrait.html"
+
+define-function: (
+    "check-trait-item",
+    [nth, text],
+    block {
+        store-value: (selector, ".methods:nth-of-type(" + |nth| + ") > details summary")
+        assert-text: (|selector| + " h4", |text|)
+        assert-position: (
+            |selector| + "::before",
+            {"x": 6},
+        )
+    },
+)
+
+// Assert the position of the toggle on an associated const.
+call-function: ("check-trait-item", {"nth": 2, "text": "const X: u32"})
+// Assert the position of the toggle on an associated type.
+call-function: ("check-trait-item", {"nth": 3, "text": "type F"})
+// Assert the position of the toggle on an associated required method.
+call-function: ("check-trait-item", {"nth": 4, "text": "fn bar()"})
+// Assert the position of the toggle on an associated provided method.
+call-function: ("check-trait-item", {"nth": 5, "text": "fn foo()"})