about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume.gomez@huawei.com>2024-04-06 15:24:09 +0200
committerGuillaume Gomez <guillaume.gomez@huawei.com>2024-04-06 15:24:09 +0200
commitf14e4db1f92bcdde9ffa1488bbb1024712df06e5 (patch)
treeb0959fab57c8ac6080aa1c4045dc206adb5888c6
parent4967895e558870303a38b5b92b9d7ebc018eba65 (diff)
downloadrust-f14e4db1f92bcdde9ffa1488bbb1024712df06e5.tar.gz
rust-f14e4db1f92bcdde9ffa1488bbb1024712df06e5.zip
Move more common code into a function in `tests/rustdoc-gui/search-result-color.goml`
-rw-r--r--tests/rustdoc-gui/search-result-color.goml74
1 files changed, 44 insertions, 30 deletions
diff --git a/tests/rustdoc-gui/search-result-color.goml b/tests/rustdoc-gui/search-result-color.goml
index c26d5628033..33f45d0d393 100644
--- a/tests/rustdoc-gui/search-result-color.goml
+++ b/tests/rustdoc-gui/search-result-color.goml
@@ -69,6 +69,32 @@ define-function: (
     },
 )
 
+define-function: (
+    "check-container-color",
+    [link_color, path_color, hover_background],
+    block {
+        // Checking the `<a>` container.
+        move-cursor-to: ".search-input"
+        focus: ".search-input" // To ensure the `<a>` container isn't focused or hovered.
+        assert-css: (
+            "//*[@class='result-name']//*[text()='test_docs::']/ancestor::a",
+            {"color": |link_color|, "background-color": "transparent"},
+            ALL,
+        )
+
+        // Checking color and background on hover.
+        move-cursor-to: "//*[@class='desc'][text()='Just a normal struct.']"
+        assert-css: (
+            "//*[@class='result-name']//*[text()='test_docs::']",
+            {"color": |path_color|},
+        )
+        assert-css: (
+            "//*[@class='result-name']//*[text()='test_docs::']/ancestor::a",
+            {"color": |path_color|, "background-color": |hover_background|},
+        )
+    }
+)
+
 go-to: "file://" + |DOC_PATH| + "/test_docs/index.html?search=coo"
 
 // This is needed so that the text color is computed.
@@ -146,24 +172,12 @@ call-function: (
     },
 )
 
-// Checking the `<a>` container.
-move-cursor-to: ".search-input"
-focus: ".search-input" // To ensure the `<a>` container isnt focus or hover.
-assert-css: (
-    "//*[@class='result-name']//*[text()='test_docs::']/ancestor::a",
-    {"color": "#0096cf", "background-color": "transparent"},
-    ALL,
-)
-
-// Checking color and background on hover.
-move-cursor-to: "//*[@class='desc'][text()='Just a normal struct.']"
-assert-css: (
-    "//*[@class='result-name']//*[text()='test_docs::']",
-    {"color": "#fff"},
-)
-assert-css: (
-    "//*[@class='result-name']//*[text()='test_docs::']/ancestor::a",
-    {"color": "#fff", "background-color": "#3c3c3c"},
+call-function: (
+    "check-container-color", {
+        "link_color": "#0096cf",
+        "path_color": "#fff",
+        "hover_background": "#3c3c3c",
+    },
 )
 
 // Dark theme
@@ -238,12 +252,12 @@ call-function: (
     },
 )
 
-// Checking the `<a>` container.
-move-cursor-to: ".search-input"
-focus: ".search-input" // To ensure the `<a>` container isnt focus or hover.
-assert-css: (
-    "//*[@class='result-name']//*[text()='test_docs::']/ancestor::a",
-    {"color": "#ddd", "background-color": "transparent"},
+call-function: (
+    "check-container-color", {
+        "link_color": "#ddd",
+        "path_color": "#ddd",
+        "hover_background": "#616161",
+    },
 )
 
 // Light theme
@@ -318,12 +332,12 @@ call-function: (
     },
 )
 
-// Checking the `<a>` container.
-move-cursor-to: ".search-input"
-focus: ".search-input" // To ensure the `<a>` container isnt focus or hover.
-assert-css: (
-    "//*[@class='result-name']//*[text()='test_docs::']/ancestor::a",
-    {"color": "#000", "background-color": "transparent"},
+call-function: (
+    "check-container-color", {
+        "link_color": "#000",
+        "path_color": "#000",
+        "hover_background": "#ccc",
+    },
 )
 
 // Check the alias.