1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246
|
// The goal of this test is to ensure the color of the text is the one expected.
include: "utils.goml"
define-function: (
"check-search-color",
[
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
],
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'][normalize-space()='Just a normal struct.']",
{"color": |desc_color|},
)
assert-css: (
"//*[@class='result-name']//*[normalize-space()='test_docs::']",
{"color": |path_color|},
)
// Checking the color of the bottom border.
assert-css: (
".search-results > a",
{"border-bottom-color": |bottom_border_color|}
)
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|,
})
// 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']//*[normalize-space()='test_docs::']/ancestor::a",
{"color": |path_color|, "background-color": "transparent"},
ALL,
)
// Checking color and background on hover.
move-cursor-to: "//*[@class='desc'][normalize-space()='Just a normal struct.']"
assert-css: (
"//*[@class='result-name']//*[normalize-space()='test_docs::']",
{"color": |hover_path_color|},
)
assert-css: (
"//*[@class='result-name']//*[normalize-space()='test_docs::']/ancestor::a",
{"color": |hover_path_color|, "background-color": |hover_background|},
)
}
)
define-function: (
"check-result-color",
[result_kind, color, hover_color],
block {
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|},
)
// color of the typename (struct, module, method, ...) before search results
assert-css: (
".result-name .typename",
{"color": |grey|},
ALL,
)
},
)
// Searching for the `for` keyword
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html?search=fo"
// This is needed so that the text color is computed.
show-text: true
// Ayu theme
call-function: ("check-search-color", {
"theme": "ayu",
"count_color": "#888",
"desc_color": "#c5c5c5",
"path_color": "#0096cf",
"bottom_border_color": "#aaa3",
"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",
})
// Dark theme
call-function: ("check-search-color", {
"theme": "dark",
"count_color": "#888",
"desc_color": "#ddd",
"path_color": "#ddd",
"bottom_border_color": "#aaa3",
"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",
})
// Light theme
call-function: ("check-search-color", {
"theme": "light",
"count_color": "#888",
"desc_color": "#000",
"path_color": "#000",
"bottom_border_color": "#aaa3",
"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",
})
// Check the alias.
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
write-into: (".search-input", "thisisanalias")
// To be SURE that the search will be run.
press-key: 'Enter'
// Waiting for the search results to appear...
wait-for: "#search-tabs"
define-function: (
"check-alias",
[theme, alias, grey],
block {
call-function: ("switch-theme", {"theme": |theme|})
// Checking that the colors for the alias element are the ones expected.
assert-css: (".result-name .path .alias", {"color": |alias|})
assert-css: (".result-name .path .alias > .grey", {"color": |grey|})
},
)
call-function: ("check-alias", {
"theme": "ayu",
"alias": "#c5c5c5",
"grey": "#999",
})
call-function: ("check-alias", {
"theme": "dark",
"alias": "#fff",
"grey": "#ccc",
})
call-function: ("check-alias", {
"theme": "light",
"alias": "#000",
"grey": "#999",
})
|