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/focus_cycler.h" | 5 #include "ash/focus_cycler.h" |
6 | 6 |
7 #include "ash/root_window_controller.h" | 7 #include "ash/root_window_controller.h" |
8 #include "ash/shelf/shelf.h" | 8 #include "ash/shelf/shelf.h" |
9 #include "ash/shelf/shelf_widget.h" | 9 #include "ash/shelf/shelf_widget.h" |
10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
11 #include "ash/shell_factory.h" | 11 #include "ash/shell_factory.h" |
12 #include "ash/shell_window_ids.h" | 12 #include "ash/shell_window_ids.h" |
13 #include "ash/system/status_area_widget.h" | 13 #include "ash/system/status_area_widget.h" |
14 #include "ash/system/status_area_widget_delegate.h" | 14 #include "ash/system/status_area_widget_delegate.h" |
15 #include "ash/system/tray/system_tray.h" | 15 #include "ash/system/tray/system_tray.h" |
16 #include "ash/test/ash_test_base.h" | 16 #include "ash/test/ash_test_base.h" |
17 #include "ash/wm/window_util.h" | 17 #include "ash/wm/window_util.h" |
18 #include "ui/aura/test/event_generator.h" | 18 #include "ui/aura/test/event_generator.h" |
19 #include "ui/aura/test/test_windows.h" | 19 #include "ui/aura/test/test_windows.h" |
20 #include "ui/aura/window.h" | 20 #include "ui/aura/window.h" |
21 #include "ui/aura/window_event_dispatcher.h" | 21 #include "ui/aura/window_event_dispatcher.h" |
22 #include "ui/views/accessible_pane_view.h" | 22 #include "ui/views/accessible_pane_view.h" |
23 #include "ui/views/controls/button/menu_button.h" | 23 #include "ui/views/controls/button/menu_button.h" |
24 #include "ui/views/widget/widget.h" | 24 #include "ui/views/widget/widget.h" |
25 | 25 |
26 namespace ash { | 26 namespace ash { |
27 namespace test { | 27 namespace test { |
28 | 28 |
29 using aura::Window; | 29 using aura::Window; |
30 using internal::FocusCycler; | |
31 | 30 |
32 namespace { | 31 namespace { |
33 | 32 |
34 internal::StatusAreaWidgetDelegate* GetStatusAreaWidgetDelegate( | 33 StatusAreaWidgetDelegate* GetStatusAreaWidgetDelegate(views::Widget* widget) { |
35 views::Widget* widget) { | 34 return static_cast<StatusAreaWidgetDelegate*>(widget->GetContentsView()); |
36 return static_cast<internal::StatusAreaWidgetDelegate*>( | |
37 widget->GetContentsView()); | |
38 } | 35 } |
39 | 36 |
40 class PanedWidgetDelegate : public views::WidgetDelegate { | 37 class PanedWidgetDelegate : public views::WidgetDelegate { |
41 public: | 38 public: |
42 PanedWidgetDelegate(views::Widget* widget) : widget_(widget) {} | 39 PanedWidgetDelegate(views::Widget* widget) : widget_(widget) {} |
43 | 40 |
44 void SetAccessiblePanes(const std::vector<views::View*>& panes) { | 41 void SetAccessiblePanes(const std::vector<views::View*>& panes) { |
45 accessible_panes_ = panes; | 42 accessible_panes_ = panes; |
46 } | 43 } |
47 | 44 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 focus_cycler_.reset(); | 86 focus_cycler_.reset(); |
90 | 87 |
91 AshTestBase::TearDown(); | 88 AshTestBase::TearDown(); |
92 } | 89 } |
93 | 90 |
94 protected: | 91 protected: |
95 // Creates the system tray, returning true on success. | 92 // Creates the system tray, returning true on success. |
96 bool CreateTray() { | 93 bool CreateTray() { |
97 if (tray_) | 94 if (tray_) |
98 return false; | 95 return false; |
99 aura::Window* parent = Shell::GetPrimaryRootWindowController()-> | 96 aura::Window* parent = |
100 GetContainer(ash::internal::kShellWindowId_StatusContainer); | 97 Shell::GetPrimaryRootWindowController()->GetContainer( |
| 98 ash::kShellWindowId_StatusContainer); |
101 | 99 |
102 internal::StatusAreaWidget* widget = new internal::StatusAreaWidget(parent); | 100 StatusAreaWidget* widget = new StatusAreaWidget(parent); |
103 widget->CreateTrayViews(); | 101 widget->CreateTrayViews(); |
104 widget->Show(); | 102 widget->Show(); |
105 tray_.reset(widget->system_tray()); | 103 tray_.reset(widget->system_tray()); |
106 if (!tray_->GetWidget()) | 104 if (!tray_->GetWidget()) |
107 return false; | 105 return false; |
108 focus_cycler_->AddWidget(tray()->GetWidget()); | 106 focus_cycler_->AddWidget(tray()->GetWidget()); |
109 GetStatusAreaWidgetDelegate(tray_->GetWidget())->SetFocusCyclerForTesting( | 107 GetStatusAreaWidgetDelegate(tray_->GetWidget())->SetFocusCyclerForTesting( |
110 focus_cycler()); | 108 focus_cycler()); |
111 return true; | 109 return true; |
112 } | 110 } |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 // should do the same thing. | 398 // should do the same thing. |
401 focus_cycler()->RotateFocus(FocusCycler::BACKWARD); | 399 focus_cycler()->RotateFocus(FocusCycler::BACKWARD); |
402 EXPECT_TRUE(shelf_widget()->IsActive()); | 400 EXPECT_TRUE(shelf_widget()->IsActive()); |
403 event_generator.PressKey(ui::VKEY_ESCAPE, 0); | 401 event_generator.PressKey(ui::VKEY_ESCAPE, 0); |
404 EXPECT_TRUE(wm::IsActiveWindow(browser_window)); | 402 EXPECT_TRUE(wm::IsActiveWindow(browser_window)); |
405 EXPECT_EQ(focus_manager->GetFocusedView(), view1); | 403 EXPECT_EQ(focus_manager->GetFocusedView(), view1); |
406 } | 404 } |
407 | 405 |
408 } // namespace test | 406 } // namespace test |
409 } // namespace ash | 407 } // namespace ash |
OLD | NEW |