| 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/accessibility_delegate.h" | 9 #include "ash/accessibility_delegate.h" |
| 10 #include "ash/root_window_controller.h" | 10 #include "ash/root_window_controller.h" |
| 11 #include "ash/shelf/shelf_layout_manager.h" | 11 #include "ash/shelf/shelf_layout_manager.h" |
| 12 #include "ash/shelf/shelf_widget.h" | 12 #include "ash/shelf/shelf_widget.h" |
| 13 #include "ash/shell.h" | 13 #include "ash/shell.h" |
| 14 #include "ash/system/status_area_widget.h" | 14 #include "ash/system/status_area_widget.h" |
| 15 #include "ash/system/tray/system_tray_item.h" | 15 #include "ash/system/tray/system_tray_item.h" |
| 16 #include "ash/system/tray/tray_background_view.h" |
| 16 #include "ash/system/tray/tray_constants.h" | 17 #include "ash/system/tray/tray_constants.h" |
| 17 #include "ash/test/ash_test_base.h" | 18 #include "ash/test/ash_test_base.h" |
| 18 #include "ash/wm/window_util.h" | 19 #include "ash/wm/window_util.h" |
| 19 #include "base/run_loop.h" | 20 #include "base/run_loop.h" |
| 20 #include "base/strings/utf_string_conversions.h" | 21 #include "base/strings/utf_string_conversions.h" |
| 21 #include "ui/aura/test/event_generator.h" | 22 #include "ui/aura/test/event_generator.h" |
| 22 #include "ui/aura/window.h" | 23 #include "ui/aura/window.h" |
| 23 #include "ui/base/ui_base_types.h" | 24 #include "ui/base/ui_base_types.h" |
| 24 #include "ui/gfx/geometry/rect.h" | 25 #include "ui/gfx/geometry/rect.h" |
| 25 #include "ui/views/controls/label.h" | 26 #include "ui/views/controls/label.h" |
| 26 #include "ui/views/layout/fill_layout.h" | 27 #include "ui/views/layout/fill_layout.h" |
| 27 #include "ui/views/view.h" | 28 #include "ui/views/view.h" |
| 28 #include "ui/views/widget/widget.h" | 29 #include "ui/views/widget/widget.h" |
| 29 #include "ui/views/widget/widget_delegate.h" | 30 #include "ui/views/widget/widget_delegate.h" |
| 30 | 31 |
| 31 #if defined(OS_WIN) | 32 #if defined(OS_WIN) |
| 32 #include "base/win/windows_version.h" | 33 #include "base/win/windows_version.h" |
| 33 #endif | 34 #endif |
| 34 | 35 |
| 35 namespace ash { | 36 namespace ash { |
| 36 namespace test { | |
| 37 | 37 |
| 38 namespace { | 38 namespace { |
| 39 | 39 |
| 40 SystemTray* GetSystemTray() { | 40 SystemTray* GetSystemTray() { |
| 41 return Shell::GetPrimaryRootWindowController()->shelf()-> | 41 return Shell::GetPrimaryRootWindowController()->shelf()-> |
| 42 status_area_widget()->system_tray(); | 42 status_area_widget()->system_tray(); |
| 43 } | 43 } |
| 44 | 44 |
| 45 // Trivial item implementation that tracks its views for testing. | 45 // Trivial item implementation that tracks its views for testing. |
| 46 class TestItem : public SystemTrayItem { | 46 class TestItem : public SystemTrayItem { |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 virtual ui::ModalType GetModalType() const OVERRIDE { | 149 virtual ui::ModalType GetModalType() const OVERRIDE { |
| 150 return ui::MODAL_TYPE_SYSTEM; | 150 return ui::MODAL_TYPE_SYSTEM; |
| 151 } | 151 } |
| 152 | 152 |
| 153 private: | 153 private: |
| 154 DISALLOW_COPY_AND_ASSIGN(ModalWidgetDelegate); | 154 DISALLOW_COPY_AND_ASSIGN(ModalWidgetDelegate); |
| 155 }; | 155 }; |
| 156 | 156 |
| 157 } // namespace | 157 } // namespace |
| 158 | 158 |
| 159 typedef AshTestBase SystemTrayTest; | 159 class SystemTrayTest : public test::AshTestBase { |
| 160 public: |
| 161 SystemTrayTest() {} |
| 162 virtual ~SystemTrayTest() {} |
| 163 |
| 164 virtual void SetUp() OVERRIDE { |
| 165 TrayBackgroundView::DisableAnimationsForTest(); |
| 166 test::AshTestBase::SetUp(); |
| 167 } |
| 168 |
| 169 private: |
| 170 DISALLOW_COPY_AND_ASSIGN(SystemTrayTest); |
| 171 }; |
| 160 | 172 |
| 161 TEST_F(SystemTrayTest, SystemTrayDefaultView) { | 173 TEST_F(SystemTrayTest, SystemTrayDefaultView) { |
| 162 SystemTray* tray = GetSystemTray(); | 174 SystemTray* tray = GetSystemTray(); |
| 163 ASSERT_TRUE(tray->GetWidget()); | 175 ASSERT_TRUE(tray->GetWidget()); |
| 164 | 176 |
| 165 tray->ShowDefaultView(BUBBLE_CREATE_NEW); | 177 tray->ShowDefaultView(BUBBLE_CREATE_NEW); |
| 166 | 178 |
| 167 // Ensure that closing the bubble destroys it. | 179 // Ensure that closing the bubble destroys it. |
| 168 ASSERT_TRUE(tray->CloseSystemBubble()); | 180 ASSERT_TRUE(tray->CloseSystemBubble()); |
| 169 RunAllPendingInMessageLoop(); | 181 RunAllPendingInMessageLoop(); |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 476 ASSERT_TRUE(accessibility); | 488 ASSERT_TRUE(accessibility); |
| 477 EXPECT_TRUE(accessibility->visible()); | 489 EXPECT_TRUE(accessibility->visible()); |
| 478 | 490 |
| 479 const views::View* settings = | 491 const views::View* settings = |
| 480 tray->GetSystemBubble()->bubble_view()->GetViewByID( | 492 tray->GetSystemBubble()->bubble_view()->GetViewByID( |
| 481 test::kSettingsTrayItemViewId); | 493 test::kSettingsTrayItemViewId); |
| 482 ASSERT_TRUE(settings); | 494 ASSERT_TRUE(settings); |
| 483 EXPECT_TRUE(settings->visible()); | 495 EXPECT_TRUE(settings->visible()); |
| 484 } | 496 } |
| 485 | 497 |
| 486 } // namespace test | |
| 487 } // namespace ash | 498 } // namespace ash |
| OLD | NEW |