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/accelerators/accelerator_controller.h" | 5 #include "ash/accelerators/accelerator_controller.h" |
6 #include "ash/accelerators/accelerator_table.h" | 6 #include "ash/accelerators/accelerator_table.h" |
7 #include "ash/caps_lock_delegate.h" | 7 #include "ash/caps_lock_delegate.h" |
8 #include "ash/display/display_manager.h" | 8 #include "ash/display/display_manager.h" |
9 #include "ash/ime_control_delegate.h" | 9 #include "ash/ime_control_delegate.h" |
10 #include "ash/screenshot_delegate.h" | 10 #include "ash/screenshot_delegate.h" |
11 #include "ash/shell.h" | 11 #include "ash/shell.h" |
12 #include "ash/shell_window_ids.h" | 12 #include "ash/shell_window_ids.h" |
13 #include "ash/system/brightness/brightness_control_delegate.h" | 13 #include "ash/system/brightness/brightness_control_delegate.h" |
14 #include "ash/system/keyboard_brightness/keyboard_brightness_control_delegate.h" | 14 #include "ash/system/keyboard_brightness/keyboard_brightness_control_delegate.h" |
15 #include "ash/system/tray/system_tray_delegate.h" | 15 #include "ash/system/tray/system_tray_delegate.h" |
16 #include "ash/test/ash_test_base.h" | 16 #include "ash/test/ash_test_base.h" |
17 #include "ash/test/display_manager_test_api.h" | 17 #include "ash/test/display_manager_test_api.h" |
18 #include "ash/test/test_shell_delegate.h" | 18 #include "ash/test/test_shell_delegate.h" |
19 #include "ash/volume_control_delegate.h" | 19 #include "ash/volume_control_delegate.h" |
20 #include "ash/wm/window_util.h" | 20 #include "ash/wm/window_util.h" |
| 21 #include "ash/wm/workspace/snap_sizer.h" |
21 #include "ui/aura/root_window.h" | 22 #include "ui/aura/root_window.h" |
22 #include "ui/aura/test/test_window_delegate.h" | 23 #include "ui/aura/test/test_window_delegate.h" |
23 #include "ui/aura/test/test_windows.h" | 24 #include "ui/aura/test/test_windows.h" |
24 #include "ui/aura/window.h" | 25 #include "ui/aura/window.h" |
25 #include "ui/base/events/event.h" | 26 #include "ui/base/events/event.h" |
26 | 27 |
27 #if defined(USE_X11) | 28 #if defined(USE_X11) |
28 #include <X11/Xlib.h> | 29 #include <X11/Xlib.h> |
29 #include "ui/base/x/x11_util.h" | 30 #include "ui/base/x/x11_util.h" |
30 #endif | 31 #endif |
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
494 } | 495 } |
495 | 496 |
496 TEST_F(AcceleratorControllerTest, WindowSnap) { | 497 TEST_F(AcceleratorControllerTest, WindowSnap) { |
497 scoped_ptr<aura::Window> window( | 498 scoped_ptr<aura::Window> window( |
498 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); | 499 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); |
499 const ui::Accelerator dummy; | 500 const ui::Accelerator dummy; |
500 | 501 |
501 wm::ActivateWindow(window.get()); | 502 wm::ActivateWindow(window.get()); |
502 | 503 |
503 { | 504 { |
504 GetController()->PerformAction(WINDOW_SNAP_LEFT, dummy); | 505 internal::SnapSizer snap_sizer_left(window.get(), |
505 gfx::Rect snap_left = window->bounds(); | 506 gfx::Point(), |
506 GetController()->PerformAction(WINDOW_SNAP_LEFT, dummy); | 507 internal::SnapSizer::LEFT_EDGE, |
507 EXPECT_NE(window->bounds().ToString(), snap_left.ToString()); | 508 internal::SnapSizer::STEP_NO); |
508 GetController()->PerformAction(WINDOW_SNAP_LEFT, dummy); | 509 gfx::Rect snap_left = snap_sizer_left.target_bounds(); |
509 EXPECT_NE(window->bounds().ToString(), snap_left.ToString()); | 510 EXPECT_NE(window->bounds().ToString(), snap_left.ToString()); |
510 | 511 |
511 // It should cycle back to the first snapped position. | |
512 GetController()->PerformAction(WINDOW_SNAP_LEFT, dummy); | 512 GetController()->PerformAction(WINDOW_SNAP_LEFT, dummy); |
513 EXPECT_EQ(window->bounds().ToString(), snap_left.ToString()); | 513 EXPECT_EQ(window->bounds().ToString(), snap_left.ToString()); |
514 } | 514 |
515 { | 515 internal::SnapSizer snap_sizer_right(window.get(), |
516 GetController()->PerformAction(WINDOW_SNAP_RIGHT, dummy); | 516 gfx::Point(), |
517 gfx::Rect snap_right = window->bounds(); | 517 internal::SnapSizer::RIGHT_EDGE, |
518 GetController()->PerformAction(WINDOW_SNAP_RIGHT, dummy); | 518 internal::SnapSizer::STEP_NO); |
519 EXPECT_NE(window->bounds().ToString(), snap_right.ToString()); | 519 gfx::Rect snap_right = snap_sizer_right.target_bounds(); |
520 GetController()->PerformAction(WINDOW_SNAP_RIGHT, dummy); | 520 EXPECT_NE(snap_left.ToString(), snap_right.ToString()); |
521 EXPECT_NE(window->bounds().ToString(), snap_right.ToString()); | 521 EXPECT_NE(window->bounds().ToString(), snap_right.ToString()); |
522 | 522 |
523 // It should cycle back to the first snapped position. | |
524 GetController()->PerformAction(WINDOW_SNAP_RIGHT, dummy); | 523 GetController()->PerformAction(WINDOW_SNAP_RIGHT, dummy); |
525 EXPECT_EQ(window->bounds().ToString(), snap_right.ToString()); | 524 EXPECT_EQ(window->bounds().ToString(), snap_right.ToString()); |
| 525 |
| 526 // Restore the window because side maximizing stores restore bounds. |
| 527 wm::RestoreWindow(window.get()); |
526 } | 528 } |
527 { | 529 { |
528 gfx::Rect normal_bounds = window->bounds(); | 530 gfx::Rect normal_bounds = window->bounds(); |
529 | 531 |
530 GetController()->PerformAction(TOGGLE_MAXIMIZED, dummy); | 532 GetController()->PerformAction(TOGGLE_MAXIMIZED, dummy); |
531 EXPECT_TRUE(wm::IsWindowMaximized(window.get())); | 533 EXPECT_TRUE(wm::IsWindowMaximized(window.get())); |
532 EXPECT_NE(normal_bounds.ToString(), window->bounds().ToString()); | 534 EXPECT_NE(normal_bounds.ToString(), window->bounds().ToString()); |
533 | 535 |
534 GetController()->PerformAction(TOGGLE_MAXIMIZED, dummy); | 536 GetController()->PerformAction(TOGGLE_MAXIMIZED, dummy); |
535 EXPECT_FALSE(wm::IsWindowMaximized(window.get())); | 537 EXPECT_FALSE(wm::IsWindowMaximized(window.get())); |
(...skipping 798 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1334 EXPECT_EQ(volume_down, delegate->last_accelerator()); | 1336 EXPECT_EQ(volume_down, delegate->last_accelerator()); |
1335 EXPECT_EQ(0, delegate->handle_volume_up_count()); | 1337 EXPECT_EQ(0, delegate->handle_volume_up_count()); |
1336 EXPECT_TRUE(ProcessWithContext(volume_up)); | 1338 EXPECT_TRUE(ProcessWithContext(volume_up)); |
1337 EXPECT_EQ(1, delegate->handle_volume_up_count()); | 1339 EXPECT_EQ(1, delegate->handle_volume_up_count()); |
1338 EXPECT_EQ(volume_up, delegate->last_accelerator()); | 1340 EXPECT_EQ(volume_up, delegate->last_accelerator()); |
1339 } | 1341 } |
1340 } | 1342 } |
1341 #endif | 1343 #endif |
1342 | 1344 |
1343 } // namespace ash | 1345 } // namespace ash |
OLD | NEW |