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/accessibility_delegate.h" | 7 #include "ash/accessibility_delegate.h" |
8 #include "ash/ash_switches.h" | 8 #include "ash/ash_switches.h" |
9 #include "ash/caps_lock_delegate.h" | 9 #include "ash/caps_lock_delegate.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_ash.h" |
12 #include "ash/shell.h" | 13 #include "ash/shell.h" |
13 #include "ash/shell_window_ids.h" | 14 #include "ash/shell_window_ids.h" |
14 #include "ash/system/brightness_control_delegate.h" | 15 #include "ash/system/brightness_control_delegate.h" |
15 #include "ash/system/keyboard_brightness/keyboard_brightness_control_delegate.h" | 16 #include "ash/system/keyboard_brightness/keyboard_brightness_control_delegate.h" |
16 #include "ash/system/tray/system_tray_delegate.h" | 17 #include "ash/system/tray/system_tray_delegate.h" |
17 #include "ash/test/ash_test_base.h" | 18 #include "ash/test/ash_test_base.h" |
18 #include "ash/test/display_manager_test_api.h" | 19 #include "ash/test/display_manager_test_api.h" |
19 #include "ash/test/test_screenshot_delegate.h" | 20 #include "ash/test/test_screenshot_delegate.h" |
20 #include "ash/test/test_shell_delegate.h" | 21 #include "ash/test/test_shell_delegate.h" |
21 #include "ash/volume_control_delegate.h" | 22 #include "ash/volume_control_delegate.h" |
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
529 EXPECT_TRUE(window_state->IsMinimized()); | 530 EXPECT_TRUE(window_state->IsMinimized()); |
530 window_state->Restore(); | 531 window_state->Restore(); |
531 window_state->Activate(); | 532 window_state->Activate(); |
532 } | 533 } |
533 { | 534 { |
534 GetController()->PerformAction(WINDOW_MINIMIZE, dummy); | 535 GetController()->PerformAction(WINDOW_MINIMIZE, dummy); |
535 EXPECT_TRUE(window_state->IsMinimized()); | 536 EXPECT_TRUE(window_state->IsMinimized()); |
536 } | 537 } |
537 } | 538 } |
538 | 539 |
| 540 TEST_F(AcceleratorControllerTest, CenterWindowAccelerator) { |
| 541 scoped_ptr<aura::Window> window( |
| 542 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); |
| 543 const ui::Accelerator dummy; |
| 544 wm::WindowState* window_state = wm::GetWindowState(window.get()); |
| 545 window_state->Activate(); |
| 546 |
| 547 // Center the window using accelerator. |
| 548 GetController()->PerformAction(WINDOW_POSITION_CENTER, dummy); |
| 549 gfx::Rect work_area = |
| 550 Shell::GetScreen()->GetDisplayNearestWindow(window.get()).work_area(); |
| 551 gfx::Rect bounds = window->GetBoundsInScreen(); |
| 552 EXPECT_NEAR(bounds.x() - work_area.x(), |
| 553 work_area.right() - bounds.right(), |
| 554 1); |
| 555 EXPECT_NEAR(bounds.y() - work_area.y(), |
| 556 work_area.bottom() - bounds.bottom(), |
| 557 1); |
| 558 |
| 559 // Add the window to docked container and try to center it. |
| 560 window->SetBounds(gfx::Rect(0, 0, 20, 20)); |
| 561 aura::Window* docked_container = Shell::GetContainer( |
| 562 window->GetRootWindow(), internal::kShellWindowId_DockedContainer); |
| 563 docked_container->AddChild(window.get()); |
| 564 gfx::Rect docked_bounds = window->GetBoundsInScreen(); |
| 565 GetController()->PerformAction(WINDOW_POSITION_CENTER, dummy); |
| 566 // It should not get centered and should remain docked. |
| 567 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id()); |
| 568 EXPECT_EQ(docked_bounds.ToString(), window->GetBoundsInScreen().ToString()); |
| 569 } |
| 570 |
539 TEST_F(AcceleratorControllerTest, ControllerContext) { | 571 TEST_F(AcceleratorControllerTest, ControllerContext) { |
540 ui::Accelerator accelerator_a(ui::VKEY_A, ui::EF_NONE); | 572 ui::Accelerator accelerator_a(ui::VKEY_A, ui::EF_NONE); |
541 ui::Accelerator accelerator_a2(ui::VKEY_A, ui::EF_NONE); | 573 ui::Accelerator accelerator_a2(ui::VKEY_A, ui::EF_NONE); |
542 ui::Accelerator accelerator_b(ui::VKEY_B, ui::EF_NONE); | 574 ui::Accelerator accelerator_b(ui::VKEY_B, ui::EF_NONE); |
543 | 575 |
544 accelerator_a.set_type(ui::ET_KEY_PRESSED); | 576 accelerator_a.set_type(ui::ET_KEY_PRESSED); |
545 accelerator_a2.set_type(ui::ET_KEY_RELEASED); | 577 accelerator_a2.set_type(ui::ET_KEY_RELEASED); |
546 accelerator_b.set_type(ui::ET_KEY_PRESSED); | 578 accelerator_b.set_type(ui::ET_KEY_PRESSED); |
547 | 579 |
548 EXPECT_FALSE(GetController()->context()->repeated()); | 580 EXPECT_FALSE(GetController()->context()->repeated()); |
(...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1324 EXPECT_EQ(volume_down, delegate->last_accelerator()); | 1356 EXPECT_EQ(volume_down, delegate->last_accelerator()); |
1325 EXPECT_EQ(0, delegate->handle_volume_up_count()); | 1357 EXPECT_EQ(0, delegate->handle_volume_up_count()); |
1326 EXPECT_TRUE(ProcessWithContext(volume_up)); | 1358 EXPECT_TRUE(ProcessWithContext(volume_up)); |
1327 EXPECT_EQ(1, delegate->handle_volume_up_count()); | 1359 EXPECT_EQ(1, delegate->handle_volume_up_count()); |
1328 EXPECT_EQ(volume_up, delegate->last_accelerator()); | 1360 EXPECT_EQ(volume_up, delegate->last_accelerator()); |
1329 } | 1361 } |
1330 } | 1362 } |
1331 #endif | 1363 #endif |
1332 | 1364 |
1333 } // namespace ash | 1365 } // namespace ash |
OLD | NEW |