From ba33bb45694854a6ac5e3224f1eb41597e7f91c0 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sat, 19 Aug 2023 17:19:46 +0200 Subject: [PATCH 1/3] Use function to remove code duplication for `search-form-elements.goml` test --- tests/rustdoc-gui/search-form-elements.goml | 393 +++++++------------- 1 file changed, 143 insertions(+), 250 deletions(-) diff --git a/tests/rustdoc-gui/search-form-elements.goml b/tests/rustdoc-gui/search-form-elements.goml index 83c6980909c..d84c16449ab 100644 --- a/tests/rustdoc-gui/search-form-elements.goml +++ b/tests/rustdoc-gui/search-form-elements.goml @@ -2,262 +2,155 @@ go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" show-text: true -// Ayu theme -set-local-storage: { - "rustdoc-theme": "ayu", - "rustdoc-use-system-theme": "false", -} -reload: - -assert-css: ( - ".search-input", - { - "border-color": "rgb(92, 103, 115)", - "background-color": "rgb(20, 25, 32)", - "color": "rgb(255, 255, 255)", - }, -) -focus: ".search-input" -// Nothing should change. -assert-css: ( - ".search-input", - { - "border-color": "rgb(92, 103, 115)", - "background-color": "rgb(20, 25, 32)", - "color": "rgb(255, 255, 255)", +define-function: ( + "check-search-colors", + ( + theme, search_input_border, search_input_background, search_input_color, + search_input_border_focus, menu_button_border, menu_button_a_color, menu_button_a_border, + menu_button_a_background, menu_button_border_hover, menu_button_a_hover, + menu_button_a_border_hover, menu_button_a_background_hover, menu_a_color, + ), + block { + set-local-storage: { + "rustdoc-theme": |theme|, + "rustdoc-use-system-theme": "false", + } + reload: + assert-css: ( + ".search-input", + { + "border-color": |search_input_border|, + "background-color": |search_input_background|, + "color": |search_input_color|, + }, + ) + // Focus on search input. + focus: ".search-input" + assert-css: ( + ".search-input", + { + "border-color": |search_input_border_focus|, + "background-color": |search_input_background|, + "color": |search_input_color|, + }, + ) + assert-css: ( + "#help-button", + {"border-color": |menu_button_border|}, + ) + assert-css: ( + "#help-button > a", + { + "color": |menu_button_a_color|, + "border-color": |menu_button_a_border|, + "background-color": |menu_button_a_background|, + }, + ) + // Hover help button. + move-cursor-to: "#help-button" + assert-css: ( + "#help-button:hover", + {"border-color": |menu_button_border_hover|}, + ) + assert-css: ( + "#help-button > a", + { + "color": |menu_button_a_hover|, + "border-color": |menu_button_a_border_hover|, + "background-color": |menu_button_a_background_hover|, + }, + ) + // Link color inside + click: "#help-button" + assert-css: ( + "#help a", + { + "color": |menu_a_color|, + }, + ) + assert-css: ( + "#settings-menu", + {"border-color": |menu_button_border|}, + ) + assert-css: ( + "#settings-menu > a", + { + "color": |menu_button_a_color|, + "border-color": |menu_button_a_border|, + "background-color": |menu_button_a_background|, + }, + ) + // Hover settings menu. + move-cursor-to: "#settings-menu" + assert-css: ( + "#settings-menu:hover", + {"border-color": |menu_button_border|}, + ) + assert-css: ( + "#settings-menu:hover > a", + { + "color": |menu_button_a_hover|, + "border-color": |menu_button_a_border_hover|, + "background-color": |menu_button_a_background_hover|, + }, + ) }, ) -assert-css: ( - "#help-button", - {"border-color": "rgb(197, 197, 197)"}, -) -assert-css: ( - "#help-button > a", +call-function: ( + "check-search-colors", { - "color": "rgb(255, 255, 255)", - "border-color": "rgb(92, 103, 115)", - "background-color": "rgb(20, 25, 32)", - }, + "theme": "ayu", + "search_input_border": "rgb(92, 103, 115)", + "search_input_background": "rgb(20, 25, 32)", + "search_input_color": "rgb(255, 255, 255)", + "search_input_border_focus": "rgb(92, 103, 115)", + "menu_button_border": "rgb(197, 197, 197)", + "menu_button_a_color": "rgb(255, 255, 255)", + "menu_button_a_border": "rgb(92, 103, 115)", + "menu_button_a_background": "rgb(20, 25, 32)", + "menu_button_border_hover": "rgb(197, 197, 197)", + "menu_button_a_hover": "rgb(255, 255, 255)", + "menu_button_a_border_hover": "rgb(224, 224, 224)", + "menu_button_a_background_hover": "rgb(20, 25, 32)", + "menu_a_color": "rgb(57, 175, 215)", + } ) -move-cursor-to: "#help-button" -assert-css: ( - "#help-button:hover", - {"border-color": "rgb(197, 197, 197)"}, -) -// Only "border-color" should change. -assert-css: ( - "#help-button:hover > a", +call-function: ( + "check-search-colors", { - "color": "rgb(255, 255, 255)", - "border-color": "rgb(224, 224, 224)", - "background-color": "rgb(20, 25, 32)", - }, + "theme": "dark", + "search_input_border": "rgb(224, 224, 224)", + "search_input_background": "rgb(240, 240, 240)", + "search_input_color": "rgb(17, 17, 17)", + "search_input_border_focus": "rgb(0, 141, 253)", + "menu_button_border": "rgb(221, 221, 221)", + "menu_button_a_color": "rgb(0, 0, 0)", + "menu_button_a_border": "rgb(224, 224, 224)", + "menu_button_a_background": "rgb(240, 240, 240)", + "menu_button_border_hover": "rgb(221, 221, 221)", + "menu_button_a_hover": "rgb(0, 0, 0)", + "menu_button_a_border_hover": "rgb(255, 185, 0)", + "menu_button_a_background_hover": "rgb(240, 240, 240)", + "menu_a_color": "rgb(210, 153, 29)", + } ) -// Link color inside -click: "#help-button" -assert-css: ( - "#help a", +call-function: ( + "check-search-colors", { - "color": "rgb(57, 175, 215)", - }, -) - -assert-css: ( - "#settings-menu", - {"border-color": "rgb(197, 197, 197)"}, -) -assert-css: ( - "#settings-menu > a", - { - "border-color": "rgb(92, 103, 115)", - "background-color": "rgb(20, 25, 32)", - }, -) -move-cursor-to: "#settings-menu" -assert-css: ( - "#settings-menu:hover", - {"border-color": "rgb(197, 197, 197)"}, -) -// Only "border-color" should change. -assert-css: ( - "#settings-menu:hover > a", - { - "border-color": "rgb(224, 224, 224)", - "background-color": "rgb(20, 25, 32)", - }, -) - -// Dark theme -set-local-storage: { - "rustdoc-theme": "dark", - "rustdoc-use-system-theme": "false", -} -reload: - -assert-css: ( - ".search-input", - { - "border-color": "rgb(224, 224, 224)", - "background-color": "rgb(240, 240, 240)", - "color": "rgb(17, 17, 17)", - }, -) -focus: ".search-input" -// Only "border-color" should change. -assert-css: ( - ".search-input", - { - "border-color": "rgb(0, 141, 253)", - "background-color": "rgb(240, 240, 240)", - "color": "rgb(17, 17, 17)", - }, -) - -assert-css: ( - "#help-button", - {"border-color": "rgb(221, 221, 221)"}, -) -assert-css: ( - "#help-button > a", - { - "color": "rgb(0, 0, 0)", - "border-color": "rgb(224, 224, 224)", - "background-color": "rgb(240, 240, 240)", - }, -) -move-cursor-to: "#help-button" -assert-css: ( - "#help-button:hover", - {"border-color": "rgb(221, 221, 221)"}, -) -// Only "border-color" should change. -assert-css: ( - "#help-button:hover > a", - { - "color": "rgb(0, 0, 0)", - "border-color": "rgb(255, 185, 0)", - "background-color": "rgb(240, 240, 240)", - }, -) -// Link color inside -click: "#help-button" -assert-css: ( - "#help a", - { - "color": "rgb(210, 153, 29)", - }, -) - -assert-css: ( - "#settings-menu", - {"border-color": "rgb(221, 221, 221)"}, -) -assert-css: ( - "#settings-menu > a", - { - "border-color": "rgb(224, 224, 224)", - "background-color": "rgb(240, 240, 240)", - }, -) -move-cursor-to: "#settings-menu" -assert-css: ( - "#settings-menu:hover", - {"border-color": "rgb(221, 221, 221)"}, -) -// Only "border-color" should change. -assert-css: ( - "#settings-menu:hover > a", - { - "color": "rgb(0, 0, 0)", - "border-color": "rgb(255, 185, 0)", - "background-color": "rgb(240, 240, 240)", - }, -) - -// Light theme -set-local-storage: { - "rustdoc-theme": "light", - "rustdoc-use-system-theme": "false", -} -reload: - -assert-css: ( - ".search-input", - { - "border-color": "rgb(224, 224, 224)", - "background-color": "rgb(255, 255, 255)", - "color": "rgb(0, 0, 0)", - }, -) -focus: ".search-input" -// Nothing should change. -assert-css: ( - ".search-input", - { - "border-color": "rgb(102, 175, 233)", - "background-color": "rgb(255, 255, 255)", - "color": "rgb(0, 0, 0)", - }, -) - -assert-css: ( - "#help-button", - {"border-color": "rgb(0, 0, 0)"}, -) -assert-css: ( - "#help-button > a", - { - "color": "rgb(0, 0, 0)", - "border-color": "rgb(224, 224, 224)", - "background-color": "rgb(255, 255, 255)", - }, -) -move-cursor-to: "#help-button" -assert-css: ( - "#help-button:hover", - {"border-color": "rgb(0, 0, 0)"}, -) -// Only "border-color" should change. -assert-css: ( - "#help-button:hover > a", - { - "color": "rgb(0, 0, 0)", - "border-color": "rgb(113, 113, 113)", - "background-color": "rgb(255, 255, 255)", - }, -) -// Link color inside -click: "#help-button" -assert-css: ( - "#help a", - { - "color": "rgb(56, 115, 173)", - }, -) - -assert-css: ( - "#settings-menu", - {"border-color": "rgb(0, 0, 0)"}, -) -assert-css: ( - "#settings-menu > a", - { - "border-color": "rgb(224, 224, 224)", - "background-color": "rgb(255, 255, 255)", - }, -) -move-cursor-to: "#settings-menu" -assert-css: ( - "#settings-menu:hover", - {"border-color": "rgb(0, 0, 0)"}, -) -// Only "border-color" should change. -assert-css: ( - "#settings-menu:hover > a", - { - "color": "rgb(0, 0, 0)", - "border-color": "rgb(113, 113, 113)", - "background-color": "rgb(255, 255, 255)", - }, + "theme": "light", + "search_input_border": "rgb(224, 224, 224)", + "search_input_background": "rgb(255, 255, 255)", + "search_input_color": "rgb(0, 0, 0)", + "search_input_border_focus": "rgb(102, 175, 233)", + "menu_button_border": "rgb(0, 0, 0)", + "menu_button_a_color": "rgb(0, 0, 0)", + "menu_button_a_border": "rgb(224, 224, 224)", + "menu_button_a_background": "rgb(255, 255, 255)", + "menu_button_border_hover": "rgb(0, 0, 0)", + "menu_button_a_hover": "rgb(0, 0, 0)", + "menu_button_a_border_hover": "rgb(113, 113, 113)", + "menu_button_a_background_hover": "rgb(255, 255, 255)", + "menu_a_color": "rgb(56, 115, 173)", + } ) From 87a0efbf02c79c37d71b815b4baa7f433a23b67b Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sat, 19 Aug 2023 17:51:23 +0200 Subject: [PATCH 2/3] Merge values with same colors --- tests/rustdoc-gui/search-form-elements.goml | 57 ++++++++------------- 1 file changed, 20 insertions(+), 37 deletions(-) diff --git a/tests/rustdoc-gui/search-form-elements.goml b/tests/rustdoc-gui/search-form-elements.goml index d84c16449ab..fb75114fe45 100644 --- a/tests/rustdoc-gui/search-form-elements.goml +++ b/tests/rustdoc-gui/search-form-elements.goml @@ -5,10 +5,8 @@ show-text: true define-function: ( "check-search-colors", ( - theme, search_input_border, search_input_background, search_input_color, - search_input_border_focus, menu_button_border, menu_button_a_color, menu_button_a_border, - menu_button_a_background, menu_button_border_hover, menu_button_a_hover, - menu_button_a_border_hover, menu_button_a_background_hover, menu_a_color, + theme, border, background, search_input_color, search_input_border_focus, + menu_button_border, menu_button_a_color, menu_button_a_border_hover, menu_a_color, ), block { set-local-storage: { @@ -19,8 +17,8 @@ define-function: ( assert-css: ( ".search-input", { - "border-color": |search_input_border|, - "background-color": |search_input_background|, + "border-color": |border|, + "background-color": |background|, "color": |search_input_color|, }, ) @@ -30,7 +28,7 @@ define-function: ( ".search-input", { "border-color": |search_input_border_focus|, - "background-color": |search_input_background|, + "background-color": |background|, "color": |search_input_color|, }, ) @@ -42,22 +40,22 @@ define-function: ( "#help-button > a", { "color": |menu_button_a_color|, - "border-color": |menu_button_a_border|, - "background-color": |menu_button_a_background|, + "border-color": |border|, + "background-color": |background|, }, ) // Hover help button. move-cursor-to: "#help-button" assert-css: ( "#help-button:hover", - {"border-color": |menu_button_border_hover|}, + {"border-color": |menu_button_border|}, ) assert-css: ( "#help-button > a", { - "color": |menu_button_a_hover|, + "color": |menu_button_a_color|, "border-color": |menu_button_a_border_hover|, - "background-color": |menu_button_a_background_hover|, + "background-color": |background|, }, ) // Link color inside @@ -76,8 +74,8 @@ define-function: ( "#settings-menu > a", { "color": |menu_button_a_color|, - "border-color": |menu_button_a_border|, - "background-color": |menu_button_a_background|, + "border-color": |border|, + "background-color": |background|, }, ) // Hover settings menu. @@ -89,9 +87,9 @@ define-function: ( assert-css: ( "#settings-menu:hover > a", { - "color": |menu_button_a_hover|, + "color": |menu_button_a_color|, "border-color": |menu_button_a_border_hover|, - "background-color": |menu_button_a_background_hover|, + "background-color": |background|, }, ) }, @@ -101,18 +99,13 @@ call-function: ( "check-search-colors", { "theme": "ayu", - "search_input_border": "rgb(92, 103, 115)", - "search_input_background": "rgb(20, 25, 32)", + "border": "rgb(92, 103, 115)", + "background": "rgb(20, 25, 32)", "search_input_color": "rgb(255, 255, 255)", "search_input_border_focus": "rgb(92, 103, 115)", "menu_button_border": "rgb(197, 197, 197)", "menu_button_a_color": "rgb(255, 255, 255)", - "menu_button_a_border": "rgb(92, 103, 115)", - "menu_button_a_background": "rgb(20, 25, 32)", - "menu_button_border_hover": "rgb(197, 197, 197)", - "menu_button_a_hover": "rgb(255, 255, 255)", "menu_button_a_border_hover": "rgb(224, 224, 224)", - "menu_button_a_background_hover": "rgb(20, 25, 32)", "menu_a_color": "rgb(57, 175, 215)", } ) @@ -120,18 +113,13 @@ call-function: ( "check-search-colors", { "theme": "dark", - "search_input_border": "rgb(224, 224, 224)", - "search_input_background": "rgb(240, 240, 240)", + "border": "rgb(224, 224, 224)", + "background": "rgb(240, 240, 240)", "search_input_color": "rgb(17, 17, 17)", "search_input_border_focus": "rgb(0, 141, 253)", "menu_button_border": "rgb(221, 221, 221)", "menu_button_a_color": "rgb(0, 0, 0)", - "menu_button_a_border": "rgb(224, 224, 224)", - "menu_button_a_background": "rgb(240, 240, 240)", - "menu_button_border_hover": "rgb(221, 221, 221)", - "menu_button_a_hover": "rgb(0, 0, 0)", "menu_button_a_border_hover": "rgb(255, 185, 0)", - "menu_button_a_background_hover": "rgb(240, 240, 240)", "menu_a_color": "rgb(210, 153, 29)", } ) @@ -139,18 +127,13 @@ call-function: ( "check-search-colors", { "theme": "light", - "search_input_border": "rgb(224, 224, 224)", - "search_input_background": "rgb(255, 255, 255)", + "border": "rgb(224, 224, 224)", + "background": "rgb(255, 255, 255)", "search_input_color": "rgb(0, 0, 0)", "search_input_border_focus": "rgb(102, 175, 233)", "menu_button_border": "rgb(0, 0, 0)", "menu_button_a_color": "rgb(0, 0, 0)", - "menu_button_a_border": "rgb(224, 224, 224)", - "menu_button_a_background": "rgb(255, 255, 255)", - "menu_button_border_hover": "rgb(0, 0, 0)", - "menu_button_a_hover": "rgb(0, 0, 0)", "menu_button_a_border_hover": "rgb(113, 113, 113)", - "menu_button_a_background_hover": "rgb(255, 255, 255)", "menu_a_color": "rgb(56, 115, 173)", } ) From 03a3d24a116ced3b33a0541e3de559ff62907f0d Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sat, 19 Aug 2023 17:51:47 +0200 Subject: [PATCH 3/3] Migrate GUI colors test to original CSS color format --- tests/rustdoc-gui/search-form-elements.goml | 48 ++++++++++----------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/tests/rustdoc-gui/search-form-elements.goml b/tests/rustdoc-gui/search-form-elements.goml index fb75114fe45..a4e22364859 100644 --- a/tests/rustdoc-gui/search-form-elements.goml +++ b/tests/rustdoc-gui/search-form-elements.goml @@ -99,41 +99,41 @@ call-function: ( "check-search-colors", { "theme": "ayu", - "border": "rgb(92, 103, 115)", - "background": "rgb(20, 25, 32)", - "search_input_color": "rgb(255, 255, 255)", - "search_input_border_focus": "rgb(92, 103, 115)", - "menu_button_border": "rgb(197, 197, 197)", - "menu_button_a_color": "rgb(255, 255, 255)", - "menu_button_a_border_hover": "rgb(224, 224, 224)", - "menu_a_color": "rgb(57, 175, 215)", + "border": "#5c6773", + "background": "#141920", + "search_input_color": "#fff", + "search_input_border_focus": "#5c6773", + "menu_button_border": "#c5c5c5", + "menu_button_a_color": "#fff", + "menu_button_a_border_hover": "#e0e0e0", + "menu_a_color": "#39afd7", } ) call-function: ( "check-search-colors", { "theme": "dark", - "border": "rgb(224, 224, 224)", - "background": "rgb(240, 240, 240)", - "search_input_color": "rgb(17, 17, 17)", - "search_input_border_focus": "rgb(0, 141, 253)", - "menu_button_border": "rgb(221, 221, 221)", - "menu_button_a_color": "rgb(0, 0, 0)", - "menu_button_a_border_hover": "rgb(255, 185, 0)", - "menu_a_color": "rgb(210, 153, 29)", + "border": "#e0e0e0", + "background": "#f0f0f0", + "search_input_color": "#111", + "search_input_border_focus": "#008dfd", + "menu_button_border": "#ddd", + "menu_button_a_color": "#000", + "menu_button_a_border_hover": "#ffb900", + "menu_a_color": "#d2991d", } ) call-function: ( "check-search-colors", { "theme": "light", - "border": "rgb(224, 224, 224)", - "background": "rgb(255, 255, 255)", - "search_input_color": "rgb(0, 0, 0)", - "search_input_border_focus": "rgb(102, 175, 233)", - "menu_button_border": "rgb(0, 0, 0)", - "menu_button_a_color": "rgb(0, 0, 0)", - "menu_button_a_border_hover": "rgb(113, 113, 113)", - "menu_a_color": "rgb(56, 115, 173)", + "border": "#e0e0e0", + "background": "#fff", + "search_input_color": "#000", + "search_input_border_focus": "#66afe9", + "menu_button_border": "#000", + "menu_button_a_color": "#000", + "menu_button_a_border_hover": "#717171", + "menu_a_color": "#3873ad", } )