Alison Maher | 17ff3d6 | 2019-10-02 19:47:05 | [diff] [blame] | 1 | // Copyright 2019 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "build/build_config.h" |
Peter Kasting | 919ce65 | 2020-05-07 10:22:36 | [diff] [blame] | 6 | #include "content/public/test/browser_test.h" |
Alison Maher | 17ff3d6 | 2019-10-02 19:47:05 | [diff] [blame] | 7 | #include "content/public/test/content_browser_test.h" |
| 8 | #include "content/public/test/content_browser_test_utils.h" |
| 9 | |
Alison Maher | 758e630 | 2019-10-04 23:17:48 | [diff] [blame] | 10 | #if defined(OS_WIN) |
| 11 | #include "base/win/windows_version.h" |
| 12 | #endif // defined (OS_WIN) |
| 13 | |
Alison Maher | 17ff3d6 | 2019-10-02 19:47:05 | [diff] [blame] | 14 | namespace content { |
| 15 | |
| 16 | class WebThemeEngineImplDefaultBrowserTest : public ContentBrowserTest { |
| 17 | public: |
| 18 | WebThemeEngineImplDefaultBrowserTest() {} |
| 19 | }; |
| 20 | |
| 21 | #if defined(OS_WIN) |
Alison Maher | 758e630 | 2019-10-04 23:17:48 | [diff] [blame] | 22 | IN_PROC_BROWSER_TEST_F(WebThemeEngineImplDefaultBrowserTest, GetSystemColor) { |
Alison Maher | 35d4d53 | 2019-10-25 17:41:53 | [diff] [blame] | 23 | // The test non-deterministically fails on Windows-2008ServerR2 builders due |
| 24 | // to a difference in the default theme. As a result, only run the test on |
| 25 | // non-server versions. |
| 26 | if (base::win::OSInfo::GetInstance()->version_type() == |
| 27 | base::win::VersionType::SUITE_SERVER) { |
Alison Maher | b70df62 | 2019-10-11 19:34:21 | [diff] [blame] | 28 | return; |
Alison Maher | 35d4d53 | 2019-10-25 17:41:53 | [diff] [blame] | 29 | } |
Alison Maher | 17ff3d6 | 2019-10-02 19:47:05 | [diff] [blame] | 30 | GURL url( |
| 31 | "data:text/html," |
| 32 | "<!doctype html><html>" |
| 33 | "<body>" |
| 34 | "<div id='activeBorder' style='color: ActiveBorder'>ActiveBorder</div>" |
| 35 | "<div id='activeCaption' style='color: ActiveCaption'>ActiveCaption</div>" |
Alison Maher | 21f00f4 | 2019-10-25 20:20:55 | [diff] [blame] | 36 | "<div id='activeText' style='color: ActiveText'>ActiveText</div>" |
Alison Maher | 17ff3d6 | 2019-10-02 19:47:05 | [diff] [blame] | 37 | "<div id='appWorkspace' style='color: AppWorkspace'>AppWorkspace</div>" |
| 38 | "<div id='background' style='color: Background'>Background</div>" |
| 39 | "<div id='buttonFace' style='color: ButtonFace'>ButtonFace</div>" |
| 40 | "<div id='buttonHighlight' style='color: " |
| 41 | "ButtonHighlight'>ButtonHighlight</div>" |
| 42 | "<div id='buttonShadow' style='color: ButtonShadow'>ButtonShadow</div>" |
| 43 | "<div id='buttonText' style='color: ButtonText'>ButtonText</div>" |
Alison Maher | 9b5b02c | 2019-11-04 18:46:16 | [diff] [blame] | 44 | "<div id='canvas' style='color: Canvas'>Canvas</div>" |
| 45 | "<div id='canvasText' style='color: CanvasText'>CanvasText</div>" |
Alison Maher | 17ff3d6 | 2019-10-02 19:47:05 | [diff] [blame] | 46 | "<div id='captionText' style='color: CaptionText'>CaptionText</div>" |
Alison Maher | 21f00f4 | 2019-10-25 20:20:55 | [diff] [blame] | 47 | "<div id='field' style='color: Field'>Field</div>" |
| 48 | "<div id='fieldText' style='color: FieldText'>FieldText</div>" |
Alison Maher | 17ff3d6 | 2019-10-02 19:47:05 | [diff] [blame] | 49 | "<div id='grayText' style='color: GrayText'>GrayText</div>" |
| 50 | "<div id='highlight' style='color: Highlight'>Highlight</div>" |
| 51 | "<div id='highlightText' style='color: HighlightText'>HighlightText</div>" |
| 52 | "<div id='inactiveBorder' style='color: " |
| 53 | "InactiveBorder'>InactiveBorder</div>" |
| 54 | "<div id='inactiveCaption' style='color: " |
| 55 | "InactiveCaption'>InactiveCaption</div>" |
| 56 | "<div id='inactiveCaptionText' style='color: " |
| 57 | "InactiveCaptionText'>InactiveCaptionText</div>" |
| 58 | "<div id='infoBackground' style='color: " |
| 59 | "InfoBackground'>InfoBackground</div>" |
| 60 | "<div id='infoText' style='color: InfoText'>InfoText</div>" |
| 61 | "<div id='linkText' style='color: LinkText'>LinkText</div>" |
| 62 | "<div id='menu' style='color: Menu'>Menu</div>" |
| 63 | "<div id='menuText' style='color: MenuText'>MenuText</div>" |
| 64 | "<div id='scrollbar' style='color: Scrollbar'>Scrollbar</div>" |
| 65 | "<div id='threeDDarkShadow' style='color: " |
| 66 | "ThreeDDarkShadow'>ThreeDDarkShadow</div>" |
| 67 | "<div id='threeDFace' style='color: ThreeDFace'>ThreeDFace</div>" |
| 68 | "<div id='threeDHighlight' style='color: " |
| 69 | "ThreeDHighlight'>ThreeDHighlight</div>" |
| 70 | "<div id='threeDLightShadow' style='color: " |
| 71 | "ThreeDLightShadow'>ThreeDLightShadow</div>" |
| 72 | "<div id='threeDShadow' style='color: ThreeDShadow'>ThreeDShadow</div>" |
| 73 | "<div id='visitedText' style='color: VisitedText'>VisitedText</div>" |
| 74 | "<div id='window' style='color: Window'>Window</div>" |
| 75 | "<div id='windowFrame' style='color: WindowFrame'>WindowFrame</div>" |
| 76 | "<div id='windowText' style='color: WindowText'>WindowText</div>" |
| 77 | "</body></html>"); |
| 78 | EXPECT_TRUE(NavigateToURL(shell(), url)); |
| 79 | |
| 80 | std::vector<std::string> ids = {"activeBorder", |
| 81 | "activeCaption", |
Alison Maher | 21f00f4 | 2019-10-25 20:20:55 | [diff] [blame] | 82 | "activeText", |
Alison Maher | 17ff3d6 | 2019-10-02 19:47:05 | [diff] [blame] | 83 | "appWorkspace", |
| 84 | "background", |
| 85 | "buttonFace", |
| 86 | "buttonHighlight", |
| 87 | "buttonShadow", |
| 88 | "buttonText", |
Alison Maher | 9b5b02c | 2019-11-04 18:46:16 | [diff] [blame] | 89 | "canvas", |
| 90 | "canvasText", |
Alison Maher | 17ff3d6 | 2019-10-02 19:47:05 | [diff] [blame] | 91 | "captionText", |
Alison Maher | 21f00f4 | 2019-10-25 20:20:55 | [diff] [blame] | 92 | "field", |
| 93 | "fieldText", |
Alison Maher | 17ff3d6 | 2019-10-02 19:47:05 | [diff] [blame] | 94 | "grayText", |
| 95 | "highlight", |
| 96 | "highlightText", |
| 97 | "inactiveBorder", |
| 98 | "inactiveCaption", |
| 99 | "inactiveCaptionText", |
| 100 | "infoBackground", |
| 101 | "infoText", |
| 102 | "linkText", |
| 103 | "menu", |
| 104 | "menuText", |
| 105 | "scrollbar", |
| 106 | "threeDDarkShadow", |
| 107 | "threeDFace", |
| 108 | "threeDHighlight", |
| 109 | "threeDLightShadow", |
| 110 | "threeDShadow", |
| 111 | "visitedText", |
| 112 | "window", |
| 113 | "windowFrame", |
| 114 | "windowText"}; |
Alison Maher | 758e630 | 2019-10-04 23:17:48 | [diff] [blame] | 115 | std::vector<std::string> expected_colors; |
| 116 | if (base::win::GetVersion() <= base::win::Version::WIN8_1) { |
| 117 | expected_colors = { |
Alison Maher | 127ee4d | 2019-12-02 18:17:44 | [diff] [blame] | 118 | "rgb(255, 255, 255)", "rgb(204, 204, 204)", "rgb(0, 102, 204)", |
Alison Maher | 21f00f4 | 2019-10-25 20:20:55 | [diff] [blame] | 119 | "rgb(255, 255, 255)", "rgb(99, 99, 206)", "rgb(240, 240, 240)", |
| 120 | "rgb(221, 221, 221)", "rgb(136, 136, 136)", "rgb(0, 0, 0)", |
Alison Maher | 9b5b02c | 2019-11-04 18:46:16 | [diff] [blame] | 121 | "rgb(255, 255, 255)", "rgb(0, 0, 0)", "rgb(0, 0, 0)", |
Alison Maher | 127ee4d | 2019-12-02 18:17:44 | [diff] [blame] | 122 | "rgb(255, 255, 255)", "rgb(0, 0, 0)", "rgb(109, 109, 109)", |
Alison Maher | 9b5b02c | 2019-11-04 18:46:16 | [diff] [blame] | 123 | "rgb(51, 153, 255)", "rgb(255, 255, 255)", "rgb(255, 255, 255)", |
| 124 | "rgb(255, 255, 255)", "rgb(127, 127, 127)", "rgb(251, 252, 197)", |
| 125 | "rgb(0, 0, 0)", "rgb(0, 102, 204)", "rgb(247, 247, 247)", |
| 126 | "rgb(0, 0, 0)", "rgb(255, 255, 255)", "rgb(102, 102, 102)", |
| 127 | "rgb(192, 192, 192)", "rgb(221, 221, 221)", "rgb(192, 192, 192)", |
| 128 | "rgb(136, 136, 136)", "rgb(0, 102, 204)", "rgb(255, 255, 255)", |
| 129 | "rgb(204, 204, 204)", "rgb(0, 0, 0)"}; |
Alison Maher | 758e630 | 2019-10-04 23:17:48 | [diff] [blame] | 130 | } else { |
| 131 | expected_colors = { |
Alison Maher | 127ee4d | 2019-12-02 18:17:44 | [diff] [blame] | 132 | "rgb(255, 255, 255)", "rgb(204, 204, 204)", "rgb(0, 102, 204)", |
Alison Maher | 21f00f4 | 2019-10-25 20:20:55 | [diff] [blame] | 133 | "rgb(255, 255, 255)", "rgb(99, 99, 206)", "rgb(240, 240, 240)", |
| 134 | "rgb(221, 221, 221)", "rgb(136, 136, 136)", "rgb(0, 0, 0)", |
Alison Maher | 9b5b02c | 2019-11-04 18:46:16 | [diff] [blame] | 135 | "rgb(255, 255, 255)", "rgb(0, 0, 0)", "rgb(0, 0, 0)", |
Alison Maher | 127ee4d | 2019-12-02 18:17:44 | [diff] [blame] | 136 | "rgb(255, 255, 255)", "rgb(0, 0, 0)", "rgb(109, 109, 109)", |
Alison Maher | 9b5b02c | 2019-11-04 18:46:16 | [diff] [blame] | 137 | "rgb(0, 120, 215)", "rgb(255, 255, 255)", "rgb(255, 255, 255)", |
| 138 | "rgb(255, 255, 255)", "rgb(127, 127, 127)", "rgb(251, 252, 197)", |
| 139 | "rgb(0, 0, 0)", "rgb(0, 102, 204)", "rgb(247, 247, 247)", |
| 140 | "rgb(0, 0, 0)", "rgb(255, 255, 255)", "rgb(102, 102, 102)", |
| 141 | "rgb(192, 192, 192)", "rgb(221, 221, 221)", "rgb(192, 192, 192)", |
| 142 | "rgb(136, 136, 136)", "rgb(0, 102, 204)", "rgb(255, 255, 255)", |
| 143 | "rgb(204, 204, 204)", "rgb(0, 0, 0)"}; |
Alison Maher | 758e630 | 2019-10-04 23:17:48 | [diff] [blame] | 144 | } |
Alison Maher | 17ff3d6 | 2019-10-02 19:47:05 | [diff] [blame] | 145 | |
| 146 | ASSERT_EQ(ids.size(), expected_colors.size()); |
| 147 | |
| 148 | for (size_t i = 0; i < ids.size(); i++) { |
| 149 | EXPECT_EQ(expected_colors[i], |
| 150 | EvalJs(shell(), |
| 151 | "window.getComputedStyle(document.getElementById('" + |
| 152 | ids[i] + "')).getPropertyValue('color').toString()")); |
| 153 | } |
| 154 | } |
| 155 | #endif // defined(OS_WIN) |
| 156 | |
| 157 | } // namespace content |