OLD | NEW |
(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 { |
| 46 return static_cast<int>(pointer_count) - 1; |
| 47 } |
| 48 |
| 49 size_t MockMotionEvent::GetPointerCount() const { return pointer_count; } |
| 50 |
| 51 int MockMotionEvent::GetPointerId(size_t pointer_index) const { |
| 52 return static_cast<int>(pointer_index); |
| 53 } |
| 54 |
| 55 float MockMotionEvent::GetX(size_t pointer_index) const { |
| 56 return points[pointer_index].x(); |
| 57 } |
| 58 |
| 59 float MockMotionEvent::GetY(size_t pointer_index) const { |
| 60 return points[pointer_index].y(); |
| 61 } |
| 62 |
| 63 float MockMotionEvent::GetTouchMajor(size_t pointer_index) const { |
| 64 return kTouchMajor; |
| 65 } |
| 66 |
| 67 TimeTicks MockMotionEvent::GetEventTime() const { return time; } |
| 68 |
| 69 size_t MockMotionEvent::GetHistorySize() const { return 0; } |
| 70 |
| 71 TimeTicks MockMotionEvent::GetHistoricalEventTime( |
| 72 size_t historical_index) const { |
| 73 return TimeTicks(); |
| 74 } |
| 75 |
| 76 float MockMotionEvent::GetHistoricalTouchMajor(size_t pointer_index, |
| 77 size_t historical_index) const { |
| 78 return 0; |
| 79 } |
| 80 |
| 81 float MockMotionEvent::GetHistoricalX(size_t pointer_index, |
| 82 size_t historical_index) const { |
| 83 return 0; |
| 84 } |
| 85 |
| 86 float MockMotionEvent::GetHistoricalY(size_t pointer_index, |
| 87 size_t historical_index) const { |
| 88 return 0; |
| 89 } |
| 90 |
| 91 scoped_ptr<MotionEvent> MockMotionEvent::Clone() const { |
| 92 return scoped_ptr<MotionEvent>(new MockMotionEvent(*this)); |
| 93 } |
| 94 |
| 95 scoped_ptr<MotionEvent> MockMotionEvent::Cancel() const { |
| 96 scoped_ptr<MockMotionEvent> cancel_event(new MockMotionEvent(*this)); |
| 97 cancel_event->action = MotionEvent::ACTION_CANCEL; |
| 98 return cancel_event.PassAs<MotionEvent>(); |
| 99 } |
| 100 |
| 101 } // namespace ui |
OLD | NEW |