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

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

Issue 147203004: aura: Remove event-dispatch methods from WindowTreeHostDelegate interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: win Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | ash/autoclick/autoclick_controller.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "ash/accelerators/accelerator_table.h" 6 #include "ash/accelerators/accelerator_table.h"
7 #include "ash/accessibility_delegate.h" 7 #include "ash/accessibility_delegate.h"
8 #include "ash/ash_switches.h" 8 #include "ash/ash_switches.h"
9 #include "ash/caps_lock_delegate.h" 9 #include "ash/caps_lock_delegate.h"
10 #include "ash/display/display_manager.h" 10 #include "ash/display/display_manager.h"
(...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after
647 ui::Accelerator accelerator_a(ui::VKEY_A, ui::EF_NONE); 647 ui::Accelerator accelerator_a(ui::VKEY_A, ui::EF_NONE);
648 TestTarget target; 648 TestTarget target;
649 GetController()->Register(accelerator_a, &target); 649 GetController()->Register(accelerator_a, &target);
650 650
651 // The accelerator is processed only once. 651 // The accelerator is processed only once.
652 aura::WindowEventDispatcher* dispatcher = 652 aura::WindowEventDispatcher* dispatcher =
653 Shell::GetPrimaryRootWindow()->GetDispatcher(); 653 Shell::GetPrimaryRootWindow()->GetDispatcher();
654 #if defined(OS_WIN) 654 #if defined(OS_WIN)
655 MSG msg1 = { NULL, WM_KEYDOWN, ui::VKEY_A, 0 }; 655 MSG msg1 = { NULL, WM_KEYDOWN, ui::VKEY_A, 0 };
656 ui::TranslatedKeyEvent key_event1(msg1, false); 656 ui::TranslatedKeyEvent key_event1(msg1, false);
657 EXPECT_TRUE(dispatcher->AsWindowTreeHostDelegate()->OnHostKeyEvent( 657 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&key_event1);
658 &key_event1)); 658 EXPECT_TRUE(key_event1.handled() || details.dispatcher_destroyed);
659 659
660 MSG msg2 = { NULL, WM_CHAR, L'A', 0 }; 660 MSG msg2 = { NULL, WM_CHAR, L'A', 0 };
661 ui::TranslatedKeyEvent key_event2(msg2, true); 661 ui::TranslatedKeyEvent key_event2(msg2, true);
662 EXPECT_FALSE(dispatcher->AsWindowTreeHostDelegate()->OnHostKeyEvent( 662 details = dispatcher->OnEventFromSource(&key_event2);
663 &key_event2)); 663 EXPECT_FALSE(key_event2.handled() || details.dispatcher_destroyed);
664 664
665 MSG msg3 = { NULL, WM_KEYUP, ui::VKEY_A, 0 }; 665 MSG msg3 = { NULL, WM_KEYUP, ui::VKEY_A, 0 };
666 ui::TranslatedKeyEvent key_event3(msg3, false); 666 ui::TranslatedKeyEvent key_event3(msg3, false);
667 EXPECT_FALSE(dispatcher->AsWindowTreeHostDelegate()->OnHostKeyEvent( 667 details = dispatcher->OnEventFromSource(&key_event3);
668 &key_event3)); 668 EXPECT_FALSE(key_event3.handled() || details.dispatcher_destroyed);
669 #elif defined(USE_X11) 669 #elif defined(USE_X11)
670 ui::ScopedXI2Event key_event; 670 ui::ScopedXI2Event key_event;
671 key_event.InitKeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_A, 0); 671 key_event.InitKeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_A, 0);
672 ui::TranslatedKeyEvent key_event1(key_event, false); 672 ui::TranslatedKeyEvent key_event1(key_event, false);
673 EXPECT_TRUE(dispatcher->AsWindowTreeHostDelegate()->OnHostKeyEvent( 673 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&key_event1);
674 &key_event1)); 674 EXPECT_TRUE(key_event1.handled() || details.dispatcher_destroyed);
675 675
676 ui::TranslatedKeyEvent key_event2(key_event, true); 676 ui::TranslatedKeyEvent key_event2(key_event, true);
677 EXPECT_FALSE(dispatcher->AsWindowTreeHostDelegate()->OnHostKeyEvent( 677 details = dispatcher->OnEventFromSource(&key_event2);
678 &key_event2)); 678 EXPECT_FALSE(key_event2.handled() || details.dispatcher_destroyed);
679 679
680 key_event.InitKeyEvent(ui::ET_KEY_RELEASED, ui::VKEY_A, 0); 680 key_event.InitKeyEvent(ui::ET_KEY_RELEASED, ui::VKEY_A, 0);
681 ui::TranslatedKeyEvent key_event3(key_event, false); 681 ui::TranslatedKeyEvent key_event3(key_event, false);
682 EXPECT_FALSE(dispatcher->AsWindowTreeHostDelegate()->OnHostKeyEvent( 682 details = dispatcher->OnEventFromSource(&key_event3);
683 &key_event3)); 683 EXPECT_FALSE(key_event3.handled() || details.dispatcher_destroyed);
684 #endif 684 #endif
685 EXPECT_EQ(1, target.accelerator_pressed_count()); 685 EXPECT_EQ(1, target.accelerator_pressed_count());
686 } 686 }
687 #endif 687 #endif
688 688
689 TEST_F(AcceleratorControllerTest, GlobalAccelerators) { 689 TEST_F(AcceleratorControllerTest, GlobalAccelerators) {
690 // CycleBackward 690 // CycleBackward
691 EXPECT_TRUE(ProcessWithContext( 691 EXPECT_TRUE(ProcessWithContext(
692 ui::Accelerator(ui::VKEY_TAB, ui::EF_SHIFT_DOWN | ui::EF_ALT_DOWN))); 692 ui::Accelerator(ui::VKEY_TAB, ui::EF_SHIFT_DOWN | ui::EF_ALT_DOWN)));
693 // CycleForward 693 // CycleForward
(...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after
1383 // Don't alert if we have a minimized window either. 1383 // Don't alert if we have a minimized window either.
1384 GetController()->PerformAction(WINDOW_MINIMIZE, dummy); 1384 GetController()->PerformAction(WINDOW_MINIMIZE, dummy);
1385 for (size_t i = 0; i < kActionsNeedingWindowLength; ++i) { 1385 for (size_t i = 0; i < kActionsNeedingWindowLength; ++i) {
1386 delegate->TriggerAccessibilityAlert(A11Y_ALERT_NONE); 1386 delegate->TriggerAccessibilityAlert(A11Y_ALERT_NONE);
1387 GetController()->PerformAction(kActionsNeedingWindow[i], dummy); 1387 GetController()->PerformAction(kActionsNeedingWindow[i], dummy);
1388 EXPECT_EQ(delegate->GetLastAccessibilityAlert(), A11Y_ALERT_NONE); 1388 EXPECT_EQ(delegate->GetLastAccessibilityAlert(), A11Y_ALERT_NONE);
1389 } 1389 }
1390 } 1390 }
1391 1391
1392 } // namespace ash 1392 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/autoclick/autoclick_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698