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" |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 | 245 |
246 // Cycle focus to the shelf. | 246 // Cycle focus to the shelf. |
247 focus_cycler()->RotateFocus(FocusCycler::BACKWARD); | 247 focus_cycler()->RotateFocus(FocusCycler::BACKWARD); |
248 EXPECT_TRUE(shelf_widget()->IsActive()); | 248 EXPECT_TRUE(shelf_widget()->IsActive()); |
249 | 249 |
250 // Cycle focus to the status area. | 250 // Cycle focus to the status area. |
251 focus_cycler()->RotateFocus(FocusCycler::BACKWARD); | 251 focus_cycler()->RotateFocus(FocusCycler::BACKWARD); |
252 EXPECT_TRUE(tray()->GetWidget()->IsActive()); | 252 EXPECT_TRUE(tray()->GetWidget()->IsActive()); |
253 } | 253 } |
254 | 254 |
| 255 // Tests that focus cycles from the active browser to the status area and back. |
255 TEST_F(FocusCyclerTest, Shelf_CycleFocusForward) { | 256 TEST_F(FocusCyclerTest, Shelf_CycleFocusForward) { |
256 ASSERT_TRUE(CreateTray()); | 257 ASSERT_TRUE(CreateTray()); |
257 InstallFocusCycleOnShelf(); | 258 InstallFocusCycleOnShelf(); |
258 shelf_widget()->Hide(); | 259 shelf_widget()->Hide(); |
259 | 260 |
260 // Create a single test window. | 261 // Create two test windows. |
261 scoped_ptr<Window> window0(CreateTestWindowInShellWithId(0)); | 262 scoped_ptr<Window> window0(CreateTestWindowInShellWithId(0)); |
| 263 scoped_ptr<Window> window1(CreateTestWindowInShellWithId(1)); |
| 264 wm::ActivateWindow(window1.get()); |
262 wm::ActivateWindow(window0.get()); | 265 wm::ActivateWindow(window0.get()); |
263 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); | 266 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); |
264 | 267 |
265 // Cycle focus to the status area. | 268 // Cycle focus to the status area. |
266 focus_cycler()->RotateFocus(FocusCycler::FORWARD); | 269 focus_cycler()->RotateFocus(FocusCycler::FORWARD); |
267 EXPECT_TRUE(tray()->GetWidget()->IsActive()); | 270 EXPECT_TRUE(tray()->GetWidget()->IsActive()); |
268 | 271 |
269 // Cycle focus to the browser. | 272 // Cycle focus to the browser. |
270 focus_cycler()->RotateFocus(FocusCycler::FORWARD); | 273 focus_cycler()->RotateFocus(FocusCycler::FORWARD); |
271 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); | 274 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); |
| 275 |
| 276 // Cycle focus to the status area. |
| 277 focus_cycler()->RotateFocus(FocusCycler::FORWARD); |
| 278 EXPECT_TRUE(tray()->GetWidget()->IsActive()); |
272 } | 279 } |
273 | 280 |
274 TEST_F(FocusCyclerTest, Shelf_CycleFocusBackwardInvisible) { | 281 TEST_F(FocusCyclerTest, Shelf_CycleFocusBackwardInvisible) { |
275 ASSERT_TRUE(CreateTray()); | 282 ASSERT_TRUE(CreateTray()); |
276 InstallFocusCycleOnShelf(); | 283 InstallFocusCycleOnShelf(); |
277 shelf_widget()->Hide(); | 284 shelf_widget()->Hide(); |
278 | 285 |
279 // Create a single test window. | 286 // Create a single test window. |
280 scoped_ptr<Window> window0(CreateTestWindowInShellWithId(0)); | 287 scoped_ptr<Window> window0(CreateTestWindowInShellWithId(0)); |
281 wm::ActivateWindow(window0.get()); | 288 wm::ActivateWindow(window0.get()); |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 // should do the same thing. | 400 // should do the same thing. |
394 focus_cycler()->RotateFocus(FocusCycler::BACKWARD); | 401 focus_cycler()->RotateFocus(FocusCycler::BACKWARD); |
395 EXPECT_TRUE(shelf_widget()->IsActive()); | 402 EXPECT_TRUE(shelf_widget()->IsActive()); |
396 event_generator.PressKey(ui::VKEY_ESCAPE, 0); | 403 event_generator.PressKey(ui::VKEY_ESCAPE, 0); |
397 EXPECT_TRUE(wm::IsActiveWindow(browser_window)); | 404 EXPECT_TRUE(wm::IsActiveWindow(browser_window)); |
398 EXPECT_EQ(focus_manager->GetFocusedView(), view1); | 405 EXPECT_EQ(focus_manager->GetFocusedView(), view1); |
399 } | 406 } |
400 | 407 |
401 } // namespace test | 408 } // namespace test |
402 } // namespace ash | 409 } // namespace ash |
OLD | NEW |