Chromium Code Reviews| 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/common/focus_cycler.h" | 5 #include "ash/common/focus_cycler.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "ash/common/shell_window_ids.h" | 9 #include "ash/common/shell_window_ids.h" |
|
James Cook
2016/06/24 23:04:14
nit: do you need this include?
Qiang(Joe) Xu
2016/06/24 23:34:08
Both are not needed. And "ash/common/wm_window.h"
| |
| 10 #include "ash/common/wm_root_window_controller.h" | |
|
James Cook
2016/06/24 23:04:14
nit: or this one?
| |
| 10 #include "ash/common/wm_shell.h" | 11 #include "ash/common/wm_shell.h" |
| 11 #include "ash/common/wm_window.h" | 12 #include "ash/common/wm_window.h" |
| 12 #include "ash/shelf/shelf.h" | 13 #include "ash/shelf/shelf.h" |
| 13 #include "ash/shelf/shelf_widget.h" | 14 #include "ash/shelf/shelf_widget.h" |
| 14 #include "ash/system/status_area_widget.h" | 15 #include "ash/system/status_area_widget.h" |
| 15 #include "ash/system/status_area_widget_delegate.h" | 16 #include "ash/system/status_area_widget_delegate.h" |
| 16 #include "ash/system/tray/system_tray.h" | 17 #include "ash/system/tray/system_tray.h" |
| 17 #include "ash/test/ash_test_base.h" | 18 #include "ash/test/ash_test_base.h" |
| 19 #include "ash/test/status_area_widget_test_helper.h" | |
| 18 #include "ash/wm/window_util.h" | 20 #include "ash/wm/window_util.h" |
| 19 #include "ui/aura/test/test_windows.h" | 21 #include "ui/aura/test/test_windows.h" |
| 20 #include "ui/aura/window.h" | 22 #include "ui/aura/window.h" |
| 21 #include "ui/aura/window_event_dispatcher.h" | 23 #include "ui/aura/window_event_dispatcher.h" |
| 22 #include "ui/events/test/event_generator.h" | 24 #include "ui/events/test/event_generator.h" |
| 23 #include "ui/views/accessible_pane_view.h" | 25 #include "ui/views/accessible_pane_view.h" |
| 24 #include "ui/views/controls/button/menu_button.h" | 26 #include "ui/views/controls/button/menu_button.h" |
| 25 #include "ui/views/widget/widget.h" | 27 #include "ui/views/widget/widget.h" |
| 26 | 28 |
| 27 namespace ash { | 29 namespace ash { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 67 | 69 |
| 68 void SetUp() override { | 70 void SetUp() override { |
| 69 AshTestBase::SetUp(); | 71 AshTestBase::SetUp(); |
| 70 | 72 |
| 71 focus_cycler_.reset(new FocusCycler()); | 73 focus_cycler_.reset(new FocusCycler()); |
| 72 | 74 |
| 73 ASSERT_TRUE(Shelf::ForPrimaryDisplay()); | 75 ASSERT_TRUE(Shelf::ForPrimaryDisplay()); |
| 74 } | 76 } |
| 75 | 77 |
| 76 void TearDown() override { | 78 void TearDown() override { |
| 77 if (tray_) { | 79 GetStatusAreaWidgetDelegate(GetSystemTray()->GetWidget()) |
| 78 GetStatusAreaWidgetDelegate(tray_->GetWidget())-> | 80 ->SetFocusCyclerForTesting(nullptr); |
| 79 SetFocusCyclerForTesting(NULL); | |
| 80 tray_.reset(); | |
| 81 } | |
| 82 | 81 |
| 83 shelf_widget()->SetFocusCycler(NULL); | 82 shelf_widget()->SetFocusCycler(nullptr); |
| 84 | 83 |
| 85 focus_cycler_.reset(); | 84 focus_cycler_.reset(); |
| 86 | 85 |
| 87 AshTestBase::TearDown(); | 86 AshTestBase::TearDown(); |
| 88 } | 87 } |
| 89 | 88 |
| 90 protected: | 89 protected: |
| 91 // Creates the system tray, returning true on success. | 90 // Setup the system tray using StatusAreaWidgetTestHelper and focus_cycler. |
| 92 bool CreateTray() { | 91 void SetUpTrayFocusCycle() { |
| 93 if (tray_) | 92 StatusAreaWidget* widget = |
| 94 return false; | 93 StatusAreaWidgetTestHelper::GetStatusAreaWidget(); |
| 95 WmWindow* parent = | |
| 96 WmShell::Get()->GetRootWindowForNewWindows()->GetChildByShellWindowId( | |
| 97 kShellWindowId_StatusContainer); | |
| 98 | |
| 99 StatusAreaWidget* widget = new StatusAreaWidget(parent, GetPrimaryShelf()); | |
| 100 widget->CreateTrayViews(); | 94 widget->CreateTrayViews(); |
| 101 widget->Show(); | 95 widget->Show(); |
| 102 tray_.reset(widget->system_tray()); | 96 views::Widget* system_tray_widget = GetPrimarySystemTray()->GetWidget(); |
| 103 if (!tray_->GetWidget()) | 97 ASSERT_TRUE(system_tray_widget); |
| 104 return false; | 98 focus_cycler_->AddWidget(system_tray_widget); |
| 105 focus_cycler_->AddWidget(tray()->GetWidget()); | 99 GetStatusAreaWidgetDelegate(system_tray_widget) |
| 106 GetStatusAreaWidgetDelegate(tray_->GetWidget())->SetFocusCyclerForTesting( | 100 ->SetFocusCyclerForTesting(focus_cycler()); |
| 107 focus_cycler()); | |
| 108 return true; | 101 return true; |
| 109 } | 102 } |
| 110 | 103 |
| 111 FocusCycler* focus_cycler() { return focus_cycler_.get(); } | 104 FocusCycler* focus_cycler() { return focus_cycler_.get(); } |
| 112 | 105 |
| 113 SystemTray* tray() { return tray_.get(); } | |
| 114 | |
| 115 ShelfWidget* shelf_widget() { | 106 ShelfWidget* shelf_widget() { |
| 116 return Shelf::ForPrimaryDisplay()->shelf_widget(); | 107 return Shelf::ForPrimaryDisplay()->shelf_widget(); |
| 117 } | 108 } |
| 118 | 109 |
| 119 void InstallFocusCycleOnShelf() { | 110 void InstallFocusCycleOnShelf() { |
| 120 // Add the shelf. | 111 // Add the shelf. |
| 121 shelf_widget()->SetFocusCycler(focus_cycler()); | 112 shelf_widget()->SetFocusCycler(focus_cycler()); |
| 122 } | 113 } |
| 123 | 114 |
| 124 private: | 115 private: |
| 125 std::unique_ptr<FocusCycler> focus_cycler_; | 116 std::unique_ptr<FocusCycler> focus_cycler_; |
| 126 std::unique_ptr<SystemTray> tray_; | |
| 127 | 117 |
| 128 DISALLOW_COPY_AND_ASSIGN(FocusCyclerTest); | 118 DISALLOW_COPY_AND_ASSIGN(FocusCyclerTest); |
| 129 }; | 119 }; |
| 130 | 120 |
| 131 TEST_F(FocusCyclerTest, CycleFocusBrowserOnly) { | 121 TEST_F(FocusCyclerTest, CycleFocusBrowserOnly) { |
| 132 // Create a single test window. | 122 // Create a single test window. |
| 133 std::unique_ptr<Window> window0(CreateTestWindowInShellWithId(0)); | 123 std::unique_ptr<Window> window0(CreateTestWindowInShellWithId(0)); |
| 134 wm::ActivateWindow(window0.get()); | 124 wm::ActivateWindow(window0.get()); |
| 135 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); | 125 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); |
| 136 | 126 |
| 137 // Cycle the window | 127 // Cycle the window |
| 138 focus_cycler()->RotateFocus(FocusCycler::FORWARD); | 128 focus_cycler()->RotateFocus(FocusCycler::FORWARD); |
| 139 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); | 129 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); |
| 140 } | 130 } |
| 141 | 131 |
| 142 TEST_F(FocusCyclerTest, CycleFocusForward) { | 132 TEST_F(FocusCyclerTest, CycleFocusForward) { |
| 143 ASSERT_TRUE(CreateTray()); | 133 SetUpTrayFocusCycle(); |
| 144 | 134 |
| 145 InstallFocusCycleOnShelf(); | 135 InstallFocusCycleOnShelf(); |
| 146 | 136 |
| 147 // Create a single test window. | 137 // Create a single test window. |
| 148 std::unique_ptr<Window> window0(CreateTestWindowInShellWithId(0)); | 138 std::unique_ptr<Window> window0(CreateTestWindowInShellWithId(0)); |
| 149 wm::ActivateWindow(window0.get()); | 139 wm::ActivateWindow(window0.get()); |
| 150 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); | 140 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); |
| 151 | 141 |
| 152 // Cycle focus to the status area. | 142 // Cycle focus to the status area. |
| 153 focus_cycler()->RotateFocus(FocusCycler::FORWARD); | 143 focus_cycler()->RotateFocus(FocusCycler::FORWARD); |
| 154 EXPECT_TRUE(tray()->GetWidget()->IsActive()); | 144 EXPECT_TRUE(GetPrimarySystemTray()->GetWidget()->IsActive()); |
| 155 | 145 |
| 156 // Cycle focus to the shelf. | 146 // Cycle focus to the shelf. |
| 157 focus_cycler()->RotateFocus(FocusCycler::FORWARD); | 147 focus_cycler()->RotateFocus(FocusCycler::FORWARD); |
| 158 EXPECT_TRUE(shelf_widget()->IsActive()); | 148 EXPECT_TRUE(shelf_widget()->IsActive()); |
| 159 | 149 |
| 160 // Cycle focus to the browser. | 150 // Cycle focus to the browser. |
| 161 focus_cycler()->RotateFocus(FocusCycler::FORWARD); | 151 focus_cycler()->RotateFocus(FocusCycler::FORWARD); |
| 162 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); | 152 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); |
| 163 } | 153 } |
| 164 | 154 |
| 165 TEST_F(FocusCyclerTest, CycleFocusBackward) { | 155 TEST_F(FocusCyclerTest, CycleFocusBackward) { |
| 166 ASSERT_TRUE(CreateTray()); | 156 SetUpTrayFocusCycle(); |
| 167 | 157 |
| 168 InstallFocusCycleOnShelf(); | 158 InstallFocusCycleOnShelf(); |
| 169 | 159 |
| 170 // Create a single test window. | 160 // Create a single test window. |
| 171 std::unique_ptr<Window> window0(CreateTestWindowInShellWithId(0)); | 161 std::unique_ptr<Window> window0(CreateTestWindowInShellWithId(0)); |
| 172 wm::ActivateWindow(window0.get()); | 162 wm::ActivateWindow(window0.get()); |
| 173 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); | 163 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); |
| 174 | 164 |
| 175 // Cycle focus to the shelf. | 165 // Cycle focus to the shelf. |
| 176 focus_cycler()->RotateFocus(FocusCycler::BACKWARD); | 166 focus_cycler()->RotateFocus(FocusCycler::BACKWARD); |
| 177 EXPECT_TRUE(shelf_widget()->IsActive()); | 167 EXPECT_TRUE(shelf_widget()->IsActive()); |
| 178 | 168 |
| 179 // Cycle focus to the status area. | 169 // Cycle focus to the status area. |
| 180 focus_cycler()->RotateFocus(FocusCycler::BACKWARD); | 170 focus_cycler()->RotateFocus(FocusCycler::BACKWARD); |
| 181 EXPECT_TRUE(tray()->GetWidget()->IsActive()); | 171 EXPECT_TRUE(GetPrimarySystemTray()->GetWidget()->IsActive()); |
| 182 | 172 |
| 183 // Cycle focus to the browser. | 173 // Cycle focus to the browser. |
| 184 focus_cycler()->RotateFocus(FocusCycler::BACKWARD); | 174 focus_cycler()->RotateFocus(FocusCycler::BACKWARD); |
| 185 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); | 175 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); |
| 186 } | 176 } |
| 187 | 177 |
| 188 TEST_F(FocusCyclerTest, CycleFocusForwardBackward) { | 178 TEST_F(FocusCyclerTest, CycleFocusForwardBackward) { |
| 189 ASSERT_TRUE(CreateTray()); | 179 SetUpTrayFocusCycle(); |
| 190 | 180 |
| 191 InstallFocusCycleOnShelf(); | 181 InstallFocusCycleOnShelf(); |
| 192 | 182 |
| 193 // Create a single test window. | 183 // Create a single test window. |
| 194 std::unique_ptr<Window> window0(CreateTestWindowInShellWithId(0)); | 184 std::unique_ptr<Window> window0(CreateTestWindowInShellWithId(0)); |
| 195 wm::ActivateWindow(window0.get()); | 185 wm::ActivateWindow(window0.get()); |
| 196 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); | 186 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); |
| 197 | 187 |
| 198 // Cycle focus to the shelf. | 188 // Cycle focus to the shelf. |
| 199 focus_cycler()->RotateFocus(FocusCycler::BACKWARD); | 189 focus_cycler()->RotateFocus(FocusCycler::BACKWARD); |
| 200 EXPECT_TRUE(shelf_widget()->IsActive()); | 190 EXPECT_TRUE(shelf_widget()->IsActive()); |
| 201 | 191 |
| 202 // Cycle focus to the status area. | 192 // Cycle focus to the status area. |
| 203 focus_cycler()->RotateFocus(FocusCycler::BACKWARD); | 193 focus_cycler()->RotateFocus(FocusCycler::BACKWARD); |
| 204 EXPECT_TRUE(tray()->GetWidget()->IsActive()); | 194 EXPECT_TRUE(GetPrimarySystemTray()->GetWidget()->IsActive()); |
| 205 | 195 |
| 206 // Cycle focus to the browser. | 196 // Cycle focus to the browser. |
| 207 focus_cycler()->RotateFocus(FocusCycler::BACKWARD); | 197 focus_cycler()->RotateFocus(FocusCycler::BACKWARD); |
| 208 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); | 198 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); |
| 209 | 199 |
| 210 // Cycle focus to the status area. | 200 // Cycle focus to the status area. |
| 211 focus_cycler()->RotateFocus(FocusCycler::FORWARD); | 201 focus_cycler()->RotateFocus(FocusCycler::FORWARD); |
| 212 EXPECT_TRUE(tray()->GetWidget()->IsActive()); | 202 EXPECT_TRUE(GetPrimarySystemTray()->GetWidget()->IsActive()); |
| 213 | 203 |
| 214 // Cycle focus to the shelf. | 204 // Cycle focus to the shelf. |
| 215 focus_cycler()->RotateFocus(FocusCycler::FORWARD); | 205 focus_cycler()->RotateFocus(FocusCycler::FORWARD); |
| 216 EXPECT_TRUE(shelf_widget()->IsActive()); | 206 EXPECT_TRUE(shelf_widget()->IsActive()); |
| 217 | 207 |
| 218 // Cycle focus to the browser. | 208 // Cycle focus to the browser. |
| 219 focus_cycler()->RotateFocus(FocusCycler::FORWARD); | 209 focus_cycler()->RotateFocus(FocusCycler::FORWARD); |
| 220 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); | 210 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); |
| 221 } | 211 } |
| 222 | 212 |
| 223 TEST_F(FocusCyclerTest, CycleFocusNoBrowser) { | 213 TEST_F(FocusCyclerTest, CycleFocusNoBrowser) { |
| 224 ASSERT_TRUE(CreateTray()); | 214 SetUpTrayFocusCycle(); |
| 225 | 215 |
| 226 InstallFocusCycleOnShelf(); | 216 InstallFocusCycleOnShelf(); |
| 227 | 217 |
| 228 // Add the shelf and focus it. | 218 // Add the shelf and focus it. |
| 229 focus_cycler()->FocusWidget(shelf_widget()); | 219 focus_cycler()->FocusWidget(shelf_widget()); |
| 230 | 220 |
| 231 // Cycle focus to the status area. | 221 // Cycle focus to the status area. |
| 232 focus_cycler()->RotateFocus(FocusCycler::FORWARD); | 222 focus_cycler()->RotateFocus(FocusCycler::FORWARD); |
| 233 EXPECT_TRUE(tray()->GetWidget()->IsActive()); | 223 EXPECT_TRUE(GetPrimarySystemTray()->GetWidget()->IsActive()); |
| 234 | 224 |
| 235 // Cycle focus to the shelf. | 225 // Cycle focus to the shelf. |
| 236 focus_cycler()->RotateFocus(FocusCycler::FORWARD); | 226 focus_cycler()->RotateFocus(FocusCycler::FORWARD); |
| 237 EXPECT_TRUE(shelf_widget()->IsActive()); | 227 EXPECT_TRUE(shelf_widget()->IsActive()); |
| 238 | 228 |
| 239 // Cycle focus to the status area. | 229 // Cycle focus to the status area. |
| 240 focus_cycler()->RotateFocus(FocusCycler::FORWARD); | 230 focus_cycler()->RotateFocus(FocusCycler::FORWARD); |
| 241 EXPECT_TRUE(tray()->GetWidget()->IsActive()); | 231 EXPECT_TRUE(GetPrimarySystemTray()->GetWidget()->IsActive()); |
| 242 | 232 |
| 243 // Cycle focus to the shelf. | 233 // Cycle focus to the shelf. |
| 244 focus_cycler()->RotateFocus(FocusCycler::BACKWARD); | 234 focus_cycler()->RotateFocus(FocusCycler::BACKWARD); |
| 245 EXPECT_TRUE(shelf_widget()->IsActive()); | 235 EXPECT_TRUE(shelf_widget()->IsActive()); |
| 246 | 236 |
| 247 // Cycle focus to the status area. | 237 // Cycle focus to the status area. |
| 248 focus_cycler()->RotateFocus(FocusCycler::BACKWARD); | 238 focus_cycler()->RotateFocus(FocusCycler::BACKWARD); |
| 249 EXPECT_TRUE(tray()->GetWidget()->IsActive()); | 239 EXPECT_TRUE(GetPrimarySystemTray()->GetWidget()->IsActive()); |
| 250 } | 240 } |
| 251 | 241 |
| 252 // Tests that focus cycles from the active browser to the status area and back. | 242 // Tests that focus cycles from the active browser to the status area and back. |
| 253 TEST_F(FocusCyclerTest, Shelf_CycleFocusForward) { | 243 TEST_F(FocusCyclerTest, Shelf_CycleFocusForward) { |
| 254 ASSERT_TRUE(CreateTray()); | 244 SetUpTrayFocusCycle(); |
| 255 InstallFocusCycleOnShelf(); | 245 InstallFocusCycleOnShelf(); |
| 256 shelf_widget()->Hide(); | 246 shelf_widget()->Hide(); |
| 257 | 247 |
| 258 // Create two test windows. | 248 // Create two test windows. |
| 259 std::unique_ptr<Window> window0(CreateTestWindowInShellWithId(0)); | 249 std::unique_ptr<Window> window0(CreateTestWindowInShellWithId(0)); |
| 260 std::unique_ptr<Window> window1(CreateTestWindowInShellWithId(1)); | 250 std::unique_ptr<Window> window1(CreateTestWindowInShellWithId(1)); |
| 261 wm::ActivateWindow(window1.get()); | 251 wm::ActivateWindow(window1.get()); |
| 262 wm::ActivateWindow(window0.get()); | 252 wm::ActivateWindow(window0.get()); |
| 263 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); | 253 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); |
| 264 | 254 |
| 265 // Cycle focus to the status area. | 255 // Cycle focus to the status area. |
| 266 focus_cycler()->RotateFocus(FocusCycler::FORWARD); | 256 focus_cycler()->RotateFocus(FocusCycler::FORWARD); |
| 267 EXPECT_TRUE(tray()->GetWidget()->IsActive()); | 257 EXPECT_TRUE(GetPrimarySystemTray()->GetWidget()->IsActive()); |
| 268 | 258 |
| 269 // Cycle focus to the browser. | 259 // Cycle focus to the browser. |
| 270 focus_cycler()->RotateFocus(FocusCycler::FORWARD); | 260 focus_cycler()->RotateFocus(FocusCycler::FORWARD); |
| 271 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); | 261 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); |
| 272 | 262 |
| 273 // Cycle focus to the status area. | 263 // Cycle focus to the status area. |
| 274 focus_cycler()->RotateFocus(FocusCycler::FORWARD); | 264 focus_cycler()->RotateFocus(FocusCycler::FORWARD); |
| 275 EXPECT_TRUE(tray()->GetWidget()->IsActive()); | 265 EXPECT_TRUE(GetPrimarySystemTray()->GetWidget()->IsActive()); |
| 276 } | 266 } |
| 277 | 267 |
| 278 TEST_F(FocusCyclerTest, Shelf_CycleFocusBackwardInvisible) { | 268 TEST_F(FocusCyclerTest, Shelf_CycleFocusBackwardInvisible) { |
| 279 ASSERT_TRUE(CreateTray()); | 269 SetUpTrayFocusCycle(); |
| 280 InstallFocusCycleOnShelf(); | 270 InstallFocusCycleOnShelf(); |
| 281 shelf_widget()->Hide(); | 271 shelf_widget()->Hide(); |
| 282 | 272 |
| 283 // Create a single test window. | 273 // Create a single test window. |
| 284 std::unique_ptr<Window> window0(CreateTestWindowInShellWithId(0)); | 274 std::unique_ptr<Window> window0(CreateTestWindowInShellWithId(0)); |
| 285 wm::ActivateWindow(window0.get()); | 275 wm::ActivateWindow(window0.get()); |
| 286 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); | 276 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); |
| 287 | 277 |
| 288 // Cycle focus to the status area. | 278 // Cycle focus to the status area. |
| 289 focus_cycler()->RotateFocus(FocusCycler::BACKWARD); | 279 focus_cycler()->RotateFocus(FocusCycler::BACKWARD); |
| 290 EXPECT_TRUE(tray()->GetWidget()->IsActive()); | 280 EXPECT_TRUE(GetPrimarySystemTray()->GetWidget()->IsActive()); |
| 291 | 281 |
| 292 // Cycle focus to the browser. | 282 // Cycle focus to the browser. |
| 293 focus_cycler()->RotateFocus(FocusCycler::BACKWARD); | 283 focus_cycler()->RotateFocus(FocusCycler::BACKWARD); |
| 294 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); | 284 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); |
| 295 } | 285 } |
| 296 | 286 |
| 297 TEST_F(FocusCyclerTest, CycleFocusThroughWindowWithPanes) { | 287 TEST_F(FocusCyclerTest, CycleFocusThroughWindowWithPanes) { |
| 298 ASSERT_TRUE(CreateTray()); | 288 SetUpTrayFocusCycle(); |
| 299 | 289 |
| 300 InstallFocusCycleOnShelf(); | 290 InstallFocusCycleOnShelf(); |
| 301 | 291 |
| 302 std::unique_ptr<PanedWidgetDelegate> test_widget_delegate; | 292 std::unique_ptr<PanedWidgetDelegate> test_widget_delegate; |
| 303 std::unique_ptr<views::Widget> browser_widget(new views::Widget); | 293 std::unique_ptr<views::Widget> browser_widget(new views::Widget); |
| 304 test_widget_delegate.reset(new PanedWidgetDelegate(browser_widget.get())); | 294 test_widget_delegate.reset(new PanedWidgetDelegate(browser_widget.get())); |
| 305 views::Widget::InitParams widget_params( | 295 views::Widget::InitParams widget_params( |
| 306 views::Widget::InitParams::TYPE_WINDOW); | 296 views::Widget::InitParams::TYPE_WINDOW); |
| 307 widget_params.context = CurrentContext(); | 297 widget_params.context = CurrentContext(); |
| 308 widget_params.delegate = test_widget_delegate.get(); | 298 widget_params.delegate = test_widget_delegate.get(); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 340 std::vector<views::View*> panes; | 330 std::vector<views::View*> panes; |
| 341 panes.push_back(pane1); | 331 panes.push_back(pane1); |
| 342 panes.push_back(pane2); | 332 panes.push_back(pane2); |
| 343 | 333 |
| 344 test_widget_delegate->SetAccessiblePanes(panes); | 334 test_widget_delegate->SetAccessiblePanes(panes); |
| 345 | 335 |
| 346 views::FocusManager* focus_manager = browser_widget->GetFocusManager(); | 336 views::FocusManager* focus_manager = browser_widget->GetFocusManager(); |
| 347 | 337 |
| 348 // Cycle focus to the status area. | 338 // Cycle focus to the status area. |
| 349 focus_cycler()->RotateFocus(FocusCycler::FORWARD); | 339 focus_cycler()->RotateFocus(FocusCycler::FORWARD); |
| 350 EXPECT_TRUE(tray()->GetWidget()->IsActive()); | 340 EXPECT_TRUE(GetPrimarySystemTray()->GetWidget()->IsActive()); |
| 351 | 341 |
| 352 // Cycle focus to the shelf. | 342 // Cycle focus to the shelf. |
| 353 focus_cycler()->RotateFocus(FocusCycler::FORWARD); | 343 focus_cycler()->RotateFocus(FocusCycler::FORWARD); |
| 354 EXPECT_TRUE(shelf_widget()->IsActive()); | 344 EXPECT_TRUE(shelf_widget()->IsActive()); |
| 355 | 345 |
| 356 // Cycle focus to the first pane in the browser. | 346 // Cycle focus to the first pane in the browser. |
| 357 focus_cycler()->RotateFocus(FocusCycler::FORWARD); | 347 focus_cycler()->RotateFocus(FocusCycler::FORWARD); |
| 358 EXPECT_TRUE(wm::IsActiveWindow(browser_window)); | 348 EXPECT_TRUE(wm::IsActiveWindow(browser_window)); |
| 359 EXPECT_EQ(focus_manager->GetFocusedView(), view1); | 349 EXPECT_EQ(focus_manager->GetFocusedView(), view1); |
| 360 | 350 |
| 361 // Cycle focus to the second pane in the browser. | 351 // Cycle focus to the second pane in the browser. |
| 362 focus_cycler()->RotateFocus(FocusCycler::FORWARD); | 352 focus_cycler()->RotateFocus(FocusCycler::FORWARD); |
| 363 EXPECT_TRUE(wm::IsActiveWindow(browser_window)); | 353 EXPECT_TRUE(wm::IsActiveWindow(browser_window)); |
| 364 EXPECT_EQ(focus_manager->GetFocusedView(), view3); | 354 EXPECT_EQ(focus_manager->GetFocusedView(), view3); |
| 365 | 355 |
| 366 // Cycle focus back to the status area. | 356 // Cycle focus back to the status area. |
| 367 focus_cycler()->RotateFocus(FocusCycler::FORWARD); | 357 focus_cycler()->RotateFocus(FocusCycler::FORWARD); |
| 368 EXPECT_TRUE(tray()->GetWidget()->IsActive()); | 358 EXPECT_TRUE(GetPrimarySystemTray()->GetWidget()->IsActive()); |
| 369 | 359 |
| 370 // Reverse direction - back to the second pane in the browser. | 360 // Reverse direction - back to the second pane in the browser. |
| 371 focus_cycler()->RotateFocus(FocusCycler::BACKWARD); | 361 focus_cycler()->RotateFocus(FocusCycler::BACKWARD); |
| 372 EXPECT_TRUE(wm::IsActiveWindow(browser_window)); | 362 EXPECT_TRUE(wm::IsActiveWindow(browser_window)); |
| 373 EXPECT_EQ(focus_manager->GetFocusedView(), view3); | 363 EXPECT_EQ(focus_manager->GetFocusedView(), view3); |
| 374 | 364 |
| 375 // Back to the first pane in the browser. | 365 // Back to the first pane in the browser. |
| 376 focus_cycler()->RotateFocus(FocusCycler::BACKWARD); | 366 focus_cycler()->RotateFocus(FocusCycler::BACKWARD); |
| 377 EXPECT_TRUE(wm::IsActiveWindow(browser_window)); | 367 EXPECT_TRUE(wm::IsActiveWindow(browser_window)); |
| 378 EXPECT_EQ(focus_manager->GetFocusedView(), view1); | 368 EXPECT_EQ(focus_manager->GetFocusedView(), view1); |
| 379 | 369 |
| 380 // Back to the shelf. | 370 // Back to the shelf. |
| 381 focus_cycler()->RotateFocus(FocusCycler::BACKWARD); | 371 focus_cycler()->RotateFocus(FocusCycler::BACKWARD); |
| 382 EXPECT_TRUE(shelf_widget()->IsActive()); | 372 EXPECT_TRUE(shelf_widget()->IsActive()); |
| 383 | 373 |
| 384 // Back to the status area. | 374 // Back to the status area. |
| 385 focus_cycler()->RotateFocus(FocusCycler::BACKWARD); | 375 focus_cycler()->RotateFocus(FocusCycler::BACKWARD); |
| 386 EXPECT_TRUE(tray()->GetWidget()->IsActive()); | 376 EXPECT_TRUE(GetPrimarySystemTray()->GetWidget()->IsActive()); |
| 387 | 377 |
| 388 // Pressing "Escape" while on the status area should | 378 // Pressing "Escape" while on the status area should |
| 389 // deactivate it, and activate the browser window. | 379 // deactivate it, and activate the browser window. |
| 390 ui::test::EventGenerator& event_generator = GetEventGenerator(); | 380 ui::test::EventGenerator& event_generator = GetEventGenerator(); |
| 391 event_generator.PressKey(ui::VKEY_ESCAPE, 0); | 381 event_generator.PressKey(ui::VKEY_ESCAPE, 0); |
| 392 EXPECT_TRUE(wm::IsActiveWindow(browser_window)); | 382 EXPECT_TRUE(wm::IsActiveWindow(browser_window)); |
| 393 EXPECT_EQ(focus_manager->GetFocusedView(), view1); | 383 EXPECT_EQ(focus_manager->GetFocusedView(), view1); |
| 394 | 384 |
| 395 // Similarly, pressing "Escape" while on the shelf. | 385 // Similarly, pressing "Escape" while on the shelf. |
| 396 // should do the same thing. | 386 // should do the same thing. |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 423 // Cycle focus to the shelf. | 413 // Cycle focus to the shelf. |
| 424 WmShell::Get()->focus_cycler()->RotateFocus(FocusCycler::FORWARD); | 414 WmShell::Get()->focus_cycler()->RotateFocus(FocusCycler::FORWARD); |
| 425 | 415 |
| 426 // Cycle focus should go back to the browser. | 416 // Cycle focus should go back to the browser. |
| 427 WmShell::Get()->focus_cycler()->RotateFocus(FocusCycler::FORWARD); | 417 WmShell::Get()->focus_cycler()->RotateFocus(FocusCycler::FORWARD); |
| 428 EXPECT_TRUE(wm::IsActiveWindow(window.get())); | 418 EXPECT_TRUE(wm::IsActiveWindow(window.get())); |
| 429 } | 419 } |
| 430 | 420 |
| 431 } // namespace test | 421 } // namespace test |
| 432 } // namespace ash | 422 } // namespace ash |
| OLD | NEW |