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

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

Issue 10823218: ash: Add some test coverage for WM gestures. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: doc Created 8 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/aura/test/event_generator.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/event.h" 8 #include "ui/aura/event.h"
9 #include "ui/aura/root_window.h" 9 #include "ui/aura/root_window.h"
10 10
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 location.Offset(dx, dy); 196 location.Offset(dx, dy);
197 timestamp += step_delay; 197 timestamp += step_delay;
198 TouchEvent move(ui::ET_TOUCH_MOVED, location, kTouchId, timestamp); 198 TouchEvent move(ui::ET_TOUCH_MOVED, location, kTouchId, timestamp);
199 Dispatch(move); 199 Dispatch(move);
200 } 200 }
201 201
202 TouchEvent release(ui::ET_TOUCH_RELEASED, end, kTouchId, timestamp); 202 TouchEvent release(ui::ET_TOUCH_RELEASED, end, kTouchId, timestamp);
203 Dispatch(release); 203 Dispatch(release);
204 } 204 }
205 205
206 void EventGenerator::GestureMultiFingerScroll(int count,
207 const gfx::Point* start,
208 int event_separation_time_ms,
209 int steps,
210 int move_x,
211 int move_y) {
212 const int kMaxTouchPoints = 10;
213 gfx::Point points[kMaxTouchPoints];
214 CHECK_LE(count, kMaxTouchPoints);
215 CHECK_GT(steps, 0);
216
217 int delta_x = move_x / steps;
218 int delta_y = move_y / steps;
219
220 base::TimeDelta press_time = base::Time::NowFromSystemTime() - base::Time();
221 for (int i = 0; i < count; ++i) {
222 points[i] = start[i];
223 TouchEvent press(ui::ET_TOUCH_PRESSED, points[i], i, press_time);
224 Dispatch(press);
225 }
226
227 for (int step = 0; step < steps; ++step) {
228 base::TimeDelta move_time = press_time +
229 base::TimeDelta::FromMilliseconds(event_separation_time_ms * step);
230 for (int i = 0; i < count; ++i) {
231 points[i].Offset(delta_x, delta_y);
232 TouchEvent move(ui::ET_TOUCH_MOVED, points[i], i, move_time);
233 Dispatch(move);
234 }
235 }
236
237 base::TimeDelta release_time = press_time +
238 base::TimeDelta::FromMilliseconds(event_separation_time_ms * steps);
239 for (int i = 0; i < count; ++i) {
240 TouchEvent release(ui::ET_TOUCH_RELEASED, points[i], i, release_time);
241 Dispatch(release);
242 }
243 }
244
206 void EventGenerator::PressKey(ui::KeyboardCode key_code, int flags) { 245 void EventGenerator::PressKey(ui::KeyboardCode key_code, int flags) {
207 DispatchKeyEvent(true, key_code, flags); 246 DispatchKeyEvent(true, key_code, flags);
208 } 247 }
209 248
210 void EventGenerator::ReleaseKey(ui::KeyboardCode key_code, int flags) { 249 void EventGenerator::ReleaseKey(ui::KeyboardCode key_code, int flags) {
211 DispatchKeyEvent(false, key_code, flags); 250 DispatchKeyEvent(false, key_code, flags);
212 } 251 }
213 252
214 void EventGenerator::Dispatch(Event& event) { 253 void EventGenerator::Dispatch(Event& event) {
215 switch (event.type()) { 254 switch (event.type()) {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 TestKeyEvent keyev(native_event.get(), flags); 296 TestKeyEvent keyev(native_event.get(), flags);
258 #else 297 #else
259 KeyEvent keyev(type, key_code, flags); 298 KeyEvent keyev(type, key_code, flags);
260 #endif // USE_X11 299 #endif // USE_X11
261 #endif // OS_WIN 300 #endif // OS_WIN
262 Dispatch(keyev); 301 Dispatch(keyev);
263 } 302 }
264 303
265 } // namespace test 304 } // namespace test
266 } // namespace aura 305 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/test/event_generator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698