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 "chrome/browser/ui/views/aura/chrome_shell_delegate.h" | |
16 #endif | |
12 | 17 |
13 namespace chromeos { | 18 namespace chromeos { |
14 | 19 |
15 class PowerMenuButtonTest : public InProcessBrowserTest { | 20 class PowerMenuButtonTest : public InProcessBrowserTest { |
16 protected: | 21 protected: |
17 PowerMenuButtonTest() : InProcessBrowserTest() { | 22 PowerMenuButtonTest() : InProcessBrowserTest() { |
18 } | 23 } |
19 | 24 |
20 virtual void SetUpInProcessBrowserTestFixture() { | 25 virtual void SetUpInProcessBrowserTestFixture() { |
21 } | 26 } |
22 | 27 |
23 PowerMenuButton* GetPowerMenuButton() { | 28 PowerMenuButton* GetPowerMenuButton() { |
24 BrowserView* view = static_cast<BrowserView*>(browser()->window()); | 29 const views::View* view = |
25 return static_cast<PowerMenuButton*>(view->GetViewByID( | 30 #if defined(USE_AURA) |
26 VIEW_ID_STATUS_BUTTON_POWER)); | 31 ChromeShellDelegate::instance()->GetStatusArea(); |
32 #else | |
33 static_cast<BrowserView*>(browser()->window()); | |
34 #endif | |
35 return const_cast<PowerMenuButton*>( | |
Daniel Erat
2011/11/19 01:49:11
This is somewhat gross. Scott, what's the plan fo
sky
2011/11/19 23:26:52
I was hoping we could keep it const as most tests
Daniel Erat
2011/11/21 16:45:51
I'm happy leaving it const if you're okay with the
| |
36 static_cast<const PowerMenuButton*>( | |
37 view->GetViewByID(VIEW_ID_STATUS_BUTTON_POWER))); | |
27 } | 38 } |
28 | 39 |
29 string16 CallPowerChangedAndGetTooltipText(const PowerSupplyStatus& status) { | 40 string16 CallPowerChangedAndGetTooltipText(const PowerSupplyStatus& status) { |
30 PowerMenuButton* power = GetPowerMenuButton(); | 41 PowerMenuButton* power = GetPowerMenuButton(); |
31 | 42 |
32 power->PowerChanged(status); | 43 power->PowerChanged(status); |
33 EXPECT_TRUE(power->IsVisible()); | 44 EXPECT_TRUE(power->IsVisible()); |
34 | 45 |
35 string16 tooltip; | 46 string16 tooltip; |
36 // There is static_cast<StatusAreaButton*> because GetTootipText is also | 47 // There is static_cast<StatusAreaButton*> because GetTootipText is also |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
134 // Simulate various levels of discharging. | 145 // Simulate various levels of discharging. |
135 for (double percent = 5.0; percent < 100.0; percent += 5.0) { | 146 for (double percent = 5.0; percent < 100.0; percent += 5.0) { |
136 status.battery_percentage = percent; | 147 status.battery_percentage = percent; |
137 const string16 tooltip_after = CallPowerChangedAndGetTooltipText(status); | 148 const string16 tooltip_after = CallPowerChangedAndGetTooltipText(status); |
138 EXPECT_NE(tooltip_before, tooltip_after); | 149 EXPECT_NE(tooltip_before, tooltip_after); |
139 tooltip_before = tooltip_after; | 150 tooltip_before = tooltip_after; |
140 } | 151 } |
141 } | 152 } |
142 | 153 |
143 } // namespace chromeos | 154 } // namespace chromeos |
OLD | NEW |