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 664 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1199 for (size_t k = 0 ; k < kActionsAllowedAtModalWindowLength; ++k) | 1199 for (size_t k = 0 ; k < kActionsAllowedAtModalWindowLength; ++k) |
1200 actionsAllowedAtModalWindow.insert(kActionsAllowedAtModalWindow[k]); | 1200 actionsAllowedAtModalWindow.insert(kActionsAllowedAtModalWindow[k]); |
1201 for (std::set<AcceleratorAction>::const_iterator it = | 1201 for (std::set<AcceleratorAction>::const_iterator it = |
1202 actionsAllowedAtModalWindow.begin(); | 1202 actionsAllowedAtModalWindow.begin(); |
1203 it != actionsAllowedAtModalWindow.end(); ++it) { | 1203 it != actionsAllowedAtModalWindow.end(); ++it) { |
1204 EXPECT_FALSE(allActions.find(*it) == allActions.end()) | 1204 EXPECT_FALSE(allActions.find(*it) == allActions.end()) |
1205 << " action from kActionsAllowedAtModalWindow" | 1205 << " action from kActionsAllowedAtModalWindow" |
1206 << " not found in kAcceleratorData. action: " << *it; | 1206 << " not found in kAcceleratorData. action: " << *it; |
1207 } | 1207 } |
1208 scoped_ptr<aura::Window> window( | 1208 scoped_ptr<aura::Window> window( |
1209 aura::test::CreateTestWindowWithBounds(gfx::Rect(5, 5, 20, 20), NULL)); | 1209 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); |
1210 const ui::Accelerator dummy; | 1210 const ui::Accelerator dummy; |
1211 wm::ActivateWindow(window.get()); | 1211 wm::ActivateWindow(window.get()); |
1212 Shell::GetInstance()->SimulateModalWindowOpenForTesting(true); | 1212 Shell::GetInstance()->SimulateModalWindowOpenForTesting(true); |
1213 for (std::set<AcceleratorAction>::const_iterator it = allActions.begin(); | 1213 for (std::set<AcceleratorAction>::const_iterator it = allActions.begin(); |
1214 it != allActions.end(); ++it) { | 1214 it != allActions.end(); ++it) { |
1215 if (actionsAllowedAtModalWindow.find(*it) == | 1215 if (actionsAllowedAtModalWindow.find(*it) == |
1216 actionsAllowedAtModalWindow.end()) { | 1216 actionsAllowedAtModalWindow.end()) { |
1217 EXPECT_TRUE(GetController()->PerformAction(*it, dummy)) | 1217 EXPECT_TRUE(GetController()->PerformAction(*it, dummy)) |
1218 << " for action (disallowed at modal window): " << *it; | 1218 << " for action (disallowed at modal window): " << *it; |
1219 } | 1219 } |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1326 EXPECT_EQ(f9, delegate->last_accelerator()); | 1326 EXPECT_EQ(f9, delegate->last_accelerator()); |
1327 EXPECT_EQ(0, delegate->handle_volume_up_count()); | 1327 EXPECT_EQ(0, delegate->handle_volume_up_count()); |
1328 EXPECT_TRUE(ProcessWithContext(f10)); | 1328 EXPECT_TRUE(ProcessWithContext(f10)); |
1329 EXPECT_EQ(1, delegate->handle_volume_up_count()); | 1329 EXPECT_EQ(1, delegate->handle_volume_up_count()); |
1330 EXPECT_EQ(f10, delegate->last_accelerator()); | 1330 EXPECT_EQ(f10, delegate->last_accelerator()); |
1331 } | 1331 } |
1332 } | 1332 } |
1333 #endif | 1333 #endif |
1334 | 1334 |
1335 } // namespace ash | 1335 } // namespace ash |
OLD | NEW |