summaryrefslogtreecommitdiffstats
path: root/src/test/rustdoc-gui/search-result-color.goml
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/rustdoc-gui/search-result-color.goml')
-rw-r--r--src/test/rustdoc-gui/search-result-color.goml410
1 files changed, 243 insertions, 167 deletions
diff --git a/src/test/rustdoc-gui/search-result-color.goml b/src/test/rustdoc-gui/search-result-color.goml
index c4b5fdf53..69bb30df9 100644
--- a/src/test/rustdoc-gui/search-result-color.goml
+++ b/src/test/rustdoc-gui/search-result-color.goml
@@ -1,5 +1,58 @@
// The goal of this test is to ensure the color of the text is the one expected.
-goto: file://|DOC_PATH|/test_docs/index.html?search=coo
+
+define-function: (
+ "check-result-color",
+ (result_kind, color, hover_color),
+ [
+ (
+ "assert-css",
+ (".result-" + |result_kind| + " ." + |result_kind|, {"color": |color|}, ALL),
+ ),
+ (
+ "assert-css",
+ (
+ ".result-" + |result_kind|,
+ {"color": |entry_color|, "background-color": |background_color|},
+ ),
+ ),
+ (
+ "move-cursor-to",
+ ".result-" + |result_kind|,
+ ),
+ (
+ "assert-css",
+ (
+ ".result-" + |result_kind| + ":hover",
+ {"color": |hover_entry_color|, "background-color": |hover_background_color|},
+ ),
+ ),
+ (
+ "assert-css",
+ (".result-" + |result_kind| + ":hover ." + |result_kind|, {"color": |hover_color|}),
+ ),
+ (
+ "move-cursor-to",
+ ".search-input",
+ ),
+ (
+ "focus",
+ ".result-" + |result_kind|,
+ ),
+ (
+ "assert-css",
+ (
+ ".result-" + |result_kind| + ":focus",
+ {"color": |hover_entry_color|, "background-color": |hover_background_color|},
+ ),
+ ),
+ (
+ "assert-css",
+ (".result-" + |result_kind| + ":focus ." + |result_kind|, {"color": |hover_color|}),
+ ),
+ ],
+)
+
+goto: "file://" + |DOC_PATH| + "/test_docs/index.html?search=coo"
// This is needed so that the text color is computed.
show-text: true
@@ -28,56 +81,71 @@ assert-css: (
{"color": "rgb(120, 135, 151)"},
)
-// Checking the color of "keyword".
-assert-css: (
- ".result-name .keyword",
- {"color": "rgb(57, 175, 215)"},
- ALL,
-)
-// Check the color of "struct".
-assert-css: (
- ".result-name .struct",
- {"color": "rgb(255, 160, 165)"},
- ALL,
-)
-// Check the color of "associated type".
-assert-css: (
- ".result-name .associatedtype",
- {"color": "rgb(57, 175, 215)"},
- ALL,
-)
-// Check the color of "type method".
-assert-css: (
- ".result-name .tymethod",
- {"color": "rgb(253, 214, 135)"},
- ALL,
-)
-// Check the color of "method".
-assert-css: (
- ".result-name .method",
- {"color": "rgb(253, 214, 135)"},
- ALL,
-)
-// Check the color of "struct field".
-assert-css: (
- ".result-name .structfield",
- {"color": "rgb(0, 150, 207)"},
- ALL,
-)
-// Check the color of "macro".
-assert-css: (
- ".result-name .macro",
- {"color": "rgb(163, 122, 204)"},
- ALL,
-)
-// Check the color of "fn".
-assert-css: (
- ".result-name .fn",
- {"color": "rgb(253, 214, 135)"},
- ALL,
+store-value: (entry_color, "rgb(0, 150, 207)") // color of the search entry
+store-value: (hover_entry_color, "rgb(255, 255, 255)") // color of the hovered/focused search entry
+store-value: (background_color, "rgba(0, 0, 0, 0)") // background color
+store-value: (hover_background_color, "rgb(60, 60, 60)") // hover background color
+
+call-function: (
+ "check-result-color", (
+ "keyword", // item kind
+ "rgb(57, 175, 215)", // color of item kind
+ "rgb(57, 175, 215)", // color of hovered/focused item kind
+ ),
+)
+call-function: (
+ "check-result-color", (
+ "struct", // item kind
+ "rgb(255, 160, 165)", // color of item kind
+ "rgb(255, 160, 165)", // color of hovered/focused item kind
+ ),
+)
+call-function: (
+ "check-result-color", (
+ "associatedtype", // item kind
+ "rgb(57, 175, 215)", // color of item kind
+ "rgb(57, 175, 215)", // color of hovered/focused item kind
+ ),
+)
+call-function: (
+ "check-result-color", (
+ "tymethod", // item kind
+ "rgb(253, 214, 135)", // color of item kind
+ "rgb(253, 214, 135)", // color of hovered/focused item kind
+ ),
+)
+call-function: (
+ "check-result-color", (
+ "method", // item kind
+ "rgb(253, 214, 135)", // color of item kind
+ "rgb(253, 214, 135)", // color of hovered/focused item kind
+ ),
+)
+call-function: (
+ "check-result-color", (
+ "structfield", // item kind
+ "rgb(0, 150, 207)", // color of item kind
+ "rgb(255, 255, 255)", // color of hovered/focused item kind
+ ),
+)
+call-function: (
+ "check-result-color", (
+ "macro", // item kind
+ "rgb(163, 122, 204)", // color of item kind
+ "rgb(163, 122, 204)", // color of hovered/focused item kind
+ ),
+)
+call-function: (
+ "check-result-color", (
+ "fn", // item kind
+ "rgb(253, 214, 135)", // color of item kind
+ "rgb(253, 214, 135)", // color of hovered/focused item kind
+ ),
)
// 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": "rgb(0, 150, 207)", "background-color": "rgba(0, 0, 0, 0)"},
@@ -113,78 +181,82 @@ assert-css: (
{"color": "rgb(221, 221, 221)"},
)
-// Checking the color for "keyword".
+// Checking the color for "keyword" text.
assert-css: (
"//*[@class='result-name']//*[text()='(keyword)']",
{"color": "rgb(221, 221, 221)"},
)
-// Checking the color of "keyword".
-assert-css: (
- ".result-name .keyword",
- {"color": "rgb(210, 153, 29)"},
- ALL,
-)
-// Check the color of "struct".
-assert-css: (
- ".result-name .struct",
- {"color": "rgb(45, 191, 184)"},
- ALL,
-)
-// Check the color of "associated type".
-assert-css: (
- ".result-name .associatedtype",
- {"color": "rgb(210, 153, 29)"},
- ALL,
-)
-// Check the color of "type method".
-assert-css: (
- ".result-name .tymethod",
- {"color": "rgb(43, 171, 99)"},
- ALL,
-)
-// Check the color of "method".
-assert-css: (
- ".result-name .method",
- {"color": "rgb(43, 171, 99)"},
- ALL,
-)
-// Check the color of "struct field".
-assert-css: (
- ".result-name .structfield",
- {"color": "rgb(221, 221, 221)"},
- ALL,
-)
-// Check the color of "macro".
-assert-css: (
- ".result-name .macro",
- {"color": "rgb(9, 189, 0)"},
- ALL,
-)
-// Check the color of "fn".
-assert-css: (
- ".result-name .fn",
- {"color": "rgb(43, 171, 99)"},
- ALL,
+store-value: (entry_color, "rgb(221, 221, 221)") // color of the search entry
+store-value: (hover_entry_color, "rgb(221, 221, 221)") // color of the hovered/focused search entry
+store-value: (background_color, "rgba(0, 0, 0, 0)") // background color
+store-value: (hover_background_color, "rgb(97, 97, 97)") // hover background color
+
+call-function: (
+ "check-result-color", (
+ "keyword", // item kind
+ "rgb(210, 153, 29)", // color of item kind
+ "rgb(210, 153, 29)", // color of hovered/focused item kind
+ ),
+)
+call-function: (
+ "check-result-color", (
+ "struct", // item kind
+ "rgb(45, 191, 184)", // color of item kind
+ "rgb(45, 191, 184)", // color of hovered/focused item kind
+ ),
+)
+call-function: (
+ "check-result-color", (
+ "associatedtype", // item kind
+ "rgb(210, 153, 29)", // color of item kind
+ "rgb(210, 153, 29)", // color of hovered/focused item kind
+ ),
+)
+call-function: (
+ "check-result-color", (
+ "tymethod", // item kind
+ "rgb(43, 171, 99)", // color of item kind
+ "rgb(43, 171, 99)", // color of hovered/focused item kind
+ ),
+)
+call-function: (
+ "check-result-color", (
+ "method", // item kind
+ "rgb(43, 171, 99)", // color of item kind
+ "rgb(43, 171, 99)", // color of hovered/focused item kind
+ ),
+)
+call-function: (
+ "check-result-color", (
+ "structfield", // item kind
+ "rgb(221, 221, 221)", // color of item kind
+ "rgb(221, 221, 221)", // color of hovered/focused item kind
+ ),
+)
+call-function: (
+ "check-result-color", (
+ "macro", // item kind
+ "rgb(9, 189, 0)", // color of item kind
+ "rgb(9, 189, 0)", // color of hovered/focused item kind
+ ),
+)
+call-function: (
+ "check-result-color", (
+ "fn", // item kind
+ "rgb(43, 171, 99)", // color of item kind
+ "rgb(43, 171, 99)", // color of hovered/focused item kind
+ ),
)
// 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": "rgb(221, 221, 221)", "background-color": "rgba(0, 0, 0, 0)"},
)
-// 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": "rgb(221, 221, 221)"},
-)
-assert-css: (
- "//*[@class='result-name']/*[text()='test_docs::']/ancestor::a",
- {"color": "rgb(221, 221, 221)", "background-color": "rgb(119, 119, 119)"},
-)
-
// Light theme
local-storage: {"rustdoc-theme": "light", "rustdoc-use-system-theme": "false"}
reload:
@@ -200,80 +272,84 @@ assert-css: (
{"color": "rgb(0, 0, 0)"},
)
-// Checking the color for "keyword".
+// Checking the color for "keyword" text.
assert-css: (
"//*[@class='result-name']//*[text()='(keyword)']",
{"color": "rgb(0, 0, 0)"},
)
-// Checking the color of "keyword".
-assert-css: (
- ".result-name .keyword",
- {"color": "rgb(56, 115, 173)"},
- ALL,
-)
-// Check the color of "struct".
-assert-css: (
- ".result-name .struct",
- {"color": "rgb(173, 55, 138)"},
- ALL,
-)
-// Check the color of "associated type".
-assert-css: (
- ".result-name .associatedtype",
- {"color": "rgb(56, 115, 173)"},
- ALL,
-)
-// Check the color of "type method".
-assert-css: (
- ".result-name .tymethod",
- {"color": "rgb(173, 124, 55)"},
- ALL,
-)
-// Check the color of "method".
-assert-css: (
- ".result-name .method",
- {"color": "rgb(173, 124, 55)"},
- ALL,
-)
-// Check the color of "struct field".
-assert-css: (
- ".result-name .structfield",
- {"color": "rgb(0, 0, 0)"},
- ALL,
-)
-// Check the color of "macro".
-assert-css: (
- ".result-name .macro",
- {"color": "rgb(6, 128, 0)"},
- ALL,
-)
-// Check the color of "fn".
-assert-css: (
- ".result-name .fn",
- {"color": "rgb(173, 124, 55)"},
- ALL,
+store-value: (entry_color, "rgb(0, 0, 0)") // color of the search entry
+store-value: (hover_entry_color, "rgb(0, 0, 0)") // color of the hovered/focused search entry
+store-value: (background_color, "rgba(0, 0, 0, 0)") // background color
+store-value: (hover_background_color, "rgb(204, 204, 204)") // hover background color
+
+call-function: (
+ "check-result-color", (
+ "keyword", // item kind
+ "rgb(56, 115, 173)", // color of item kind
+ "rgb(56, 115, 173)", // color of hovered/focused item kind
+ ),
+)
+call-function: (
+ "check-result-color", (
+ "struct", // item kind
+ "rgb(173, 55, 138)", // color of item kind
+ "rgb(173, 55, 138)", // color of hovered/focused item kind
+ ),
+)
+call-function: (
+ "check-result-color", (
+ "associatedtype", // item kind
+ "rgb(56, 115, 173)", // color of item kind
+ "rgb(56, 115, 173)", // color of hovered/focused item kind
+ ),
+)
+call-function: (
+ "check-result-color", (
+ "tymethod", // item kind
+ "rgb(173, 124, 55)", // color of item kind
+ "rgb(173, 124, 55)", // color of hovered/focused item kind
+ ),
+)
+call-function: (
+ "check-result-color", (
+ "method", // item kind
+ "rgb(173, 124, 55)", // color of item kind
+ "rgb(173, 124, 55)", // color of hovered/focused item kind
+ ),
+)
+call-function: (
+ "check-result-color", (
+ "structfield", // item kind
+ "rgb(0, 0, 0)", // color of item kind
+ "rgb(0, 0, 0)", // color of hovered/focused item kind
+ ),
+)
+call-function: (
+ "check-result-color", (
+ "macro", // item kind
+ "rgb(6, 128, 0)", // color of item kind
+ "rgb(6, 128, 0)", // color of hovered/focused item kind
+ ),
+)
+call-function: (
+ "check-result-color", (
+ "fn", // item kind
+ "rgb(173, 124, 55)", // color of item kind
+ "rgb(173, 124, 55)", // color of hovered/focused item kind
+ ),
)
// 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": "rgb(0, 0, 0)", "background-color": "rgba(0, 0, 0, 0)"},
)
-// 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": "rgb(0, 0, 0)"},
-)
-assert-css: (
- "//*[@class='result-name']/*[text()='test_docs::']/ancestor::a",
- {"color": "rgb(0, 0, 0)", "background-color": "rgb(221, 221, 221)"},
-)
-
// Check the alias more specifically in the dark theme.
-goto: file://|DOC_PATH|/test_docs/index.html
+goto: "file://" + |DOC_PATH| + "/test_docs/index.html"
// We set the theme so we're sure that the correct values will be used, whatever the computer
// this test is running on.
local-storage: {