]> git.lizzy.rs Git - rust.git/commitdiff
Add GUI test for scraped examples colors
authorGuillaume Gomez <guillaume.gomez@huawei.com>
Wed, 28 Dec 2022 16:15:09 +0000 (17:15 +0100)
committerGuillaume Gomez <guillaume.gomez@huawei.com>
Wed, 28 Dec 2022 16:15:09 +0000 (17:15 +0100)
src/test/rustdoc-gui/scrape-examples-color.goml [new file with mode: 0644]

diff --git a/src/test/rustdoc-gui/scrape-examples-color.goml b/src/test/rustdoc-gui/scrape-examples-color.goml
new file mode 100644 (file)
index 0000000..5175891
--- /dev/null
@@ -0,0 +1,34 @@
+// Check that scrape example code blocks have the expected colors.
+goto: "file://" + |DOC_PATH| + "/scrape_examples/fn.test_many.html"
+
+define-function: (
+    "check-colors",
+    (theme, highlight, highlight_focus),
+    [
+        ("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)),
+    ]
+)
+
+call-function: ("check-colors", {
+    "theme": "ayu",
+    "highlight": "rgb(91, 59, 1)",
+    "highlight_focus": "rgb(124, 75, 15)",
+})
+call-function: ("check-colors", {
+    "theme": "dark",
+    "highlight": "rgb(91, 59, 1)",
+    "highlight_focus": "rgb(124, 75, 15)",
+})
+call-function: ("check-colors", {
+    "theme": "light",
+    "highlight": "rgb(252, 255, 214)",
+    "highlight_focus": "rgb(246, 253, 176)",
+})