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/caps_lock_delegate.h" | 6 #include "ash/caps_lock_delegate.h" |
7 #include "ash/ime_control_delegate.h" | 7 #include "ash/ime_control_delegate.h" |
8 #include "ash/screenshot_delegate.h" | 8 #include "ash/screenshot_delegate.h" |
9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
10 #include "ash/shell_window_ids.h" | 10 #include "ash/shell_window_ids.h" |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 // All the accelerators registered for |target1| are no longer processed. | 342 // All the accelerators registered for |target1| are no longer processed. |
343 EXPECT_FALSE(GetController()->Process(accelerator_a)); | 343 EXPECT_FALSE(GetController()->Process(accelerator_a)); |
344 EXPECT_FALSE(GetController()->Process(accelerator_b)); | 344 EXPECT_FALSE(GetController()->Process(accelerator_b)); |
345 EXPECT_EQ(0, target1.accelerator_pressed_count()); | 345 EXPECT_EQ(0, target1.accelerator_pressed_count()); |
346 | 346 |
347 // UnregisterAll with a different target does not affect the other target. | 347 // UnregisterAll with a different target does not affect the other target. |
348 EXPECT_TRUE(GetController()->Process(accelerator_c)); | 348 EXPECT_TRUE(GetController()->Process(accelerator_c)); |
349 EXPECT_EQ(1, target2.accelerator_pressed_count()); | 349 EXPECT_EQ(1, target2.accelerator_pressed_count()); |
350 } | 350 } |
351 | 351 |
| 352 TEST_F(AcceleratorControllerTest, IsAccelerator) { |
| 353 const ui::Accelerator accelerator_a(ui::VKEY_A, false, false, false); |
| 354 const ui::Accelerator accelerator_shift_a(ui::VKEY_A, true, false, false); |
| 355 TestTarget target; |
| 356 GetController()->Register(accelerator_a, &target); |
| 357 |
| 358 EXPECT_TRUE(GetController()->IsAccelerator(accelerator_a)); |
| 359 EXPECT_FALSE(GetController()->IsAccelerator(accelerator_shift_a)); |
| 360 GetController()->UnregisterAll(&target); |
| 361 EXPECT_FALSE(GetController()->IsAccelerator(accelerator_a)); |
| 362 } |
| 363 |
352 TEST_F(AcceleratorControllerTest, Process) { | 364 TEST_F(AcceleratorControllerTest, Process) { |
353 const ui::Accelerator accelerator_a(ui::VKEY_A, false, false, false); | 365 const ui::Accelerator accelerator_a(ui::VKEY_A, false, false, false); |
354 TestTarget target1; | 366 TestTarget target1; |
355 GetController()->Register(accelerator_a, &target1); | 367 GetController()->Register(accelerator_a, &target1); |
356 | 368 |
357 // The registered accelerator is processed. | 369 // The registered accelerator is processed. |
358 EXPECT_TRUE(GetController()->Process(accelerator_a)); | 370 EXPECT_TRUE(GetController()->Process(accelerator_a)); |
359 EXPECT_EQ(1, target1.accelerator_pressed_count()); | 371 EXPECT_EQ(1, target1.accelerator_pressed_count()); |
360 | 372 |
361 // The non-registered accelerator is not processed. | 373 // The non-registered accelerator is not processed. |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
722 EXPECT_FALSE(GetController()->Process(shift_alt_press)); | 734 EXPECT_FALSE(GetController()->Process(shift_alt_press)); |
723 EXPECT_FALSE(GetController()->Process(shift_alt_x_press)); | 735 EXPECT_FALSE(GetController()->Process(shift_alt_x_press)); |
724 EXPECT_FALSE(GetController()->Process(shift_alt_x)); | 736 EXPECT_FALSE(GetController()->Process(shift_alt_x)); |
725 EXPECT_FALSE(GetController()->Process(shift_alt)); | 737 EXPECT_FALSE(GetController()->Process(shift_alt)); |
726 EXPECT_EQ(2, delegate->handle_next_ime_count()); | 738 EXPECT_EQ(2, delegate->handle_next_ime_count()); |
727 } | 739 } |
728 } | 740 } |
729 | 741 |
730 } // namespace test | 742 } // namespace test |
731 } // namespace ash | 743 } // namespace ash |
OLD | NEW |