about summary refs log tree commit diff
path: root/tests/rustdoc-gui/code-example-buttons.goml
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume.gomez@huawei.com>2024-07-30 15:24:05 +0200
committerGuillaume Gomez <guillaume.gomez@huawei.com>2024-08-05 11:04:51 +0200
commitbe71bd9cec149ba2a7ed2f4ae4c499840c1faddc (patch)
treebf7bae5d1a436723496defced476b02390b5e8bf /tests/rustdoc-gui/code-example-buttons.goml
parenta282e520b253403b9b4dd6107f29cfc4bcd1b956 (diff)
downloadrust-be71bd9cec149ba2a7ed2f4ae4c499840c1faddc.tar.gz
rust-be71bd9cec149ba2a7ed2f4ae4c499840c1faddc.zip
Update GUI tests for code example buttons
Diffstat (limited to 'tests/rustdoc-gui/code-example-buttons.goml')
-rw-r--r--tests/rustdoc-gui/code-example-buttons.goml69
1 files changed, 69 insertions, 0 deletions
diff --git a/tests/rustdoc-gui/code-example-buttons.goml b/tests/rustdoc-gui/code-example-buttons.goml
index 57ea2970072..a8505812b88 100644
--- a/tests/rustdoc-gui/code-example-buttons.goml
+++ b/tests/rustdoc-gui/code-example-buttons.goml
@@ -1,5 +1,6 @@
 // This test ensures that code blocks buttons are displayed on hover and when you click on them.
 go-to: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html"
+include: "utils.goml"
 
 // First we check we "hover".
 move-cursor-to: ".example-wrap"
@@ -19,3 +20,71 @@ click: ".example-wrap"
 move-cursor-to: ".search-input"
 assert-count: (".example-wrap:not(:hover) .button-holder.keep-visible", 0)
 assert-css: (".example-wrap .copy-button", { "visibility": "hidden" })
+
+define-function: (
+    "check-buttons",
+    [theme, background, filter, filter_hover],
+    block {
+        call-function: ("switch-theme", {"theme": |theme|})
+
+        assert-css: (".example-wrap .test-arrow", {"visibility": "hidden"})
+        assert-css: (".example-wrap .copy-button", {"visibility": "hidden"})
+
+        move-cursor-to: ".example-wrap"
+        assert-css: (".example-wrap .test-arrow", {
+            "visibility": "visible",
+            "background-color": |background|,
+            "border-radius": "2px",
+        })
+        assert-css: (".example-wrap .test-arrow::before", {
+            "filter": |filter|,
+        })
+        assert-css: (".example-wrap .copy-button", {
+            "visibility": "visible",
+            "background-color": |background|,
+            "border-radius": "2px",
+        })
+        assert-css: (".example-wrap .copy-button::before", {
+            "filter": |filter|,
+        })
+
+        move-cursor-to: ".example-wrap .test-arrow"
+        assert-css: (".example-wrap .test-arrow:hover", {
+            "visibility": "visible",
+            "background-color": |background|,
+            "border-radius": "2px",
+        })
+        assert-css: (".example-wrap .test-arrow:hover::before", {
+            "filter": |filter_hover|,
+        })
+
+        move-cursor-to: ".example-wrap .copy-button"
+        assert-css: (".example-wrap .copy-button:hover", {
+            "visibility": "visible",
+            "background-color": |background|,
+            "border-radius": "2px",
+        })
+        assert-css: (".example-wrap .copy-button:hover::before", {
+            "filter": |filter_hover|,
+        })
+    },
+)
+
+call-function: ("check-buttons",{
+    "theme": "ayu",
+    "background": "#0f1419",
+    "filter": "invert(0.7)",
+    "filter_hover": "invert(1)",
+})
+call-function: ("check-buttons",{
+    "theme": "dark",
+    "background": "#353535",
+    "filter": "invert(0.5)",
+    "filter_hover": "invert(0.65)",
+})
+call-function: ("check-buttons",{
+    "theme": "light",
+    "background": "#fff",
+    "filter": "invert(0.5)",
+    "filter_hover": "invert(0.35)",
+})