| 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 <vector> | 5 #include <vector> |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/time/time.h" | 8 #include "base/time/time.h" |
| 9 #include "ui/events/gesture_detection/motion_event.h" | 9 #include "ui/events/gesture_detection/motion_event.h" |
| 10 #include "ui/gfx/geometry/point_f.h" | 10 #include "ui/gfx/geometry/point_f.h" |
| 11 | 11 |
| 12 namespace ui { | 12 namespace ui { |
| 13 namespace test { |
| 13 | 14 |
| 14 struct MockMotionEvent : public MotionEvent { | 15 struct MockMotionEvent : public MotionEvent { |
| 15 enum { MAX_POINTERS = 3 }; | 16 enum { MAX_POINTERS = 3 }; |
| 16 enum { TOUCH_MAJOR = 10 }; | 17 enum { TOUCH_MAJOR = 10 }; |
| 17 | 18 |
| 18 MockMotionEvent(); | 19 MockMotionEvent(); |
| 19 explicit MockMotionEvent(Action action); | 20 explicit MockMotionEvent(Action action); |
| 20 MockMotionEvent(Action action, base::TimeTicks time, float x, float y); | 21 MockMotionEvent(Action action, base::TimeTicks time, float x, float y); |
| 21 MockMotionEvent(Action action, | 22 MockMotionEvent(Action action, |
| 22 base::TimeTicks time, | 23 base::TimeTicks time, |
| 23 float x0, | 24 float x0, |
| 24 float y0, | 25 float y0, |
| 25 float x1, | 26 float x1, |
| 26 float y1); | 27 float y1); |
| 27 MockMotionEvent(Action action, | 28 MockMotionEvent(Action action, |
| 28 base::TimeTicks time, | 29 base::TimeTicks time, |
| 29 float x0, | 30 float x0, |
| 30 float y0, | 31 float y0, |
| 31 float x1, | 32 float x1, |
| 32 float y1, | 33 float y1, |
| 33 float x2, | 34 float x2, |
| 34 float y2); | 35 float y2); |
| 35 MockMotionEvent(Action action, | 36 MockMotionEvent(Action action, |
| 36 base::TimeTicks time, | 37 base::TimeTicks time, |
| 37 const std::vector<gfx::PointF>& positions); | 38 const std::vector<gfx::PointF>& positions); |
| 38 MockMotionEvent(const MockMotionEvent& other); | 39 MockMotionEvent(const MockMotionEvent& other); |
| 40 |
| 39 virtual ~MockMotionEvent(); | 41 virtual ~MockMotionEvent(); |
| 40 | 42 |
| 41 // MotionEvent methods. | 43 // MotionEvent methods. |
| 42 virtual Action GetAction() const OVERRIDE; | 44 virtual Action GetAction() const OVERRIDE; |
| 43 virtual int GetActionIndex() const OVERRIDE; | 45 virtual int GetActionIndex() const OVERRIDE; |
| 44 virtual size_t GetPointerCount() const OVERRIDE; | 46 virtual size_t GetPointerCount() const OVERRIDE; |
| 45 virtual int GetId() const OVERRIDE; | 47 virtual int GetId() const OVERRIDE; |
| 46 virtual int GetPointerId(size_t pointer_index) const OVERRIDE; | 48 virtual int GetPointerId(size_t pointer_index) const OVERRIDE; |
| 47 virtual float GetX(size_t pointer_index) const OVERRIDE; | 49 virtual float GetX(size_t pointer_index) const OVERRIDE; |
| 48 virtual float GetY(size_t pointer_index) const OVERRIDE; | 50 virtual float GetY(size_t pointer_index) const OVERRIDE; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 68 | 70 |
| 69 // Utility methods. | 71 // Utility methods. |
| 70 void SetId(int new_id); | 72 void SetId(int new_id); |
| 71 void SetTime(base::TimeTicks new_time); | 73 void SetTime(base::TimeTicks new_time); |
| 72 void PressPoint(float x, float y); | 74 void PressPoint(float x, float y); |
| 73 void MovePoint(size_t index, float x, float y); | 75 void MovePoint(size_t index, float x, float y); |
| 74 void ReleasePoint(); | 76 void ReleasePoint(); |
| 75 void CancelPoint(); | 77 void CancelPoint(); |
| 76 void SetTouchMajor(float new_touch_major); | 78 void SetTouchMajor(float new_touch_major); |
| 77 void SetRawOffset(float raw_offset_x, float raw_offset_y); | 79 void SetRawOffset(float raw_offset_x, float raw_offset_y); |
| 80 void SetToolType(size_t index, ToolType tool_type); |
| 81 void SetButtonState(int button_state); |
| 78 | 82 |
| 79 MotionEvent::Action action; | 83 MotionEvent::Action action; |
| 80 size_t pointer_count; | 84 size_t pointer_count; |
| 81 gfx::PointF points[MAX_POINTERS]; | 85 gfx::PointF points[MAX_POINTERS]; |
| 86 ToolType tool_types[MAX_POINTERS]; |
| 82 gfx::Vector2dF raw_offset; | 87 gfx::Vector2dF raw_offset; |
| 83 base::TimeTicks time; | 88 base::TimeTicks time; |
| 84 float touch_major; | 89 float touch_major; |
| 85 int id; | 90 int id; |
| 91 int button_state; |
| 86 }; | 92 }; |
| 87 | 93 |
| 94 } // namespace test |
| 88 } // namespace ui | 95 } // namespace ui |
| OLD | NEW |