| 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/test/mock_motion_event.h" | 5 #include "ui/events/test/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 |
| 11 namespace ui { | 11 namespace ui { |
| 12 namespace test { | 12 namespace test { |
| 13 namespace { | 13 namespace { |
| 14 | 14 |
| 15 PointerProperties CreatePointer() { | 15 PointerProperties CreatePointer() { |
| 16 PointerProperties pointer; | 16 PointerProperties pointer; |
| 17 pointer.touch_major = MockMotionEvent::TOUCH_MAJOR; | 17 pointer.touch_major = MockMotionEvent::TOUCH_MAJOR; |
| 18 return pointer; | 18 return pointer; |
| 19 } | 19 } |
| 20 | 20 |
| 21 PointerProperties CreatePointer(float x, float y, int id) { | 21 PointerProperties CreatePointer(float x, float y, int id) { |
| 22 PointerProperties pointer(x, y); | 22 PointerProperties pointer(x, y, MockMotionEvent::TOUCH_MAJOR); |
| 23 pointer.touch_major = MockMotionEvent::TOUCH_MAJOR; | |
| 24 pointer.id = id; | 23 pointer.id = id; |
| 25 return pointer; | 24 return pointer; |
| 26 } | 25 } |
| 27 | 26 |
| 28 | 27 |
| 29 } // namespace | 28 } // namespace |
| 30 | 29 |
| 31 MockMotionEvent::MockMotionEvent() | 30 MockMotionEvent::MockMotionEvent() |
| 32 : MotionEventGeneric(ACTION_CANCEL, base::TimeTicks(), CreatePointer()) { | 31 : MotionEventGeneric(ACTION_CANCEL, base::TimeTicks(), CreatePointer()) { |
| 33 } | 32 } |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 for (size_t i = 0; i < positions.size(); ++i) | 79 for (size_t i = 0; i < positions.size(); ++i) |
| 81 PushPointer(positions[i].x(), positions[i].y()); | 80 PushPointer(positions[i].x(), positions[i].y()); |
| 82 } | 81 } |
| 83 | 82 |
| 84 MockMotionEvent::MockMotionEvent(const MockMotionEvent& other) | 83 MockMotionEvent::MockMotionEvent(const MockMotionEvent& other) |
| 85 : MotionEventGeneric(other) { | 84 : MotionEventGeneric(other) { |
| 86 } | 85 } |
| 87 | 86 |
| 88 MockMotionEvent::~MockMotionEvent() {} | 87 MockMotionEvent::~MockMotionEvent() {} |
| 89 | 88 |
| 90 scoped_ptr<MotionEvent> MockMotionEvent::Clone() const { | |
| 91 return scoped_ptr<MotionEvent>(new MockMotionEvent(*this)); | |
| 92 } | |
| 93 | |
| 94 scoped_ptr<MotionEvent> MockMotionEvent::Cancel() const { | |
| 95 scoped_ptr<MockMotionEvent> event(new MockMotionEvent(*this)); | |
| 96 event->set_action(MotionEvent::ACTION_CANCEL); | |
| 97 return event.Pass(); | |
| 98 } | |
| 99 | |
| 100 void MockMotionEvent::PressPoint(float x, float y) { | 89 void MockMotionEvent::PressPoint(float x, float y) { |
| 101 ResolvePointers(); | 90 ResolvePointers(); |
| 102 PushPointer(x, y); | 91 PushPointer(x, y); |
| 103 if (GetPointerCount() > 1) { | 92 if (GetPointerCount() > 1) { |
| 104 set_action_index(static_cast<int>(GetPointerCount()) - 1); | 93 set_action_index(static_cast<int>(GetPointerCount()) - 1); |
| 105 set_action(ACTION_POINTER_DOWN); | 94 set_action(ACTION_POINTER_DOWN); |
| 106 } else { | 95 } else { |
| 107 set_action(ACTION_DOWN); | 96 set_action(ACTION_DOWN); |
| 108 } | 97 } |
| 109 } | 98 } |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 case ACTION_CANCEL: | 157 case ACTION_CANCEL: |
| 169 PopPointer(); | 158 PopPointer(); |
| 170 return; | 159 return; |
| 171 default: | 160 default: |
| 172 break; | 161 break; |
| 173 } | 162 } |
| 174 } | 163 } |
| 175 | 164 |
| 176 } // namespace test | 165 } // namespace test |
| 177 } // namespace ui | 166 } // namespace ui |
| OLD | NEW |