Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/wm/window_cycle_controller.h" | 5 #include "ash/common/wm/window_cycle_controller.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "ash/aura/wm_window_aura.h" | 10 #include "ash/aura/wm_window_aura.h" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 71 | 71 |
| 72 class WindowCycleControllerTest : public test::AshTestBase { | 72 class WindowCycleControllerTest : public test::AshTestBase { |
| 73 public: | 73 public: |
| 74 WindowCycleControllerTest() {} | 74 WindowCycleControllerTest() {} |
| 75 ~WindowCycleControllerTest() override {} | 75 ~WindowCycleControllerTest() override {} |
| 76 | 76 |
| 77 void SetUp() override { | 77 void SetUp() override { |
| 78 test::AshTestBase::SetUp(); | 78 test::AshTestBase::SetUp(); |
| 79 ASSERT_TRUE(test::TestShelfDelegate::instance()); | 79 ASSERT_TRUE(test::TestShelfDelegate::instance()); |
| 80 | 80 |
| 81 WindowCycleList::DisableInitialDelayForTesting(); | |
| 82 | |
| 81 shelf_view_test_.reset(new test::ShelfViewTestAPI( | 83 shelf_view_test_.reset(new test::ShelfViewTestAPI( |
| 82 test::ShelfTestAPI(Shelf::ForPrimaryDisplay()).shelf_view())); | 84 test::ShelfTestAPI(Shelf::ForPrimaryDisplay()).shelf_view())); |
| 83 shelf_view_test_->SetAnimationDuration(1); | 85 shelf_view_test_->SetAnimationDuration(1); |
| 84 } | 86 } |
| 85 | 87 |
| 86 aura::Window* CreatePanelWindow() { | 88 aura::Window* CreatePanelWindow() { |
| 87 gfx::Rect rect(100, 100); | 89 gfx::Rect rect(100, 100); |
| 88 aura::Window* window = CreateTestWindowInShellWithDelegateAndType( | 90 aura::Window* window = CreateTestWindowInShellWithDelegateAndType( |
| 89 NULL, ui::wm::WINDOW_TYPE_PANEL, 0, rect); | 91 NULL, ui::wm::WINDOW_TYPE_PANEL, 0, rect); |
| 90 test::TestShelfDelegate::instance()->AddShelfItem(window); | 92 test::TestShelfDelegate::instance()->AddShelfItem(window); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 166 // Pressing and releasing Alt-tab again should cycle back to the most- | 168 // Pressing and releasing Alt-tab again should cycle back to the most- |
| 167 // recently-used window in the current child order. | 169 // recently-used window in the current child order. |
| 168 controller->HandleCycleWindow(WindowCycleController::FORWARD); | 170 controller->HandleCycleWindow(WindowCycleController::FORWARD); |
| 169 controller->StopCycling(); | 171 controller->StopCycling(); |
| 170 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); | 172 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); |
| 171 | 173 |
| 172 // Pressing Alt-tab multiple times without releasing Alt should cycle through | 174 // Pressing Alt-tab multiple times without releasing Alt should cycle through |
| 173 // all the windows and wrap around. | 175 // all the windows and wrap around. |
| 174 controller->HandleCycleWindow(WindowCycleController::FORWARD); | 176 controller->HandleCycleWindow(WindowCycleController::FORWARD); |
| 175 EXPECT_TRUE(controller->IsCycling()); | 177 EXPECT_TRUE(controller->IsCycling()); |
| 176 EXPECT_TRUE(wm::IsActiveWindow(window1.get())); | |
|
Evan Stade
2016/08/12 22:51:57
here and in many places in this file: Alt+Tab no l
| |
| 177 | 178 |
| 178 controller->HandleCycleWindow(WindowCycleController::FORWARD); | 179 controller->HandleCycleWindow(WindowCycleController::FORWARD); |
| 179 EXPECT_TRUE(controller->IsCycling()); | 180 EXPECT_TRUE(controller->IsCycling()); |
| 180 EXPECT_TRUE(wm::IsActiveWindow(window2.get())); | |
| 181 | 181 |
| 182 controller->HandleCycleWindow(WindowCycleController::FORWARD); | 182 controller->HandleCycleWindow(WindowCycleController::FORWARD); |
| 183 EXPECT_TRUE(controller->IsCycling()); | 183 EXPECT_TRUE(controller->IsCycling()); |
| 184 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); | |
| 185 | 184 |
| 186 controller->StopCycling(); | 185 controller->StopCycling(); |
| 187 EXPECT_FALSE(controller->IsCycling()); | 186 EXPECT_FALSE(controller->IsCycling()); |
| 188 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); | 187 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); |
| 189 | 188 |
| 190 // Reset our stacking order. | 189 // Reset our stacking order. |
| 191 wm::ActivateWindow(window2.get()); | 190 wm::ActivateWindow(window2.get()); |
| 192 wm::ActivateWindow(window1.get()); | 191 wm::ActivateWindow(window1.get()); |
| 193 wm::ActivateWindow(window0.get()); | 192 wm::ActivateWindow(window0.get()); |
| 194 | 193 |
| 195 // Likewise we can cycle backwards through all the windows. | 194 // Likewise we can cycle backwards through the windows. |
| 196 controller->HandleCycleWindow(WindowCycleController::BACKWARD); | 195 controller->HandleCycleWindow(WindowCycleController::BACKWARD); |
| 197 EXPECT_TRUE(wm::IsActiveWindow(window2.get())); | |
| 198 controller->HandleCycleWindow(WindowCycleController::BACKWARD); | 196 controller->HandleCycleWindow(WindowCycleController::BACKWARD); |
| 197 controller->StopCycling(); | |
| 199 EXPECT_TRUE(wm::IsActiveWindow(window1.get())); | 198 EXPECT_TRUE(wm::IsActiveWindow(window1.get())); |
| 200 controller->HandleCycleWindow(WindowCycleController::BACKWARD); | 199 |
| 201 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); | 200 // Reset our stacking order. |
| 202 controller->StopCycling(); | 201 wm::ActivateWindow(window2.get()); |
| 203 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); | 202 wm::ActivateWindow(window1.get()); |
| 203 wm::ActivateWindow(window0.get()); | |
| 204 | 204 |
| 205 // When the screen is locked, cycling window does not take effect. | 205 // When the screen is locked, cycling window does not take effect. |
| 206 WmShell::Get()->GetSessionStateDelegate()->LockScreen(); | 206 WmShell::Get()->GetSessionStateDelegate()->LockScreen(); |
| 207 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); | 207 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); |
| 208 controller->HandleCycleWindow(WindowCycleController::FORWARD); | 208 controller->HandleCycleWindow(WindowCycleController::FORWARD); |
| 209 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); | 209 EXPECT_FALSE(controller->IsCycling()); |
| 210 controller->HandleCycleWindow(WindowCycleController::BACKWARD); | |
| 211 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); | |
| 212 | 210 |
| 211 // Unlock, it works again. | |
| 213 WmShell::Get()->GetSessionStateDelegate()->UnlockScreen(); | 212 WmShell::Get()->GetSessionStateDelegate()->UnlockScreen(); |
| 214 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); | 213 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); |
| 215 controller->HandleCycleWindow(WindowCycleController::FORWARD); | 214 controller->HandleCycleWindow(WindowCycleController::FORWARD); |
| 216 EXPECT_TRUE(wm::IsActiveWindow(window1.get())); | |
| 217 controller->HandleCycleWindow(WindowCycleController::FORWARD); | 215 controller->HandleCycleWindow(WindowCycleController::FORWARD); |
| 216 controller->StopCycling(); | |
| 218 EXPECT_TRUE(wm::IsActiveWindow(window2.get())); | 217 EXPECT_TRUE(wm::IsActiveWindow(window2.get())); |
| 219 | 218 |
| 220 // When a modal window is active, cycling window does not take effect. | 219 // When a modal window is active, cycling window does not take effect. |
| 221 aura::Window* modal_container = Shell::GetContainer( | 220 aura::Window* modal_container = Shell::GetContainer( |
| 222 Shell::GetPrimaryRootWindow(), kShellWindowId_SystemModalContainer); | 221 Shell::GetPrimaryRootWindow(), kShellWindowId_SystemModalContainer); |
| 223 std::unique_ptr<Window> modal_window( | 222 std::unique_ptr<Window> modal_window( |
| 224 CreateTestWindowWithId(-2, modal_container)); | 223 CreateTestWindowWithId(-2, modal_container)); |
| 225 modal_window->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_SYSTEM); | 224 modal_window->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_SYSTEM); |
| 226 wm::ActivateWindow(modal_window.get()); | 225 wm::ActivateWindow(modal_window.get()); |
| 227 EXPECT_TRUE(wm::IsActiveWindow(modal_window.get())); | 226 EXPECT_TRUE(wm::IsActiveWindow(modal_window.get())); |
| 228 controller->HandleCycleWindow(WindowCycleController::FORWARD); | 227 controller->HandleCycleWindow(WindowCycleController::FORWARD); |
| 229 EXPECT_TRUE(wm::IsActiveWindow(modal_window.get())); | 228 EXPECT_TRUE(wm::IsActiveWindow(modal_window.get())); |
| 229 EXPECT_FALSE(controller->IsCycling()); | |
| 230 EXPECT_FALSE(wm::IsActiveWindow(window0.get())); | 230 EXPECT_FALSE(wm::IsActiveWindow(window0.get())); |
| 231 EXPECT_FALSE(wm::IsActiveWindow(window1.get())); | 231 EXPECT_FALSE(wm::IsActiveWindow(window1.get())); |
| 232 EXPECT_FALSE(wm::IsActiveWindow(window2.get())); | 232 EXPECT_FALSE(wm::IsActiveWindow(window2.get())); |
| 233 controller->HandleCycleWindow(WindowCycleController::BACKWARD); | 233 controller->HandleCycleWindow(WindowCycleController::BACKWARD); |
| 234 EXPECT_TRUE(wm::IsActiveWindow(modal_window.get())); | 234 EXPECT_TRUE(wm::IsActiveWindow(modal_window.get())); |
| 235 EXPECT_FALSE(controller->IsCycling()); | |
| 235 EXPECT_FALSE(wm::IsActiveWindow(window0.get())); | 236 EXPECT_FALSE(wm::IsActiveWindow(window0.get())); |
| 236 EXPECT_FALSE(wm::IsActiveWindow(window1.get())); | 237 EXPECT_FALSE(wm::IsActiveWindow(window1.get())); |
| 237 EXPECT_FALSE(wm::IsActiveWindow(window2.get())); | 238 EXPECT_FALSE(wm::IsActiveWindow(window2.get())); |
| 238 } | 239 } |
| 239 | 240 |
| 240 // Cycles between a maximized and normal window. | 241 // Cycles between a maximized and normal window. |
| 241 TEST_F(WindowCycleControllerTest, MaximizedWindow) { | 242 TEST_F(WindowCycleControllerTest, MaximizedWindow) { |
| 242 // Create a couple of test windows. | 243 // Create a couple of test windows. |
| 243 std::unique_ptr<Window> window0(CreateTestWindowInShellWithId(0)); | 244 std::unique_ptr<Window> window0(CreateTestWindowInShellWithId(0)); |
| 244 std::unique_ptr<Window> window1(CreateTestWindowInShellWithId(1)); | 245 std::unique_ptr<Window> window1(CreateTestWindowInShellWithId(1)); |
| 245 wm::WindowState* window1_state = wm::GetWindowState(window1.get()); | 246 wm::WindowState* window1_state = wm::GetWindowState(window1.get()); |
| 246 window1_state->Maximize(); | 247 window1_state->Maximize(); |
| 247 window1_state->Activate(); | 248 window1_state->Activate(); |
| 248 EXPECT_TRUE(window1_state->IsActive()); | 249 EXPECT_TRUE(window1_state->IsActive()); |
| 249 | 250 |
| 250 // Rotate focus, this should move focus to window0. | 251 // Rotate focus, this should move focus to window0. |
| 251 WindowCycleController* controller = WmShell::Get()->window_cycle_controller(); | 252 WindowCycleController* controller = WmShell::Get()->window_cycle_controller(); |
| 252 controller->HandleCycleWindow(WindowCycleController::FORWARD); | 253 controller->HandleCycleWindow(WindowCycleController::FORWARD); |
| 254 controller->StopCycling(); | |
| 253 EXPECT_TRUE(wm::GetWindowState(window0.get())->IsActive()); | 255 EXPECT_TRUE(wm::GetWindowState(window0.get())->IsActive()); |
| 256 EXPECT_FALSE(window1_state->IsActive()); | |
| 254 | 257 |
| 255 // One more time. | 258 // One more time. |
| 256 controller->HandleCycleWindow(WindowCycleController::FORWARD); | 259 controller->HandleCycleWindow(WindowCycleController::FORWARD); |
| 260 controller->StopCycling(); | |
| 257 EXPECT_TRUE(window1_state->IsActive()); | 261 EXPECT_TRUE(window1_state->IsActive()); |
| 258 } | 262 } |
| 259 | 263 |
| 260 // Cycles to a minimized window. | 264 // Cycles to a minimized window. |
| 261 TEST_F(WindowCycleControllerTest, Minimized) { | 265 TEST_F(WindowCycleControllerTest, Minimized) { |
| 262 // Create a couple of test windows. | 266 // Create a couple of test windows. |
| 263 std::unique_ptr<Window> window0(CreateTestWindowInShellWithId(0)); | 267 std::unique_ptr<Window> window0(CreateTestWindowInShellWithId(0)); |
| 264 std::unique_ptr<Window> window1(CreateTestWindowInShellWithId(1)); | 268 std::unique_ptr<Window> window1(CreateTestWindowInShellWithId(1)); |
| 265 wm::WindowState* window0_state = wm::GetWindowState(window0.get()); | 269 wm::WindowState* window0_state = wm::GetWindowState(window0.get()); |
| 266 wm::WindowState* window1_state = wm::GetWindowState(window1.get()); | 270 wm::WindowState* window1_state = wm::GetWindowState(window1.get()); |
| 267 | 271 |
| 268 window1_state->Minimize(); | 272 window1_state->Minimize(); |
| 269 window0_state->Activate(); | 273 window0_state->Activate(); |
| 270 EXPECT_TRUE(window0_state->IsActive()); | 274 EXPECT_TRUE(window0_state->IsActive()); |
| 271 | 275 |
| 272 // Rotate focus, this should move focus to window1 and unminimize it. | 276 // Rotate focus, this should move focus to window1 and unminimize it. |
| 273 WindowCycleController* controller = WmShell::Get()->window_cycle_controller(); | 277 WindowCycleController* controller = WmShell::Get()->window_cycle_controller(); |
| 274 controller->HandleCycleWindow(WindowCycleController::FORWARD); | 278 controller->HandleCycleWindow(WindowCycleController::FORWARD); |
| 279 controller->StopCycling(); | |
| 280 EXPECT_FALSE(window0_state->IsActive()); | |
| 275 EXPECT_FALSE(window1_state->IsMinimized()); | 281 EXPECT_FALSE(window1_state->IsMinimized()); |
| 276 EXPECT_TRUE(window1_state->IsActive()); | 282 EXPECT_TRUE(window1_state->IsActive()); |
| 277 | 283 |
| 278 // One more time back to w0. | 284 // One more time back to w0. |
| 279 controller->HandleCycleWindow(WindowCycleController::FORWARD); | 285 controller->HandleCycleWindow(WindowCycleController::FORWARD); |
| 286 controller->StopCycling(); | |
| 280 EXPECT_TRUE(window0_state->IsActive()); | 287 EXPECT_TRUE(window0_state->IsActive()); |
| 281 } | 288 } |
| 282 | 289 |
| 283 TEST_F(WindowCycleControllerTest, AlwaysOnTopWindow) { | 290 TEST_F(WindowCycleControllerTest, AlwaysOnTopWindow) { |
| 284 WindowCycleController* controller = WmShell::Get()->window_cycle_controller(); | 291 WindowCycleController* controller = WmShell::Get()->window_cycle_controller(); |
| 285 | 292 |
| 286 // Set up several windows to use to test cycling. | 293 // Set up several windows to use to test cycling. |
| 287 std::unique_ptr<Window> window0(CreateTestWindowInShellWithId(0)); | 294 std::unique_ptr<Window> window0(CreateTestWindowInShellWithId(0)); |
| 288 std::unique_ptr<Window> window1(CreateTestWindowInShellWithId(1)); | 295 std::unique_ptr<Window> window1(CreateTestWindowInShellWithId(1)); |
| 289 | 296 |
| 290 Window* top_container = Shell::GetContainer( | 297 Window* top_container = Shell::GetContainer( |
| 291 Shell::GetPrimaryRootWindow(), kShellWindowId_AlwaysOnTopContainer); | 298 Shell::GetPrimaryRootWindow(), kShellWindowId_AlwaysOnTopContainer); |
| 292 std::unique_ptr<Window> window2(CreateTestWindowWithId(2, top_container)); | 299 std::unique_ptr<Window> window2(CreateTestWindowWithId(2, top_container)); |
| 293 wm::ActivateWindow(window0.get()); | 300 wm::ActivateWindow(window0.get()); |
| 294 | 301 |
| 295 // Simulate pressing and releasing Alt-tab. | 302 // Simulate pressing and releasing Alt-tab. |
| 296 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); | 303 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); |
| 297 controller->HandleCycleWindow(WindowCycleController::FORWARD); | 304 controller->HandleCycleWindow(WindowCycleController::FORWARD); |
| 298 | 305 |
| 299 // Window lists should return the topmost window in front. | 306 // Window lists should return the topmost window in front. |
| 300 ASSERT_TRUE(controller->window_cycle_list()); | 307 ASSERT_TRUE(controller->window_cycle_list()); |
| 301 ASSERT_EQ(3u, GetWindows(controller).size()); | 308 ASSERT_EQ(3u, GetWindows(controller).size()); |
| 302 EXPECT_EQ(window0.get(), GetWindows(controller)[0]); | 309 EXPECT_EQ(window0.get(), GetWindows(controller)[0]); |
| 303 EXPECT_EQ(window2.get(), GetWindows(controller)[1]); | 310 EXPECT_EQ(window2.get(), GetWindows(controller)[1]); |
| 304 EXPECT_EQ(window1.get(), GetWindows(controller)[2]); | 311 EXPECT_EQ(window1.get(), GetWindows(controller)[2]); |
| 305 | |
| 306 controller->StopCycling(); | |
| 307 EXPECT_TRUE(wm::IsActiveWindow(window2.get())); | |
|
Evan Stade
2016/08/12 22:51:58
this doesn't really seem worth updating. Instead I
| |
| 308 | |
| 309 controller->HandleCycleWindow(WindowCycleController::FORWARD); | |
| 310 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); | |
| 311 | |
| 312 controller->StopCycling(); | |
| 313 | |
| 314 controller->HandleCycleWindow(WindowCycleController::FORWARD); | |
| 315 EXPECT_TRUE(wm::IsActiveWindow(window2.get())); | |
| 316 | |
| 317 controller->HandleCycleWindow(WindowCycleController::FORWARD); | |
| 318 EXPECT_TRUE(wm::IsActiveWindow(window1.get())); | |
| 319 | |
| 320 controller->HandleCycleWindow(WindowCycleController::FORWARD); | |
| 321 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); | |
| 322 } | 312 } |
| 323 | 313 |
| 324 TEST_F(WindowCycleControllerTest, AlwaysOnTopMultiWindow) { | 314 TEST_F(WindowCycleControllerTest, AlwaysOnTopMultiWindow) { |
| 325 WindowCycleController* controller = WmShell::Get()->window_cycle_controller(); | 315 WindowCycleController* controller = WmShell::Get()->window_cycle_controller(); |
| 326 | 316 |
| 327 // Set up several windows to use to test cycling. | 317 // Set up several windows to use to test cycling. |
| 328 std::unique_ptr<Window> window0(CreateTestWindowInShellWithId(0)); | 318 std::unique_ptr<Window> window0(CreateTestWindowInShellWithId(0)); |
| 329 std::unique_ptr<Window> window1(CreateTestWindowInShellWithId(1)); | 319 std::unique_ptr<Window> window1(CreateTestWindowInShellWithId(1)); |
| 330 | 320 |
| 331 Window* top_container = Shell::GetContainer( | 321 Window* top_container = Shell::GetContainer( |
| 332 Shell::GetPrimaryRootWindow(), kShellWindowId_AlwaysOnTopContainer); | 322 Shell::GetPrimaryRootWindow(), kShellWindowId_AlwaysOnTopContainer); |
| 333 std::unique_ptr<Window> window2(CreateTestWindowWithId(2, top_container)); | 323 std::unique_ptr<Window> window2(CreateTestWindowWithId(2, top_container)); |
| 334 std::unique_ptr<Window> window3(CreateTestWindowWithId(3, top_container)); | 324 std::unique_ptr<Window> window3(CreateTestWindowWithId(3, top_container)); |
| 335 wm::ActivateWindow(window0.get()); | 325 wm::ActivateWindow(window0.get()); |
| 336 | 326 |
| 337 // Simulate pressing and releasing Alt-tab. | 327 // Simulate pressing and releasing Alt-tab. |
| 338 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); | 328 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); |
| 339 controller->HandleCycleWindow(WindowCycleController::FORWARD); | 329 controller->HandleCycleWindow(WindowCycleController::FORWARD); |
| 340 | 330 |
| 341 // Window lists should return the topmost window in front. | 331 // Window lists should return the topmost window in front. |
| 342 ASSERT_TRUE(controller->window_cycle_list()); | 332 ASSERT_TRUE(controller->window_cycle_list()); |
| 343 ASSERT_EQ(4u, GetWindows(controller).size()); | 333 ASSERT_EQ(4u, GetWindows(controller).size()); |
| 344 EXPECT_EQ(window0.get(), GetWindows(controller)[0]); | 334 EXPECT_EQ(window0.get(), GetWindows(controller)[0]); |
| 345 EXPECT_EQ(window3.get(), GetWindows(controller)[1]); | 335 EXPECT_EQ(window3.get(), GetWindows(controller)[1]); |
| 346 EXPECT_EQ(window2.get(), GetWindows(controller)[2]); | 336 EXPECT_EQ(window2.get(), GetWindows(controller)[2]); |
| 347 EXPECT_EQ(window1.get(), GetWindows(controller)[3]); | 337 EXPECT_EQ(window1.get(), GetWindows(controller)[3]); |
| 348 | |
| 349 controller->StopCycling(); | |
|
Evan Stade
2016/08/12 22:51:58
ditto
| |
| 350 EXPECT_TRUE(wm::IsActiveWindow(window3.get())); | |
| 351 | |
| 352 controller->HandleCycleWindow(WindowCycleController::FORWARD); | |
| 353 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); | |
| 354 | |
| 355 controller->StopCycling(); | |
| 356 | |
| 357 controller->HandleCycleWindow(WindowCycleController::FORWARD); | |
| 358 EXPECT_TRUE(wm::IsActiveWindow(window3.get())); | |
| 359 | |
| 360 controller->HandleCycleWindow(WindowCycleController::FORWARD); | |
| 361 EXPECT_TRUE(wm::IsActiveWindow(window2.get())); | |
| 362 | |
| 363 controller->HandleCycleWindow(WindowCycleController::FORWARD); | |
| 364 EXPECT_TRUE(wm::IsActiveWindow(window1.get())); | |
| 365 | |
| 366 controller->HandleCycleWindow(WindowCycleController::FORWARD); | |
| 367 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); | |
| 368 } | 338 } |
| 369 | 339 |
| 370 TEST_F(WindowCycleControllerTest, AlwaysOnTopMultipleRootWindows) { | 340 TEST_F(WindowCycleControllerTest, AlwaysOnTopMultipleRootWindows) { |
| 371 if (!SupportsMultipleDisplays()) | 341 if (!SupportsMultipleDisplays()) |
| 372 return; | 342 return; |
| 373 | 343 |
| 374 // Set up a second root window | 344 // Set up a second root window |
| 375 UpdateDisplay("1000x600,600x400"); | 345 UpdateDisplay("1000x600,600x400"); |
| 376 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 346 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 377 ASSERT_EQ(2U, root_windows.size()); | 347 ASSERT_EQ(2U, root_windows.size()); |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 408 EXPECT_TRUE(wm::IsActiveWindow(window2.get())); | 378 EXPECT_TRUE(wm::IsActiveWindow(window2.get())); |
| 409 controller->HandleCycleWindow(WindowCycleController::FORWARD); | 379 controller->HandleCycleWindow(WindowCycleController::FORWARD); |
| 410 | 380 |
| 411 // Window lists should return the topmost window in front. | 381 // Window lists should return the topmost window in front. |
| 412 ASSERT_TRUE(controller->window_cycle_list()); | 382 ASSERT_TRUE(controller->window_cycle_list()); |
| 413 ASSERT_EQ(4u, GetWindows(controller).size()); | 383 ASSERT_EQ(4u, GetWindows(controller).size()); |
| 414 EXPECT_EQ(window2.get(), GetWindows(controller)[0]); | 384 EXPECT_EQ(window2.get(), GetWindows(controller)[0]); |
| 415 EXPECT_EQ(window3.get(), GetWindows(controller)[1]); | 385 EXPECT_EQ(window3.get(), GetWindows(controller)[1]); |
| 416 EXPECT_EQ(window1.get(), GetWindows(controller)[2]); | 386 EXPECT_EQ(window1.get(), GetWindows(controller)[2]); |
| 417 EXPECT_EQ(window0.get(), GetWindows(controller)[3]); | 387 EXPECT_EQ(window0.get(), GetWindows(controller)[3]); |
| 418 | |
| 419 controller->StopCycling(); | |
|
Evan Stade
2016/08/12 22:51:57
ditto
| |
| 420 EXPECT_TRUE(wm::IsActiveWindow(window3.get())); | |
| 421 | |
| 422 controller->HandleCycleWindow(WindowCycleController::FORWARD); | |
| 423 EXPECT_TRUE(wm::IsActiveWindow(window2.get())); | |
| 424 | |
| 425 controller->StopCycling(); | |
| 426 | |
| 427 controller->HandleCycleWindow(WindowCycleController::FORWARD); | |
| 428 EXPECT_TRUE(wm::IsActiveWindow(window3.get())); | |
| 429 | |
| 430 controller->HandleCycleWindow(WindowCycleController::FORWARD); | |
| 431 EXPECT_TRUE(wm::IsActiveWindow(window1.get())); | |
| 432 | |
| 433 controller->HandleCycleWindow(WindowCycleController::FORWARD); | |
| 434 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); | |
| 435 | |
| 436 controller->HandleCycleWindow(WindowCycleController::FORWARD); | |
| 437 EXPECT_TRUE(wm::IsActiveWindow(window2.get())); | |
| 438 } | 388 } |
| 439 | 389 |
| 440 TEST_F(WindowCycleControllerTest, MostRecentlyUsed) { | 390 TEST_F(WindowCycleControllerTest, MostRecentlyUsed) { |
| 441 WindowCycleController* controller = WmShell::Get()->window_cycle_controller(); | 391 WindowCycleController* controller = WmShell::Get()->window_cycle_controller(); |
| 442 | 392 |
| 443 // Set up several windows to use to test cycling. | 393 // Set up several windows to use to test cycling. |
| 444 std::unique_ptr<Window> window0(CreateTestWindowInShellWithId(0)); | 394 std::unique_ptr<Window> window0(CreateTestWindowInShellWithId(0)); |
| 445 std::unique_ptr<Window> window1(CreateTestWindowInShellWithId(1)); | 395 std::unique_ptr<Window> window1(CreateTestWindowInShellWithId(1)); |
| 446 std::unique_ptr<Window> window2(CreateTestWindowInShellWithId(2)); | 396 std::unique_ptr<Window> window2(CreateTestWindowInShellWithId(2)); |
| 447 | 397 |
| 448 wm::ActivateWindow(window0.get()); | 398 wm::ActivateWindow(window0.get()); |
| 449 | 399 |
| 450 // Simulate pressing and releasing Alt-tab. | 400 // Simulate pressing and releasing Alt-tab. |
| 451 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); | 401 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); |
| 452 controller->HandleCycleWindow(WindowCycleController::FORWARD); | 402 controller->HandleCycleWindow(WindowCycleController::FORWARD); |
| 453 | 403 |
| 454 // Window lists should return the topmost window in front. | 404 // Window lists should return the topmost window in front. |
| 455 ASSERT_TRUE(controller->window_cycle_list()); | 405 ASSERT_TRUE(controller->window_cycle_list()); |
| 456 ASSERT_EQ(3u, GetWindows(controller).size()); | 406 ASSERT_EQ(3u, GetWindows(controller).size()); |
| 457 EXPECT_EQ(window0.get(), GetWindows(controller)[0]); | 407 EXPECT_EQ(window0.get(), GetWindows(controller)[0]); |
| 458 EXPECT_EQ(window2.get(), GetWindows(controller)[1]); | 408 EXPECT_EQ(window2.get(), GetWindows(controller)[1]); |
| 459 EXPECT_EQ(window1.get(), GetWindows(controller)[2]); | 409 EXPECT_EQ(window1.get(), GetWindows(controller)[2]); |
| 460 | 410 |
| 411 // Cycling through then stopping the cycling will activate a window. | |
| 461 controller->HandleCycleWindow(WindowCycleController::FORWARD); | 412 controller->HandleCycleWindow(WindowCycleController::FORWARD); |
| 462 controller->StopCycling(); | 413 controller->StopCycling(); |
| 463 EXPECT_TRUE(wm::IsActiveWindow(window1.get())); | 414 EXPECT_TRUE(wm::IsActiveWindow(window1.get())); |
| 464 | 415 |
| 416 // Cycling alone (without StopCycling()) doesn't activate. | |
| 465 controller->HandleCycleWindow(WindowCycleController::FORWARD); | 417 controller->HandleCycleWindow(WindowCycleController::FORWARD); |
| 466 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); | 418 EXPECT_FALSE(wm::IsActiveWindow(window0.get())); |
| 419 | |
| 420 // Showing the Alt+Tab UI does however deactivate the erstwhile active window. | |
| 421 EXPECT_FALSE(wm::IsActiveWindow(window1.get())); | |
| 467 | 422 |
| 468 controller->StopCycling(); | 423 controller->StopCycling(); |
| 469 | |
| 470 controller->HandleCycleWindow(WindowCycleController::FORWARD); | |
| 471 EXPECT_TRUE(wm::IsActiveWindow(window1.get())); | |
| 472 | |
| 473 controller->HandleCycleWindow(WindowCycleController::FORWARD); | |
| 474 EXPECT_TRUE(wm::IsActiveWindow(window2.get())); | |
| 475 | |
| 476 controller->HandleCycleWindow(WindowCycleController::FORWARD); | |
| 477 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); | |
| 478 } | 424 } |
| 479 | 425 |
| 480 // Tests that beginning window selection hides the app list. | 426 // Tests that beginning window selection hides the app list. |
| 481 TEST_F(WindowCycleControllerTest, SelectingHidesAppList) { | 427 TEST_F(WindowCycleControllerTest, SelectingHidesAppList) { |
| 482 WindowCycleController* controller = WmShell::Get()->window_cycle_controller(); | 428 WindowCycleController* controller = WmShell::Get()->window_cycle_controller(); |
| 483 | 429 |
| 484 std::unique_ptr<aura::Window> window0(CreateTestWindowInShellWithId(0)); | 430 std::unique_ptr<aura::Window> window0(CreateTestWindowInShellWithId(0)); |
| 485 std::unique_ptr<aura::Window> window1(CreateTestWindowInShellWithId(1)); | 431 std::unique_ptr<aura::Window> window1(CreateTestWindowInShellWithId(1)); |
| 486 WmShell::Get()->ShowAppList(); | 432 WmShell::Get()->ShowAppList(); |
| 487 EXPECT_TRUE(WmShell::Get()->GetAppListTargetVisibility()); | 433 EXPECT_TRUE(WmShell::Get()->GetAppListTargetVisibility()); |
| 488 controller->HandleCycleWindow(WindowCycleController::FORWARD); | 434 controller->HandleCycleWindow(WindowCycleController::FORWARD); |
| 489 EXPECT_FALSE(WmShell::Get()->GetAppListTargetVisibility()); | 435 EXPECT_FALSE(WmShell::Get()->GetAppListTargetVisibility()); |
| 490 } | 436 } |
| 491 | 437 |
| 492 // Tests that cycling through windows shows and minimizes windows as they | 438 // Tests that cycling through windows doesn't change their minimized state. |
| 493 // are passed. | |
| 494 TEST_F(WindowCycleControllerTest, CyclePreservesMinimization) { | 439 TEST_F(WindowCycleControllerTest, CyclePreservesMinimization) { |
| 495 WindowCycleController* controller = WmShell::Get()->window_cycle_controller(); | 440 WindowCycleController* controller = WmShell::Get()->window_cycle_controller(); |
| 496 | 441 |
| 497 std::unique_ptr<aura::Window> window0(CreateTestWindowInShellWithId(0)); | 442 std::unique_ptr<aura::Window> window0(CreateTestWindowInShellWithId(0)); |
| 498 std::unique_ptr<aura::Window> window1(CreateTestWindowInShellWithId(1)); | 443 std::unique_ptr<aura::Window> window1(CreateTestWindowInShellWithId(1)); |
| 499 wm::ActivateWindow(window1.get()); | 444 wm::ActivateWindow(window1.get()); |
| 500 wm::GetWindowState(window1.get())->Minimize(); | 445 wm::GetWindowState(window1.get())->Minimize(); |
| 501 wm::ActivateWindow(window0.get()); | 446 wm::ActivateWindow(window0.get()); |
| 502 EXPECT_TRUE(IsWindowMinimized(window1.get())); | 447 EXPECT_TRUE(IsWindowMinimized(window1.get())); |
| 503 | 448 |
| 504 // On window 2. | 449 // On window 2. |
| 505 controller->HandleCycleWindow(WindowCycleController::FORWARD); | 450 controller->HandleCycleWindow(WindowCycleController::FORWARD); |
| 506 EXPECT_FALSE(IsWindowMinimized(window1.get())); | 451 EXPECT_TRUE(IsWindowMinimized(window1.get())); |
| 507 | 452 |
| 508 // Back on window 1. | 453 // Back on window 1. |
| 509 controller->HandleCycleWindow(WindowCycleController::FORWARD); | 454 controller->HandleCycleWindow(WindowCycleController::FORWARD); |
| 510 EXPECT_TRUE(IsWindowMinimized(window1.get())); | 455 EXPECT_TRUE(IsWindowMinimized(window1.get())); |
| 511 | 456 |
| 512 controller->StopCycling(); | 457 controller->StopCycling(); |
| 513 | 458 |
| 514 EXPECT_TRUE(IsWindowMinimized(window1.get())); | 459 EXPECT_TRUE(IsWindowMinimized(window1.get())); |
| 515 } | 460 } |
| 516 | 461 |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 609 generator.PressKey(ui::VKEY_TAB, ui::EF_ALT_DOWN); | 554 generator.PressKey(ui::VKEY_TAB, ui::EF_ALT_DOWN); |
| 610 EXPECT_EQ(0u, key_count.GetCountAndReset()); | 555 EXPECT_EQ(0u, key_count.GetCountAndReset()); |
| 611 generator.ReleaseKey(ui::VKEY_TAB, ui::EF_ALT_DOWN); | 556 generator.ReleaseKey(ui::VKEY_TAB, ui::EF_ALT_DOWN); |
| 612 EXPECT_EQ(0u, key_count.GetCountAndReset()); | 557 EXPECT_EQ(0u, key_count.GetCountAndReset()); |
| 613 generator.ReleaseKey(ui::VKEY_MENU, ui::EF_NONE); | 558 generator.ReleaseKey(ui::VKEY_MENU, ui::EF_NONE); |
| 614 EXPECT_TRUE(wm::GetWindowState(w1.get())->IsActive()); | 559 EXPECT_TRUE(wm::GetWindowState(w1.get())->IsActive()); |
| 615 EXPECT_EQ(0u, key_count.GetCountAndReset()); | 560 EXPECT_EQ(0u, key_count.GetCountAndReset()); |
| 616 } | 561 } |
| 617 | 562 |
| 618 } // namespace ash | 563 } // namespace ash |
| OLD | NEW |