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/ime_control_delegate.h" | 8 #include "ash/ime_control_delegate.h" |
9 #include "ash/screenshot_delegate.h" | 9 #include "ash/screenshot_delegate.h" |
10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
11 #include "ash/shell_window_ids.h" | 11 #include "ash/shell_window_ids.h" |
12 #include "ash/system/brightness/brightness_control_delegate.h" | 12 #include "ash/system/brightness/brightness_control_delegate.h" |
13 #include "ash/system/keyboard_brightness/keyboard_brightness_control_delegate.h" | 13 #include "ash/system/keyboard_brightness/keyboard_brightness_control_delegate.h" |
14 #include "ash/test/ash_test_base.h" | 14 #include "ash/test/ash_test_base.h" |
15 #include "ash/test/test_shell_delegate.h" | 15 #include "ash/test/test_shell_delegate.h" |
16 #include "ash/volume_control_delegate.h" | 16 #include "ash/volume_control_delegate.h" |
17 #include "ash/wm/window_util.h" | 17 #include "ash/wm/window_util.h" |
18 #include "ui/aura/event.h" | |
19 #include "ui/aura/root_window.h" | 18 #include "ui/aura/root_window.h" |
20 #include "ui/aura/test/test_window_delegate.h" | 19 #include "ui/aura/test/test_window_delegate.h" |
21 #include "ui/aura/test/test_windows.h" | 20 #include "ui/aura/test/test_windows.h" |
22 #include "ui/aura/window.h" | 21 #include "ui/aura/window.h" |
| 22 #include "ui/base/event.h" |
23 | 23 |
24 #if defined(USE_X11) | 24 #if defined(USE_X11) |
25 #include <X11/Xlib.h> | 25 #include <X11/Xlib.h> |
26 #include "ui/base/x/x11_util.h" | 26 #include "ui/base/x/x11_util.h" |
27 #endif | 27 #endif |
28 | 28 |
29 namespace ash { | 29 namespace ash { |
30 namespace test { | 30 namespace test { |
31 | 31 |
32 namespace { | 32 namespace { |
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
490 | 490 |
491 #if defined(OS_WIN) || defined(USE_X11) | 491 #if defined(OS_WIN) || defined(USE_X11) |
492 TEST_F(AcceleratorControllerTest, ProcessOnce) { | 492 TEST_F(AcceleratorControllerTest, ProcessOnce) { |
493 ui::Accelerator accelerator_a(ui::VKEY_A, ui::EF_NONE); | 493 ui::Accelerator accelerator_a(ui::VKEY_A, ui::EF_NONE); |
494 TestTarget target; | 494 TestTarget target; |
495 GetController()->Register(accelerator_a, &target); | 495 GetController()->Register(accelerator_a, &target); |
496 | 496 |
497 // The accelerator is processed only once. | 497 // The accelerator is processed only once. |
498 #if defined(OS_WIN) | 498 #if defined(OS_WIN) |
499 MSG msg1 = { NULL, WM_KEYDOWN, ui::VKEY_A, 0 }; | 499 MSG msg1 = { NULL, WM_KEYDOWN, ui::VKEY_A, 0 }; |
500 aura::TranslatedKeyEvent key_event1(msg1, false); | 500 ui::TranslatedKeyEvent key_event1(msg1, false); |
501 EXPECT_TRUE(Shell::GetPrimaryRootWindow()->AsRootWindowHostDelegate()-> | 501 EXPECT_TRUE(Shell::GetPrimaryRootWindow()->AsRootWindowHostDelegate()-> |
502 OnHostKeyEvent(&key_event1)); | 502 OnHostKeyEvent(&key_event1)); |
503 | 503 |
504 MSG msg2 = { NULL, WM_CHAR, L'A', 0 }; | 504 MSG msg2 = { NULL, WM_CHAR, L'A', 0 }; |
505 aura::TranslatedKeyEvent key_event2(msg2, true); | 505 ui::TranslatedKeyEvent key_event2(msg2, true); |
506 EXPECT_FALSE(Shell::GetPrimaryRootWindow()->AsRootWindowHostDelegate()-> | 506 EXPECT_FALSE(Shell::GetPrimaryRootWindow()->AsRootWindowHostDelegate()-> |
507 OnHostKeyEvent(&key_event2)); | 507 OnHostKeyEvent(&key_event2)); |
508 | 508 |
509 MSG msg3 = { NULL, WM_KEYUP, ui::VKEY_A, 0 }; | 509 MSG msg3 = { NULL, WM_KEYUP, ui::VKEY_A, 0 }; |
510 aura::TranslatedKeyEvent key_event3(msg3, false); | 510 ui::TranslatedKeyEvent key_event3(msg3, false); |
511 EXPECT_FALSE(Shell::GetPrimaryRootWindow()->AsRootWindowHostDelegate()-> | 511 EXPECT_FALSE(Shell::GetPrimaryRootWindow()->AsRootWindowHostDelegate()-> |
512 OnHostKeyEvent(&key_event3)); | 512 OnHostKeyEvent(&key_event3)); |
513 #elif defined(USE_X11) | 513 #elif defined(USE_X11) |
514 XEvent key_event; | 514 XEvent key_event; |
515 ui::InitXKeyEventForTesting(ui::ET_KEY_PRESSED, | 515 ui::InitXKeyEventForTesting(ui::ET_KEY_PRESSED, |
516 ui::VKEY_A, | 516 ui::VKEY_A, |
517 0, | 517 0, |
518 &key_event); | 518 &key_event); |
519 aura::TranslatedKeyEvent key_event1(&key_event, false); | 519 ui::TranslatedKeyEvent key_event1(&key_event, false); |
520 EXPECT_TRUE(Shell::GetPrimaryRootWindow()->AsRootWindowHostDelegate()-> | 520 EXPECT_TRUE(Shell::GetPrimaryRootWindow()->AsRootWindowHostDelegate()-> |
521 OnHostKeyEvent(&key_event1)); | 521 OnHostKeyEvent(&key_event1)); |
522 | 522 |
523 aura::TranslatedKeyEvent key_event2(&key_event, true); | 523 ui::TranslatedKeyEvent key_event2(&key_event, true); |
524 EXPECT_FALSE(Shell::GetPrimaryRootWindow()->AsRootWindowHostDelegate()-> | 524 EXPECT_FALSE(Shell::GetPrimaryRootWindow()->AsRootWindowHostDelegate()-> |
525 OnHostKeyEvent(&key_event2)); | 525 OnHostKeyEvent(&key_event2)); |
526 | 526 |
527 ui::InitXKeyEventForTesting(ui::ET_KEY_RELEASED, | 527 ui::InitXKeyEventForTesting(ui::ET_KEY_RELEASED, |
528 ui::VKEY_A, | 528 ui::VKEY_A, |
529 0, | 529 0, |
530 &key_event); | 530 &key_event); |
531 aura::TranslatedKeyEvent key_event3(&key_event, false); | 531 ui::TranslatedKeyEvent key_event3(&key_event, false); |
532 EXPECT_FALSE(Shell::GetPrimaryRootWindow()->AsRootWindowHostDelegate()-> | 532 EXPECT_FALSE(Shell::GetPrimaryRootWindow()->AsRootWindowHostDelegate()-> |
533 OnHostKeyEvent(&key_event3)); | 533 OnHostKeyEvent(&key_event3)); |
534 #endif | 534 #endif |
535 EXPECT_EQ(1, target.accelerator_pressed_count()); | 535 EXPECT_EQ(1, target.accelerator_pressed_count()); |
536 } | 536 } |
537 #endif | 537 #endif |
538 | 538 |
539 TEST_F(AcceleratorControllerTest, GlobalAccelerators) { | 539 TEST_F(AcceleratorControllerTest, GlobalAccelerators) { |
540 // CycleBackward | 540 // CycleBackward |
541 EXPECT_TRUE(GetController()->Process( | 541 EXPECT_TRUE(GetController()->Process( |
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
979 EXPECT_FALSE(GetController()->IsReservedAccelerator( | 979 EXPECT_FALSE(GetController()->IsReservedAccelerator( |
980 ui::Accelerator(ui::VKEY_PRINT, ui::EF_NONE))); | 980 ui::Accelerator(ui::VKEY_PRINT, ui::EF_NONE))); |
981 EXPECT_FALSE(GetController()->IsReservedAccelerator( | 981 EXPECT_FALSE(GetController()->IsReservedAccelerator( |
982 ui::Accelerator(ui::VKEY_TAB, ui::EF_NONE))); | 982 ui::Accelerator(ui::VKEY_TAB, ui::EF_NONE))); |
983 EXPECT_FALSE(GetController()->IsReservedAccelerator( | 983 EXPECT_FALSE(GetController()->IsReservedAccelerator( |
984 ui::Accelerator(ui::VKEY_A, ui::EF_NONE))); | 984 ui::Accelerator(ui::VKEY_A, ui::EF_NONE))); |
985 } | 985 } |
986 | 986 |
987 } // namespace test | 987 } // namespace test |
988 } // namespace ash | 988 } // namespace ash |
OLD | NEW |