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

Side by Side Diff: ash/sticky_keys/sticky_keys_unittest.cc

Issue 184903003: Window ownership -> WindowTreeHost (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 9 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 | « ash/sticky_keys/sticky_keys_overlay_unittest.cc ('k') | ash/test/ash_test_base.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/sticky_keys/sticky_keys_controller.h" 5 #include "ash/sticky_keys/sticky_keys_controller.h"
6 6
7 #include <X11/Xlib.h> 7 #include <X11/Xlib.h>
8 #undef None 8 #undef None
9 #undef Bool 9 #undef Bool
10 #undef RootWindow 10 #undef RootWindow
(...skipping 776 matching lines...) Expand 10 before | Expand all | Expand 10 after
787 mev.reset(GenerateSynthesizedMouseEvent(false)); 787 mev.reset(GenerateSynthesizedMouseEvent(false));
788 sticky_key.HandleMouseEvent(mev.get()); 788 sticky_key.HandleMouseEvent(mev.get());
789 EXPECT_TRUE(mev->flags() & ui::EF_CONTROL_DOWN); 789 EXPECT_TRUE(mev->flags() & ui::EF_CONTROL_DOWN);
790 EXPECT_EQ(STICKY_KEY_STATE_DISABLED, sticky_key.current_state()); 790 EXPECT_EQ(STICKY_KEY_STATE_DISABLED, sticky_key.current_state());
791 } 791 }
792 792
793 TEST_F(StickyKeysTest, KeyEventDispatchImpl) { 793 TEST_F(StickyKeysTest, KeyEventDispatchImpl) {
794 // Test the actual key event dispatch implementation. 794 // Test the actual key event dispatch implementation.
795 EventBuffer buffer; 795 EventBuffer buffer;
796 ScopedVector<ui::Event> events; 796 ScopedVector<ui::Event> events;
797 aura::WindowEventDispatcher* dispatcher = Shell::GetPrimaryRootWindow() 797 aura::WindowEventDispatcher* dispatcher =
798 ->GetDispatcher(); 798 Shell::GetPrimaryRootWindow()->GetHost()->dispatcher();
799 Shell::GetInstance()->AddPreTargetHandler(&buffer); 799 Shell::GetInstance()->AddPreTargetHandler(&buffer);
800 Shell::GetInstance()->sticky_keys_controller()->Enable(true); 800 Shell::GetInstance()->sticky_keys_controller()->Enable(true);
801 801
802 SendActivateStickyKeyPattern(dispatcher, ui::VKEY_CONTROL); 802 SendActivateStickyKeyPattern(dispatcher, ui::VKEY_CONTROL);
803 scoped_ptr<ui::KeyEvent> ev; 803 scoped_ptr<ui::KeyEvent> ev;
804 buffer.PopEvents(&events); 804 buffer.PopEvents(&events);
805 805
806 // Test key press event is correctly modified and modifier release 806 // Test key press event is correctly modified and modifier release
807 // event is sent. 807 // event is sent.
808 ev.reset(GenerateKey(true, ui::VKEY_C)); 808 ev.reset(GenerateKey(true, ui::VKEY_C));
(...skipping 18 matching lines...) Expand all
827 static_cast<ui::KeyEvent*>(events[0])->key_code()); 827 static_cast<ui::KeyEvent*>(events[0])->key_code());
828 EXPECT_FALSE(events[0]->flags() & ui::EF_CONTROL_DOWN); 828 EXPECT_FALSE(events[0]->flags() & ui::EF_CONTROL_DOWN);
829 829
830 Shell::GetInstance()->RemovePreTargetHandler(&buffer); 830 Shell::GetInstance()->RemovePreTargetHandler(&buffer);
831 } 831 }
832 832
833 TEST_F(StickyKeysTest, MouseEventDispatchImpl) { 833 TEST_F(StickyKeysTest, MouseEventDispatchImpl) {
834 // Test the actual sticky mouse event dispatch implementation. 834 // Test the actual sticky mouse event dispatch implementation.
835 EventBuffer buffer; 835 EventBuffer buffer;
836 ScopedVector<ui::Event> events; 836 ScopedVector<ui::Event> events;
837 aura::WindowEventDispatcher* dispatcher = Shell::GetPrimaryRootWindow() 837 aura::WindowEventDispatcher* dispatcher =
838 ->GetDispatcher(); 838 Shell::GetPrimaryRootWindow()->GetHost()->dispatcher();
839 Shell::GetInstance()->AddPreTargetHandler(&buffer); 839 Shell::GetInstance()->AddPreTargetHandler(&buffer);
840 Shell::GetInstance()->sticky_keys_controller()->Enable(true); 840 Shell::GetInstance()->sticky_keys_controller()->Enable(true);
841 841
842 scoped_ptr<ui::MouseEvent> ev; 842 scoped_ptr<ui::MouseEvent> ev;
843 SendActivateStickyKeyPattern(dispatcher, ui::VKEY_CONTROL); 843 SendActivateStickyKeyPattern(dispatcher, ui::VKEY_CONTROL);
844 buffer.PopEvents(&events); 844 buffer.PopEvents(&events);
845 845
846 // Test mouse press event is correctly modified. 846 // Test mouse press event is correctly modified.
847 ev.reset(GenerateMouseEvent(true)); 847 ev.reset(GenerateMouseEvent(true));
848 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(ev.get()); 848 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(ev.get());
(...skipping 15 matching lines...) Expand all
864 EXPECT_EQ(ui::VKEY_CONTROL, 864 EXPECT_EQ(ui::VKEY_CONTROL,
865 static_cast<ui::KeyEvent*>(events[1])->key_code()); 865 static_cast<ui::KeyEvent*>(events[1])->key_code());
866 866
867 Shell::GetInstance()->RemovePreTargetHandler(&buffer); 867 Shell::GetInstance()->RemovePreTargetHandler(&buffer);
868 } 868 }
869 869
870 TEST_F(StickyKeysTest, MouseWheelEventDispatchImpl) { 870 TEST_F(StickyKeysTest, MouseWheelEventDispatchImpl) {
871 // Test the actual mouse wheel event dispatch implementation. 871 // Test the actual mouse wheel event dispatch implementation.
872 EventBuffer buffer; 872 EventBuffer buffer;
873 ScopedVector<ui::Event> events; 873 ScopedVector<ui::Event> events;
874 aura::WindowEventDispatcher* dispatcher = Shell::GetPrimaryRootWindow() 874 aura::WindowEventDispatcher* dispatcher =
875 ->GetDispatcher(); 875 Shell::GetPrimaryRootWindow()->GetHost()->dispatcher();
876 Shell::GetInstance()->AddPreTargetHandler(&buffer); 876 Shell::GetInstance()->AddPreTargetHandler(&buffer);
877 Shell::GetInstance()->sticky_keys_controller()->Enable(true); 877 Shell::GetInstance()->sticky_keys_controller()->Enable(true);
878 878
879 scoped_ptr<ui::MouseWheelEvent> ev; 879 scoped_ptr<ui::MouseWheelEvent> ev;
880 SendActivateStickyKeyPattern(dispatcher, ui::VKEY_CONTROL); 880 SendActivateStickyKeyPattern(dispatcher, ui::VKEY_CONTROL);
881 buffer.PopEvents(&events); 881 buffer.PopEvents(&events);
882 882
883 // Test positive mouse wheel event is correctly modified and modifier release 883 // Test positive mouse wheel event is correctly modified and modifier release
884 // event is sent. 884 // event is sent.
885 ev.reset(GenerateMouseWheelEvent(ui::MouseWheelEvent::kWheelDelta)); 885 ev.reset(GenerateMouseWheelEvent(ui::MouseWheelEvent::kWheelDelta));
(...skipping 24 matching lines...) Expand all
910 static_cast<ui::MouseWheelEvent*>(events[0])->y_offset()); 910 static_cast<ui::MouseWheelEvent*>(events[0])->y_offset());
911 EXPECT_TRUE(events[0]->flags() & ui::EF_CONTROL_DOWN); 911 EXPECT_TRUE(events[0]->flags() & ui::EF_CONTROL_DOWN);
912 EXPECT_EQ(ui::ET_KEY_RELEASED, events[1]->type()); 912 EXPECT_EQ(ui::ET_KEY_RELEASED, events[1]->type());
913 EXPECT_EQ(ui::VKEY_CONTROL, 913 EXPECT_EQ(ui::VKEY_CONTROL,
914 static_cast<ui::KeyEvent*>(events[1])->key_code()); 914 static_cast<ui::KeyEvent*>(events[1])->key_code());
915 915
916 Shell::GetInstance()->RemovePreTargetHandler(&buffer); 916 Shell::GetInstance()->RemovePreTargetHandler(&buffer);
917 } 917 }
918 918
919 } // namespace ash 919 } // namespace ash
OLDNEW
« no previous file with comments | « ash/sticky_keys/sticky_keys_overlay_unittest.cc ('k') | ash/test/ash_test_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698