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

Side by Side Diff: ash/accelerators/accelerator_controller_unittest.cc

Issue 1901773002: Removes most of aura dependencies from DefaultState (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@wm_window_positioner
Patch Set: nit and merge Created 4 years, 8 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 | « no previous file | ash/ash.gyp » ('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 (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/accelerators/accelerator_controller.h" 5 #include "ash/accelerators/accelerator_controller.h"
6 6
7 #include "ash/accelerators/accelerator_table.h" 7 #include "ash/accelerators/accelerator_table.h"
8 #include "ash/accessibility_delegate.h" 8 #include "ash/accessibility_delegate.h"
9 #include "ash/ash_switches.h" 9 #include "ash/ash_switches.h"
10 #include "ash/display/display_manager.h" 10 #include "ash/display/display_manager.h"
11 #include "ash/ime_control_delegate.h" 11 #include "ash/ime_control_delegate.h"
12 #include "ash/screen_util.h" 12 #include "ash/screen_util.h"
13 #include "ash/shell.h" 13 #include "ash/shell.h"
14 #include "ash/shell_window_ids.h" 14 #include "ash/shell_window_ids.h"
15 #include "ash/system/brightness_control_delegate.h" 15 #include "ash/system/brightness_control_delegate.h"
16 #include "ash/system/keyboard_brightness/keyboard_brightness_control_delegate.h" 16 #include "ash/system/keyboard_brightness/keyboard_brightness_control_delegate.h"
17 #include "ash/system/tray/system_tray_delegate.h" 17 #include "ash/system/tray/system_tray_delegate.h"
18 #include "ash/test/ash_test_base.h" 18 #include "ash/test/ash_test_base.h"
19 #include "ash/test/display_manager_test_api.h" 19 #include "ash/test/display_manager_test_api.h"
20 #include "ash/test/test_screenshot_delegate.h" 20 #include "ash/test/test_screenshot_delegate.h"
21 #include "ash/test/test_session_state_animator.h" 21 #include "ash/test/test_session_state_animator.h"
22 #include "ash/test/test_shelf_delegate.h" 22 #include "ash/test/test_shelf_delegate.h"
23 #include "ash/test/test_shell_delegate.h" 23 #include "ash/test/test_shell_delegate.h"
24 #include "ash/test/test_volume_control_delegate.h" 24 #include "ash/test/test_volume_control_delegate.h"
25 #include "ash/volume_control_delegate.h" 25 #include "ash/volume_control_delegate.h"
26 #include "ash/wm/common/window_positioning_utils.h"
26 #include "ash/wm/common/wm_event.h" 27 #include "ash/wm/common/wm_event.h"
27 #include "ash/wm/lock_state_controller.h" 28 #include "ash/wm/lock_state_controller.h"
28 #include "ash/wm/panels/panel_layout_manager.h" 29 #include "ash/wm/panels/panel_layout_manager.h"
29 #include "ash/wm/window_state.h" 30 #include "ash/wm/window_state.h"
30 #include "ash/wm/window_state_aura.h" 31 #include "ash/wm/window_state_aura.h"
31 #include "ash/wm/window_util.h" 32 #include "ash/wm/window_util.h"
32 #include "base/command_line.h" 33 #include "base/command_line.h"
33 #include "ui/aura/client/aura_constants.h" 34 #include "ui/aura/client/aura_constants.h"
34 #include "ui/aura/test/test_window_delegate.h" 35 #include "ui/aura/test/test_window_delegate.h"
35 #include "ui/aura/test/test_windows.h" 36 #include "ui/aura/test/test_windows.h"
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 TEST_F(AcceleratorControllerTest, WindowSnap) { 444 TEST_F(AcceleratorControllerTest, WindowSnap) {
444 std::unique_ptr<aura::Window> window( 445 std::unique_ptr<aura::Window> window(
445 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); 446 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20)));
446 wm::WindowState* window_state = wm::GetWindowState(window.get()); 447 wm::WindowState* window_state = wm::GetWindowState(window.get());
447 448
448 window_state->Activate(); 449 window_state->Activate();
449 450
450 { 451 {
451 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); 452 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT);
452 gfx::Rect expected_bounds = wm::GetDefaultLeftSnappedWindowBoundsInParent( 453 gfx::Rect expected_bounds = wm::GetDefaultLeftSnappedWindowBoundsInParent(
453 window.get()); 454 wm::WmWindowAura::Get(window.get()));
454 EXPECT_EQ(expected_bounds.ToString(), window->bounds().ToString()); 455 EXPECT_EQ(expected_bounds.ToString(), window->bounds().ToString());
455 } 456 }
456 { 457 {
457 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT); 458 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT);
458 gfx::Rect expected_bounds = wm::GetDefaultRightSnappedWindowBoundsInParent( 459 gfx::Rect expected_bounds = wm::GetDefaultRightSnappedWindowBoundsInParent(
459 window.get()); 460 wm::WmWindowAura::Get(window.get()));
460 EXPECT_EQ(expected_bounds.ToString(), window->bounds().ToString()); 461 EXPECT_EQ(expected_bounds.ToString(), window->bounds().ToString());
461 } 462 }
462 { 463 {
463 gfx::Rect normal_bounds = window_state->GetRestoreBoundsInParent(); 464 gfx::Rect normal_bounds = window_state->GetRestoreBoundsInParent();
464 465
465 GetController()->PerformActionIfEnabled(TOGGLE_MAXIMIZED); 466 GetController()->PerformActionIfEnabled(TOGGLE_MAXIMIZED);
466 EXPECT_TRUE(window_state->IsMaximized()); 467 EXPECT_TRUE(window_state->IsMaximized());
467 EXPECT_NE(normal_bounds.ToString(), window->bounds().ToString()); 468 EXPECT_NE(normal_bounds.ToString(), window->bounds().ToString());
468 469
469 GetController()->PerformActionIfEnabled(TOGGLE_MAXIMIZED); 470 GetController()->PerformActionIfEnabled(TOGGLE_MAXIMIZED);
(...skipping 28 matching lines...) Expand all
498 std::unique_ptr<aura::Window> window0( 499 std::unique_ptr<aura::Window> window0(
499 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); 500 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20)));
500 std::unique_ptr<aura::Window> window1( 501 std::unique_ptr<aura::Window> window1(
501 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); 502 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20)));
502 wm::WindowState* window1_state = wm::GetWindowState(window1.get()); 503 wm::WindowState* window1_state = wm::GetWindowState(window1.get());
503 window1_state->Activate(); 504 window1_state->Activate();
504 505
505 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); 506 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT);
506 gfx::Rect normal_bounds = window1_state->GetRestoreBoundsInParent(); 507 gfx::Rect normal_bounds = window1_state->GetRestoreBoundsInParent();
507 gfx::Rect expected_bounds = wm::GetDefaultLeftSnappedWindowBoundsInParent( 508 gfx::Rect expected_bounds = wm::GetDefaultLeftSnappedWindowBoundsInParent(
508 window1.get()); 509 wm::WmWindowAura::Get(window1.get()));
509 EXPECT_EQ(expected_bounds.ToString(), window1->bounds().ToString()); 510 EXPECT_EQ(expected_bounds.ToString(), window1->bounds().ToString());
510 EXPECT_TRUE(window1_state->IsSnapped()); 511 EXPECT_TRUE(window1_state->IsSnapped());
511 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); 512 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT);
512 EXPECT_FALSE(window1_state->IsNormalOrSnapped()); 513 EXPECT_FALSE(window1_state->IsNormalOrSnapped());
513 EXPECT_TRUE(window1_state->IsDocked()); 514 EXPECT_TRUE(window1_state->IsDocked());
514 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); 515 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT);
515 EXPECT_FALSE(window1_state->IsDocked()); 516 EXPECT_FALSE(window1_state->IsDocked());
516 EXPECT_EQ(normal_bounds.ToString(), window1->bounds().ToString()); 517 EXPECT_EQ(normal_bounds.ToString(), window1->bounds().ToString());
517 } 518 }
518 519
519 TEST_F(AcceleratorControllerTest, WindowSnapRightDockRightRestore) { 520 TEST_F(AcceleratorControllerTest, WindowSnapRightDockRightRestore) {
520 std::unique_ptr<aura::Window> window0( 521 std::unique_ptr<aura::Window> window0(
521 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); 522 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20)));
522 std::unique_ptr<aura::Window> window1( 523 std::unique_ptr<aura::Window> window1(
523 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); 524 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20)));
524 525
525 wm::WindowState* window1_state = wm::GetWindowState(window1.get()); 526 wm::WindowState* window1_state = wm::GetWindowState(window1.get());
526 window1_state->Activate(); 527 window1_state->Activate();
527 528
528 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT); 529 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT);
529 gfx::Rect normal_bounds = window1_state->GetRestoreBoundsInParent(); 530 gfx::Rect normal_bounds = window1_state->GetRestoreBoundsInParent();
530 gfx::Rect expected_bounds = 531 gfx::Rect expected_bounds = wm::GetDefaultRightSnappedWindowBoundsInParent(
531 wm::GetDefaultRightSnappedWindowBoundsInParent(window1.get()); 532 wm::WmWindowAura::Get(window1.get()));
532 EXPECT_EQ(expected_bounds.ToString(), window1->bounds().ToString()); 533 EXPECT_EQ(expected_bounds.ToString(), window1->bounds().ToString());
533 EXPECT_TRUE(window1_state->IsSnapped()); 534 EXPECT_TRUE(window1_state->IsSnapped());
534 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT); 535 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT);
535 EXPECT_FALSE(window1_state->IsNormalOrSnapped()); 536 EXPECT_FALSE(window1_state->IsNormalOrSnapped());
536 EXPECT_TRUE(window1_state->IsDocked()); 537 EXPECT_TRUE(window1_state->IsDocked());
537 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT); 538 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT);
538 EXPECT_FALSE(window1_state->IsDocked()); 539 EXPECT_FALSE(window1_state->IsDocked());
539 EXPECT_EQ(normal_bounds.ToString(), window1->bounds().ToString()); 540 EXPECT_EQ(normal_bounds.ToString(), window1->bounds().ToString());
540 } 541 }
541 542
542 TEST_F(AcceleratorControllerTest, WindowSnapLeftDockLeftSnapRight) { 543 TEST_F(AcceleratorControllerTest, WindowSnapLeftDockLeftSnapRight) {
543 std::unique_ptr<aura::Window> window0( 544 std::unique_ptr<aura::Window> window0(
544 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); 545 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20)));
545 std::unique_ptr<aura::Window> window1( 546 std::unique_ptr<aura::Window> window1(
546 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); 547 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20)));
547 548
548 wm::WindowState* window1_state = wm::GetWindowState(window1.get()); 549 wm::WindowState* window1_state = wm::GetWindowState(window1.get());
549 window1_state->Activate(); 550 window1_state->Activate();
550 551
551 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); 552 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT);
552 gfx::Rect expected_bounds = 553 gfx::Rect expected_bounds = wm::GetDefaultLeftSnappedWindowBoundsInParent(
553 wm::GetDefaultLeftSnappedWindowBoundsInParent(window1.get()); 554 wm::WmWindowAura::Get(window1.get()));
554 gfx::Rect expected_bounds2 = 555 gfx::Rect expected_bounds2 = wm::GetDefaultRightSnappedWindowBoundsInParent(
555 wm::GetDefaultRightSnappedWindowBoundsInParent(window1.get()); 556 wm::WmWindowAura::Get(window1.get()));
556 EXPECT_EQ(expected_bounds.ToString(), window1->bounds().ToString()); 557 EXPECT_EQ(expected_bounds.ToString(), window1->bounds().ToString());
557 EXPECT_TRUE(window1_state->IsSnapped()); 558 EXPECT_TRUE(window1_state->IsSnapped());
558 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); 559 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT);
559 EXPECT_FALSE(window1_state->IsNormalOrSnapped()); 560 EXPECT_FALSE(window1_state->IsNormalOrSnapped());
560 EXPECT_TRUE(window1_state->IsDocked()); 561 EXPECT_TRUE(window1_state->IsDocked());
561 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT); 562 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT);
562 EXPECT_FALSE(window1_state->IsDocked()); 563 EXPECT_FALSE(window1_state->IsDocked());
563 EXPECT_TRUE(window1_state->IsSnapped()); 564 EXPECT_TRUE(window1_state->IsSnapped());
564 EXPECT_EQ(expected_bounds2.ToString(), window1->bounds().ToString()); 565 EXPECT_EQ(expected_bounds2.ToString(), window1->bounds().ToString());
565 } 566 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 TEST_F(AcceleratorControllerTest, WindowPanelDockLeftDockRightRestore) { 615 TEST_F(AcceleratorControllerTest, WindowPanelDockLeftDockRightRestore) {
615 std::unique_ptr<aura::Window> window0( 616 std::unique_ptr<aura::Window> window0(
616 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); 617 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20)));
617 618
618 std::unique_ptr<aura::Window> window(CreatePanel()); 619 std::unique_ptr<aura::Window> window(CreatePanel());
619 wm::WindowState* window_state = wm::GetWindowState(window.get()); 620 wm::WindowState* window_state = wm::GetWindowState(window.get());
620 window_state->Activate(); 621 window_state->Activate();
621 622
622 gfx::Rect window_restore_bounds2 = window->bounds(); 623 gfx::Rect window_restore_bounds2 = window->bounds();
623 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); 624 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT);
624 gfx::Rect expected_bounds = 625 gfx::Rect expected_bounds = wm::GetDefaultLeftSnappedWindowBoundsInParent(
625 wm::GetDefaultLeftSnappedWindowBoundsInParent(window.get()); 626 wm::WmWindowAura::Get(window.get()));
626 gfx::Rect window_restore_bounds = 627 gfx::Rect window_restore_bounds =
627 window_state->GetRestoreBoundsInScreen(); 628 window_state->GetRestoreBoundsInScreen();
628 EXPECT_NE(expected_bounds.ToString(), window->bounds().ToString()); 629 EXPECT_NE(expected_bounds.ToString(), window->bounds().ToString());
629 EXPECT_FALSE(window_state->IsSnapped()); 630 EXPECT_FALSE(window_state->IsSnapped());
630 EXPECT_FALSE(window_state->IsNormalOrSnapped()); 631 EXPECT_FALSE(window_state->IsNormalOrSnapped());
631 EXPECT_TRUE(window_state->IsDocked()); 632 EXPECT_TRUE(window_state->IsDocked());
632 window_state->Restore(); 633 window_state->Restore();
633 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT); 634 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT);
634 EXPECT_TRUE(window_state->IsDocked()); 635 EXPECT_TRUE(window_state->IsDocked());
635 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT); 636 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT);
(...skipping 952 matching lines...) Expand 10 before | Expand all | Expand 10 after
1588 EXPECT_TRUE(IsMessageCenterEmpty()); 1589 EXPECT_TRUE(IsMessageCenterEmpty());
1589 1590
1590 // If the action is LOCK_SCREEN, we must reset the state by unlocking the 1591 // If the action is LOCK_SCREEN, we must reset the state by unlocking the
1591 // screen before we proceed testing the rest of accelerators. 1592 // screen before we proceed testing the rest of accelerators.
1592 ResetStateIfNeeded(); 1593 ResetStateIfNeeded();
1593 } 1594 }
1594 } 1595 }
1595 #endif // defined(OS_CHROMEOS) 1596 #endif // defined(OS_CHROMEOS)
1596 1597
1597 } // namespace ash 1598 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/ash.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698