| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ash/system/tray/system_tray.h" | 5 #include "ash/system/tray/system_tray.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "ash/accelerators/accelerator_controller.h" |
| 10 #include "ash/volume_control_delegate.h" |
| 9 #include "ash/system/status_area_widget.h" | 11 #include "ash/system/status_area_widget.h" |
| 10 #include "ash/system/tray/system_tray_item.h" | 12 #include "ash/system/tray/system_tray_item.h" |
| 11 #include "ash/test/ash_test_base.h" | 13 #include "ash/test/ash_test_base.h" |
| 12 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
| 13 #include "ui/views/controls/label.h" | 15 #include "ui/views/controls/label.h" |
| 14 #include "ui/views/layout/fill_layout.h" | 16 #include "ui/views/layout/fill_layout.h" |
| 15 #include "ui/views/view.h" | 17 #include "ui/views/view.h" |
| 16 #include "ui/views/widget/widget.h" | 18 #include "ui/views/widget/widget.h" |
| 17 | 19 |
| 18 namespace ash { | 20 namespace ash { |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 views::View* detailed_view() const { return detailed_view_; } | 82 views::View* detailed_view() const { return detailed_view_; } |
| 81 views::View* notification_view() const { return notification_view_; } | 83 views::View* notification_view() const { return notification_view_; } |
| 82 | 84 |
| 83 private: | 85 private: |
| 84 views::View* tray_view_; | 86 views::View* tray_view_; |
| 85 views::View* default_view_; | 87 views::View* default_view_; |
| 86 views::View* detailed_view_; | 88 views::View* detailed_view_; |
| 87 views::View* notification_view_; | 89 views::View* notification_view_; |
| 88 }; | 90 }; |
| 89 | 91 |
| 92 class DummyVolumeControlDelegate : public VolumeControlDelegate { |
| 93 public: |
| 94 explicit DummyVolumeControlDelegate() {} |
| 95 virtual ~DummyVolumeControlDelegate() {} |
| 96 |
| 97 virtual bool HandleVolumeMute(const ui::Accelerator& accelerator) OVERRIDE { |
| 98 return true; |
| 99 } |
| 100 virtual bool HandleVolumeDown(const ui::Accelerator& accelerator) OVERRIDE { |
| 101 return true; |
| 102 } |
| 103 virtual bool HandleVolumeUp(const ui::Accelerator& accelerator) OVERRIDE { |
| 104 return true; |
| 105 } |
| 106 virtual void SetVolumePercent(double percent) OVERRIDE { |
| 107 } |
| 108 virtual bool IsAudioMuted() const OVERRIDE { |
| 109 return false; |
| 110 } |
| 111 virtual void SetAudioMuted(bool muted) OVERRIDE { |
| 112 } |
| 113 virtual float GetVolumeLevel() const OVERRIDE { |
| 114 return 0.0; |
| 115 } |
| 116 virtual void SetVolumeLevel(float level) OVERRIDE { |
| 117 } |
| 118 |
| 119 |
| 120 private: |
| 121 DISALLOW_COPY_AND_ASSIGN(DummyVolumeControlDelegate); |
| 122 }; |
| 123 |
| 90 } // namespace | 124 } // namespace |
| 91 | 125 |
| 92 typedef AshTestBase SystemTrayTest; | 126 class SystemTrayTest : public AshTestBase { |
| 127 public: |
| 128 SystemTrayTest() : AshTestBase() {} |
| 129 virtual ~SystemTrayTest() {} |
| 130 |
| 131 virtual void SetUp() OVERRIDE { |
| 132 AshTestBase::SetUp(); |
| 133 Shell::GetInstance()->accelerator_controller()->SetVolumeControlDelegate( |
| 134 scoped_ptr<ash::VolumeControlDelegate>(new |
| 135 DummyVolumeControlDelegate).Pass()); |
| 136 } |
| 137 |
| 138 private: |
| 139 DISALLOW_COPY_AND_ASSIGN(SystemTrayTest); |
| 140 }; |
| 141 |
| 93 | 142 |
| 94 TEST_F(SystemTrayTest, SystemTrayDefaultView) { | 143 TEST_F(SystemTrayTest, SystemTrayDefaultView) { |
| 95 SystemTray* tray = GetSystemTray(); | 144 SystemTray* tray = GetSystemTray(); |
| 96 ASSERT_TRUE(tray->GetWidget()); | 145 ASSERT_TRUE(tray->GetWidget()); |
| 97 | 146 |
| 98 tray->ShowDefaultView(BUBBLE_CREATE_NEW); | 147 tray->ShowDefaultView(BUBBLE_CREATE_NEW); |
| 99 | 148 |
| 100 // Ensure that closing the bubble destroys it. | 149 // Ensure that closing the bubble destroys it. |
| 101 ASSERT_TRUE(tray->CloseBubbleForTest()); | 150 ASSERT_TRUE(tray->CloseBubbleForTest()); |
| 102 RunAllPendingInMessageLoop(); | 151 RunAllPendingInMessageLoop(); |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 tray->ShowDefaultView(BUBBLE_USE_EXISTING); | 276 tray->ShowDefaultView(BUBBLE_USE_EXISTING); |
| 228 RunAllPendingInMessageLoop(); | 277 RunAllPendingInMessageLoop(); |
| 229 | 278 |
| 230 EXPECT_EQ(bubble_bounds.ToString(), test_item->default_view()->GetWidget()-> | 279 EXPECT_EQ(bubble_bounds.ToString(), test_item->default_view()->GetWidget()-> |
| 231 GetWindowBoundsInScreen().ToString()); | 280 GetWindowBoundsInScreen().ToString()); |
| 232 EXPECT_EQ(widget, test_item->default_view()->GetWidget()); | 281 EXPECT_EQ(widget, test_item->default_view()->GetWidget()); |
| 233 } | 282 } |
| 234 | 283 |
| 235 } // namespace test | 284 } // namespace test |
| 236 } // namespace ash | 285 } // namespace ash |
| OLD | NEW |