OLD | NEW |
---|---|
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/gesture_detection/mock_motion_event.h" | 5 #include "ui/events/gesture_detection/mock_motion_event.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 | 8 |
9 using base::TimeTicks; | 9 using base::TimeTicks; |
10 | 10 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
42 float x1, | 42 float x1, |
43 float y1, | 43 float y1, |
44 float x2, | 44 float x2, |
45 float y2) | 45 float y2) |
46 : action(action), pointer_count(3), time(time), id(0) { | 46 : action(action), pointer_count(3), time(time), id(0) { |
47 points[0].SetPoint(x0, y0); | 47 points[0].SetPoint(x0, y0); |
48 points[1].SetPoint(x1, y1); | 48 points[1].SetPoint(x1, y1); |
49 points[2].SetPoint(x2, y2); | 49 points[2].SetPoint(x2, y2); |
50 } | 50 } |
51 | 51 |
52 MockMotionEvent::MockMotionEvent(Action action, | |
53 TimeTicks time, | |
54 float x0, | |
55 float y0, | |
56 float x1, | |
57 float y1, | |
58 float x2, | |
59 float y2, | |
60 float x3, | |
61 float y3) | |
62 : action(action), pointer_count(4), time(time), id(0) { | |
63 points[0].SetPoint(x0, y0); | |
64 points[1].SetPoint(x1, y1); | |
65 points[2].SetPoint(x2, y2); | |
66 points[2].SetPoint(x3, y3); | |
67 } | |
68 | |
52 MockMotionEvent::MockMotionEvent(const MockMotionEvent& other) | 69 MockMotionEvent::MockMotionEvent(const MockMotionEvent& other) |
53 : action(other.action), | 70 : action(other.action), |
54 pointer_count(other.pointer_count), | 71 pointer_count(other.pointer_count), |
55 time(other.time), | 72 time(other.time), |
56 id(other.GetId()) { | 73 id(other.GetId()) { |
57 points[0] = other.points[0]; | 74 for (size_t i = 0; i < pointer_count; ++i) |
jdduke (slow)
2014/05/28 16:26:00
Ooph, good catch...
| |
58 points[1] = other.points[1]; | 75 points[i] = other.points[i]; |
59 } | 76 } |
60 | 77 |
61 MockMotionEvent::~MockMotionEvent() {} | 78 MockMotionEvent::~MockMotionEvent() {} |
62 | 79 |
63 MotionEvent::Action MockMotionEvent::GetAction() const { return action; } | 80 MotionEvent::Action MockMotionEvent::GetAction() const { return action; } |
64 | 81 |
65 int MockMotionEvent::GetActionIndex() const { | 82 int MockMotionEvent::GetActionIndex() const { |
66 return static_cast<int>(pointer_count) - 1; | 83 return static_cast<int>(pointer_count) - 1; |
67 } | 84 } |
68 | 85 |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
163 } | 180 } |
164 | 181 |
165 void MockMotionEvent::CancelPoint() { | 182 void MockMotionEvent::CancelPoint() { |
166 DCHECK_GT(pointer_count, 0U); | 183 DCHECK_GT(pointer_count, 0U); |
167 if (pointer_count > 1) | 184 if (pointer_count > 1) |
168 --pointer_count; | 185 --pointer_count; |
169 action = ACTION_CANCEL; | 186 action = ACTION_CANCEL; |
170 } | 187 } |
171 | 188 |
172 } // namespace ui | 189 } // namespace ui |
OLD | NEW |