Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(381)

Side by Side Diff: content/common/input/input_param_traits_unittest.cc

Issue 1707943002: Add SyntheticPointerActionParams used in Chromedriver extension (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use get functions in the IPC message Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "content/common/input/input_param_traits.h" 5 #include "content/common/input/input_param_traits.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "content/common/input/input_event.h" 10 #include "content/common/input/input_event.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 b->relative_pointer_speed_in_pixels_s); 70 b->relative_pointer_speed_in_pixels_s);
71 } 71 }
72 72
73 static void Compare(const SyntheticTapGestureParams* a, 73 static void Compare(const SyntheticTapGestureParams* a,
74 const SyntheticTapGestureParams* b) { 74 const SyntheticTapGestureParams* b) {
75 EXPECT_EQ(a->gesture_source_type, b->gesture_source_type); 75 EXPECT_EQ(a->gesture_source_type, b->gesture_source_type);
76 EXPECT_EQ(a->position, b->position); 76 EXPECT_EQ(a->position, b->position);
77 EXPECT_EQ(a->duration_ms, b->duration_ms); 77 EXPECT_EQ(a->duration_ms, b->duration_ms);
78 } 78 }
79 79
80 static void Compare(const SyntheticPointerActionParams* a,
81 const SyntheticPointerActionParams* b) {
82 EXPECT_EQ(a->gesture_source_type, b->gesture_source_type);
83 EXPECT_EQ(a->position(), b->position());
84 EXPECT_EQ(a->index(), b->index());
85 EXPECT_EQ(a->pointer_action_type, b->pointer_action_type);
86 }
87
80 static void Compare(const SyntheticGesturePacket* a, 88 static void Compare(const SyntheticGesturePacket* a,
81 const SyntheticGesturePacket* b) { 89 const SyntheticGesturePacket* b) {
82 ASSERT_EQ(!!a, !!b); 90 ASSERT_EQ(!!a, !!b);
83 if (!a) return; 91 if (!a) return;
84 ASSERT_EQ(!!a->gesture_params(), !!b->gesture_params()); 92 ASSERT_EQ(!!a->gesture_params(), !!b->gesture_params());
85 if (!a->gesture_params()) return; 93 if (!a->gesture_params()) return;
86 ASSERT_EQ(a->gesture_params()->GetGestureType(), 94 ASSERT_EQ(a->gesture_params()->GetGestureType(),
87 b->gesture_params()->GetGestureType()); 95 b->gesture_params()->GetGestureType());
88 switch (a->gesture_params()->GetGestureType()) { 96 switch (a->gesture_params()->GetGestureType()) {
89 case SyntheticGestureParams::SMOOTH_SCROLL_GESTURE: 97 case SyntheticGestureParams::SMOOTH_SCROLL_GESTURE:
90 Compare(SyntheticSmoothScrollGestureParams::Cast(a->gesture_params()), 98 Compare(SyntheticSmoothScrollGestureParams::Cast(a->gesture_params()),
91 SyntheticSmoothScrollGestureParams::Cast(b->gesture_params())); 99 SyntheticSmoothScrollGestureParams::Cast(b->gesture_params()));
92 break; 100 break;
93 case SyntheticGestureParams::SMOOTH_DRAG_GESTURE: 101 case SyntheticGestureParams::SMOOTH_DRAG_GESTURE:
94 Compare(SyntheticSmoothDragGestureParams::Cast(a->gesture_params()), 102 Compare(SyntheticSmoothDragGestureParams::Cast(a->gesture_params()),
95 SyntheticSmoothDragGestureParams::Cast(b->gesture_params())); 103 SyntheticSmoothDragGestureParams::Cast(b->gesture_params()));
96 break; 104 break;
97 case SyntheticGestureParams::PINCH_GESTURE: 105 case SyntheticGestureParams::PINCH_GESTURE:
98 Compare(SyntheticPinchGestureParams::Cast(a->gesture_params()), 106 Compare(SyntheticPinchGestureParams::Cast(a->gesture_params()),
99 SyntheticPinchGestureParams::Cast(b->gesture_params())); 107 SyntheticPinchGestureParams::Cast(b->gesture_params()));
100 break; 108 break;
101 case SyntheticGestureParams::TAP_GESTURE: 109 case SyntheticGestureParams::TAP_GESTURE:
102 Compare(SyntheticTapGestureParams::Cast(a->gesture_params()), 110 Compare(SyntheticTapGestureParams::Cast(a->gesture_params()),
103 SyntheticTapGestureParams::Cast(b->gesture_params())); 111 SyntheticTapGestureParams::Cast(b->gesture_params()));
104 break; 112 break;
113 case SyntheticGestureParams::POINTER_ACTION:
114 Compare(SyntheticPointerActionParams::Cast(a->gesture_params()),
115 SyntheticPointerActionParams::Cast(b->gesture_params()));
116 break;
105 } 117 }
106 } 118 }
107 119
108 static void Verify(const InputEvents& events_in) { 120 static void Verify(const InputEvents& events_in) {
109 IPC::Message msg; 121 IPC::Message msg;
110 IPC::ParamTraits<InputEvents>::Write(&msg, events_in); 122 IPC::ParamTraits<InputEvents>::Write(&msg, events_in);
111 123
112 InputEvents events_out; 124 InputEvents events_out;
113 base::PickleIterator iter(msg); 125 base::PickleIterator iter(msg);
114 EXPECT_TRUE(IPC::ParamTraits<InputEvents>::Read(&msg, &iter, &events_out)); 126 EXPECT_TRUE(IPC::ParamTraits<InputEvents>::Read(&msg, &iter, &events_out));
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 gesture_params->position.SetPoint(798, 233); 255 gesture_params->position.SetPoint(798, 233);
244 gesture_params->duration_ms = 13; 256 gesture_params->duration_ms = 13;
245 ASSERT_EQ(SyntheticGestureParams::TAP_GESTURE, 257 ASSERT_EQ(SyntheticGestureParams::TAP_GESTURE,
246 gesture_params->GetGestureType()); 258 gesture_params->GetGestureType());
247 SyntheticGesturePacket packet_in; 259 SyntheticGesturePacket packet_in;
248 packet_in.set_gesture_params(std::move(gesture_params)); 260 packet_in.set_gesture_params(std::move(gesture_params));
249 261
250 Verify(packet_in); 262 Verify(packet_in);
251 } 263 }
252 264
265 TEST_F(InputParamTraitsTest, SyntheticPointerActionParams) {
266 scoped_ptr<SyntheticPointerActionParams> gesture_params(
267 new SyntheticPointerActionParams(
268 SyntheticGestureParams::PointerActionType::MOVE));
269 gesture_params->gesture_source_type = SyntheticGestureParams::TOUCH_INPUT;
270 gesture_params->set_position(gfx::PointF(356, 287));
271 gesture_params->set_index(1);
272 ASSERT_EQ(SyntheticGestureParams::POINTER_ACTION,
273 gesture_params->GetGestureType());
274 SyntheticGesturePacket packet_in;
275 packet_in.set_gesture_params(std::move(gesture_params));
276 Verify(packet_in);
277 }
278
253 } // namespace 279 } // namespace
254 } // namespace content 280 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698