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" |
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
420 TestTarget target; | 420 TestTarget target; |
421 GetController()->Register(accelerator_a, &target); | 421 GetController()->Register(accelerator_a, &target); |
422 EXPECT_TRUE(GetController()->IsRegistered(accelerator_a)); | 422 EXPECT_TRUE(GetController()->IsRegistered(accelerator_a)); |
423 EXPECT_FALSE(GetController()->IsRegistered(accelerator_shift_a)); | 423 EXPECT_FALSE(GetController()->IsRegistered(accelerator_shift_a)); |
424 GetController()->UnregisterAll(&target); | 424 GetController()->UnregisterAll(&target); |
425 EXPECT_FALSE(GetController()->IsRegistered(accelerator_a)); | 425 EXPECT_FALSE(GetController()->IsRegistered(accelerator_a)); |
426 } | 426 } |
427 | 427 |
428 TEST_F(AcceleratorControllerTest, WindowSnap) { | 428 TEST_F(AcceleratorControllerTest, WindowSnap) { |
429 scoped_ptr<aura::Window> window( | 429 scoped_ptr<aura::Window> window( |
430 aura::test::CreateTestWindowWithBounds(gfx::Rect(5, 5, 20, 20), NULL)); | 430 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); |
431 const ui::Accelerator dummy; | 431 const ui::Accelerator dummy; |
432 | 432 |
433 wm::ActivateWindow(window.get()); | 433 wm::ActivateWindow(window.get()); |
434 | 434 |
435 { | 435 { |
436 GetController()->PerformAction(WINDOW_SNAP_LEFT, dummy); | 436 GetController()->PerformAction(WINDOW_SNAP_LEFT, dummy); |
437 gfx::Rect snap_left = window->bounds(); | 437 gfx::Rect snap_left = window->bounds(); |
438 GetController()->PerformAction(WINDOW_SNAP_LEFT, dummy); | 438 GetController()->PerformAction(WINDOW_SNAP_LEFT, dummy); |
439 EXPECT_NE(window->bounds().ToString(), snap_left.ToString()); | 439 EXPECT_NE(window->bounds().ToString(), snap_left.ToString()); |
440 | 440 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
514 GetController()->context()->previous_accelerator().type()); | 514 GetController()->context()->previous_accelerator().type()); |
515 | 515 |
516 GetController()->context()->UpdateContext(accelerator_b); | 516 GetController()->context()->UpdateContext(accelerator_b); |
517 EXPECT_FALSE(GetController()->context()->repeated()); | 517 EXPECT_FALSE(GetController()->context()->repeated()); |
518 EXPECT_EQ(ui::ET_KEY_RELEASED, | 518 EXPECT_EQ(ui::ET_KEY_RELEASED, |
519 GetController()->context()->previous_accelerator().type()); | 519 GetController()->context()->previous_accelerator().type()); |
520 } | 520 } |
521 | 521 |
522 TEST_F(AcceleratorControllerTest, SuppressToggleMaximized) { | 522 TEST_F(AcceleratorControllerTest, SuppressToggleMaximized) { |
523 scoped_ptr<aura::Window> window( | 523 scoped_ptr<aura::Window> window( |
524 aura::test::CreateTestWindowWithBounds(gfx::Rect(5, 5, 20, 20), NULL)); | 524 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); |
525 wm::ActivateWindow(window.get()); | 525 wm::ActivateWindow(window.get()); |
526 const ui::Accelerator accelerator(ui::VKEY_A, ui::EF_NONE); | 526 const ui::Accelerator accelerator(ui::VKEY_A, ui::EF_NONE); |
527 const ui::Accelerator empty_accelerator; | 527 const ui::Accelerator empty_accelerator; |
528 | 528 |
529 // Toggling not suppressed. | 529 // Toggling not suppressed. |
530 GetController()->context()->UpdateContext(accelerator); | 530 GetController()->context()->UpdateContext(accelerator); |
531 GetController()->PerformAction(TOGGLE_MAXIMIZED, accelerator); | 531 GetController()->PerformAction(TOGGLE_MAXIMIZED, accelerator); |
532 EXPECT_TRUE(wm::IsWindowMaximized(window.get())); | 532 EXPECT_TRUE(wm::IsWindowMaximized(window.get())); |
533 | 533 |
534 // The same accelerator - toggling suppressed. | 534 // The same accelerator - toggling suppressed. |
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1137 for (size_t k = 0 ; k < kActionsAllowedAtModalWindowLength; ++k) | 1137 for (size_t k = 0 ; k < kActionsAllowedAtModalWindowLength; ++k) |
1138 actionsAllowedAtModalWindow.insert(kActionsAllowedAtModalWindow[k]); | 1138 actionsAllowedAtModalWindow.insert(kActionsAllowedAtModalWindow[k]); |
1139 for (std::set<AcceleratorAction>::const_iterator it = | 1139 for (std::set<AcceleratorAction>::const_iterator it = |
1140 actionsAllowedAtModalWindow.begin(); | 1140 actionsAllowedAtModalWindow.begin(); |
1141 it != actionsAllowedAtModalWindow.end(); ++it) { | 1141 it != actionsAllowedAtModalWindow.end(); ++it) { |
1142 EXPECT_FALSE(allActions.find(*it) == allActions.end()) | 1142 EXPECT_FALSE(allActions.find(*it) == allActions.end()) |
1143 << " action from kActionsAllowedAtModalWindow" | 1143 << " action from kActionsAllowedAtModalWindow" |
1144 << " not found in kAcceleratorData. action: " << *it; | 1144 << " not found in kAcceleratorData. action: " << *it; |
1145 } | 1145 } |
1146 scoped_ptr<aura::Window> window( | 1146 scoped_ptr<aura::Window> window( |
1147 aura::test::CreateTestWindowWithBounds(gfx::Rect(5, 5, 20, 20), NULL)); | 1147 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); |
1148 const ui::Accelerator dummy; | 1148 const ui::Accelerator dummy; |
1149 wm::ActivateWindow(window.get()); | 1149 wm::ActivateWindow(window.get()); |
1150 Shell::GetInstance()->SimulateModalWindowOpenForTesting(true); | 1150 Shell::GetInstance()->SimulateModalWindowOpenForTesting(true); |
1151 for (std::set<AcceleratorAction>::const_iterator it = allActions.begin(); | 1151 for (std::set<AcceleratorAction>::const_iterator it = allActions.begin(); |
1152 it != allActions.end(); ++it) { | 1152 it != allActions.end(); ++it) { |
1153 if (actionsAllowedAtModalWindow.find(*it) == | 1153 if (actionsAllowedAtModalWindow.find(*it) == |
1154 actionsAllowedAtModalWindow.end()) { | 1154 actionsAllowedAtModalWindow.end()) { |
1155 EXPECT_TRUE(GetController()->PerformAction(*it, dummy)) | 1155 EXPECT_TRUE(GetController()->PerformAction(*it, dummy)) |
1156 << " for action (disallowed at modal window): " << *it; | 1156 << " for action (disallowed at modal window): " << *it; |
1157 } | 1157 } |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1264 EXPECT_EQ(f9, delegate->last_accelerator()); | 1264 EXPECT_EQ(f9, delegate->last_accelerator()); |
1265 EXPECT_EQ(0, delegate->handle_volume_up_count()); | 1265 EXPECT_EQ(0, delegate->handle_volume_up_count()); |
1266 EXPECT_TRUE(ProcessWithContext(f10)); | 1266 EXPECT_TRUE(ProcessWithContext(f10)); |
1267 EXPECT_EQ(1, delegate->handle_volume_up_count()); | 1267 EXPECT_EQ(1, delegate->handle_volume_up_count()); |
1268 EXPECT_EQ(f10, delegate->last_accelerator()); | 1268 EXPECT_EQ(f10, delegate->last_accelerator()); |
1269 } | 1269 } |
1270 } | 1270 } |
1271 #endif | 1271 #endif |
1272 | 1272 |
1273 } // namespace ash | 1273 } // namespace ash |
OLD | NEW |