blob: 74569d300016bee6579f679ece343893af9cf4ba [file] [log] [blame]
[email protected]df1c9862012-02-27 10:37:311// 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
3// found in the LICENSE file.
4
5#include "ash/focus_cycler.h"
6
[email protected]16059276d2012-10-22 18:59:507#include "ash/root_window_controller.h"
[email protected]864b58552013-12-19 04:19:388#include "ash/shelf/shelf.h"
[email protected]478c6c32013-03-09 02:50:589#include "ash/shelf/shelf_widget.h"
[email protected]df1c9862012-02-27 10:37:3110#include "ash/shell.h"
[email protected]864b58552013-12-19 04:19:3811#include "ash/shell_factory.h"
[email protected]df1c9862012-02-27 10:37:3112#include "ash/shell_window_ids.h"
[email protected]6d6546e2012-05-30 23:12:0213#include "ash/system/status_area_widget.h"
14#include "ash/system/status_area_widget_delegate.h"
[email protected]860f5942012-04-24 16:11:3915#include "ash/system/tray/system_tray.h"
[email protected]df1c9862012-02-27 10:37:3116#include "ash/test/ash_test_base.h"
[email protected]864b58552013-12-19 04:19:3817#include "ash/wm/window_util.h"
[email protected]df1c9862012-02-27 10:37:3118#include "ui/aura/test/test_windows.h"
19#include "ui/aura/window.h"
[email protected]fcc51c952014-02-21 21:31:2620#include "ui/aura/window_event_dispatcher.h"
[email protected]73c9fd02014-07-28 01:48:5221#include "ui/events/test/event_generator.h"
[email protected]242aa4f2013-04-30 01:04:0822#include "ui/views/accessible_pane_view.h"
[email protected]df1c9862012-02-27 10:37:3123#include "ui/views/controls/button/menu_button.h"
24#include "ui/views/widget/widget.h"
25
26namespace ash {
27namespace test {
28
[email protected]df1c9862012-02-27 10:37:3129using aura::Window;
[email protected]df1c9862012-02-27 10:37:3130
[email protected]8676f0472012-03-29 20:30:1231namespace {
32
[email protected]093b8d642014-04-03 20:59:2833StatusAreaWidgetDelegate* GetStatusAreaWidgetDelegate(views::Widget* widget) {
34 return static_cast<StatusAreaWidgetDelegate*>(widget->GetContentsView());
[email protected]8676f0472012-03-29 20:30:1235}
36
[email protected]242aa4f2013-04-30 01:04:0837class PanedWidgetDelegate : public views::WidgetDelegate {
38 public:
39 PanedWidgetDelegate(views::Widget* widget) : widget_(widget) {}
40
41 void SetAccessiblePanes(const std::vector<views::View*>& panes) {
42 accessible_panes_ = panes;
43 }
44
45 // views::WidgetDelegate.
[email protected]8020c932013-05-07 06:24:2746 virtual void GetAccessiblePanes(std::vector<views::View*>* panes) OVERRIDE {
47 std::copy(accessible_panes_.begin(),
48 accessible_panes_.end(),
[email protected]242aa4f2013-04-30 01:04:0849 std::back_inserter(*panes));
50 }
51 virtual views::Widget* GetWidget() OVERRIDE {
52 return widget_;
53 };
54 virtual const views::Widget* GetWidget() const OVERRIDE {
55 return widget_;
56 }
57
58 private:
59 views::Widget* widget_;
60 std::vector<views::View*> accessible_panes_;
61};
62
[email protected]8676f0472012-03-29 20:30:1263} // namespace
64
[email protected]eb5a0ab2012-10-20 00:50:2565class FocusCyclerTest : public AshTestBase {
66 public:
67 FocusCyclerTest() {}
[email protected]df1c9862012-02-27 10:37:3168
[email protected]eb5a0ab2012-10-20 00:50:2569 virtual void SetUp() OVERRIDE {
70 AshTestBase::SetUp();
[email protected]df1c9862012-02-27 10:37:3171
[email protected]eb5a0ab2012-10-20 00:50:2572 focus_cycler_.reset(new FocusCycler());
73
[email protected]864b58552013-12-19 04:19:3874 ASSERT_TRUE(Shelf::ForPrimaryDisplay());
[email protected]eb5a0ab2012-10-20 00:50:2575 }
76
77 virtual void TearDown() OVERRIDE {
[email protected]7f7f65c2013-04-17 16:47:1378 if (tray_) {
[email protected]eb5a0ab2012-10-20 00:50:2579 GetStatusAreaWidgetDelegate(tray_->GetWidget())->
80 SetFocusCyclerForTesting(NULL);
81 tray_.reset();
82 }
83
[email protected]478c6c32013-03-09 02:50:5884 shelf_widget()->SetFocusCycler(NULL);
[email protected]eb5a0ab2012-10-20 00:50:2585
86 focus_cycler_.reset();
87
88 AshTestBase::TearDown();
89 }
90
91 protected:
92 // Creates the system tray, returning true on success.
93 bool CreateTray() {
[email protected]7f7f65c2013-04-17 16:47:1394 if (tray_)
[email protected]eb5a0ab2012-10-20 00:50:2595 return false;
[email protected]093b8d642014-04-03 20:59:2896 aura::Window* parent =
97 Shell::GetPrimaryRootWindowController()->GetContainer(
98 ash::kShellWindowId_StatusContainer);
[email protected]16059276d2012-10-22 18:59:5099
[email protected]093b8d642014-04-03 20:59:28100 StatusAreaWidget* widget = new StatusAreaWidget(parent);
[email protected]51ed5992012-11-07 10:14:39101 widget->CreateTrayViews();
[email protected]eb5a0ab2012-10-20 00:50:25102 widget->Show();
103 tray_.reset(widget->system_tray());
104 if (!tray_->GetWidget())
105 return false;
106 focus_cycler_->AddWidget(tray()->GetWidget());
107 GetStatusAreaWidgetDelegate(tray_->GetWidget())->SetFocusCyclerForTesting(
108 focus_cycler());
109 return true;
110 }
111
112 FocusCycler* focus_cycler() { return focus_cycler_.get(); }
113
114 SystemTray* tray() { return tray_.get(); }
115
[email protected]478c6c32013-03-09 02:50:58116 ShelfWidget* shelf_widget() {
[email protected]864b58552013-12-19 04:19:38117 return Shelf::ForPrimaryDisplay()->shelf_widget();
[email protected]eb5a0ab2012-10-20 00:50:25118 }
119
[email protected]478c6c32013-03-09 02:50:58120 void InstallFocusCycleOnShelf() {
121 // Add the shelf.
122 shelf_widget()->SetFocusCycler(focus_cycler());
[email protected]eb5a0ab2012-10-20 00:50:25123 }
124
125 private:
126 scoped_ptr<FocusCycler> focus_cycler_;
127 scoped_ptr<SystemTray> tray_;
128
129 DISALLOW_COPY_AND_ASSIGN(FocusCyclerTest);
130};
131
132TEST_F(FocusCyclerTest, CycleFocusBrowserOnly) {
[email protected]df1c9862012-02-27 10:37:31133 // Create a single test window.
[email protected]5ebe6102012-11-28 21:00:03134 scoped_ptr<Window> window0(CreateTestWindowInShellWithId(0));
[email protected]f3c7b252012-02-27 12:17:54135 wm::ActivateWindow(window0.get());
136 EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
[email protected]df1c9862012-02-27 10:37:31137
138 // Cycle the window
[email protected]eb5a0ab2012-10-20 00:50:25139 focus_cycler()->RotateFocus(FocusCycler::FORWARD);
[email protected]f3c7b252012-02-27 12:17:54140 EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
[email protected]df1c9862012-02-27 10:37:31141}
142
[email protected]eb5a0ab2012-10-20 00:50:25143TEST_F(FocusCyclerTest, CycleFocusForward) {
144 ASSERT_TRUE(CreateTray());
[email protected]df1c9862012-02-27 10:37:31145
[email protected]478c6c32013-03-09 02:50:58146 InstallFocusCycleOnShelf();
[email protected]df1c9862012-02-27 10:37:31147
148 // Create a single test window.
[email protected]5ebe6102012-11-28 21:00:03149 scoped_ptr<Window> window0(CreateTestWindowInShellWithId(0));
[email protected]f3c7b252012-02-27 12:17:54150 wm::ActivateWindow(window0.get());
151 EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
[email protected]df1c9862012-02-27 10:37:31152
[email protected]478c6c32013-03-09 02:50:58153 // Cycle focus to the status area.
[email protected]eb5a0ab2012-10-20 00:50:25154 focus_cycler()->RotateFocus(FocusCycler::FORWARD);
155 EXPECT_TRUE(tray()->GetWidget()->IsActive());
[email protected]df1c9862012-02-27 10:37:31156
[email protected]478c6c32013-03-09 02:50:58157 // Cycle focus to the shelf.
[email protected]eb5a0ab2012-10-20 00:50:25158 focus_cycler()->RotateFocus(FocusCycler::FORWARD);
[email protected]478c6c32013-03-09 02:50:58159 EXPECT_TRUE(shelf_widget()->IsActive());
[email protected]df1c9862012-02-27 10:37:31160
[email protected]478c6c32013-03-09 02:50:58161 // Cycle focus to the browser.
[email protected]eb5a0ab2012-10-20 00:50:25162 focus_cycler()->RotateFocus(FocusCycler::FORWARD);
[email protected]f3c7b252012-02-27 12:17:54163 EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
[email protected]df1c9862012-02-27 10:37:31164}
165
[email protected]eb5a0ab2012-10-20 00:50:25166TEST_F(FocusCyclerTest, CycleFocusBackward) {
167 ASSERT_TRUE(CreateTray());
[email protected]df1c9862012-02-27 10:37:31168
[email protected]478c6c32013-03-09 02:50:58169 InstallFocusCycleOnShelf();
[email protected]df1c9862012-02-27 10:37:31170
171 // Create a single test window.
[email protected]5ebe6102012-11-28 21:00:03172 scoped_ptr<Window> window0(CreateTestWindowInShellWithId(0));
[email protected]f3c7b252012-02-27 12:17:54173 wm::ActivateWindow(window0.get());
174 EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
[email protected]df1c9862012-02-27 10:37:31175
[email protected]478c6c32013-03-09 02:50:58176 // Cycle focus to the shelf.
[email protected]eb5a0ab2012-10-20 00:50:25177 focus_cycler()->RotateFocus(FocusCycler::BACKWARD);
[email protected]478c6c32013-03-09 02:50:58178 EXPECT_TRUE(shelf_widget()->IsActive());
[email protected]df1c9862012-02-27 10:37:31179
[email protected]478c6c32013-03-09 02:50:58180 // Cycle focus to the status area.
[email protected]eb5a0ab2012-10-20 00:50:25181 focus_cycler()->RotateFocus(FocusCycler::BACKWARD);
182 EXPECT_TRUE(tray()->GetWidget()->IsActive());
[email protected]df1c9862012-02-27 10:37:31183
[email protected]478c6c32013-03-09 02:50:58184 // Cycle focus to the browser.
[email protected]eb5a0ab2012-10-20 00:50:25185 focus_cycler()->RotateFocus(FocusCycler::BACKWARD);
[email protected]f3c7b252012-02-27 12:17:54186 EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
[email protected]df1c9862012-02-27 10:37:31187}
188
[email protected]eb5a0ab2012-10-20 00:50:25189TEST_F(FocusCyclerTest, CycleFocusForwardBackward) {
190 ASSERT_TRUE(CreateTray());
[email protected]ce711ac2012-06-14 07:05:41191
[email protected]478c6c32013-03-09 02:50:58192 InstallFocusCycleOnShelf();
[email protected]ce711ac2012-06-14 07:05:41193
194 // Create a single test window.
[email protected]5ebe6102012-11-28 21:00:03195 scoped_ptr<Window> window0(CreateTestWindowInShellWithId(0));
[email protected]ce711ac2012-06-14 07:05:41196 wm::ActivateWindow(window0.get());
197 EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
198
[email protected]478c6c32013-03-09 02:50:58199 // Cycle focus to the shelf.
[email protected]eb5a0ab2012-10-20 00:50:25200 focus_cycler()->RotateFocus(FocusCycler::BACKWARD);
[email protected]478c6c32013-03-09 02:50:58201 EXPECT_TRUE(shelf_widget()->IsActive());
[email protected]ce711ac2012-06-14 07:05:41202
[email protected]478c6c32013-03-09 02:50:58203 // Cycle focus to the status area.
[email protected]eb5a0ab2012-10-20 00:50:25204 focus_cycler()->RotateFocus(FocusCycler::BACKWARD);
205 EXPECT_TRUE(tray()->GetWidget()->IsActive());
[email protected]ce711ac2012-06-14 07:05:41206
[email protected]478c6c32013-03-09 02:50:58207 // Cycle focus to the browser.
[email protected]eb5a0ab2012-10-20 00:50:25208 focus_cycler()->RotateFocus(FocusCycler::BACKWARD);
[email protected]ce711ac2012-06-14 07:05:41209 EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
210
[email protected]478c6c32013-03-09 02:50:58211 // Cycle focus to the status area.
[email protected]eb5a0ab2012-10-20 00:50:25212 focus_cycler()->RotateFocus(FocusCycler::FORWARD);
213 EXPECT_TRUE(tray()->GetWidget()->IsActive());
[email protected]ce711ac2012-06-14 07:05:41214
[email protected]478c6c32013-03-09 02:50:58215 // Cycle focus to the shelf.
[email protected]eb5a0ab2012-10-20 00:50:25216 focus_cycler()->RotateFocus(FocusCycler::FORWARD);
[email protected]478c6c32013-03-09 02:50:58217 EXPECT_TRUE(shelf_widget()->IsActive());
[email protected]ce711ac2012-06-14 07:05:41218
[email protected]478c6c32013-03-09 02:50:58219 // Cycle focus to the browser.
[email protected]eb5a0ab2012-10-20 00:50:25220 focus_cycler()->RotateFocus(FocusCycler::FORWARD);
[email protected]ce711ac2012-06-14 07:05:41221 EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
222}
223
[email protected]eb5a0ab2012-10-20 00:50:25224TEST_F(FocusCyclerTest, CycleFocusNoBrowser) {
225 ASSERT_TRUE(CreateTray());
[email protected]ce711ac2012-06-14 07:05:41226
[email protected]478c6c32013-03-09 02:50:58227 InstallFocusCycleOnShelf();
[email protected]ce711ac2012-06-14 07:05:41228
[email protected]478c6c32013-03-09 02:50:58229 // Add the shelf and focus it.
230 focus_cycler()->FocusWidget(shelf_widget());
[email protected]ce711ac2012-06-14 07:05:41231
[email protected]478c6c32013-03-09 02:50:58232 // Cycle focus to the status area.
[email protected]eb5a0ab2012-10-20 00:50:25233 focus_cycler()->RotateFocus(FocusCycler::FORWARD);
234 EXPECT_TRUE(tray()->GetWidget()->IsActive());
[email protected]ce711ac2012-06-14 07:05:41235
[email protected]478c6c32013-03-09 02:50:58236 // Cycle focus to the shelf.
[email protected]eb5a0ab2012-10-20 00:50:25237 focus_cycler()->RotateFocus(FocusCycler::FORWARD);
[email protected]478c6c32013-03-09 02:50:58238 EXPECT_TRUE(shelf_widget()->IsActive());
[email protected]ce711ac2012-06-14 07:05:41239
[email protected]478c6c32013-03-09 02:50:58240 // Cycle focus to the status area.
[email protected]eb5a0ab2012-10-20 00:50:25241 focus_cycler()->RotateFocus(FocusCycler::FORWARD);
242 EXPECT_TRUE(tray()->GetWidget()->IsActive());
[email protected]ce711ac2012-06-14 07:05:41243
[email protected]478c6c32013-03-09 02:50:58244 // Cycle focus to the shelf.
[email protected]eb5a0ab2012-10-20 00:50:25245 focus_cycler()->RotateFocus(FocusCycler::BACKWARD);
[email protected]478c6c32013-03-09 02:50:58246 EXPECT_TRUE(shelf_widget()->IsActive());
[email protected]ce711ac2012-06-14 07:05:41247
[email protected]478c6c32013-03-09 02:50:58248 // Cycle focus to the status area.
[email protected]eb5a0ab2012-10-20 00:50:25249 focus_cycler()->RotateFocus(FocusCycler::BACKWARD);
250 EXPECT_TRUE(tray()->GetWidget()->IsActive());
[email protected]ce711ac2012-06-14 07:05:41251}
252
[email protected]fba1eb22014-03-12 21:12:50253// Tests that focus cycles from the active browser to the status area and back.
[email protected]478c6c32013-03-09 02:50:58254TEST_F(FocusCyclerTest, Shelf_CycleFocusForward) {
[email protected]eb5a0ab2012-10-20 00:50:25255 ASSERT_TRUE(CreateTray());
[email protected]478c6c32013-03-09 02:50:58256 InstallFocusCycleOnShelf();
257 shelf_widget()->Hide();
[email protected]057dc5752012-03-06 23:59:31258
[email protected]fba1eb22014-03-12 21:12:50259 // Create two test windows.
[email protected]5ebe6102012-11-28 21:00:03260 scoped_ptr<Window> window0(CreateTestWindowInShellWithId(0));
[email protected]fba1eb22014-03-12 21:12:50261 scoped_ptr<Window> window1(CreateTestWindowInShellWithId(1));
262 wm::ActivateWindow(window1.get());
[email protected]057dc5752012-03-06 23:59:31263 wm::ActivateWindow(window0.get());
264 EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
265
[email protected]478c6c32013-03-09 02:50:58266 // Cycle focus to the status area.
[email protected]eb5a0ab2012-10-20 00:50:25267 focus_cycler()->RotateFocus(FocusCycler::FORWARD);
268 EXPECT_TRUE(tray()->GetWidget()->IsActive());
[email protected]057dc5752012-03-06 23:59:31269
[email protected]478c6c32013-03-09 02:50:58270 // Cycle focus to the browser.
[email protected]eb5a0ab2012-10-20 00:50:25271 focus_cycler()->RotateFocus(FocusCycler::FORWARD);
[email protected]057dc5752012-03-06 23:59:31272 EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
[email protected]fba1eb22014-03-12 21:12:50273
274 // Cycle focus to the status area.
275 focus_cycler()->RotateFocus(FocusCycler::FORWARD);
276 EXPECT_TRUE(tray()->GetWidget()->IsActive());
[email protected]057dc5752012-03-06 23:59:31277}
278
[email protected]478c6c32013-03-09 02:50:58279TEST_F(FocusCyclerTest, Shelf_CycleFocusBackwardInvisible) {
[email protected]eb5a0ab2012-10-20 00:50:25280 ASSERT_TRUE(CreateTray());
[email protected]478c6c32013-03-09 02:50:58281 InstallFocusCycleOnShelf();
282 shelf_widget()->Hide();
[email protected]057dc5752012-03-06 23:59:31283
284 // Create a single test window.
[email protected]5ebe6102012-11-28 21:00:03285 scoped_ptr<Window> window0(CreateTestWindowInShellWithId(0));
[email protected]057dc5752012-03-06 23:59:31286 wm::ActivateWindow(window0.get());
287 EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
288
[email protected]478c6c32013-03-09 02:50:58289 // Cycle focus to the status area.
[email protected]eb5a0ab2012-10-20 00:50:25290 focus_cycler()->RotateFocus(FocusCycler::BACKWARD);
291 EXPECT_TRUE(tray()->GetWidget()->IsActive());
[email protected]057dc5752012-03-06 23:59:31292
[email protected]478c6c32013-03-09 02:50:58293 // Cycle focus to the browser.
[email protected]eb5a0ab2012-10-20 00:50:25294 focus_cycler()->RotateFocus(FocusCycler::BACKWARD);
[email protected]057dc5752012-03-06 23:59:31295 EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
296}
297
[email protected]242aa4f2013-04-30 01:04:08298TEST_F(FocusCyclerTest, CycleFocusThroughWindowWithPanes) {
299 ASSERT_TRUE(CreateTray());
300
301 InstallFocusCycleOnShelf();
302
[email protected]464a0012013-11-12 18:22:44303 scoped_ptr<PanedWidgetDelegate> test_widget_delegate;
[email protected]242aa4f2013-04-30 01:04:08304 scoped_ptr<views::Widget> browser_widget(new views::Widget);
[email protected]464a0012013-11-12 18:22:44305 test_widget_delegate.reset(new PanedWidgetDelegate(browser_widget.get()));
[email protected]242aa4f2013-04-30 01:04:08306 views::Widget::InitParams widget_params(
307 views::Widget::InitParams::TYPE_WINDOW);
308 widget_params.context = CurrentContext();
[email protected]464a0012013-11-12 18:22:44309 widget_params.delegate = test_widget_delegate.get();
[email protected]242aa4f2013-04-30 01:04:08310 widget_params.ownership =
311 views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
312 browser_widget->Init(widget_params);
313 browser_widget->Show();
314
315 aura::Window* browser_window = browser_widget->GetNativeView();
316
317 views::View* root_view = browser_widget->GetRootView();
318
319 views::AccessiblePaneView* pane1 = new views::AccessiblePaneView();
320 root_view->AddChildView(pane1);
321
322 views::View* view1 = new views::View;
[email protected]505df7b2013-12-16 14:07:19323 view1->SetFocusable(true);
[email protected]242aa4f2013-04-30 01:04:08324 pane1->AddChildView(view1);
325
326 views::View* view2 = new views::View;
[email protected]505df7b2013-12-16 14:07:19327 view2->SetFocusable(true);
[email protected]242aa4f2013-04-30 01:04:08328 pane1->AddChildView(view2);
329
330 views::AccessiblePaneView* pane2 = new views::AccessiblePaneView();
331 root_view->AddChildView(pane2);
332
333 views::View* view3 = new views::View;
[email protected]505df7b2013-12-16 14:07:19334 view3->SetFocusable(true);
[email protected]242aa4f2013-04-30 01:04:08335 pane2->AddChildView(view3);
336
337 views::View* view4 = new views::View;
[email protected]505df7b2013-12-16 14:07:19338 view4->SetFocusable(true);
[email protected]242aa4f2013-04-30 01:04:08339 pane2->AddChildView(view4);
340
341 std::vector<views::View*> panes;
342 panes.push_back(pane1);
343 panes.push_back(pane2);
344
345 test_widget_delegate->SetAccessiblePanes(panes);
346
347 views::FocusManager* focus_manager = browser_widget->GetFocusManager();
348
349 // Cycle focus to the status area.
350 focus_cycler()->RotateFocus(FocusCycler::FORWARD);
351 EXPECT_TRUE(tray()->GetWidget()->IsActive());
352
353 // Cycle focus to the shelf.
354 focus_cycler()->RotateFocus(FocusCycler::FORWARD);
355 EXPECT_TRUE(shelf_widget()->IsActive());
356
357 // Cycle focus to the first pane in the browser.
358 focus_cycler()->RotateFocus(FocusCycler::FORWARD);
359 EXPECT_TRUE(wm::IsActiveWindow(browser_window));
360 EXPECT_EQ(focus_manager->GetFocusedView(), view1);
361
362 // Cycle focus to the second pane in the browser.
363 focus_cycler()->RotateFocus(FocusCycler::FORWARD);
364 EXPECT_TRUE(wm::IsActiveWindow(browser_window));
365 EXPECT_EQ(focus_manager->GetFocusedView(), view3);
366
367 // Cycle focus back to the status area.
368 focus_cycler()->RotateFocus(FocusCycler::FORWARD);
369 EXPECT_TRUE(tray()->GetWidget()->IsActive());
370
371 // Reverse direction - back to the second pane in the browser.
372 focus_cycler()->RotateFocus(FocusCycler::BACKWARD);
373 EXPECT_TRUE(wm::IsActiveWindow(browser_window));
374 EXPECT_EQ(focus_manager->GetFocusedView(), view3);
375
376 // Back to the first pane in the browser.
377 focus_cycler()->RotateFocus(FocusCycler::BACKWARD);
378 EXPECT_TRUE(wm::IsActiveWindow(browser_window));
379 EXPECT_EQ(focus_manager->GetFocusedView(), view1);
380
381 // Back to the shelf.
382 focus_cycler()->RotateFocus(FocusCycler::BACKWARD);
383 EXPECT_TRUE(shelf_widget()->IsActive());
384
385 // Back to the status area.
386 focus_cycler()->RotateFocus(FocusCycler::BACKWARD);
387 EXPECT_TRUE(tray()->GetWidget()->IsActive());
388
389 // Pressing "Escape" while on the status area should
390 // deactivate it, and activate the browser window.
[email protected]bf9cdb362013-10-25 19:22:45391 aura::Window* root = Shell::GetPrimaryRootWindow();
[email protected]73c9fd02014-07-28 01:48:52392 ui::test::EventGenerator event_generator(root, root);
[email protected]242aa4f2013-04-30 01:04:08393 event_generator.PressKey(ui::VKEY_ESCAPE, 0);
394 EXPECT_TRUE(wm::IsActiveWindow(browser_window));
395 EXPECT_EQ(focus_manager->GetFocusedView(), view1);
396
397 // Similarly, pressing "Escape" while on the shelf.
398 // should do the same thing.
399 focus_cycler()->RotateFocus(FocusCycler::BACKWARD);
400 EXPECT_TRUE(shelf_widget()->IsActive());
401 event_generator.PressKey(ui::VKEY_ESCAPE, 0);
402 EXPECT_TRUE(wm::IsActiveWindow(browser_window));
403 EXPECT_EQ(focus_manager->GetFocusedView(), view1);
404}
405
[email protected]df1c9862012-02-27 10:37:31406} // namespace test
407} // namespace ash