blob: 11f79219be31be5a47996ca610d11e42237013be [file] [log] [blame]
Alison Maher17ff3d62019-10-02 19:47:051// 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 Kasting919ce652020-05-07 10:22:366#include "content/public/test/browser_test.h"
Alison Maher17ff3d62019-10-02 19:47:057#include "content/public/test/content_browser_test.h"
8#include "content/public/test/content_browser_test_utils.h"
9
Alison Maher758e6302019-10-04 23:17:4810#if defined(OS_WIN)
11#include "base/win/windows_version.h"
12#endif // defined (OS_WIN)
13
Alison Maher17ff3d62019-10-02 19:47:0514namespace content {
15
16class WebThemeEngineImplDefaultBrowserTest : public ContentBrowserTest {
17 public:
18 WebThemeEngineImplDefaultBrowserTest() {}
19};
20
21#if defined(OS_WIN)
Alison Maher758e6302019-10-04 23:17:4822IN_PROC_BROWSER_TEST_F(WebThemeEngineImplDefaultBrowserTest, GetSystemColor) {
Alison Maher35d4d532019-10-25 17:41:5323 // 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 Maherb70df622019-10-11 19:34:2128 return;
Alison Maher35d4d532019-10-25 17:41:5329 }
Alison Maher17ff3d62019-10-02 19:47:0530 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 Maher21f00f42019-10-25 20:20:5536 "<div id='activeText' style='color: ActiveText'>ActiveText</div>"
Alison Maher17ff3d62019-10-02 19:47:0537 "<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 Maher9b5b02c2019-11-04 18:46:1644 "<div id='canvas' style='color: Canvas'>Canvas</div>"
45 "<div id='canvasText' style='color: CanvasText'>CanvasText</div>"
Alison Maher17ff3d62019-10-02 19:47:0546 "<div id='captionText' style='color: CaptionText'>CaptionText</div>"
Alison Maher21f00f42019-10-25 20:20:5547 "<div id='field' style='color: Field'>Field</div>"
48 "<div id='fieldText' style='color: FieldText'>FieldText</div>"
Alison Maher17ff3d62019-10-02 19:47:0549 "<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 Maher21f00f42019-10-25 20:20:5582 "activeText",
Alison Maher17ff3d62019-10-02 19:47:0583 "appWorkspace",
84 "background",
85 "buttonFace",
86 "buttonHighlight",
87 "buttonShadow",
88 "buttonText",
Alison Maher9b5b02c2019-11-04 18:46:1689 "canvas",
90 "canvasText",
Alison Maher17ff3d62019-10-02 19:47:0591 "captionText",
Alison Maher21f00f42019-10-25 20:20:5592 "field",
93 "fieldText",
Alison Maher17ff3d62019-10-02 19:47:0594 "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 Maher758e6302019-10-04 23:17:48115 std::vector<std::string> expected_colors;
116 if (base::win::GetVersion() <= base::win::Version::WIN8_1) {
117 expected_colors = {
Alison Maher127ee4d2019-12-02 18:17:44118 "rgb(255, 255, 255)", "rgb(204, 204, 204)", "rgb(0, 102, 204)",
Alison Maher21f00f42019-10-25 20:20:55119 "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 Maher9b5b02c2019-11-04 18:46:16121 "rgb(255, 255, 255)", "rgb(0, 0, 0)", "rgb(0, 0, 0)",
Alison Maher127ee4d2019-12-02 18:17:44122 "rgb(255, 255, 255)", "rgb(0, 0, 0)", "rgb(109, 109, 109)",
Alison Maher9b5b02c2019-11-04 18:46:16123 "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 Maher758e6302019-10-04 23:17:48130 } else {
131 expected_colors = {
Alison Maher127ee4d2019-12-02 18:17:44132 "rgb(255, 255, 255)", "rgb(204, 204, 204)", "rgb(0, 102, 204)",
Alison Maher21f00f42019-10-25 20:20:55133 "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 Maher9b5b02c2019-11-04 18:46:16135 "rgb(255, 255, 255)", "rgb(0, 0, 0)", "rgb(0, 0, 0)",
Alison Maher127ee4d2019-12-02 18:17:44136 "rgb(255, 255, 255)", "rgb(0, 0, 0)", "rgb(109, 109, 109)",
Alison Maher9b5b02c2019-11-04 18:46:16137 "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 Maher758e6302019-10-04 23:17:48144 }
Alison Maher17ff3d62019-10-02 19:47:05145
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