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

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

Issue 2035543004: Shuffles and renames ash/common/wm classes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: random changes for chrome tests 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 | « no previous file | ash/ash.gyp » ('j') | ash/aura/wm_root_window_controller_aura.h » ('J')
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/aura/wm_window_aura.h"
10 #include "ash/common/shell_window_ids.h" 11 #include "ash/common/shell_window_ids.h"
11 #include "ash/common/wm/panels/panel_layout_manager.h" 12 #include "ash/common/wm/panels/panel_layout_manager.h"
12 #include "ash/common/wm/window_positioning_utils.h" 13 #include "ash/common/wm/window_positioning_utils.h"
13 #include "ash/common/wm/window_state.h" 14 #include "ash/common/wm/window_state.h"
14 #include "ash/common/wm/wm_event.h" 15 #include "ash/common/wm/wm_event.h"
15 #include "ash/display/display_manager.h" 16 #include "ash/display/display_manager.h"
16 #include "ash/ime_control_delegate.h" 17 #include "ash/ime_control_delegate.h"
17 #include "ash/screen_util.h" 18 #include "ash/screen_util.h"
18 #include "ash/shell.h" 19 #include "ash/shell.h"
19 #include "ash/system/brightness_control_delegate.h" 20 #include "ash/system/brightness_control_delegate.h"
20 #include "ash/system/keyboard_brightness/keyboard_brightness_control_delegate.h" 21 #include "ash/system/keyboard_brightness/keyboard_brightness_control_delegate.h"
21 #include "ash/system/tray/system_tray_delegate.h" 22 #include "ash/system/tray/system_tray_delegate.h"
22 #include "ash/test/ash_test_base.h" 23 #include "ash/test/ash_test_base.h"
23 #include "ash/test/display_manager_test_api.h" 24 #include "ash/test/display_manager_test_api.h"
24 #include "ash/test/test_screenshot_delegate.h" 25 #include "ash/test/test_screenshot_delegate.h"
25 #include "ash/test/test_session_state_animator.h" 26 #include "ash/test/test_session_state_animator.h"
26 #include "ash/test/test_shelf_delegate.h" 27 #include "ash/test/test_shelf_delegate.h"
27 #include "ash/test/test_shell_delegate.h" 28 #include "ash/test/test_shell_delegate.h"
28 #include "ash/test/test_volume_control_delegate.h" 29 #include "ash/test/test_volume_control_delegate.h"
29 #include "ash/volume_control_delegate.h" 30 #include "ash/volume_control_delegate.h"
30 #include "ash/wm/aura/wm_window_aura.h"
31 #include "ash/wm/lock_state_controller.h" 31 #include "ash/wm/lock_state_controller.h"
32 #include "ash/wm/window_state_aura.h" 32 #include "ash/wm/window_state_aura.h"
33 #include "ash/wm/window_util.h" 33 #include "ash/wm/window_util.h"
34 #include "base/command_line.h" 34 #include "base/command_line.h"
35 #include "ui/aura/client/aura_constants.h" 35 #include "ui/aura/client/aura_constants.h"
36 #include "ui/aura/test/test_window_delegate.h" 36 #include "ui/aura/test/test_window_delegate.h"
37 #include "ui/aura/test/test_windows.h" 37 #include "ui/aura/test/test_windows.h"
38 #include "ui/aura/window.h" 38 #include "ui/aura/window.h"
39 #include "ui/display/screen.h" 39 #include "ui/display/screen.h"
40 #include "ui/events/event.h" 40 #include "ui/events/event.h"
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 return ewh->state_ == ExitWarningHandler::EXITING; 273 return ewh->state_ == ExitWarningHandler::EXITING;
274 } 274 }
275 aura::Window* CreatePanel() { 275 aura::Window* CreatePanel() {
276 aura::Window* window = 276 aura::Window* window =
277 CreateTestWindowInShellWithDelegateAndType(NULL, 277 CreateTestWindowInShellWithDelegateAndType(NULL,
278 ui::wm::WINDOW_TYPE_PANEL, 0, gfx::Rect(5, 5, 20, 20)); 278 ui::wm::WINDOW_TYPE_PANEL, 0, gfx::Rect(5, 5, 20, 20));
279 test::TestShelfDelegate* shelf_delegate = 279 test::TestShelfDelegate* shelf_delegate =
280 test::TestShelfDelegate::instance(); 280 test::TestShelfDelegate::instance();
281 shelf_delegate->AddShelfItem(window); 281 shelf_delegate->AddShelfItem(window);
282 PanelLayoutManager* manager = 282 PanelLayoutManager* manager =
283 PanelLayoutManager::Get(wm::WmWindowAura::Get(window)); 283 PanelLayoutManager::Get(WmWindowAura::Get(window));
284 manager->Relayout(); 284 manager->Relayout();
285 return window; 285 return window;
286 } 286 }
287 287
288 private: 288 private:
289 DISALLOW_COPY_AND_ASSIGN(AcceleratorControllerTest); 289 DISALLOW_COPY_AND_ASSIGN(AcceleratorControllerTest);
290 }; 290 };
291 291
292 AcceleratorController* AcceleratorControllerTest::GetController() { 292 AcceleratorController* AcceleratorControllerTest::GetController() {
293 return Shell::GetInstance()->accelerator_controller(); 293 return Shell::GetInstance()->accelerator_controller();
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 TEST_F(AcceleratorControllerTest, WindowSnap) { 444 TEST_F(AcceleratorControllerTest, WindowSnap) {
445 std::unique_ptr<aura::Window> window( 445 std::unique_ptr<aura::Window> window(
446 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); 446 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20)));
447 wm::WindowState* window_state = wm::GetWindowState(window.get()); 447 wm::WindowState* window_state = wm::GetWindowState(window.get());
448 448
449 window_state->Activate(); 449 window_state->Activate();
450 450
451 { 451 {
452 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); 452 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT);
453 gfx::Rect expected_bounds = wm::GetDefaultLeftSnappedWindowBoundsInParent( 453 gfx::Rect expected_bounds = wm::GetDefaultLeftSnappedWindowBoundsInParent(
454 wm::WmWindowAura::Get(window.get())); 454 WmWindowAura::Get(window.get()));
455 EXPECT_EQ(expected_bounds.ToString(), window->bounds().ToString()); 455 EXPECT_EQ(expected_bounds.ToString(), window->bounds().ToString());
456 } 456 }
457 { 457 {
458 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT); 458 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT);
459 gfx::Rect expected_bounds = wm::GetDefaultRightSnappedWindowBoundsInParent( 459 gfx::Rect expected_bounds = wm::GetDefaultRightSnappedWindowBoundsInParent(
460 wm::WmWindowAura::Get(window.get())); 460 WmWindowAura::Get(window.get()));
461 EXPECT_EQ(expected_bounds.ToString(), window->bounds().ToString()); 461 EXPECT_EQ(expected_bounds.ToString(), window->bounds().ToString());
462 } 462 }
463 { 463 {
464 gfx::Rect normal_bounds = window_state->GetRestoreBoundsInParent(); 464 gfx::Rect normal_bounds = window_state->GetRestoreBoundsInParent();
465 465
466 GetController()->PerformActionIfEnabled(TOGGLE_MAXIMIZED); 466 GetController()->PerformActionIfEnabled(TOGGLE_MAXIMIZED);
467 EXPECT_TRUE(window_state->IsMaximized()); 467 EXPECT_TRUE(window_state->IsMaximized());
468 EXPECT_NE(normal_bounds.ToString(), window->bounds().ToString()); 468 EXPECT_NE(normal_bounds.ToString(), window->bounds().ToString());
469 469
470 GetController()->PerformActionIfEnabled(TOGGLE_MAXIMIZED); 470 GetController()->PerformActionIfEnabled(TOGGLE_MAXIMIZED);
(...skipping 28 matching lines...) Expand all
499 std::unique_ptr<aura::Window> window0( 499 std::unique_ptr<aura::Window> window0(
500 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); 500 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20)));
501 std::unique_ptr<aura::Window> window1( 501 std::unique_ptr<aura::Window> window1(
502 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); 502 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20)));
503 wm::WindowState* window1_state = wm::GetWindowState(window1.get()); 503 wm::WindowState* window1_state = wm::GetWindowState(window1.get());
504 window1_state->Activate(); 504 window1_state->Activate();
505 505
506 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); 506 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT);
507 gfx::Rect normal_bounds = window1_state->GetRestoreBoundsInParent(); 507 gfx::Rect normal_bounds = window1_state->GetRestoreBoundsInParent();
508 gfx::Rect expected_bounds = wm::GetDefaultLeftSnappedWindowBoundsInParent( 508 gfx::Rect expected_bounds = wm::GetDefaultLeftSnappedWindowBoundsInParent(
509 wm::WmWindowAura::Get(window1.get())); 509 WmWindowAura::Get(window1.get()));
510 EXPECT_EQ(expected_bounds.ToString(), window1->bounds().ToString()); 510 EXPECT_EQ(expected_bounds.ToString(), window1->bounds().ToString());
511 EXPECT_TRUE(window1_state->IsSnapped()); 511 EXPECT_TRUE(window1_state->IsSnapped());
512 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); 512 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT);
513 EXPECT_FALSE(window1_state->IsNormalOrSnapped()); 513 EXPECT_FALSE(window1_state->IsNormalOrSnapped());
514 EXPECT_TRUE(window1_state->IsDocked()); 514 EXPECT_TRUE(window1_state->IsDocked());
515 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); 515 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT);
516 EXPECT_FALSE(window1_state->IsDocked()); 516 EXPECT_FALSE(window1_state->IsDocked());
517 EXPECT_EQ(normal_bounds.ToString(), window1->bounds().ToString()); 517 EXPECT_EQ(normal_bounds.ToString(), window1->bounds().ToString());
518 } 518 }
519 519
520 TEST_F(AcceleratorControllerTest, WindowSnapRightDockRightRestore) { 520 TEST_F(AcceleratorControllerTest, WindowSnapRightDockRightRestore) {
521 std::unique_ptr<aura::Window> window0( 521 std::unique_ptr<aura::Window> window0(
522 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); 522 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20)));
523 std::unique_ptr<aura::Window> window1( 523 std::unique_ptr<aura::Window> window1(
524 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); 524 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20)));
525 525
526 wm::WindowState* window1_state = wm::GetWindowState(window1.get()); 526 wm::WindowState* window1_state = wm::GetWindowState(window1.get());
527 window1_state->Activate(); 527 window1_state->Activate();
528 528
529 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT); 529 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT);
530 gfx::Rect normal_bounds = window1_state->GetRestoreBoundsInParent(); 530 gfx::Rect normal_bounds = window1_state->GetRestoreBoundsInParent();
531 gfx::Rect expected_bounds = wm::GetDefaultRightSnappedWindowBoundsInParent( 531 gfx::Rect expected_bounds = wm::GetDefaultRightSnappedWindowBoundsInParent(
532 wm::WmWindowAura::Get(window1.get())); 532 WmWindowAura::Get(window1.get()));
533 EXPECT_EQ(expected_bounds.ToString(), window1->bounds().ToString()); 533 EXPECT_EQ(expected_bounds.ToString(), window1->bounds().ToString());
534 EXPECT_TRUE(window1_state->IsSnapped()); 534 EXPECT_TRUE(window1_state->IsSnapped());
535 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT); 535 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT);
536 EXPECT_FALSE(window1_state->IsNormalOrSnapped()); 536 EXPECT_FALSE(window1_state->IsNormalOrSnapped());
537 EXPECT_TRUE(window1_state->IsDocked()); 537 EXPECT_TRUE(window1_state->IsDocked());
538 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT); 538 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT);
539 EXPECT_FALSE(window1_state->IsDocked()); 539 EXPECT_FALSE(window1_state->IsDocked());
540 EXPECT_EQ(normal_bounds.ToString(), window1->bounds().ToString()); 540 EXPECT_EQ(normal_bounds.ToString(), window1->bounds().ToString());
541 } 541 }
542 542
543 TEST_F(AcceleratorControllerTest, WindowSnapLeftDockLeftSnapRight) { 543 TEST_F(AcceleratorControllerTest, WindowSnapLeftDockLeftSnapRight) {
544 std::unique_ptr<aura::Window> window0( 544 std::unique_ptr<aura::Window> window0(
545 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); 545 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20)));
546 std::unique_ptr<aura::Window> window1( 546 std::unique_ptr<aura::Window> window1(
547 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); 547 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20)));
548 548
549 wm::WindowState* window1_state = wm::GetWindowState(window1.get()); 549 wm::WindowState* window1_state = wm::GetWindowState(window1.get());
550 window1_state->Activate(); 550 window1_state->Activate();
551 551
552 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); 552 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT);
553 gfx::Rect expected_bounds = wm::GetDefaultLeftSnappedWindowBoundsInParent( 553 gfx::Rect expected_bounds = wm::GetDefaultLeftSnappedWindowBoundsInParent(
554 wm::WmWindowAura::Get(window1.get())); 554 WmWindowAura::Get(window1.get()));
555 gfx::Rect expected_bounds2 = wm::GetDefaultRightSnappedWindowBoundsInParent( 555 gfx::Rect expected_bounds2 = wm::GetDefaultRightSnappedWindowBoundsInParent(
556 wm::WmWindowAura::Get(window1.get())); 556 WmWindowAura::Get(window1.get()));
557 EXPECT_EQ(expected_bounds.ToString(), window1->bounds().ToString()); 557 EXPECT_EQ(expected_bounds.ToString(), window1->bounds().ToString());
558 EXPECT_TRUE(window1_state->IsSnapped()); 558 EXPECT_TRUE(window1_state->IsSnapped());
559 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); 559 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT);
560 EXPECT_FALSE(window1_state->IsNormalOrSnapped()); 560 EXPECT_FALSE(window1_state->IsNormalOrSnapped());
561 EXPECT_TRUE(window1_state->IsDocked()); 561 EXPECT_TRUE(window1_state->IsDocked());
562 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT); 562 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT);
563 EXPECT_FALSE(window1_state->IsDocked()); 563 EXPECT_FALSE(window1_state->IsDocked());
564 EXPECT_TRUE(window1_state->IsSnapped()); 564 EXPECT_TRUE(window1_state->IsSnapped());
565 EXPECT_EQ(expected_bounds2.ToString(), window1->bounds().ToString()); 565 EXPECT_EQ(expected_bounds2.ToString(), window1->bounds().ToString());
566 } 566 }
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 std::unique_ptr<aura::Window> window0( 616 std::unique_ptr<aura::Window> window0(
617 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); 617 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20)));
618 618
619 std::unique_ptr<aura::Window> window(CreatePanel()); 619 std::unique_ptr<aura::Window> window(CreatePanel());
620 wm::WindowState* window_state = wm::GetWindowState(window.get()); 620 wm::WindowState* window_state = wm::GetWindowState(window.get());
621 window_state->Activate(); 621 window_state->Activate();
622 622
623 gfx::Rect window_restore_bounds2 = window->bounds(); 623 gfx::Rect window_restore_bounds2 = window->bounds();
624 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); 624 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT);
625 gfx::Rect expected_bounds = wm::GetDefaultLeftSnappedWindowBoundsInParent( 625 gfx::Rect expected_bounds = wm::GetDefaultLeftSnappedWindowBoundsInParent(
626 wm::WmWindowAura::Get(window.get())); 626 WmWindowAura::Get(window.get()));
627 gfx::Rect window_restore_bounds = 627 gfx::Rect window_restore_bounds =
628 window_state->GetRestoreBoundsInScreen(); 628 window_state->GetRestoreBoundsInScreen();
629 EXPECT_NE(expected_bounds.ToString(), window->bounds().ToString()); 629 EXPECT_NE(expected_bounds.ToString(), window->bounds().ToString());
630 EXPECT_FALSE(window_state->IsSnapped()); 630 EXPECT_FALSE(window_state->IsSnapped());
631 EXPECT_FALSE(window_state->IsNormalOrSnapped()); 631 EXPECT_FALSE(window_state->IsNormalOrSnapped());
632 EXPECT_TRUE(window_state->IsDocked()); 632 EXPECT_TRUE(window_state->IsDocked());
633 window_state->Restore(); 633 window_state->Restore();
634 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT); 634 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT);
635 EXPECT_TRUE(window_state->IsDocked()); 635 EXPECT_TRUE(window_state->IsDocked());
636 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT); 636 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT);
(...skipping 941 matching lines...) Expand 10 before | Expand all | Expand 10 after
1578 EXPECT_TRUE(IsMessageCenterEmpty()); 1578 EXPECT_TRUE(IsMessageCenterEmpty());
1579 1579
1580 // If the action is LOCK_SCREEN, we must reset the state by unlocking the 1580 // If the action is LOCK_SCREEN, we must reset the state by unlocking the
1581 // screen before we proceed testing the rest of accelerators. 1581 // screen before we proceed testing the rest of accelerators.
1582 ResetStateIfNeeded(); 1582 ResetStateIfNeeded();
1583 } 1583 }
1584 } 1584 }
1585 #endif // defined(OS_CHROMEOS) 1585 #endif // defined(OS_CHROMEOS)
1586 1586
1587 } // namespace ash 1587 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/ash.gyp » ('j') | ash/aura/wm_root_window_controller_aura.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698