OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "app/l10n_util.h" | 5 #include "app/l10n_util.h" |
6 #include "base/string_util.h" | 6 #include "base/string_util.h" |
7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
8 #include "views/controls/progress_bar.h" | 8 #include "views/controls/progress_bar.h" |
9 | 9 |
10 namespace views { | 10 namespace views { |
11 | 11 |
12 TEST(ProgressBarTest, ProgressProperty) { | 12 TEST(ProgressBarTest, ProgressProperty) { |
13 ProgressBar bar; | 13 ProgressBar bar; |
14 bar.SetProgress(-1); | 14 bar.SetProgress(-1); |
15 int progress = bar.GetProgress(); | 15 int progress = bar.GetProgress(); |
16 EXPECT_EQ(0, progress); | 16 EXPECT_EQ(0, progress); |
17 bar.SetProgress(300); | 17 bar.SetProgress(300); |
18 progress = bar.GetProgress(); | 18 progress = bar.GetProgress(); |
19 EXPECT_EQ(100, progress); | 19 EXPECT_EQ(100, progress); |
20 bar.SetProgress(62); | 20 bar.SetProgress(62); |
21 progress = bar.GetProgress(); | 21 progress = bar.GetProgress(); |
22 EXPECT_EQ(62, progress); | 22 EXPECT_EQ(62, progress); |
23 } | 23 } |
24 | 24 |
| 25 TEST(ProgressBarTest, AddProgressMethod) { |
| 26 ProgressBar bar; |
| 27 bar.SetProgress(10); |
| 28 bar.AddProgress(22); |
| 29 int progress = bar.GetProgress(); |
| 30 EXPECT_EQ(32, progress); |
| 31 bar.AddProgress(200); |
| 32 progress = bar.GetProgress(); |
| 33 EXPECT_EQ(100, progress); |
| 34 } |
| 35 |
25 TEST(ProgressBarTest, TooltipTextProperty) { | 36 TEST(ProgressBarTest, TooltipTextProperty) { |
26 ProgressBar bar; | 37 ProgressBar bar; |
27 std::wstring tooltip = L"Some text"; | 38 std::wstring tooltip = L"Some text"; |
28 EXPECT_FALSE(bar.GetTooltipText(gfx::Point(), &tooltip)); | 39 EXPECT_FALSE(bar.GetTooltipText(gfx::Point(), &tooltip)); |
29 EXPECT_EQ(L"", tooltip); | 40 EXPECT_EQ(L"", tooltip); |
30 std::wstring tooltip_text = L"My progress"; | 41 std::wstring tooltip_text = L"My progress"; |
31 bar.SetTooltipText(tooltip_text); | 42 bar.SetTooltipText(tooltip_text); |
32 EXPECT_TRUE(bar.GetTooltipText(gfx::Point(), &tooltip)); | 43 EXPECT_TRUE(bar.GetTooltipText(gfx::Point(), &tooltip)); |
33 EXPECT_EQ(tooltip_text, tooltip); | 44 EXPECT_EQ(tooltip_text, tooltip); |
34 } | 45 } |
35 | 46 |
36 TEST(ProgressBarTest, Accessibility) { | 47 TEST(ProgressBarTest, Accessibility) { |
37 ProgressBar bar; | 48 ProgressBar bar; |
38 bar.SetProgress(62); | 49 bar.SetProgress(62); |
39 | 50 |
40 AccessibilityTypes::Role role; | 51 AccessibilityTypes::Role role; |
41 EXPECT_TRUE(bar.GetAccessibleRole(&role)); | 52 EXPECT_TRUE(bar.GetAccessibleRole(&role)); |
42 EXPECT_EQ(AccessibilityTypes::ROLE_TEXT, role); | 53 EXPECT_EQ(AccessibilityTypes::ROLE_TEXT, role); |
43 | 54 |
44 // TODO(denisromanov): Test accessibility text here when it's implemented. | 55 // TODO(denisromanov): Test accessibility text here when it's implemented. |
45 | 56 |
46 AccessibilityTypes::State state; | 57 AccessibilityTypes::State state; |
47 EXPECT_TRUE(bar.GetAccessibleState(&state)); | 58 EXPECT_TRUE(bar.GetAccessibleState(&state)); |
48 EXPECT_EQ(AccessibilityTypes::STATE_READONLY, state); | 59 EXPECT_EQ(AccessibilityTypes::STATE_READONLY, state); |
49 } | 60 } |
50 | 61 |
51 } // namespace views | 62 } // namespace views |
OLD | NEW |