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

Side by Side 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: more vector use fixes Created 8 years, 1 month 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
OLDNEW
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
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 - 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));
Peter Kasting 2012/10/30 01:14:14 Do you think this suggests we should support multi
danakj 2012/10/30 19:21:21 Yeh, that sounds nice. We have a Scale() method on
Peter Kasting 2012/10/30 20:24:37 You're welcome to tack Scale() -> *,/ onto the lis
danakj 2012/10/30 21:14:52 Actually, I'm less sure about this after trying it
Peter Kasting 2012/10/30 21:41:23 Commented on bug. I'll note that having operator*
danakj 2012/10/30 21:49:10 We do non-uniform scaling between different spaces
Peter Kasting 2012/10/30 21:56:35 Sure, but is it vectors you need to scale, rather
danakj 2012/10/30 21:59:34 I'm not entirely sure, since these types are going
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698