| OLD | NEW |
| 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 "ui/aura/test/event_generator.h" | 5 #include "ui/aura/test/event_generator.h" |
| 6 | 6 |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "ui/aura/root_window.h" | 8 #include "ui/aura/root_window.h" |
| 9 #include "ui/base/events/event.h" | 9 #include "ui/base/events/event.h" |
| 10 | 10 |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 current_location_, flags_); | 119 current_location_, flags_); |
| 120 Dispatch(mouseev); | 120 Dispatch(mouseev); |
| 121 flags_ ^= ui::EF_RIGHT_MOUSE_BUTTON; | 121 flags_ ^= ui::EF_RIGHT_MOUSE_BUTTON; |
| 122 } | 122 } |
| 123 } | 123 } |
| 124 | 124 |
| 125 void EventGenerator::MoveMouseTo(const gfx::Point& point, int count) { | 125 void EventGenerator::MoveMouseTo(const gfx::Point& point, int count) { |
| 126 DCHECK_GT(count, 0); | 126 DCHECK_GT(count, 0); |
| 127 const ui::EventType event_type = (flags_ & ui::EF_LEFT_MOUSE_BUTTON) ? | 127 const ui::EventType event_type = (flags_ & ui::EF_LEFT_MOUSE_BUTTON) ? |
| 128 ui::ET_MOUSE_DRAGGED : ui::ET_MOUSE_MOVED; | 128 ui::ET_MOUSE_DRAGGED : ui::ET_MOUSE_MOVED; |
| 129 const gfx::Point diff = point.Subtract(current_location_); | 129 const gfx::Vector2d diff = point.DistanceFrom(current_location_); |
| 130 for (int i = 1; i <= count; i++) { | 130 for (int i = 1; i <= count; i++) { |
| 131 const gfx::Point move_point = current_location_.Add( | 131 const gfx::Point move_point = current_location_.Add( |
| 132 gfx::Point(diff.x() / count * i, diff.y() / count * i)); | 132 gfx::Vector2d(diff.x() / count * i, diff.y() / count * i)); |
| 133 ui::MouseEvent mouseev(event_type, move_point, move_point, flags_); | 133 ui::MouseEvent mouseev(event_type, move_point, move_point, flags_); |
| 134 Dispatch(mouseev); | 134 Dispatch(mouseev); |
| 135 } | 135 } |
| 136 current_location_ = point; | 136 current_location_ = point; |
| 137 } | 137 } |
| 138 | 138 |
| 139 void EventGenerator::MoveMouseRelativeTo(const Window* window, | 139 void EventGenerator::MoveMouseRelativeTo(const Window* window, |
| 140 const gfx::Point& point) { | 140 const gfx::Point& point) { |
| 141 gfx::Point root_point(point); | 141 gfx::Point root_point(point); |
| 142 Window::ConvertPointToTarget(window, root_window_, &root_point); | 142 Window::ConvertPointToTarget(window, root_window_, &root_point); |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 TestKeyEvent keyev(native_event.get(), flags, false); | 335 TestKeyEvent keyev(native_event.get(), flags, false); |
| 336 #else | 336 #else |
| 337 ui::KeyEvent keyev(type, key_code, flags, false); | 337 ui::KeyEvent keyev(type, key_code, flags, false); |
| 338 #endif // USE_X11 | 338 #endif // USE_X11 |
| 339 #endif // OS_WIN | 339 #endif // OS_WIN |
| 340 Dispatch(keyev); | 340 Dispatch(keyev); |
| 341 } | 341 } |
| 342 | 342 |
| 343 } // namespace test | 343 } // namespace test |
| 344 } // namespace aura | 344 } // namespace aura |
| OLD | NEW |