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

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

Issue 76583003: Rename RootWindowHost* to WindowTreeHost* (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years 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_controller.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 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 244
245 void SendActivateStickyKeyPattern(StickyKeysHandler* handler, 245 void SendActivateStickyKeyPattern(StickyKeysHandler* handler,
246 ui::KeyboardCode key_code) { 246 ui::KeyboardCode key_code) {
247 scoped_ptr<ui::KeyEvent> ev; 247 scoped_ptr<ui::KeyEvent> ev;
248 ev.reset(GenerateKey(true, key_code)); 248 ev.reset(GenerateKey(true, key_code));
249 handler->HandleKeyEvent(ev.get()); 249 handler->HandleKeyEvent(ev.get());
250 ev.reset(GenerateKey(false, key_code)); 250 ev.reset(GenerateKey(false, key_code));
251 handler->HandleKeyEvent(ev.get()); 251 handler->HandleKeyEvent(ev.get());
252 } 252 }
253 253
254 void SendActivateStickyKeyPattern(aura::RootWindowHostDelegate* delegate, 254 void SendActivateStickyKeyPattern(aura::WindowTreeHostDelegate* delegate,
255 ui::KeyboardCode key_code) { 255 ui::KeyboardCode key_code) {
256 scoped_ptr<ui::KeyEvent> ev; 256 scoped_ptr<ui::KeyEvent> ev;
257 ev.reset(GenerateKey(true, key_code)); 257 ev.reset(GenerateKey(true, key_code));
258 delegate->OnHostKeyEvent(ev.get()); 258 delegate->OnHostKeyEvent(ev.get());
259 ev.reset(GenerateKey(false, key_code)); 259 ev.reset(GenerateKey(false, key_code));
260 delegate->OnHostKeyEvent(ev.get()); 260 delegate->OnHostKeyEvent(ev.get());
261 } 261 }
262 262
263 aura::Window* target() { return target_; } 263 aura::Window* target() { return target_; }
264 264
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after
749 mev.reset(GenerateSynthesizedMouseEvent(false)); 749 mev.reset(GenerateSynthesizedMouseEvent(false));
750 sticky_key.HandleMouseEvent(mev.get()); 750 sticky_key.HandleMouseEvent(mev.get());
751 EXPECT_TRUE(mev->flags() & ui::EF_CONTROL_DOWN); 751 EXPECT_TRUE(mev->flags() & ui::EF_CONTROL_DOWN);
752 EXPECT_EQ(StickyKeysHandler::DISABLED, sticky_key.current_state()); 752 EXPECT_EQ(StickyKeysHandler::DISABLED, sticky_key.current_state());
753 } 753 }
754 754
755 TEST_F(StickyKeysTest, KeyEventDispatchImpl) { 755 TEST_F(StickyKeysTest, KeyEventDispatchImpl) {
756 // Test the actual key event dispatch implementation. 756 // Test the actual key event dispatch implementation.
757 EventBuffer buffer; 757 EventBuffer buffer;
758 ScopedVector<ui::Event> events; 758 ScopedVector<ui::Event> events;
759 aura::RootWindowHostDelegate* delegate = Shell::GetPrimaryRootWindow() 759 aura::WindowTreeHostDelegate* delegate = Shell::GetPrimaryRootWindow()
760 ->GetDispatcher()->AsRootWindowHostDelegate(); 760 ->GetDispatcher()->AsWindowTreeHostDelegate();
761 Shell::GetInstance()->AddPreTargetHandler(&buffer); 761 Shell::GetInstance()->AddPreTargetHandler(&buffer);
762 Shell::GetInstance()->sticky_keys_controller()->Enable(true); 762 Shell::GetInstance()->sticky_keys_controller()->Enable(true);
763 763
764 SendActivateStickyKeyPattern(delegate, ui::VKEY_CONTROL); 764 SendActivateStickyKeyPattern(delegate, ui::VKEY_CONTROL);
765 scoped_ptr<ui::KeyEvent> ev; 765 scoped_ptr<ui::KeyEvent> ev;
766 buffer.PopEvents(&events); 766 buffer.PopEvents(&events);
767 767
768 // Test key press event is correctly modified and modifier release 768 // Test key press event is correctly modified and modifier release
769 // event is sent. 769 // event is sent.
770 ev.reset(GenerateKey(true, ui::VKEY_C)); 770 ev.reset(GenerateKey(true, ui::VKEY_C));
(...skipping 17 matching lines...) Expand all
788 static_cast<ui::KeyEvent*>(events[0])->key_code()); 788 static_cast<ui::KeyEvent*>(events[0])->key_code());
789 EXPECT_FALSE(events[0]->flags() & ui::EF_CONTROL_DOWN); 789 EXPECT_FALSE(events[0]->flags() & ui::EF_CONTROL_DOWN);
790 790
791 Shell::GetInstance()->RemovePreTargetHandler(&buffer); 791 Shell::GetInstance()->RemovePreTargetHandler(&buffer);
792 } 792 }
793 793
794 TEST_F(StickyKeysTest, MouseEventDispatchImpl) { 794 TEST_F(StickyKeysTest, MouseEventDispatchImpl) {
795 // Test the actual sticky mouse event dispatch implementation. 795 // Test the actual sticky mouse event dispatch implementation.
796 EventBuffer buffer; 796 EventBuffer buffer;
797 ScopedVector<ui::Event> events; 797 ScopedVector<ui::Event> events;
798 aura::RootWindowHostDelegate* delegate = Shell::GetPrimaryRootWindow() 798 aura::WindowTreeHostDelegate* delegate = Shell::GetPrimaryRootWindow()
799 ->GetDispatcher()->AsRootWindowHostDelegate(); 799 ->GetDispatcher()->AsWindowTreeHostDelegate();
800 Shell::GetInstance()->AddPreTargetHandler(&buffer); 800 Shell::GetInstance()->AddPreTargetHandler(&buffer);
801 Shell::GetInstance()->sticky_keys_controller()->Enable(true); 801 Shell::GetInstance()->sticky_keys_controller()->Enable(true);
802 802
803 scoped_ptr<ui::MouseEvent> ev; 803 scoped_ptr<ui::MouseEvent> ev;
804 SendActivateStickyKeyPattern(delegate, ui::VKEY_CONTROL); 804 SendActivateStickyKeyPattern(delegate, ui::VKEY_CONTROL);
805 buffer.PopEvents(&events); 805 buffer.PopEvents(&events);
806 806
807 // Test mouse press event is correctly modified. 807 // Test mouse press event is correctly modified.
808 ev.reset(GenerateMouseEvent(true)); 808 ev.reset(GenerateMouseEvent(true));
809 delegate->OnHostMouseEvent(ev.get()); 809 delegate->OnHostMouseEvent(ev.get());
(...skipping 14 matching lines...) Expand all
824 EXPECT_EQ(ui::VKEY_CONTROL, 824 EXPECT_EQ(ui::VKEY_CONTROL,
825 static_cast<ui::KeyEvent*>(events[1])->key_code()); 825 static_cast<ui::KeyEvent*>(events[1])->key_code());
826 826
827 Shell::GetInstance()->RemovePreTargetHandler(&buffer); 827 Shell::GetInstance()->RemovePreTargetHandler(&buffer);
828 } 828 }
829 829
830 TEST_F(StickyKeysTest, MouseWheelEventDispatchImpl) { 830 TEST_F(StickyKeysTest, MouseWheelEventDispatchImpl) {
831 // Test the actual mouse wheel event dispatch implementation. 831 // Test the actual mouse wheel event dispatch implementation.
832 EventBuffer buffer; 832 EventBuffer buffer;
833 ScopedVector<ui::Event> events; 833 ScopedVector<ui::Event> events;
834 aura::RootWindowHostDelegate* delegate = Shell::GetPrimaryRootWindow() 834 aura::WindowTreeHostDelegate* delegate = Shell::GetPrimaryRootWindow()
835 ->GetDispatcher()->AsRootWindowHostDelegate(); 835 ->GetDispatcher()->AsWindowTreeHostDelegate();
836 Shell::GetInstance()->AddPreTargetHandler(&buffer); 836 Shell::GetInstance()->AddPreTargetHandler(&buffer);
837 Shell::GetInstance()->sticky_keys_controller()->Enable(true); 837 Shell::GetInstance()->sticky_keys_controller()->Enable(true);
838 838
839 scoped_ptr<ui::MouseWheelEvent> ev; 839 scoped_ptr<ui::MouseWheelEvent> ev;
840 SendActivateStickyKeyPattern(delegate, ui::VKEY_CONTROL); 840 SendActivateStickyKeyPattern(delegate, ui::VKEY_CONTROL);
841 buffer.PopEvents(&events); 841 buffer.PopEvents(&events);
842 842
843 // Test positive mouse wheel event is correctly modified and modifier release 843 // Test positive mouse wheel event is correctly modified and modifier release
844 // event is sent. 844 // event is sent.
845 ev.reset(GenerateMouseWheelEvent(ui::MouseWheelEvent::kWheelDelta)); 845 ev.reset(GenerateMouseWheelEvent(ui::MouseWheelEvent::kWheelDelta));
(...skipping 22 matching lines...) Expand all
868 static_cast<ui::MouseWheelEvent*>(events[0])->y_offset()); 868 static_cast<ui::MouseWheelEvent*>(events[0])->y_offset());
869 EXPECT_TRUE(events[0]->flags() & ui::EF_CONTROL_DOWN); 869 EXPECT_TRUE(events[0]->flags() & ui::EF_CONTROL_DOWN);
870 EXPECT_EQ(ui::ET_KEY_RELEASED, events[1]->type()); 870 EXPECT_EQ(ui::ET_KEY_RELEASED, events[1]->type());
871 EXPECT_EQ(ui::VKEY_CONTROL, 871 EXPECT_EQ(ui::VKEY_CONTROL,
872 static_cast<ui::KeyEvent*>(events[1])->key_code()); 872 static_cast<ui::KeyEvent*>(events[1])->key_code());
873 873
874 Shell::GetInstance()->RemovePreTargetHandler(&buffer); 874 Shell::GetInstance()->RemovePreTargetHandler(&buffer);
875 } 875 }
876 876
877 } // namespace ash 877 } // namespace ash
OLDNEW
« no previous file with comments | « ash/sticky_keys/sticky_keys_controller.cc ('k') | ash/test/ash_test_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698