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 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 | 356 |
357 // The registered accelerator is processed. | 357 // The registered accelerator is processed. |
358 EXPECT_TRUE(GetController()->Process(accelerator_a)); | 358 EXPECT_TRUE(GetController()->Process(accelerator_a)); |
359 EXPECT_EQ(1, target1.accelerator_pressed_count()); | 359 EXPECT_EQ(1, target1.accelerator_pressed_count()); |
360 | 360 |
361 // The non-registered accelerator is not processed. | 361 // The non-registered accelerator is not processed. |
362 const ui::Accelerator accelerator_b(ui::VKEY_B, false, false, false); | 362 const ui::Accelerator accelerator_b(ui::VKEY_B, false, false, false); |
363 EXPECT_FALSE(GetController()->Process(accelerator_b)); | 363 EXPECT_FALSE(GetController()->Process(accelerator_b)); |
364 } | 364 } |
365 | 365 |
| 366 TEST_F(AcceleratorControllerTest, IsRegistered) { |
| 367 const ui::Accelerator accelerator_a(ui::VKEY_A, false, false, false); |
| 368 const ui::Accelerator accelerator_shift_a(ui::VKEY_A, true, false, false); |
| 369 TestTarget target; |
| 370 GetController()->Register(accelerator_a, &target); |
| 371 EXPECT_TRUE(GetController()->IsRegistered(accelerator_a)); |
| 372 EXPECT_FALSE(GetController()->IsRegistered(accelerator_shift_a)); |
| 373 GetController()->UnregisterAll(&target); |
| 374 EXPECT_FALSE(GetController()->IsRegistered(accelerator_a)); |
| 375 } |
| 376 |
366 #if defined(OS_WIN) || defined(USE_X11) | 377 #if defined(OS_WIN) || defined(USE_X11) |
367 TEST_F(AcceleratorControllerTest, ProcessOnce) { | 378 TEST_F(AcceleratorControllerTest, ProcessOnce) { |
368 ui::Accelerator accelerator_a(ui::VKEY_A, false, false, false); | 379 ui::Accelerator accelerator_a(ui::VKEY_A, false, false, false); |
369 TestTarget target; | 380 TestTarget target; |
370 GetController()->Register(accelerator_a, &target); | 381 GetController()->Register(accelerator_a, &target); |
371 | 382 |
372 // The accelerator is processed only once. | 383 // The accelerator is processed only once. |
373 #if defined(OS_WIN) | 384 #if defined(OS_WIN) |
374 MSG msg1 = { NULL, WM_KEYDOWN, ui::VKEY_A, 0 }; | 385 MSG msg1 = { NULL, WM_KEYDOWN, ui::VKEY_A, 0 }; |
375 aura::TranslatedKeyEvent key_event1(msg1, false); | 386 aura::TranslatedKeyEvent key_event1(msg1, false); |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
723 EXPECT_FALSE(GetController()->Process(shift_alt_press)); | 734 EXPECT_FALSE(GetController()->Process(shift_alt_press)); |
724 EXPECT_FALSE(GetController()->Process(shift_alt_x_press)); | 735 EXPECT_FALSE(GetController()->Process(shift_alt_x_press)); |
725 EXPECT_FALSE(GetController()->Process(shift_alt_x)); | 736 EXPECT_FALSE(GetController()->Process(shift_alt_x)); |
726 EXPECT_FALSE(GetController()->Process(shift_alt)); | 737 EXPECT_FALSE(GetController()->Process(shift_alt)); |
727 EXPECT_EQ(2, delegate->handle_next_ime_count()); | 738 EXPECT_EQ(2, delegate->handle_next_ime_count()); |
728 } | 739 } |
729 } | 740 } |
730 | 741 |
731 } // namespace test | 742 } // namespace test |
732 } // namespace ash | 743 } // namespace ash |
OLD | NEW |