Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / ui / events / test / motion_event_test_utils.h
blobde8d6a21f83e0ed1b8cac91164d0d8f0c8d7fbca
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.
5 #ifndef UI_EVENTS_TEST_MOTION_EVENT_TEST_UTILS_H_
6 #define UI_EVENTS_TEST_MOTION_EVENT_TEST_UTILS_H_
8 #include <string>
9 #include <vector>
11 #include "base/basictypes.h"
12 #include "base/time/time.h"
13 #include "ui/events/gesture_detection/motion_event_generic.h"
14 #include "ui/gfx/geometry/point_f.h"
16 namespace ui {
17 namespace test {
19 struct MockMotionEvent : public MotionEventGeneric {
20 enum { TOUCH_MAJOR = 10 };
22 MockMotionEvent();
23 explicit MockMotionEvent(Action action);
24 MockMotionEvent(Action action, base::TimeTicks time, float x, float y);
25 MockMotionEvent(Action action,
26 base::TimeTicks time,
27 float x0,
28 float y0,
29 float x1,
30 float y1);
31 MockMotionEvent(Action action,
32 base::TimeTicks time,
33 float x0,
34 float y0,
35 float x1,
36 float y1,
37 float x2,
38 float y2);
39 MockMotionEvent(Action action,
40 base::TimeTicks time,
41 const std::vector<gfx::PointF>& positions);
42 MockMotionEvent(const MockMotionEvent& other);
44 ~MockMotionEvent() override;
46 // Utility methods.
47 MockMotionEvent& PressPoint(float x, float y);
48 MockMotionEvent& MovePoint(size_t index, float x, float y);
49 MockMotionEvent& ReleasePoint();
50 MockMotionEvent& CancelPoint();
51 MockMotionEvent& SetTouchMajor(float new_touch_major);
52 MockMotionEvent& SetRawOffset(float raw_offset_x, float raw_offset_y);
53 MockMotionEvent& SetToolType(size_t index, ToolType tool_type);
54 MockMotionEvent& SetPrimaryPointerId(int id);
56 private:
57 void PushPointer(float x, float y);
58 void UpdatePointersAndID();
61 std::string ToString(const MotionEvent& event);
63 } // namespace test
64 } // namespace ui
66 #endif // UI_EVENTS_TEST_MOTION_EVENT_TEST_UTILS_H_