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