OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/string_util.h" | 5 #include "base/string_util.h" |
6 #include "base/utf_string_conversions.h" | 6 #include "base/utf_string_conversions.h" |
7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
8 #include "ui/base/accessibility/accessible_view_state.h" | 8 #include "ui/base/accessibility/accessible_view_state.h" |
9 #include "views/controls/progress_bar.h" | 9 #include "views/controls/progress_bar.h" |
10 | 10 |
11 namespace views { | 11 namespace views { |
12 | 12 |
13 TEST(ProgressBarTest, ProgressProperty) { | |
14 ProgressBar bar; | |
15 bar.SetProgress(-1); | |
16 int progress = bar.GetProgress(); | |
17 EXPECT_EQ(0, progress); | |
18 bar.SetProgress(300); | |
19 progress = bar.GetProgress(); | |
20 EXPECT_EQ(100, progress); | |
21 bar.SetProgress(62); | |
22 progress = bar.GetProgress(); | |
23 EXPECT_EQ(62, progress); | |
24 } | |
25 | |
26 TEST(ProgressBarTest, AddProgressMethod) { | |
27 ProgressBar bar; | |
28 bar.SetProgress(10); | |
29 bar.AddProgress(22); | |
30 int progress = bar.GetProgress(); | |
31 EXPECT_EQ(32, progress); | |
32 bar.AddProgress(200); | |
33 progress = bar.GetProgress(); | |
34 EXPECT_EQ(100, progress); | |
35 } | |
36 | |
37 TEST(ProgressBarTest, TooltipTextProperty) { | 13 TEST(ProgressBarTest, TooltipTextProperty) { |
38 ProgressBar bar; | 14 ProgressBar bar; |
39 std::wstring tooltip = L"Some text"; | 15 std::wstring tooltip = L"Some text"; |
40 EXPECT_FALSE(bar.GetTooltipText(gfx::Point(), &tooltip)); | 16 EXPECT_FALSE(bar.GetTooltipText(gfx::Point(), &tooltip)); |
41 EXPECT_EQ(L"", tooltip); | 17 EXPECT_EQ(L"", tooltip); |
42 std::wstring tooltip_text = L"My progress"; | 18 std::wstring tooltip_text = L"My progress"; |
43 bar.SetTooltipText(tooltip_text); | 19 bar.SetTooltipText(tooltip_text); |
44 EXPECT_TRUE(bar.GetTooltipText(gfx::Point(), &tooltip)); | 20 EXPECT_TRUE(bar.GetTooltipText(gfx::Point(), &tooltip)); |
45 EXPECT_EQ(tooltip_text, tooltip); | 21 EXPECT_EQ(tooltip_text, tooltip); |
46 } | 22 } |
47 | 23 |
48 TEST(ProgressBarTest, Accessibility) { | 24 TEST(ProgressBarTest, Accessibility) { |
49 ProgressBar bar; | 25 ProgressBar bar; |
50 bar.SetProgress(62); | 26 bar.SetValue(62); |
51 | 27 |
52 ui::AccessibleViewState state; | 28 ui::AccessibleViewState state; |
53 bar.GetAccessibleState(&state); | 29 bar.GetAccessibleState(&state); |
54 EXPECT_EQ(ui::AccessibilityTypes::ROLE_PROGRESSBAR, state.role); | 30 EXPECT_EQ(ui::AccessibilityTypes::ROLE_PROGRESSBAR, state.role); |
55 EXPECT_EQ(string16(), state.name); | 31 EXPECT_EQ(string16(), state.name); |
56 EXPECT_TRUE(ui::AccessibilityTypes::STATE_READONLY & state.state); | 32 EXPECT_TRUE(ui::AccessibilityTypes::STATE_READONLY & state.state); |
57 } | 33 } |
58 | 34 |
59 } // namespace views | 35 } // namespace views |
OLD | NEW |