| 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/launcher/launcher.h" | 7 #include "ash/launcher/launcher.h" |
| 8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
| 9 #include "ash/shell_window_ids.h" | 9 #include "ash/shell_window_ids.h" |
| 10 #include "ash/status_area/status_area_view.h" |
| 10 #include "ash/wm/window_util.h" | 11 #include "ash/wm/window_util.h" |
| 11 #include "ash/test/ash_test_base.h" | 12 #include "ash/test/ash_test_base.h" |
| 12 #include "ash/shell_factory.h" | 13 #include "ash/shell_factory.h" |
| 13 #include "ui/aura/test/test_windows.h" | 14 #include "ui/aura/test/test_windows.h" |
| 14 #include "ui/aura/window.h" | 15 #include "ui/aura/window.h" |
| 15 #include "ui/views/controls/button/menu_button.h" | 16 #include "ui/views/controls/button/menu_button.h" |
| 16 #include "ui/views/widget/widget.h" | 17 #include "ui/views/widget/widget.h" |
| 17 | 18 |
| 18 namespace ash { | 19 namespace ash { |
| 19 namespace test { | 20 namespace test { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 40 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); | 41 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); |
| 41 } | 42 } |
| 42 | 43 |
| 43 TEST_F(FocusCyclerTest, CycleFocusForward) { | 44 TEST_F(FocusCyclerTest, CycleFocusForward) { |
| 44 scoped_ptr<FocusCycler> focus_cycler(new FocusCycler()); | 45 scoped_ptr<FocusCycler> focus_cycler(new FocusCycler()); |
| 45 | 46 |
| 46 // Add the Status area | 47 // Add the Status area |
| 47 views::Widget* status_widget = internal::CreateStatusArea(NULL); | 48 views::Widget* status_widget = internal::CreateStatusArea(NULL); |
| 48 ASSERT_TRUE(status_widget); | 49 ASSERT_TRUE(status_widget); |
| 49 focus_cycler->AddWidget(status_widget); | 50 focus_cycler->AddWidget(status_widget); |
| 51 static_cast<internal::StatusAreaView*>(status_widget->GetContentsView())-> |
| 52 SetFocusCyclerForTesting(focus_cycler.get()); |
| 50 | 53 |
| 51 // Add a mock button to the status area. | 54 // Add a mock button to the status area. |
| 52 status_widget->GetContentsView()->AddChildView( | 55 status_widget->GetContentsView()->AddChildView( |
| 53 new views::MenuButton(NULL, string16(), NULL, false)); | 56 new views::MenuButton(NULL, string16(), NULL, false)); |
| 54 | 57 |
| 55 // Add the launcher | 58 // Add the launcher |
| 56 Launcher* launcher = Shell::GetInstance()->launcher(); | 59 Launcher* launcher = Shell::GetInstance()->launcher(); |
| 57 ASSERT_TRUE(launcher); | 60 ASSERT_TRUE(launcher); |
| 58 views::Widget* launcher_widget = launcher->widget(); | 61 views::Widget* launcher_widget = launcher->widget(); |
| 59 ASSERT_TRUE(launcher_widget); | 62 ASSERT_TRUE(launcher_widget); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 81 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); | 84 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); |
| 82 } | 85 } |
| 83 | 86 |
| 84 TEST_F(FocusCyclerTest, CycleFocusBackward) { | 87 TEST_F(FocusCyclerTest, CycleFocusBackward) { |
| 85 scoped_ptr<FocusCycler> focus_cycler(new FocusCycler()); | 88 scoped_ptr<FocusCycler> focus_cycler(new FocusCycler()); |
| 86 | 89 |
| 87 // Add the Status area | 90 // Add the Status area |
| 88 views::Widget* status_widget = internal::CreateStatusArea(NULL); | 91 views::Widget* status_widget = internal::CreateStatusArea(NULL); |
| 89 ASSERT_TRUE(status_widget); | 92 ASSERT_TRUE(status_widget); |
| 90 focus_cycler->AddWidget(status_widget); | 93 focus_cycler->AddWidget(status_widget); |
| 94 static_cast<internal::StatusAreaView*>(status_widget->GetContentsView())-> |
| 95 SetFocusCyclerForTesting(focus_cycler.get()); |
| 91 | 96 |
| 92 // Add a mock button to the status area. | 97 // Add a mock button to the status area. |
| 93 status_widget->GetContentsView()->AddChildView( | 98 status_widget->GetContentsView()->AddChildView( |
| 94 new views::MenuButton(NULL, string16(), NULL, false)); | 99 new views::MenuButton(NULL, string16(), NULL, false)); |
| 95 | 100 |
| 96 // Add the launcher | 101 // Add the launcher |
| 97 Launcher* launcher = Shell::GetInstance()->launcher(); | 102 Launcher* launcher = Shell::GetInstance()->launcher(); |
| 98 ASSERT_TRUE(launcher); | 103 ASSERT_TRUE(launcher); |
| 99 views::Widget* launcher_widget = launcher->widget(); | 104 views::Widget* launcher_widget = launcher->widget(); |
| 100 ASSERT_TRUE(launcher_widget); | 105 ASSERT_TRUE(launcher_widget); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 117 focus_cycler->RotateFocus(FocusCycler::BACKWARD); | 122 focus_cycler->RotateFocus(FocusCycler::BACKWARD); |
| 118 EXPECT_TRUE(status_widget->IsActive()); | 123 EXPECT_TRUE(status_widget->IsActive()); |
| 119 | 124 |
| 120 // Cycle focus to the browser | 125 // Cycle focus to the browser |
| 121 focus_cycler->RotateFocus(FocusCycler::BACKWARD); | 126 focus_cycler->RotateFocus(FocusCycler::BACKWARD); |
| 122 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); | 127 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); |
| 123 } | 128 } |
| 124 | 129 |
| 125 } // namespace test | 130 } // namespace test |
| 126 } // namespace ash | 131 } // namespace ash |
| OLD | NEW |