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_generic.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 namespace test { |
14 | 14 |
15 struct MockMotionEvent : public MotionEvent { | 15 struct MockMotionEvent : public MotionEventGeneric { |
16 enum { MAX_POINTERS = 3 }; | |
17 enum { TOUCH_MAJOR = 10 }; | 16 enum { TOUCH_MAJOR = 10 }; |
18 | 17 |
19 MockMotionEvent(); | 18 MockMotionEvent(); |
20 explicit MockMotionEvent(Action action); | 19 explicit MockMotionEvent(Action action); |
21 MockMotionEvent(Action action, base::TimeTicks time, float x, float y); | 20 MockMotionEvent(Action action, base::TimeTicks time, float x, float y); |
22 MockMotionEvent(Action action, | 21 MockMotionEvent(Action action, |
23 base::TimeTicks time, | 22 base::TimeTicks time, |
24 float x0, | 23 float x0, |
25 float y0, | 24 float y0, |
26 float x1, | 25 float x1, |
27 float y1); | 26 float y1); |
28 MockMotionEvent(Action action, | 27 MockMotionEvent(Action action, |
29 base::TimeTicks time, | 28 base::TimeTicks time, |
30 float x0, | 29 float x0, |
31 float y0, | 30 float y0, |
32 float x1, | 31 float x1, |
33 float y1, | 32 float y1, |
34 float x2, | 33 float x2, |
35 float y2); | 34 float y2); |
36 MockMotionEvent(Action action, | 35 MockMotionEvent(Action action, |
37 base::TimeTicks time, | 36 base::TimeTicks time, |
38 const std::vector<gfx::PointF>& positions); | 37 const std::vector<gfx::PointF>& positions); |
39 MockMotionEvent(const MockMotionEvent& other); | 38 MockMotionEvent(const MockMotionEvent& other); |
40 | 39 |
41 virtual ~MockMotionEvent(); | 40 virtual ~MockMotionEvent(); |
42 | 41 |
43 // MotionEvent methods. | 42 // MotionEvent methods. |
44 virtual Action GetAction() const OVERRIDE; | |
45 virtual int GetActionIndex() const OVERRIDE; | |
46 virtual size_t GetPointerCount() const OVERRIDE; | |
47 virtual int GetId() const OVERRIDE; | |
48 virtual int GetPointerId(size_t pointer_index) const OVERRIDE; | |
49 virtual float GetX(size_t pointer_index) const OVERRIDE; | |
50 virtual float GetY(size_t pointer_index) const OVERRIDE; | |
51 virtual float GetRawX(size_t pointer_index) const OVERRIDE; | |
52 virtual float GetRawY(size_t pointer_index) const OVERRIDE; | |
53 virtual float GetTouchMajor(size_t pointer_index) const OVERRIDE; | |
54 virtual float GetPressure(size_t pointer_index) const OVERRIDE; | |
55 virtual base::TimeTicks GetEventTime() const OVERRIDE; | |
56 virtual size_t GetHistorySize() const OVERRIDE; | |
57 virtual base::TimeTicks GetHistoricalEventTime(size_t historical_index) const | |
58 OVERRIDE; | |
59 virtual float GetHistoricalTouchMajor(size_t pointer_index, | |
60 size_t historical_index) const OVERRIDE; | |
61 virtual float GetHistoricalX(size_t pointer_index, | |
62 size_t historical_index) const OVERRIDE; | |
63 virtual float GetHistoricalY(size_t pointer_index, | |
64 size_t historical_index) const OVERRIDE; | |
65 virtual ToolType GetToolType(size_t pointer_index) const OVERRIDE; | |
66 virtual int GetButtonState() const OVERRIDE; | |
67 | |
68 virtual scoped_ptr<MotionEvent> Clone() const OVERRIDE; | 43 virtual scoped_ptr<MotionEvent> Clone() const OVERRIDE; |
69 virtual scoped_ptr<MotionEvent> Cancel() const OVERRIDE; | 44 virtual scoped_ptr<MotionEvent> Cancel() const OVERRIDE; |
70 | 45 |
71 // Utility methods. | 46 // Utility methods. |
72 void SetId(int new_id); | |
73 void SetTime(base::TimeTicks new_time); | |
74 void PressPoint(float x, float y); | 47 void PressPoint(float x, float y); |
75 void MovePoint(size_t index, float x, float y); | 48 void MovePoint(size_t index, float x, float y); |
76 void ReleasePoint(); | 49 void ReleasePoint(); |
77 void CancelPoint(); | 50 void CancelPoint(); |
78 void SetTouchMajor(float new_touch_major); | 51 void SetTouchMajor(float new_touch_major); |
79 void SetRawOffset(float raw_offset_x, float raw_offset_y); | 52 void SetRawOffset(float raw_offset_x, float raw_offset_y); |
80 void SetToolType(size_t index, ToolType tool_type); | 53 void SetToolType(size_t index, ToolType tool_type); |
81 void SetButtonState(int button_state); | |
82 | 54 |
83 MotionEvent::Action action; | 55 private: |
84 size_t pointer_count; | 56 void PushPointer(float x, float y); |
85 gfx::PointF points[MAX_POINTERS]; | 57 void ResolvePointers(); |
86 ToolType tool_types[MAX_POINTERS]; | |
87 gfx::Vector2dF raw_offset; | |
88 base::TimeTicks time; | |
89 float touch_major; | |
90 int id; | |
91 int button_state; | |
92 }; | 58 }; |
93 | 59 |
94 } // namespace test | 60 } // namespace test |
95 } // namespace ui | 61 } // namespace ui |
OLD | NEW |