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

Side by Side Diff: ui/events/test/event_generator.cc

Issue 1372253002: gfx: Make conversions from gfx::Point to PointF explicit. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: pointfconvert-event: mandol_line Created 5 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
« no previous file with comments | « ui/events/ozone/evdev/event_factory_evdev.cc ('k') | ui/events/test/events_test_utils.h » ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/events/test/event_generator.h" 5 #include "ui/events/test/event_generator.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 }; 56 };
57 57
58 class TestTouchEvent : public ui::TouchEvent { 58 class TestTouchEvent : public ui::TouchEvent {
59 public: 59 public:
60 TestTouchEvent(ui::EventType type, 60 TestTouchEvent(ui::EventType type,
61 const gfx::Point& root_location, 61 const gfx::Point& root_location,
62 int touch_id, 62 int touch_id,
63 int flags, 63 int flags,
64 base::TimeDelta timestamp) 64 base::TimeDelta timestamp)
65 : TouchEvent(type, 65 : TouchEvent(type,
66 gfx::PointF(root_location), 66 root_location,
67 flags, 67 flags,
68 touch_id, 68 touch_id,
69 timestamp, 69 timestamp,
70 1.0f, 70 1.0f,
71 1.0f, 71 1.0f,
72 0.0f, 72 0.0f,
73 0.0f) {} 73 0.0f) {}
74 74
75 private: 75 private:
76 DISALLOW_COPY_AND_ASSIGN(TestTouchEvent); 76 DISALLOW_COPY_AND_ASSIGN(TestTouchEvent);
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 157
158 void EventGenerator::PressRightButton() { 158 void EventGenerator::PressRightButton() {
159 PressButton(ui::EF_RIGHT_MOUSE_BUTTON); 159 PressButton(ui::EF_RIGHT_MOUSE_BUTTON);
160 } 160 }
161 161
162 void EventGenerator::ReleaseRightButton() { 162 void EventGenerator::ReleaseRightButton() {
163 ReleaseButton(ui::EF_RIGHT_MOUSE_BUTTON); 163 ReleaseButton(ui::EF_RIGHT_MOUSE_BUTTON);
164 } 164 }
165 165
166 void EventGenerator::MoveMouseWheel(int delta_x, int delta_y) { 166 void EventGenerator::MoveMouseWheel(int delta_x, int delta_y) {
167 auto location = gfx::PointF(GetLocationInCurrentRoot()); 167 gfx::Point location = GetLocationInCurrentRoot();
168 ui::MouseEvent mouseev(ui::ET_MOUSEWHEEL, location, location, 168 ui::MouseEvent mouseev(ui::ET_MOUSEWHEEL, location, location,
169 ui::EventTimeForNow(), flags_, 0); 169 ui::EventTimeForNow(), flags_, 0);
170 ui::MouseWheelEvent wheelev(mouseev, delta_x, delta_y); 170 ui::MouseWheelEvent wheelev(mouseev, delta_x, delta_y);
171 Dispatch(&wheelev); 171 Dispatch(&wheelev);
172 } 172 }
173 173
174 void EventGenerator::SendMouseExit() { 174 void EventGenerator::SendMouseExit() {
175 gfx::Point exit_location(current_location_); 175 gfx::Point exit_location(current_location_);
176 delegate()->ConvertPointToTarget(current_target_, &exit_location); 176 delegate()->ConvertPointToTarget(current_target_, &exit_location);
177 ui::MouseEvent mouseev(ui::ET_MOUSE_EXITED, exit_location, exit_location, 177 ui::MouseEvent mouseev(ui::ET_MOUSE_EXITED, exit_location, exit_location,
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 const ScrollStepCallback& callback) { 363 const ScrollStepCallback& callback) {
364 const int kTouchId = 5; 364 const int kTouchId = 5;
365 base::TimeDelta timestamp = Now(); 365 base::TimeDelta timestamp = Now();
366 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, start, kTouchId, timestamp); 366 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, start, kTouchId, timestamp);
367 Dispatch(&press); 367 Dispatch(&press);
368 368
369 callback.Run(ui::ET_GESTURE_SCROLL_BEGIN, gfx::Vector2dF()); 369 callback.Run(ui::ET_GESTURE_SCROLL_BEGIN, gfx::Vector2dF());
370 370
371 float dx = static_cast<float>(end.x() - start.x()) / steps; 371 float dx = static_cast<float>(end.x() - start.x()) / steps;
372 float dy = static_cast<float>(end.y() - start.y()) / steps; 372 float dy = static_cast<float>(end.y() - start.y()) / steps;
373 gfx::PointF location = start; 373 gfx::PointF location(start);
374 for (int i = 0; i < steps; ++i) { 374 for (int i = 0; i < steps; ++i) {
375 location.Offset(dx, dy); 375 location.Offset(dx, dy);
376 timestamp += step_delay; 376 timestamp += step_delay;
377 ui::TouchEvent move(ui::ET_TOUCH_MOVED, location, kTouchId, timestamp); 377 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(), kTouchId, timestamp);
378 move.set_location_f(location);
379 move.set_root_location_f(location);
378 Dispatch(&move); 380 Dispatch(&move);
379 callback.Run(ui::ET_GESTURE_SCROLL_UPDATE, gfx::Vector2dF(dx, dy)); 381 callback.Run(ui::ET_GESTURE_SCROLL_UPDATE, gfx::Vector2dF(dx, dy));
380 } 382 }
381 383
382 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, end, kTouchId, timestamp); 384 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, end, kTouchId, timestamp);
383 Dispatch(&release); 385 Dispatch(&release);
384 386
385 callback.Run(ui::ET_GESTURE_SCROLL_END, gfx::Vector2dF()); 387 callback.Run(ui::ET_GESTURE_SCROLL_END, gfx::Vector2dF());
386 } 388 }
387 389
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
693 return default_delegate; 695 return default_delegate;
694 } 696 }
695 697
696 EventGeneratorDelegate* EventGenerator::delegate() { 698 EventGeneratorDelegate* EventGenerator::delegate() {
697 return const_cast<EventGeneratorDelegate*>( 699 return const_cast<EventGeneratorDelegate*>(
698 const_cast<const EventGenerator*>(this)->delegate()); 700 const_cast<const EventGenerator*>(this)->delegate());
699 } 701 }
700 702
701 } // namespace test 703 } // namespace test
702 } // namespace ui 704 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/ozone/evdev/event_factory_evdev.cc ('k') | ui/events/test/events_test_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698