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

Side by Side Diff: ui/events/gesture_detection/mock_motion_event.cc

Issue 128613003: [Tracking Patch] Unified gesture detection (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleanup Created 6 years, 10 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "ui/events/gesture_detection/mock_motion_event.h"
6
7 using base::TimeTicks;
8
9 namespace ui {
10 namespace {
11 const float kTouchMajor = 10.f;
12 } // namespace
13
14 MockMotionEvent::MockMotionEvent(Action action,
15 TimeTicks time,
16 float x,
17 float y)
18 : action(action), pointer_count(1), time(time) {
19 points[0].SetPoint(x, y);
20 }
21
22 MockMotionEvent::MockMotionEvent(Action action,
23 TimeTicks time,
24 float x0,
25 float y0,
26 float x1,
27 float y1)
28 : action(action), pointer_count(2), time(time) {
29 points[0].SetPoint(x0, y0);
30 points[1].SetPoint(x1, y1);
31 }
32
33 MockMotionEvent::MockMotionEvent(const MockMotionEvent& other)
34 : action(other.action),
35 pointer_count(other.pointer_count),
36 time(other.time) {
37 points[0] = other.points[0];
38 points[1] = other.points[1];
39 }
40
41 MockMotionEvent::~MockMotionEvent() {}
42
43 MotionEvent::Action MockMotionEvent::GetAction() const { return action; }
44
45 int MockMotionEvent::GetActionIndex() const { return pointer_count - 1; }
46
47 size_t MockMotionEvent::GetPointerCount() const { return pointer_count; }
48
49 int MockMotionEvent::GetPointerId(size_t pointer_index) const {
50 return pointer_index;
51 }
52
53 float MockMotionEvent::GetX(size_t pointer_index) const {
54 return points[pointer_index].x();
55 }
56
57 float MockMotionEvent::GetY(size_t pointer_index) const {
58 return points[pointer_index].y();
59 }
60
61 float MockMotionEvent::GetTouchMajor(size_t pointer_index) const {
62 return kTouchMajor;
63 }
64
65 TimeTicks MockMotionEvent::GetEventTime() const { return time; }
66
67 size_t MockMotionEvent::GetHistorySize() const { return 0; }
68
69 TimeTicks MockMotionEvent::GetHistoricalEventTime(size_t historical_index)
70 const {
71 return TimeTicks();
72 }
73
74 float MockMotionEvent::GetHistoricalTouchMajor(size_t pointer_index,
75 size_t historical_index) const {
76 return 0;
77 }
78
79 float MockMotionEvent::GetHistoricalX(size_t pointer_index,
80 size_t historical_index) const {
81 return 0;
82 }
83
84 float MockMotionEvent::GetHistoricalY(size_t pointer_index,
85 size_t historical_index) const {
86 return 0;
87 }
88
89 scoped_ptr<MotionEvent> MockMotionEvent::Clone() const {
90 return scoped_ptr<MotionEvent>(new MockMotionEvent(*this));
91 }
92
93 scoped_ptr<MotionEvent> MockMotionEvent::Cancel() const {
94 scoped_ptr<MockMotionEvent> cancel_event(new MockMotionEvent(*this));
95 cancel_event->action = MotionEvent::ACTION_CANCEL;
96 return cancel_event.PassAs<MotionEvent>();
97 }
98
99 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698