| OLD | NEW |
| 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 "ash/shell.h" | 7 #include "ash/shell.h" |
| 8 #include "ash/test/ash_test_base.h" | 8 #include "ash/test/ash_test_base.h" |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 | 154 |
| 155 // Creates a synthesized KeyEvent that is not backed by a native event. | 155 // Creates a synthesized KeyEvent that is not backed by a native event. |
| 156 ui::KeyEvent* GenerateSynthesizedKeyEvent(ui::EventType type, | 156 ui::KeyEvent* GenerateSynthesizedKeyEvent(ui::EventType type, |
| 157 ui::KeyboardCode code) { | 157 ui::KeyboardCode code) { |
| 158 return new ui::KeyEvent(type, code, ui::EF_NONE); | 158 return new ui::KeyEvent(type, code, ui::EF_NONE); |
| 159 } | 159 } |
| 160 | 160 |
| 161 // Creates a synthesized MouseEvent that is not backed by a native event. | 161 // Creates a synthesized MouseEvent that is not backed by a native event. |
| 162 ui::MouseEvent* GenerateSynthesizedMouseEventAt(ui::EventType event_type, | 162 ui::MouseEvent* GenerateSynthesizedMouseEventAt(ui::EventType event_type, |
| 163 const gfx::Point& location) { | 163 const gfx::Point& location) { |
| 164 ui::MouseEvent* event = new ui::MouseEvent( | 164 ui::MouseEvent* event; |
| 165 event_type, location, location, ui::EventTimeForNow(), | 165 if (event_type == ui::ET_MOUSEWHEEL) { |
| 166 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); | 166 event = new ui::MouseWheelEvent( |
| 167 gfx::Vector2d(), location, location, ui::EventTimeForNow(), |
| 168 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); |
| 169 } else { |
| 170 event = new ui::MouseEvent( |
| 171 event_type, location, location, ui::EventTimeForNow(), |
| 172 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); |
| 173 } |
| 167 ui::Event::DispatcherApi dispatcher(event); | 174 ui::Event::DispatcherApi dispatcher(event); |
| 168 dispatcher.set_target(target_); | 175 dispatcher.set_target(target_); |
| 169 return event; | 176 return event; |
| 170 } | 177 } |
| 171 | 178 |
| 172 // Creates a synthesized mouse press or release event. | 179 // Creates a synthesized mouse press or release event. |
| 173 ui::MouseEvent* GenerateSynthesizedMouseClickEvent( | 180 ui::MouseEvent* GenerateSynthesizedMouseClickEvent( |
| 174 ui::EventType type, | 181 ui::EventType type, |
| 175 const gfx::Point& location) { | 182 const gfx::Point& location) { |
| 176 return GenerateSynthesizedMouseEventAt(type, location); | 183 return GenerateSynthesizedMouseEventAt(type, location); |
| (...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 735 gfx::Point(0, 0))); | 742 gfx::Point(0, 0))); |
| 736 released = false; | 743 released = false; |
| 737 mod_down_flags = 0; | 744 mod_down_flags = 0; |
| 738 sticky_key.HandleMouseEvent(*mev.get(), &mod_down_flags, &released); | 745 sticky_key.HandleMouseEvent(*mev.get(), &mod_down_flags, &released); |
| 739 EXPECT_TRUE(mod_down_flags & ui::EF_CONTROL_DOWN); | 746 EXPECT_TRUE(mod_down_flags & ui::EF_CONTROL_DOWN); |
| 740 EXPECT_TRUE(released); | 747 EXPECT_TRUE(released); |
| 741 EXPECT_EQ(STICKY_KEY_STATE_DISABLED, sticky_key.current_state()); | 748 EXPECT_EQ(STICKY_KEY_STATE_DISABLED, sticky_key.current_state()); |
| 742 } | 749 } |
| 743 | 750 |
| 744 } // namespace ash | 751 } // namespace ash |
| OLD | NEW |