1 // Copyright (c) 2011 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 "ui/views/controls/progress_bar.h"
6
7 #include "base/strings/utf_string_conversions.h"
8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "ui/accessibility/ax_enums.mojom.h"
10 #include "ui/accessibility/ax_node_data.h"
11 #include "ui/gfx/color_utils.h"
12 #include "ui/native_theme/native_theme.h"
13 #include "ui/views/test/views_test_base.h"
14
15 namespace views {
16
17 using ProgressBarTest = ViewsTestBase;
18
TEST_F(ProgressBarTest,Accessibility)19 TEST_F(ProgressBarTest, Accessibility) {
20 ProgressBar bar;
21 bar.SetValue(0.62);
22
23 ui::AXNodeData node_data;
24 bar.GetAccessibleNodeData(&node_data);
25 EXPECT_EQ(ax::mojom::Role::kProgressIndicator, node_data.role);
26 EXPECT_EQ(base::string16(),
27 node_data.GetString16Attribute(ax::mojom::StringAttribute::kName));
28 EXPECT_FALSE(
29 node_data.HasIntAttribute(ax::mojom::IntAttribute::kRestriction));
30 }
31
32 // Test that default colors can be overridden. Used by Chromecast.
TEST_F(ProgressBarTest,OverrideDefaultColors)33 TEST_F(ProgressBarTest, OverrideDefaultColors) {
34 ProgressBar bar;
35 EXPECT_NE(SK_ColorRED, bar.GetForegroundColor());
36 EXPECT_NE(SK_ColorGREEN, bar.GetBackgroundColor());
37 EXPECT_NE(bar.GetForegroundColor(), bar.GetBackgroundColor());
38
39 bar.SetForegroundColor(SK_ColorRED);
40 bar.SetBackgroundColor(SK_ColorGREEN);
41 EXPECT_EQ(SK_ColorRED, bar.GetForegroundColor());
42 EXPECT_EQ(SK_ColorGREEN, bar.GetBackgroundColor());
43 }
44
45 } // namespace views
46