2021-07-12 09:48:25 -05:00
|
|
|
// The goal of this test is to ensure the color of the text is the one expected.
|
2022-10-10 10:59:51 -05:00
|
|
|
|
2024-04-05 14:38:55 -05:00
|
|
|
include: "utils.goml"
|
2024-04-06 07:53:30 -05:00
|
|
|
|
|
|
|
define-function: (
|
|
|
|
"check-search-color",
|
2024-04-06 08:47:12 -05:00
|
|
|
[
|
|
|
|
theme, count_color, desc_color, path_color, bottom_border_color, keyword_color,
|
|
|
|
struct_color, associatedtype_color, tymethod_color, method_color, structfield_color,
|
|
|
|
structfield_hover_color, macro_color, fn_color, hover_path_color, hover_background, grey
|
|
|
|
],
|
2024-04-06 07:53:30 -05:00
|
|
|
block {
|
|
|
|
call-function: ("switch-theme", {"theme": |theme|})
|
|
|
|
|
|
|
|
// Waiting for the search results to appear...
|
|
|
|
wait-for: "#search-tabs"
|
|
|
|
assert-css: (
|
|
|
|
"#search-tabs > button > .count",
|
|
|
|
{"color": |count_color|},
|
|
|
|
ALL,
|
|
|
|
)
|
|
|
|
assert-css: (
|
|
|
|
"//*[@class='desc'][text()='Just a normal struct.']",
|
|
|
|
{"color": |desc_color|},
|
|
|
|
)
|
|
|
|
assert-css: (
|
|
|
|
"//*[@class='result-name']//*[text()='test_docs::']",
|
|
|
|
{"color": |path_color|},
|
|
|
|
)
|
|
|
|
|
|
|
|
// Checking the color of the bottom border.
|
|
|
|
assert-css: (
|
|
|
|
".search-results > a",
|
|
|
|
{"border-bottom-color": |bottom_border_color|}
|
|
|
|
)
|
2024-04-06 08:47:12 -05:00
|
|
|
|
|
|
|
store-value: (entry_color, |path_color|) // color of the search entry
|
|
|
|
store-value: (hover_entry_color, |hover_path_color|) // color of the hovered/focused search entry
|
|
|
|
store-value: (background_color, "transparent")
|
|
|
|
store-value: (hover_background_color, |hover_background|)
|
|
|
|
store-value: (grey, |grey|)
|
|
|
|
|
|
|
|
call-function: ("check-result-color", {
|
|
|
|
"result_kind": "keyword",
|
|
|
|
"color": |keyword_color|,
|
|
|
|
"hover_color": |keyword_color|,
|
|
|
|
})
|
|
|
|
call-function: ("check-result-color", {
|
|
|
|
"result_kind": "struct",
|
|
|
|
"color": |struct_color|,
|
|
|
|
"hover_color": |struct_color|,
|
|
|
|
})
|
|
|
|
call-function: ("check-result-color", {
|
|
|
|
"result_kind": "associatedtype",
|
|
|
|
"color": |associatedtype_color|,
|
|
|
|
"hover_color": |associatedtype_color|,
|
|
|
|
})
|
|
|
|
call-function: ("check-result-color", {
|
|
|
|
"result_kind": "tymethod",
|
|
|
|
"color": |tymethod_color|,
|
|
|
|
"hover_color": |tymethod_color|,
|
|
|
|
})
|
|
|
|
call-function: ("check-result-color", {
|
|
|
|
"result_kind": "method",
|
|
|
|
"color": |method_color|,
|
|
|
|
"hover_color": |method_color|,
|
|
|
|
})
|
|
|
|
call-function: ("check-result-color", {
|
|
|
|
"result_kind": "structfield",
|
|
|
|
"color": |structfield_color|,
|
|
|
|
"hover_color": |structfield_hover_color|,
|
|
|
|
})
|
|
|
|
call-function: ("check-result-color", {
|
|
|
|
"result_kind": "macro",
|
|
|
|
"color": |macro_color|,
|
|
|
|
"hover_color": |macro_color|,
|
|
|
|
})
|
|
|
|
call-function: ("check-result-color", {
|
|
|
|
"result_kind": "fn",
|
|
|
|
"color": |fn_color|,
|
|
|
|
"hover_color": |fn_color|,
|
|
|
|
})
|
|
|
|
|
2024-04-06 08:52:00 -05:00
|
|
|
// 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": |path_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": |hover_path_color|},
|
|
|
|
)
|
|
|
|
assert-css: (
|
|
|
|
"//*[@class='result-name']//*[text()='test_docs::']/ancestor::a",
|
|
|
|
{"color": |hover_path_color|, "background-color": |hover_background|},
|
|
|
|
)
|
2024-04-06 07:53:30 -05:00
|
|
|
}
|
|
|
|
)
|
|
|
|
|
2022-10-10 10:59:51 -05:00
|
|
|
define-function: (
|
|
|
|
"check-result-color",
|
2024-04-01 14:11:22 -05:00
|
|
|
[result_kind, color, hover_color],
|
2023-01-06 08:18:51 -06:00
|
|
|
block {
|
|
|
|
assert-css: (".result-" + |result_kind| + " ." + |result_kind|, {"color": |color|}, ALL)
|
|
|
|
assert-css: (
|
2022-10-10 10:59:51 -05:00
|
|
|
".result-" + |result_kind|,
|
2023-01-06 08:18:51 -06:00
|
|
|
{"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|},
|
|
|
|
)
|
2023-06-20 01:28:56 -05:00
|
|
|
// color of the typename (struct, module, method, ...) before search results
|
|
|
|
assert-css: (
|
|
|
|
".result-name .typename",
|
2023-06-23 08:50:30 -05:00
|
|
|
{"color": |grey|},
|
2023-06-20 01:28:56 -05:00
|
|
|
ALL,
|
|
|
|
)
|
2023-01-06 08:18:51 -06:00
|
|
|
},
|
2022-10-10 10:59:51 -05:00
|
|
|
)
|
|
|
|
|
2023-04-11 12:11:34 -05:00
|
|
|
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html?search=coo"
|
2021-07-12 09:48:25 -05:00
|
|
|
|
|
|
|
// This is needed so that the text color is computed.
|
|
|
|
show-text: true
|
|
|
|
|
|
|
|
// Ayu theme
|
2024-04-06 07:53:30 -05:00
|
|
|
call-function: ("check-search-color", {
|
|
|
|
"theme": "ayu",
|
|
|
|
"count_color": "#888",
|
|
|
|
"desc_color": "#c5c5c5",
|
|
|
|
"path_color": "#0096cf",
|
|
|
|
"bottom_border_color": "#aaa3",
|
2024-04-06 08:47:12 -05:00
|
|
|
"keyword_color": "#39afd7",
|
|
|
|
"struct_color": "#ffa0a5",
|
|
|
|
"associatedtype_color": "#39afd7",
|
|
|
|
"tymethod_color": "#fdd687",
|
|
|
|
"method_color": "#fdd687",
|
|
|
|
"structfield_color": "#0096cf",
|
|
|
|
"structfield_hover_color": "#fff",
|
|
|
|
"macro_color": "#a37acc",
|
|
|
|
"fn_color": "#fdd687",
|
|
|
|
"hover_path_color": "#fff",
|
|
|
|
"hover_background": "#3c3c3c",
|
|
|
|
"grey": "#999",
|
2024-04-06 07:53:30 -05:00
|
|
|
})
|
2022-11-03 14:29:17 -05:00
|
|
|
|
2021-07-12 09:48:25 -05:00
|
|
|
// Dark theme
|
2024-04-06 07:53:30 -05:00
|
|
|
call-function: ("check-search-color", {
|
|
|
|
"theme": "dark",
|
|
|
|
"count_color": "#888",
|
|
|
|
"desc_color": "#ddd",
|
|
|
|
"path_color": "#ddd",
|
|
|
|
"bottom_border_color": "#aaa3",
|
2024-04-06 08:47:12 -05:00
|
|
|
"keyword_color": "#d2991d",
|
|
|
|
"struct_color": "#2dbfb8",
|
|
|
|
"associatedtype_color": "#d2991d",
|
|
|
|
"tymethod_color": "#2bab63",
|
|
|
|
"method_color": "#2bab63",
|
|
|
|
"structfield_color": "#ddd",
|
|
|
|
"structfield_hover_color": "#ddd",
|
|
|
|
"macro_color": "#09bd00",
|
|
|
|
"fn_color": "#2bab63",
|
|
|
|
"hover_path_color": "#ddd",
|
|
|
|
"hover_background": "#616161",
|
|
|
|
"grey": "#ccc",
|
2024-04-06 07:53:30 -05:00
|
|
|
})
|
2022-11-03 14:29:17 -05:00
|
|
|
|
2021-07-12 09:48:25 -05:00
|
|
|
// Light theme
|
2024-04-06 07:53:30 -05:00
|
|
|
call-function: ("check-search-color", {
|
|
|
|
"theme": "light",
|
|
|
|
"count_color": "#888",
|
|
|
|
"desc_color": "#000",
|
|
|
|
"path_color": "#000",
|
|
|
|
"bottom_border_color": "#aaa3",
|
2024-04-06 08:47:12 -05:00
|
|
|
"keyword_color": "#3873ad",
|
|
|
|
"struct_color": "#ad378a",
|
|
|
|
"associatedtype_color": "#3873ad",
|
|
|
|
"tymethod_color": "#ad7c37",
|
|
|
|
"method_color": "#ad7c37",
|
|
|
|
"structfield_color": "#000",
|
|
|
|
"structfield_hover_color": "#000",
|
|
|
|
"macro_color": "#068000",
|
|
|
|
"fn_color": "#ad7c37",
|
|
|
|
"hover_path_color": "#000",
|
|
|
|
"hover_background": "#ccc",
|
|
|
|
"grey": "#999",
|
2024-04-06 07:53:30 -05:00
|
|
|
})
|
2022-11-03 14:29:17 -05:00
|
|
|
|
2022-11-21 04:15:54 -06:00
|
|
|
// Check the alias.
|
2023-04-11 12:11:34 -05:00
|
|
|
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
|
2022-03-15 14:41:24 -05:00
|
|
|
// If the text isn't displayed, the browser doesn't compute color style correctly...
|
|
|
|
show-text: true
|
2022-11-21 04:15:54 -06:00
|
|
|
|
|
|
|
define-function: (
|
|
|
|
"check-alias",
|
2024-04-01 14:11:22 -05:00
|
|
|
[theme, alias, grey],
|
2023-01-06 08:18:51 -06:00
|
|
|
block {
|
2024-04-05 14:38:55 -05:00
|
|
|
call-function: ("switch-theme", {"theme": |theme|})
|
2024-04-01 14:11:22 -05:00
|
|
|
write-into: (".search-input", "thisisanalias")
|
2022-11-21 04:15:54 -06:00
|
|
|
// To be SURE that the search will be run.
|
2023-01-06 08:18:51 -06:00
|
|
|
press-key: 'Enter'
|
2022-11-21 04:15:54 -06:00
|
|
|
// Waiting for the search results to appear...
|
2023-01-06 08:18:51 -06:00
|
|
|
wait-for: "#search-tabs"
|
2022-11-21 04:15:54 -06:00
|
|
|
// Checking that the colors for the alias element are the ones expected.
|
2023-07-18 07:22:37 -05:00
|
|
|
assert-css: (".result-name .path .alias", {"color": |alias|})
|
|
|
|
assert-css: (".result-name .path .alias > .grey", {"color": |grey|})
|
2022-11-21 04:15:54 -06:00
|
|
|
// Leave the search results to prevent reloading with an already filled search input.
|
2023-01-06 08:18:51 -06:00
|
|
|
press-key: "Escape"
|
|
|
|
},
|
2022-11-21 04:15:54 -06:00
|
|
|
)
|
|
|
|
|
|
|
|
call-function: ("check-alias", {
|
|
|
|
"theme": "ayu",
|
2023-05-13 17:16:16 -05:00
|
|
|
"alias": "#c5c5c5",
|
|
|
|
"grey": "#999",
|
2022-11-21 04:15:54 -06:00
|
|
|
})
|
|
|
|
call-function: ("check-alias", {
|
|
|
|
"theme": "dark",
|
2023-05-13 17:16:16 -05:00
|
|
|
"alias": "#fff",
|
|
|
|
"grey": "#ccc",
|
2022-11-21 04:15:54 -06:00
|
|
|
})
|
|
|
|
call-function: ("check-alias", {
|
|
|
|
"theme": "light",
|
2023-05-13 17:16:16 -05:00
|
|
|
"alias": "#000",
|
|
|
|
"grey": "#999",
|
2022-11-21 04:15:54 -06:00
|
|
|
})
|