// The goal of this test is to ensure the color of the text is the one expected. 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, ) }, ) go-to: "file://" + |DOC_PATH| + "/test_docs/index.html?search=coo" // This is needed so that the text color is computed. show-text: true // Ayu theme set-local-storage: { "rustdoc-theme": "ayu", "rustdoc-use-system-theme": "false", } reload: // Waiting for the search results to appear... wait-for: "#search-tabs" assert-css: ( "#search-tabs > button > .count", {"color": "#888"}, ALL, ) assert-css: ( "//*[@class='desc'][text()='Just a normal struct.']", {"color": "#c5c5c5"}, ) assert-css: ( "//*[@class='result-name']//*[text()='test_docs::']", {"color": "#0096cf"}, ) // Checking the color of the bottom border. assert-css: ( ".search-results > a", {"border-bottom-color": "#aaa3"} ) store-value: (entry_color, "#0096cf") // color of the search entry store-value: (hover_entry_color, "#fff") // color of the hovered/focused search entry store-value: (background_color, "transparent") // background color store-value: (hover_background_color, "#3c3c3c") // hover background color store-value: (grey, "#999") call-function: ( "check-result-color", { "result_kind": "keyword", "color": "#39afd7", "hover_color": "#39afd7", }, ) call-function: ( "check-result-color", { "result_kind": "struct", "color": "#ffa0a5", "hover_color": "#ffa0a5", }, ) call-function: ( "check-result-color", { "result_kind": "associatedtype", "color": "#39afd7", "hover_color": "#39afd7", }, ) call-function: ( "check-result-color", { "result_kind": "tymethod", "color": "#fdd687", "hover_color": "#fdd687", }, ) call-function: ( "check-result-color", { "result_kind": "method", "color": "#fdd687", "hover_color": "#fdd687", }, ) call-function: ( "check-result-color", { "result_kind": "structfield", "color": "#0096cf", "hover_color": "#fff", }, ) call-function: ( "check-result-color", { "result_kind": "macro", "color": "#a37acc", "hover_color": "#a37acc", }, ) call-function: ( "check-result-color", { "result_kind": "fn", "color": "#fdd687", "hover_color": "#fdd687", }, ) // Checking the `` container. move-cursor-to: ".search-input" focus: ".search-input" // To ensure the `` container isnt focus or hover. assert-css: ( "//*[@class='result-name']//*[text()='test_docs::']/ancestor::a", {"color": "#0096cf", "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": "#fff"}, ) assert-css: ( "//*[@class='result-name']//*[text()='test_docs::']/ancestor::a", {"color": "#fff", "background-color": "#3c3c3c"}, ) // Dark theme set-local-storage: { "rustdoc-theme": "dark", "rustdoc-use-system-theme": "false", } reload: // Waiting for the search results to appear... wait-for: "#search-tabs" assert-css: ( "#search-tabs > button > .count", {"color": "#888"}, ALL, ) assert-css: ( "//*[@class='desc'][text()='Just a normal struct.']", {"color": "#ddd"}, ) assert-css: ( "//*[@class='result-name']//*[text()='test_docs::']", {"color": "#ddd"}, ) // Checking the color of the bottom border. assert-css: ( ".search-results > a", {"border-bottom-color": "#aaa3"} ) store-value: (entry_color, "#ddd") // color of the search entry store-value: (hover_entry_color, "#ddd") // color of the hovered/focused search entry store-value: (background_color, "transparent") // background color store-value: (hover_background_color, "#616161") // hover background color store-value: (grey, "#ccc") call-function: ( "check-result-color", { "result_kind": "keyword", "color": "#d2991d", "hover_color": "#d2991d", }, ) call-function: ( "check-result-color", { "result_kind": "struct", "color": "#2dbfb8", "hover_color": "#2dbfb8", }, ) call-function: ( "check-result-color", { "result_kind": "associatedtype", "color": "#d2991d", "hover_color": "#d2991d", }, ) call-function: ( "check-result-color", { "result_kind": "tymethod", "color": "#2bab63", "hover_color": "#2bab63", }, ) call-function: ( "check-result-color", { "result_kind": "method", "color": "#2bab63", "hover_color": "#2bab63", }, ) call-function: ( "check-result-color", { "result_kind": "structfield", "color": "#ddd", "hover_color": "#ddd", }, ) call-function: ( "check-result-color", { "result_kind": "macro", "color": "#09bd00", "hover_color": "#09bd00", }, ) call-function: ( "check-result-color", { "result_kind": "fn", "color": "#2bab63", "hover_color": "#2bab63", }, ) // Checking the `` container. move-cursor-to: ".search-input" focus: ".search-input" // To ensure the `` container isnt focus or hover. assert-css: ( "//*[@class='result-name']//*[text()='test_docs::']/ancestor::a", {"color": "#ddd", "background-color": "transparent"}, ) // Light theme set-local-storage: {"rustdoc-theme": "light", "rustdoc-use-system-theme": "false"} reload: // Waiting for the search results to appear... wait-for: "#search-tabs" assert-css: ( "#search-tabs > button > .count", {"color": "#888"}, ALL, ) assert-css: ( "//*[@class='desc'][text()='Just a normal struct.']", {"color": "#000"}, ) assert-css: ( "//*[@class='result-name']//*[text()='test_docs::']", {"color": "#000"}, ) // Checking the color of the bottom border. assert-css: ( ".search-results > a", {"border-bottom-color": "#aaa3"} ) store-value: (entry_color, "#000") // color of the search entry store-value: (hover_entry_color, "#000") // color of the hovered/focused search entry store-value: (background_color, "transparent") // background color store-value: (hover_background_color, "#ccc") // hover background color store-value: (grey, "#999") call-function: ( "check-result-color", { "result_kind": "keyword", "color": "#3873ad", "hover_color": "#3873ad", }, ) call-function: ( "check-result-color", { "result_kind": "struct", "color": "#ad378a", "hover_color": "#ad378a", }, ) call-function: ( "check-result-color", { "result_kind": "associatedtype", "color": "#3873ad", "hover_color": "#3873ad", }, ) call-function: ( "check-result-color", { "result_kind": "tymethod", "color": "#ad7c37", "hover_color": "#ad7c37", }, ) call-function: ( "check-result-color", { "result_kind": "method", "color": "#ad7c37", "hover_color": "#ad7c37", }, ) call-function: ( "check-result-color", { "result_kind": "structfield", "color": "#000", "hover_color": "#000", }, ) call-function: ( "check-result-color", { "result_kind": "macro", "color": "#068000", "hover_color": "#068000", }, ) call-function: ( "check-result-color", { "result_kind": "fn", "color": "#ad7c37", "hover_color": "#ad7c37", }, ) // Checking the `` container. move-cursor-to: ".search-input" focus: ".search-input" // To ensure the `` container isnt focus or hover. assert-css: ( "//*[@class='result-name']//*[text()='test_docs::']/ancestor::a", {"color": "#000", "background-color": "transparent"}, ) // Check the alias. go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" // If the text isn't displayed, the browser doesn't compute color style correctly... show-text: true define-function: ( "check-alias", [theme, alias, grey], block { set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} reload: 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" // 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|}) // Leave the search results to prevent reloading with an already filled search input. press-key: "Escape" }, ) 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", })