Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1120)

Side by Side Diff: ash/accelerators/accelerator_controller_unittest.cc

Issue 2872343003: Remove InputMethodEventHandler. (Closed)
Patch Set: Add a unittest. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 6
7 #include "ash/accelerators/accelerator_table.h" 7 #include "ash/accelerators/accelerator_table.h"
8 #include "ash/accessibility_delegate.h" 8 #include "ash/accessibility_delegate.h"
9 #include "ash/accessibility_types.h" 9 #include "ash/accessibility_types.h"
10 #include "ash/ash_switches.h" 10 #include "ash/ash_switches.h"
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 // Different accelerator. 620 // Different accelerator.
621 generator.PressKey(ui::VKEY_K, ui::EF_ALT_DOWN); 621 generator.PressKey(ui::VKEY_K, ui::EF_ALT_DOWN);
622 EXPECT_FALSE(window_state->IsFullscreen()); 622 EXPECT_FALSE(window_state->IsFullscreen());
623 } 623 }
624 624
625 // TODO(oshima): Fix this test to use EventGenerator. 625 // TODO(oshima): Fix this test to use EventGenerator.
626 #if defined(USE_X11) 626 #if defined(USE_X11)
627 TEST_F(AcceleratorControllerTest, ProcessOnce) { 627 TEST_F(AcceleratorControllerTest, ProcessOnce) {
628 // The IME event filter interferes with the basic key event propagation we 628 // The IME event filter interferes with the basic key event propagation we
629 // attempt to do here, so we disable it. 629 // attempt to do here, so we disable it.
630 DisableIME(); 630 const bool kSkipIME = true;
631
631 ui::Accelerator accelerator_a(ui::VKEY_A, ui::EF_NONE); 632 ui::Accelerator accelerator_a(ui::VKEY_A, ui::EF_NONE);
632 TestTarget target; 633 TestTarget target;
633 GetController()->Register({accelerator_a}, &target); 634 GetController()->Register({accelerator_a}, &target);
634 635
635 // The accelerator is processed only once. 636 // The accelerator is processed only once.
636 ui::EventSink* sink = Shell::GetPrimaryRootWindow()->GetHost()->event_sink(); 637 ui::EventSink* sink = Shell::GetPrimaryRootWindow()->GetHost()->event_sink();
637 638
638 ui::ScopedXI2Event key_event; 639 ui::ScopedXI2Event key_event;
639 key_event.InitKeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_A, 0); 640 key_event.InitKeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_A, 0);
640 ui::KeyEvent key_event1(key_event); 641 ui::KeyEvent key_event1(key_event);
642 key_event1.set_skip_ime(kSkipIME);
641 ui::EventDispatchDetails details = sink->OnEventFromSource(&key_event1); 643 ui::EventDispatchDetails details = sink->OnEventFromSource(&key_event1);
642 EXPECT_TRUE(key_event1.handled() || details.dispatcher_destroyed); 644 EXPECT_TRUE(key_event1.handled() || details.dispatcher_destroyed);
643 645
644 ui::KeyEvent key_event2('A', ui::VKEY_A, ui::EF_NONE); 646 ui::KeyEvent key_event2('A', ui::VKEY_A, 0);
647 key_event2.set_skip_ime(kSkipIME);
645 details = sink->OnEventFromSource(&key_event2); 648 details = sink->OnEventFromSource(&key_event2);
646 EXPECT_FALSE(key_event2.handled() || details.dispatcher_destroyed); 649 EXPECT_FALSE(key_event2.handled() || details.dispatcher_destroyed);
647 650
648 key_event.InitKeyEvent(ui::ET_KEY_RELEASED, ui::VKEY_A, 0); 651 key_event.InitKeyEvent(ui::ET_KEY_RELEASED, ui::VKEY_A, 0);
649 ui::KeyEvent key_event3(key_event); 652 ui::KeyEvent key_event3(key_event);
653 key_event3.set_skip_ime(kSkipIME);
650 details = sink->OnEventFromSource(&key_event3); 654 details = sink->OnEventFromSource(&key_event3);
651 EXPECT_FALSE(key_event3.handled() || details.dispatcher_destroyed); 655 EXPECT_FALSE(key_event3.handled() || details.dispatcher_destroyed);
652 EXPECT_EQ(1, target.accelerator_pressed_count()); 656 EXPECT_EQ(1, target.accelerator_pressed_count());
653 } 657 }
654 #endif 658 #endif
655 659
656 TEST_F(AcceleratorControllerTest, GlobalAccelerators) { 660 TEST_F(AcceleratorControllerTest, GlobalAccelerators) {
657 // TODO: TestScreenshotDelegate is null in mash http://crbug.com/632111. 661 // TODO: TestScreenshotDelegate is null in mash http://crbug.com/632111.
658 if (Shell::GetAshConfig() == Config::MASH) 662 if (Shell::GetAshConfig() == Config::MASH)
659 return; 663 return;
(...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after
1362 // Expect no notifications from the new accelerators. 1366 // Expect no notifications from the new accelerators.
1363 EXPECT_TRUE(IsMessageCenterEmpty()); 1367 EXPECT_TRUE(IsMessageCenterEmpty());
1364 1368
1365 // If the action is LOCK_SCREEN, we must reset the state by unlocking the 1369 // If the action is LOCK_SCREEN, we must reset the state by unlocking the
1366 // screen before we proceed testing the rest of accelerators. 1370 // screen before we proceed testing the rest of accelerators.
1367 ResetStateIfNeeded(); 1371 ResetStateIfNeeded();
1368 } 1372 }
1369 } 1373 }
1370 1374
1371 } // namespace ash 1375 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698