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

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

Issue 1884883005: Prepare SyntheticPointerAction to handle touch actions for multiple fingers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: return nullptr Created 4 years, 5 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
« no previous file with comments | « content/common/input/OWNERS ('k') | content/common/input/synthetic_pointer_action_params.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/memory/ptr_util.h"
10 #include "content/common/input/input_event.h" 11 #include "content/common/input/input_event.h"
11 #include "content/common/input/synthetic_gesture_params.h" 12 #include "content/common/input/synthetic_gesture_params.h"
12 #include "content/common/input/synthetic_pinch_gesture_params.h" 13 #include "content/common/input/synthetic_pinch_gesture_params.h"
13 #include "content/common/input/synthetic_pointer_action_params.h" 14 #include "content/common/input/synthetic_pointer_action_params.h"
14 #include "content/common/input/synthetic_smooth_drag_gesture_params.h" 15 #include "content/common/input/synthetic_smooth_drag_gesture_params.h"
15 #include "content/common/input/synthetic_smooth_scroll_gesture_params.h" 16 #include "content/common/input/synthetic_smooth_scroll_gesture_params.h"
16 #include "content/common/input_messages.h" 17 #include "content/common/input_messages.h"
17 #include "ipc/ipc_message.h" 18 #include "ipc/ipc_message.h"
18 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
19 #include "third_party/WebKit/public/web/WebInputEvent.h" 20 #include "third_party/WebKit/public/web/WebInputEvent.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 const SyntheticPointerActionParams* b) { 83 const SyntheticPointerActionParams* b) {
83 EXPECT_EQ(a->gesture_source_type, b->gesture_source_type); 84 EXPECT_EQ(a->gesture_source_type, b->gesture_source_type);
84 EXPECT_EQ(a->pointer_action_type(), b->pointer_action_type()); 85 EXPECT_EQ(a->pointer_action_type(), b->pointer_action_type());
85 if (a->pointer_action_type() == 86 if (a->pointer_action_type() ==
86 SyntheticPointerActionParams::PointerActionType::PRESS || 87 SyntheticPointerActionParams::PointerActionType::PRESS ||
87 a->pointer_action_type() == 88 a->pointer_action_type() ==
88 SyntheticPointerActionParams::PointerActionType::MOVE) { 89 SyntheticPointerActionParams::PointerActionType::MOVE) {
89 EXPECT_EQ(a->position(), b->position()); 90 EXPECT_EQ(a->position(), b->position());
90 } 91 }
91 if (a->pointer_action_type() != 92 if (a->pointer_action_type() !=
92 SyntheticPointerActionParams::PointerActionType::PROCESS) { 93 SyntheticPointerActionParams::PointerActionType::PROCESS &&
94 a->pointer_action_type() !=
95 SyntheticPointerActionParams::PointerActionType::FINISH) {
93 EXPECT_EQ(a->index(), b->index()); 96 EXPECT_EQ(a->index(), b->index());
94 } 97 }
95 } 98 }
96 99
97 static void Compare(const SyntheticGesturePacket* a, 100 static void Compare(const SyntheticGesturePacket* a,
98 const SyntheticGesturePacket* b) { 101 const SyntheticGesturePacket* b) {
99 ASSERT_EQ(!!a, !!b); 102 ASSERT_EQ(!!a, !!b);
100 if (!a) return; 103 if (!a) return;
101 ASSERT_EQ(!!a->gesture_params(), !!b->gesture_params()); 104 ASSERT_EQ(!!a->gesture_params(), !!b->gesture_params());
102 if (!a->gesture_params()) return; 105 if (!a->gesture_params()) return;
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 gesture_params->duration_ms = 13; 268 gesture_params->duration_ms = 13;
266 ASSERT_EQ(SyntheticGestureParams::TAP_GESTURE, 269 ASSERT_EQ(SyntheticGestureParams::TAP_GESTURE,
267 gesture_params->GetGestureType()); 270 gesture_params->GetGestureType());
268 SyntheticGesturePacket packet_in; 271 SyntheticGesturePacket packet_in;
269 packet_in.set_gesture_params(std::move(gesture_params)); 272 packet_in.set_gesture_params(std::move(gesture_params));
270 273
271 Verify(packet_in); 274 Verify(packet_in);
272 } 275 }
273 276
274 TEST_F(InputParamTraitsTest, SyntheticPointerActionParamsMove) { 277 TEST_F(InputParamTraitsTest, SyntheticPointerActionParamsMove) {
275 std::unique_ptr<SyntheticPointerActionParams> gesture_params( 278 std::unique_ptr<SyntheticPointerActionParams> gesture_params =
276 new SyntheticPointerActionParams( 279 base::MakeUnique<SyntheticPointerActionParams>(
277 SyntheticPointerActionParams::PointerActionType::MOVE)); 280 SyntheticPointerActionParams::PointerActionType::MOVE);
278 gesture_params->gesture_source_type = SyntheticGestureParams::TOUCH_INPUT; 281 gesture_params->gesture_source_type = SyntheticGestureParams::TOUCH_INPUT;
279 gesture_params->set_position(gfx::PointF(356, 287)); 282 gesture_params->set_position(gfx::PointF(356, 287));
280 gesture_params->set_index(0); 283 gesture_params->set_index(0);
281 ASSERT_EQ(SyntheticGestureParams::POINTER_ACTION, 284 ASSERT_EQ(SyntheticGestureParams::POINTER_ACTION,
282 gesture_params->GetGestureType()); 285 gesture_params->GetGestureType());
283 SyntheticGesturePacket packet_in; 286 SyntheticGesturePacket packet_in;
284 packet_in.set_gesture_params(std::move(gesture_params)); 287 packet_in.set_gesture_params(std::move(gesture_params));
285 Verify(packet_in); 288 Verify(packet_in);
286 } 289 }
287 290
288 TEST_F(InputParamTraitsTest, SyntheticPointerActionParamsRelease) { 291 TEST_F(InputParamTraitsTest, SyntheticPointerActionParamsRelease) {
289 std::unique_ptr<SyntheticPointerActionParams> gesture_params( 292 std::unique_ptr<SyntheticPointerActionParams> gesture_params =
290 new SyntheticPointerActionParams( 293 base::MakeUnique<SyntheticPointerActionParams>(
291 SyntheticPointerActionParams::PointerActionType::RELEASE)); 294 SyntheticPointerActionParams::PointerActionType::RELEASE);
292 gesture_params->gesture_source_type = SyntheticGestureParams::TOUCH_INPUT; 295 gesture_params->gesture_source_type = SyntheticGestureParams::TOUCH_INPUT;
293 gesture_params->set_index(0); 296 gesture_params->set_index(0);
294 ASSERT_EQ(SyntheticGestureParams::POINTER_ACTION, 297 ASSERT_EQ(SyntheticGestureParams::POINTER_ACTION,
295 gesture_params->GetGestureType()); 298 gesture_params->GetGestureType());
296 SyntheticGesturePacket packet_in; 299 SyntheticGesturePacket packet_in;
297 packet_in.set_gesture_params(std::move(gesture_params)); 300 packet_in.set_gesture_params(std::move(gesture_params));
298 Verify(packet_in); 301 Verify(packet_in);
299 } 302 }
300 303
301 TEST_F(InputParamTraitsTest, SyntheticPointerActionParamsProcess) { 304 TEST_F(InputParamTraitsTest, SyntheticPointerActionParamsProcess) {
302 std::unique_ptr<SyntheticPointerActionParams> gesture_params( 305 std::unique_ptr<SyntheticPointerActionParams> gesture_params =
303 new SyntheticPointerActionParams( 306 base::MakeUnique<SyntheticPointerActionParams>(
304 SyntheticPointerActionParams::PointerActionType::PROCESS)); 307 SyntheticPointerActionParams::PointerActionType::PROCESS);
305 gesture_params->gesture_source_type = SyntheticGestureParams::TOUCH_INPUT; 308 gesture_params->gesture_source_type = SyntheticGestureParams::TOUCH_INPUT;
306 ASSERT_EQ(SyntheticGestureParams::POINTER_ACTION, 309 ASSERT_EQ(SyntheticGestureParams::POINTER_ACTION,
307 gesture_params->GetGestureType()); 310 gesture_params->GetGestureType());
311 SyntheticGesturePacket packet_in;
312 packet_in.set_gesture_params(std::move(gesture_params));
313 Verify(packet_in);
314 }
315
316 TEST_F(InputParamTraitsTest, SyntheticPointerActionParamsFinish) {
317 std::unique_ptr<SyntheticPointerActionParams> gesture_params =
318 base::MakeUnique<SyntheticPointerActionParams>(
319 SyntheticPointerActionParams::PointerActionType::FINISH);
320 gesture_params->gesture_source_type = SyntheticGestureParams::TOUCH_INPUT;
321 ASSERT_EQ(SyntheticGestureParams::POINTER_ACTION,
322 gesture_params->GetGestureType());
308 SyntheticGesturePacket packet_in; 323 SyntheticGesturePacket packet_in;
309 packet_in.set_gesture_params(std::move(gesture_params)); 324 packet_in.set_gesture_params(std::move(gesture_params));
310 Verify(packet_in); 325 Verify(packet_in);
311 } 326 }
312 327
313 } // namespace 328 } // namespace
314 } // namespace content 329 } // namespace content
OLDNEW
« no previous file with comments | « content/common/input/OWNERS ('k') | content/common/input/synthetic_pointer_action_params.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698