fork/rust
git clone https://git.julia.blue/fork/rust
3bcad65fbf6
master
1// The goal of this test is to ensure the color of the text is the one expected. 2 3define-function: ( 4 "check-result-color", 5 (result_kind, color, hover_color), 6 block { 7 assert-css: (".result-" + |result_kind| + " ." + |result_kind|, {"color": |color|}, ALL) 8 assert-css: ( 9 ".result-" + |result_kind|, 10 {"color": |entry_color|, "background-color": |background_color|}, 11 ) 12 move-cursor-to: ".result-" + |result_kind| 13 assert-css: ( 14 ".result-" + |result_kind| + ":hover", 15 {"color": |hover_entry_color|, "background-color": |hover_background_color|}, 16 ) 17 assert-css: ( 18 ".result-" + |result_kind| + ":hover ." + |result_kind|, 19 {"color": |hover_color|}, 20 ) 21 move-cursor-to: ".search-input" 22 focus: ".result-" + |result_kind| 23 assert-css: ( 24 ".result-" + |result_kind| + ":focus", 25 {"color": |hover_entry_color|, "background-color": |hover_background_color|}, 26 ) 27 assert-css: ( 28 ".result-" + |result_kind| + ":focus ." + |result_kind|, 29 {"color": |hover_color|}, 30 ) 31 // color of the typename (struct, module, method, ...) before search results 32 assert-css: ( 33 ".result-name .typename", 34 {"color": |grey|}, 35 ALL, 36 ) 37 }, 38) 39 40go-to: "file://" + |DOC_PATH| + "/test_docs/index.html?search=coo" 41 42// This is needed so that the text color is computed. 43show-text: true 44 45// Ayu theme 46set-local-storage: { 47 "rustdoc-theme": "ayu", 48 "rustdoc-use-system-theme": "false", 49} 50reload: 51 52// Waiting for the search results to appear... 53wait-for: "#search-tabs" 54assert-css: ( 55 "#search-tabs > button > .count", 56 {"color": "#888"}, 57 ALL, 58) 59assert-css: ( 60 "//*[@class='desc'][text()='Just a normal struct.']", 61 {"color": "#c5c5c5"}, 62) 63assert-css: ( 64 "//*[@class='result-name']//*[text()='test_docs::']", 65 {"color": "#0096cf"}, 66) 67 68// Checking the color of the bottom border. 69assert-css: ( 70 ".search-results > a", 71 {"border-bottom-color": "#aaa3"} 72) 73 74store-value: (entry_color, "#0096cf") // color of the search entry 75store-value: (hover_entry_color, "#fff") // color of the hovered/focused search entry 76store-value: (background_color, "transparent") // background color 77store-value: (hover_background_color, "#3c3c3c") // hover background color 78store-value: (grey, "#999") 79 80call-function: ( 81 "check-result-color", ( 82 "keyword", // item kind 83 "#39afd7", // color of item kind 84 "#39afd7", // color of hovered/focused item kind 85 ), 86) 87call-function: ( 88 "check-result-color", ( 89 "struct", // item kind 90 "#ffa0a5", // color of item kind 91 "#ffa0a5", // color of hovered/focused item kind 92 ), 93) 94call-function: ( 95 "check-result-color", ( 96 "associatedtype", // item kind 97 "#39afd7", // color of item kind 98 "#39afd7", // color of hovered/focused item kind 99 ), 100) 101call-function: ( 102 "check-result-color", ( 103 "tymethod", // item kind 104 "#fdd687", // color of item kind 105 "#fdd687", // color of hovered/focused item kind 106 ), 107) 108call-function: ( 109 "check-result-color", ( 110 "method", // item kind 111 "#fdd687", // color of item kind 112 "#fdd687", // color of hovered/focused item kind 113 ), 114) 115call-function: ( 116 "check-result-color", ( 117 "structfield", // item kind 118 "#0096cf", // color of item kind 119 "#fff", // color of hovered/focused item kind 120 ), 121) 122call-function: ( 123 "check-result-color", ( 124 "macro", // item kind 125 "#a37acc", // color of item kind 126 "#a37acc", // color of hovered/focused item kind 127 ), 128) 129call-function: ( 130 "check-result-color", ( 131 "fn", // item kind 132 "#fdd687", // color of item kind 133 "#fdd687", // color of hovered/focused item kind 134 ), 135) 136 137// Checking the `<a>` container. 138move-cursor-to: ".search-input" 139focus: ".search-input" // To ensure the `<a>` container isnt focus or hover. 140assert-css: ( 141 "//*[@class='result-name']//*[text()='test_docs::']/ancestor::a", 142 {"color": "#0096cf", "background-color": "transparent"}, 143 ALL, 144) 145 146// Checking color and background on hover. 147move-cursor-to: "//*[@class='desc'][text()='Just a normal struct.']" 148assert-css: ( 149 "//*[@class='result-name']//*[text()='test_docs::']", 150 {"color": "#fff"}, 151) 152assert-css: ( 153 "//*[@class='result-name']//*[text()='test_docs::']/ancestor::a", 154 {"color": "#fff", "background-color": "#3c3c3c"}, 155) 156 157// Dark theme 158set-local-storage: { 159 "rustdoc-theme": "dark", 160 "rustdoc-use-system-theme": "false", 161} 162reload: 163 164// Waiting for the search results to appear... 165wait-for: "#search-tabs" 166assert-css: ( 167 "#search-tabs > button > .count", 168 {"color": "#888"}, 169 ALL, 170) 171assert-css: ( 172 "//*[@class='desc'][text()='Just a normal struct.']", 173 {"color": "#ddd"}, 174) 175assert-css: ( 176 "//*[@class='result-name']//*[text()='test_docs::']", 177 {"color": "#ddd"}, 178) 179 180// Checking the color of the bottom border. 181assert-css: ( 182 ".search-results > a", 183 {"border-bottom-color": "#aaa3"} 184) 185 186store-value: (entry_color, "#ddd") // color of the search entry 187store-value: (hover_entry_color, "#ddd") // color of the hovered/focused search entry 188store-value: (background_color, "transparent") // background color 189store-value: (hover_background_color, "#616161") // hover background color 190store-value: (grey, "#ccc") 191 192call-function: ( 193 "check-result-color", ( 194 "keyword", // item kind 195 "#d2991d", // color of item kind 196 "#d2991d", // color of hovered/focused item kind 197 ), 198) 199call-function: ( 200 "check-result-color", ( 201 "struct", // item kind 202 "#2dbfb8", // color of item kind 203 "#2dbfb8", // color of hovered/focused item kind 204 ), 205) 206call-function: ( 207 "check-result-color", ( 208 "associatedtype", // item kind 209 "#d2991d", // color of item kind 210 "#d2991d", // color of hovered/focused item kind 211 ), 212) 213call-function: ( 214 "check-result-color", ( 215 "tymethod", // item kind 216 "#2bab63", // color of item kind 217 "#2bab63", // color of hovered/focused item kind 218 ), 219) 220call-function: ( 221 "check-result-color", ( 222 "method", // item kind 223 "#2bab63", // color of item kind 224 "#2bab63", // color of hovered/focused item kind 225 ), 226) 227call-function: ( 228 "check-result-color", ( 229 "structfield", // item kind 230 "#ddd", // color of item kind 231 "#ddd", // color of hovered/focused item kind 232 ), 233) 234call-function: ( 235 "check-result-color", ( 236 "macro", // item kind 237 "#09bd00", // color of item kind 238 "#09bd00", // color of hovered/focused item kind 239 ), 240) 241call-function: ( 242 "check-result-color", ( 243 "fn", // item kind 244 "#2bab63", // color of item kind 245 "#2bab63", // color of hovered/focused item kind 246 ), 247) 248 249// Checking the `<a>` container. 250move-cursor-to: ".search-input" 251focus: ".search-input" // To ensure the `<a>` container isnt focus or hover. 252assert-css: ( 253 "//*[@class='result-name']//*[text()='test_docs::']/ancestor::a", 254 {"color": "#ddd", "background-color": "transparent"}, 255) 256 257// Light theme 258set-local-storage: {"rustdoc-theme": "light", "rustdoc-use-system-theme": "false"} 259reload: 260 261// Waiting for the search results to appear... 262wait-for: "#search-tabs" 263assert-css: ( 264 "#search-tabs > button > .count", 265 {"color": "#888"}, 266 ALL, 267) 268assert-css: ( 269 "//*[@class='desc'][text()='Just a normal struct.']", 270 {"color": "#000"}, 271) 272assert-css: ( 273 "//*[@class='result-name']//*[text()='test_docs::']", 274 {"color": "#000"}, 275) 276 277// Checking the color of the bottom border. 278assert-css: ( 279 ".search-results > a", 280 {"border-bottom-color": "#aaa3"} 281) 282 283store-value: (entry_color, "#000") // color of the search entry 284store-value: (hover_entry_color, "#000") // color of the hovered/focused search entry 285store-value: (background_color, "transparent") // background color 286store-value: (hover_background_color, "#ccc") // hover background color 287store-value: (grey, "#999") 288 289call-function: ( 290 "check-result-color", ( 291 "keyword", // item kind 292 "#3873ad", // color of item kind 293 "#3873ad", // color of hovered/focused item kind 294 ), 295) 296call-function: ( 297 "check-result-color", ( 298 "struct", // item kind 299 "#ad378a", // color of item kind 300 "#ad378a", // color of hovered/focused item kind 301 ), 302) 303call-function: ( 304 "check-result-color", ( 305 "associatedtype", // item kind 306 "#3873ad", // color of item kind 307 "#3873ad", // color of hovered/focused item kind 308 ), 309) 310call-function: ( 311 "check-result-color", ( 312 "tymethod", // item kind 313 "#ad7c37", // color of item kind 314 "#ad7c37", // color of hovered/focused item kind 315 ), 316) 317call-function: ( 318 "check-result-color", ( 319 "method", // item kind 320 "#ad7c37", // color of item kind 321 "#ad7c37", // color of hovered/focused item kind 322 ), 323) 324call-function: ( 325 "check-result-color", ( 326 "structfield", // item kind 327 "#000", // color of item kind 328 "#000", // color of hovered/focused item kind 329 ), 330) 331call-function: ( 332 "check-result-color", ( 333 "macro", // item kind 334 "#068000", // color of item kind 335 "#068000", // color of hovered/focused item kind 336 ), 337) 338call-function: ( 339 "check-result-color", ( 340 "fn", // item kind 341 "#ad7c37", // color of item kind 342 "#ad7c37", // color of hovered/focused item kind 343 ), 344) 345 346// Checking the `<a>` container. 347move-cursor-to: ".search-input" 348focus: ".search-input" // To ensure the `<a>` container isnt focus or hover. 349assert-css: ( 350 "//*[@class='result-name']//*[text()='test_docs::']/ancestor::a", 351 {"color": "#000", "background-color": "transparent"}, 352) 353 354// Check the alias. 355go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" 356// If the text isn't displayed, the browser doesn't compute color style correctly... 357show-text: true 358 359define-function: ( 360 "check-alias", 361 (theme, alias, grey), 362 block { 363 set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} 364 reload: 365 write: (".search-input", "thisisanalias") 366 // To be SURE that the search will be run. 367 press-key: 'Enter' 368 // Waiting for the search results to appear... 369 wait-for: "#search-tabs" 370 // Checking that the colors for the alias element are the ones expected. 371 assert-css: (".result-name .path .alias", {"color": |alias|}) 372 assert-css: (".result-name .path .alias > .grey", {"color": |grey|}) 373 // Leave the search results to prevent reloading with an already filled search input. 374 press-key: "Escape" 375 }, 376) 377 378call-function: ("check-alias", { 379 "theme": "ayu", 380 "alias": "#c5c5c5", 381 "grey": "#999", 382}) 383call-function: ("check-alias", { 384 "theme": "dark", 385 "alias": "#fff", 386 "grey": "#ccc", 387}) 388call-function: ("check-alias", { 389 "theme": "light", 390 "alias": "#000", 391 "grey": "#999", 392})