Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(25)

Side by Side Diff: ash/wm/window_cycle_controller_unittest.cc

Issue 2095193002: clang-format all of //ash (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ash/wm/window_cycle_controller.cc ('k') | ash/wm/window_cycle_list.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/wm/window_cycle_controller.h" 5 #include "ash/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 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); 213 EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
214 214
215 Shell::GetInstance()->session_state_delegate()->UnlockScreen(); 215 Shell::GetInstance()->session_state_delegate()->UnlockScreen();
216 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); 216 EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
217 controller->HandleCycleWindow(WindowCycleController::FORWARD); 217 controller->HandleCycleWindow(WindowCycleController::FORWARD);
218 EXPECT_TRUE(wm::IsActiveWindow(window1.get())); 218 EXPECT_TRUE(wm::IsActiveWindow(window1.get()));
219 controller->HandleCycleWindow(WindowCycleController::FORWARD); 219 controller->HandleCycleWindow(WindowCycleController::FORWARD);
220 EXPECT_TRUE(wm::IsActiveWindow(window2.get())); 220 EXPECT_TRUE(wm::IsActiveWindow(window2.get()));
221 221
222 // When a modal window is active, cycling window does not take effect. 222 // When a modal window is active, cycling window does not take effect.
223 aura::Window* modal_container = 223 aura::Window* modal_container = ash::Shell::GetContainer(
224 ash::Shell::GetContainer( 224 Shell::GetPrimaryRootWindow(), kShellWindowId_SystemModalContainer);
225 Shell::GetPrimaryRootWindow(),
226 kShellWindowId_SystemModalContainer);
227 std::unique_ptr<Window> modal_window( 225 std::unique_ptr<Window> modal_window(
228 CreateTestWindowWithId(-2, modal_container)); 226 CreateTestWindowWithId(-2, modal_container));
229 modal_window->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_SYSTEM); 227 modal_window->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_SYSTEM);
230 wm::ActivateWindow(modal_window.get()); 228 wm::ActivateWindow(modal_window.get());
231 EXPECT_TRUE(wm::IsActiveWindow(modal_window.get())); 229 EXPECT_TRUE(wm::IsActiveWindow(modal_window.get()));
232 controller->HandleCycleWindow(WindowCycleController::FORWARD); 230 controller->HandleCycleWindow(WindowCycleController::FORWARD);
233 EXPECT_TRUE(wm::IsActiveWindow(modal_window.get())); 231 EXPECT_TRUE(wm::IsActiveWindow(modal_window.get()));
234 EXPECT_FALSE(wm::IsActiveWindow(window0.get())); 232 EXPECT_FALSE(wm::IsActiveWindow(window0.get()));
235 EXPECT_FALSE(wm::IsActiveWindow(window1.get())); 233 EXPECT_FALSE(wm::IsActiveWindow(window1.get()));
236 EXPECT_FALSE(wm::IsActiveWindow(window2.get())); 234 EXPECT_FALSE(wm::IsActiveWindow(window2.get()));
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 } 285 }
288 286
289 TEST_F(WindowCycleControllerTest, AlwaysOnTopWindow) { 287 TEST_F(WindowCycleControllerTest, AlwaysOnTopWindow) {
290 WindowCycleController* controller = 288 WindowCycleController* controller =
291 Shell::GetInstance()->window_cycle_controller(); 289 Shell::GetInstance()->window_cycle_controller();
292 290
293 // Set up several windows to use to test cycling. 291 // Set up several windows to use to test cycling.
294 std::unique_ptr<Window> window0(CreateTestWindowInShellWithId(0)); 292 std::unique_ptr<Window> window0(CreateTestWindowInShellWithId(0));
295 std::unique_ptr<Window> window1(CreateTestWindowInShellWithId(1)); 293 std::unique_ptr<Window> window1(CreateTestWindowInShellWithId(1));
296 294
297 Window* top_container = 295 Window* top_container = Shell::GetContainer(
298 Shell::GetContainer( 296 Shell::GetPrimaryRootWindow(), kShellWindowId_AlwaysOnTopContainer);
299 Shell::GetPrimaryRootWindow(),
300 kShellWindowId_AlwaysOnTopContainer);
301 std::unique_ptr<Window> window2(CreateTestWindowWithId(2, top_container)); 297 std::unique_ptr<Window> window2(CreateTestWindowWithId(2, top_container));
302 wm::ActivateWindow(window0.get()); 298 wm::ActivateWindow(window0.get());
303 299
304 // Simulate pressing and releasing Alt-tab. 300 // Simulate pressing and releasing Alt-tab.
305 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); 301 EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
306 controller->HandleCycleWindow(WindowCycleController::FORWARD); 302 controller->HandleCycleWindow(WindowCycleController::FORWARD);
307 303
308 // Window lists should return the topmost window in front. 304 // Window lists should return the topmost window in front.
309 ASSERT_TRUE(controller->window_cycle_list()); 305 ASSERT_TRUE(controller->window_cycle_list());
310 ASSERT_EQ(3u, GetWindows(controller).size()); 306 ASSERT_EQ(3u, GetWindows(controller).size());
(...skipping 20 matching lines...) Expand all
331 } 327 }
332 328
333 TEST_F(WindowCycleControllerTest, AlwaysOnTopMultiWindow) { 329 TEST_F(WindowCycleControllerTest, AlwaysOnTopMultiWindow) {
334 WindowCycleController* controller = 330 WindowCycleController* controller =
335 Shell::GetInstance()->window_cycle_controller(); 331 Shell::GetInstance()->window_cycle_controller();
336 332
337 // Set up several windows to use to test cycling. 333 // Set up several windows to use to test cycling.
338 std::unique_ptr<Window> window0(CreateTestWindowInShellWithId(0)); 334 std::unique_ptr<Window> window0(CreateTestWindowInShellWithId(0));
339 std::unique_ptr<Window> window1(CreateTestWindowInShellWithId(1)); 335 std::unique_ptr<Window> window1(CreateTestWindowInShellWithId(1));
340 336
341 Window* top_container = 337 Window* top_container = Shell::GetContainer(
342 Shell::GetContainer( 338 Shell::GetPrimaryRootWindow(), kShellWindowId_AlwaysOnTopContainer);
343 Shell::GetPrimaryRootWindow(),
344 kShellWindowId_AlwaysOnTopContainer);
345 std::unique_ptr<Window> window2(CreateTestWindowWithId(2, top_container)); 339 std::unique_ptr<Window> window2(CreateTestWindowWithId(2, top_container));
346 std::unique_ptr<Window> window3(CreateTestWindowWithId(3, top_container)); 340 std::unique_ptr<Window> window3(CreateTestWindowWithId(3, top_container));
347 wm::ActivateWindow(window0.get()); 341 wm::ActivateWindow(window0.get());
348 342
349 // Simulate pressing and releasing Alt-tab. 343 // Simulate pressing and releasing Alt-tab.
350 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); 344 EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
351 controller->HandleCycleWindow(WindowCycleController::FORWARD); 345 controller->HandleCycleWindow(WindowCycleController::FORWARD);
352 346
353 // Window lists should return the topmost window in front. 347 // Window lists should return the topmost window in front.
354 ASSERT_TRUE(controller->window_cycle_list()); 348 ASSERT_TRUE(controller->window_cycle_list());
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 384
391 WindowCycleController* controller = 385 WindowCycleController* controller =
392 Shell::GetInstance()->window_cycle_controller(); 386 Shell::GetInstance()->window_cycle_controller();
393 387
394 Shell::GetInstance()->set_target_root_window(root_windows[0]); 388 Shell::GetInstance()->set_target_root_window(root_windows[0]);
395 389
396 // Create two windows in the primary root. 390 // Create two windows in the primary root.
397 std::unique_ptr<Window> window0(CreateTestWindowInShellWithId(0)); 391 std::unique_ptr<Window> window0(CreateTestWindowInShellWithId(0));
398 EXPECT_EQ(root_windows[0], window0->GetRootWindow()); 392 EXPECT_EQ(root_windows[0], window0->GetRootWindow());
399 Window* top_container0 = 393 Window* top_container0 =
400 Shell::GetContainer( 394 Shell::GetContainer(root_windows[0], kShellWindowId_AlwaysOnTopContainer);
401 root_windows[0],
402 kShellWindowId_AlwaysOnTopContainer);
403 std::unique_ptr<Window> window1(CreateTestWindowWithId(1, top_container0)); 395 std::unique_ptr<Window> window1(CreateTestWindowWithId(1, top_container0));
404 EXPECT_EQ(root_windows[0], window1->GetRootWindow()); 396 EXPECT_EQ(root_windows[0], window1->GetRootWindow());
405 397
406 // And two on the secondary root. 398 // And two on the secondary root.
407 Shell::GetInstance()->set_target_root_window(root_windows[1]); 399 Shell::GetInstance()->set_target_root_window(root_windows[1]);
408 std::unique_ptr<Window> window2(CreateTestWindowInShellWithId(2)); 400 std::unique_ptr<Window> window2(CreateTestWindowInShellWithId(2));
409 EXPECT_EQ(root_windows[1], window2->GetRootWindow()); 401 EXPECT_EQ(root_windows[1], window2->GetRootWindow());
410 402
411 Window* top_container1 = 403 Window* top_container1 =
412 Shell::GetContainer( 404 Shell::GetContainer(root_windows[1], kShellWindowId_AlwaysOnTopContainer);
413 root_windows[1],
414 kShellWindowId_AlwaysOnTopContainer);
415 std::unique_ptr<Window> window3(CreateTestWindowWithId(3, top_container1)); 405 std::unique_ptr<Window> window3(CreateTestWindowWithId(3, top_container1));
416 EXPECT_EQ(root_windows[1], window3->GetRootWindow()); 406 EXPECT_EQ(root_windows[1], window3->GetRootWindow());
417 407
418 // Move the active root window to the secondary. 408 // Move the active root window to the secondary.
419 Shell::GetInstance()->set_target_root_window(root_windows[1]); 409 Shell::GetInstance()->set_target_root_window(root_windows[1]);
420 410
421 wm::ActivateWindow(window2.get()); 411 wm::ActivateWindow(window2.get());
422 412
423 EXPECT_EQ(root_windows[0], window0->GetRootWindow()); 413 EXPECT_EQ(root_windows[0], window0->GetRootWindow());
424 EXPECT_EQ(root_windows[0], window1->GetRootWindow()); 414 EXPECT_EQ(root_windows[0], window1->GetRootWindow());
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 ASSERT_TRUE(controller->window_cycle_list()); 467 ASSERT_TRUE(controller->window_cycle_list());
478 ASSERT_EQ(3u, GetWindows(controller).size()); 468 ASSERT_EQ(3u, GetWindows(controller).size());
479 EXPECT_EQ(window0.get(), GetWindows(controller)[0]); 469 EXPECT_EQ(window0.get(), GetWindows(controller)[0]);
480 EXPECT_EQ(window2.get(), GetWindows(controller)[1]); 470 EXPECT_EQ(window2.get(), GetWindows(controller)[1]);
481 EXPECT_EQ(window1.get(), GetWindows(controller)[2]); 471 EXPECT_EQ(window1.get(), GetWindows(controller)[2]);
482 472
483 controller->HandleCycleWindow(WindowCycleController::FORWARD); 473 controller->HandleCycleWindow(WindowCycleController::FORWARD);
484 controller->StopCycling(); 474 controller->StopCycling();
485 EXPECT_TRUE(wm::IsActiveWindow(window1.get())); 475 EXPECT_TRUE(wm::IsActiveWindow(window1.get()));
486 476
487
488 controller->HandleCycleWindow(WindowCycleController::FORWARD); 477 controller->HandleCycleWindow(WindowCycleController::FORWARD);
489 EXPECT_TRUE(wm::IsActiveWindow(window0.get())); 478 EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
490 479
491 controller->StopCycling(); 480 controller->StopCycling();
492 481
493 controller->HandleCycleWindow(WindowCycleController::FORWARD); 482 controller->HandleCycleWindow(WindowCycleController::FORWARD);
494 EXPECT_TRUE(wm::IsActiveWindow(window1.get())); 483 EXPECT_TRUE(wm::IsActiveWindow(window1.get()));
495 484
496 controller->HandleCycleWindow(WindowCycleController::FORWARD); 485 controller->HandleCycleWindow(WindowCycleController::FORWARD);
497 EXPECT_TRUE(wm::IsActiveWindow(window2.get())); 486 EXPECT_TRUE(wm::IsActiveWindow(window2.get()));
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 generator.PressKey(ui::VKEY_TAB, ui::EF_ALT_DOWN); 626 generator.PressKey(ui::VKEY_TAB, ui::EF_ALT_DOWN);
638 EXPECT_EQ(0u, key_count.GetCountAndReset()); 627 EXPECT_EQ(0u, key_count.GetCountAndReset());
639 generator.ReleaseKey(ui::VKEY_TAB, ui::EF_ALT_DOWN); 628 generator.ReleaseKey(ui::VKEY_TAB, ui::EF_ALT_DOWN);
640 EXPECT_EQ(0u, key_count.GetCountAndReset()); 629 EXPECT_EQ(0u, key_count.GetCountAndReset());
641 generator.ReleaseKey(ui::VKEY_MENU, ui::EF_NONE); 630 generator.ReleaseKey(ui::VKEY_MENU, ui::EF_NONE);
642 EXPECT_TRUE(wm::GetWindowState(w1.get())->IsActive()); 631 EXPECT_TRUE(wm::GetWindowState(w1.get())->IsActive());
643 EXPECT_EQ(0u, key_count.GetCountAndReset()); 632 EXPECT_EQ(0u, key_count.GetCountAndReset());
644 } 633 }
645 634
646 } // namespace ash 635 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/window_cycle_controller.cc ('k') | ash/wm/window_cycle_list.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698