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

Unified Diff: ui/aura/test/event_generator.cc

Issue 11269022: Add Vector2d classes that represent offsets, instead of using Point. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: RenderText fixup Created 8 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: ui/aura/test/event_generator.cc
diff --git a/ui/aura/test/event_generator.cc b/ui/aura/test/event_generator.cc
index a2eb897daad5d2853beaaa66c9ad3e9699591ca8..2a6daea966b4c9ff53fade5b652bac0228c5eaab 100644
--- a/ui/aura/test/event_generator.cc
+++ b/ui/aura/test/event_generator.cc
@@ -7,6 +7,7 @@
#include "base/memory/scoped_ptr.h"
#include "ui/aura/root_window.h"
#include "ui/base/events/event.h"
+#include "ui/gfx/vector2d_conversions.h"
#if defined(USE_X11)
#include <X11/Xlib.h>
@@ -126,10 +127,11 @@ void EventGenerator::MoveMouseTo(const gfx::Point& point, int count) {
DCHECK_GT(count, 0);
const ui::EventType event_type = (flags_ & ui::EF_LEFT_MOUSE_BUTTON) ?
ui::ET_MOUSE_DRAGGED : ui::ET_MOUSE_MOVED;
- const gfx::Point diff = point.Subtract(current_location_);
- for (int i = 1; i <= count; i++) {
- const gfx::Point move_point = current_location_.Add(
- gfx::Point(diff.x() / count * i, diff.y() / count * i));
+ gfx::Vector2dF diff(point - current_location_);
+ for (float i = 1; i <= count; i++) {
+ gfx::Vector2dF step(diff);
+ step.Scale(i / count);
+ gfx::Point move_point = current_location_ + gfx::ToRoundedVector2d(step);
ui::MouseEvent mouseev(event_type, move_point, move_point, flags_);
Dispatch(mouseev);
}

Powered by Google App Engine
This is Rietveld 408576698