OLD | NEW |
1 // Copyright (c) 2011 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 "chrome/browser/chromeos/status/power_menu_button.h" | 5 #include "chrome/browser/chromeos/status/power_menu_button.h" |
6 | 6 |
7 #include "chrome/browser/chromeos/frame/browser_view.h" | 7 #include "chrome/browser/chromeos/frame/browser_view.h" |
8 #include "chrome/browser/chromeos/view_ids.h" | 8 #include "chrome/browser/chromeos/view_ids.h" |
9 #include "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
10 #include "chrome/browser/ui/browser_window.h" | 10 #include "chrome/browser/ui/browser_window.h" |
11 #include "chrome/test/base/in_process_browser_test.h" | 11 #include "chrome/test/base/in_process_browser_test.h" |
| 12 #include "views/view.h" |
| 13 |
| 14 #if defined(USE_AURA) |
| 15 #include "ui/aura_shell/shell.h" |
| 16 #include "views/widget/widget.h" |
| 17 #endif |
12 | 18 |
13 namespace chromeos { | 19 namespace chromeos { |
14 | 20 |
15 class PowerMenuButtonTest : public InProcessBrowserTest { | 21 class PowerMenuButtonTest : public InProcessBrowserTest { |
16 protected: | 22 protected: |
17 PowerMenuButtonTest() : InProcessBrowserTest() { | 23 PowerMenuButtonTest() : InProcessBrowserTest() { |
18 } | 24 } |
19 | 25 |
20 virtual void SetUpInProcessBrowserTestFixture() { | 26 virtual void SetUpInProcessBrowserTestFixture() { |
21 } | 27 } |
22 | 28 |
23 PowerMenuButton* GetPowerMenuButton() { | 29 PowerMenuButton* GetPowerMenuButton() { |
24 BrowserView* view = static_cast<BrowserView*>(browser()->window()); | 30 views::View *view = |
25 return static_cast<PowerMenuButton*>(view->GetViewByID( | 31 #if defined(USE_AURA) |
26 VIEW_ID_STATUS_BUTTON_POWER)); | 32 aura_shell::Shell::GetInstance()->GetStatusAreaWidget()-> |
| 33 GetContentsView(); |
| 34 #else |
| 35 static_cast<BrowserView*>(browser()->window()); |
| 36 #endif |
| 37 return static_cast<PowerMenuButton*>( |
| 38 view->GetViewByID(VIEW_ID_STATUS_BUTTON_POWER)); |
27 } | 39 } |
28 | 40 |
29 string16 CallPowerChangedAndGetTooltipText(const PowerSupplyStatus& status) { | 41 string16 CallPowerChangedAndGetTooltipText(const PowerSupplyStatus& status) { |
30 PowerMenuButton* power = GetPowerMenuButton(); | 42 PowerMenuButton* power = GetPowerMenuButton(); |
31 power->PowerChanged(status); | 43 power->PowerChanged(status); |
32 string16 tooltip; | 44 string16 tooltip; |
33 // There is static_cast<StatusAreaButton*> because GetTootipText is also | 45 // There is static_cast<StatusAreaButton*> because GetTootipText is also |
34 // declared in MenuDelegate | 46 // declared in MenuDelegate |
35 EXPECT_TRUE(static_cast<StatusAreaButton*>(power)->GetTooltipText( | 47 EXPECT_TRUE(static_cast<StatusAreaButton*>(power)->GetTooltipText( |
36 gfx::Point(0, 0), &tooltip)); | 48 gfx::Point(0, 0), &tooltip)); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 // Simulate various levels of discharging. | 124 // Simulate various levels of discharging. |
113 for (double percent = 5.0; percent < 100.0; percent += 5.0) { | 125 for (double percent = 5.0; percent < 100.0; percent += 5.0) { |
114 status.battery_percentage = percent; | 126 status.battery_percentage = percent; |
115 const string16 tooltip_after = CallPowerChangedAndGetTooltipText(status); | 127 const string16 tooltip_after = CallPowerChangedAndGetTooltipText(status); |
116 EXPECT_NE(tooltip_before, tooltip_after); | 128 EXPECT_NE(tooltip_before, tooltip_after); |
117 tooltip_before = tooltip_after; | 129 tooltip_before = tooltip_after; |
118 } | 130 } |
119 } | 131 } |
120 | 132 |
121 } // namespace chromeos | 133 } // namespace chromeos |
OLD | NEW |