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

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

Issue 929333002: Adding synthetic touch/mouse drag [Part1] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More nits Created 5 years, 10 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 "content/common/input/input_event.h" 7 #include "content/common/input/input_event.h"
8 #include "content/common/input/synthetic_gesture_params.h" 8 #include "content/common/input/synthetic_gesture_params.h"
9 #include "content/common/input/synthetic_pinch_gesture_params.h" 9 #include "content/common/input/synthetic_pinch_gesture_params.h"
10 #include "content/common/input/synthetic_smooth_scroll_gesture_params.h" 10 #include "content/common/input/synthetic_smooth_scroll_gesture_params.h"
(...skipping 30 matching lines...) Expand all
41 const SyntheticSmoothScrollGestureParams* b) { 41 const SyntheticSmoothScrollGestureParams* b) {
42 EXPECT_EQ(a->gesture_source_type, b->gesture_source_type); 42 EXPECT_EQ(a->gesture_source_type, b->gesture_source_type);
43 EXPECT_EQ(a->anchor, b->anchor); 43 EXPECT_EQ(a->anchor, b->anchor);
44 EXPECT_EQ(a->distances.size(), b->distances.size()); 44 EXPECT_EQ(a->distances.size(), b->distances.size());
45 for (size_t i = 0; i < a->distances.size(); i++) 45 for (size_t i = 0; i < a->distances.size(); i++)
46 EXPECT_EQ(a->distances[i], b->distances[i]); 46 EXPECT_EQ(a->distances[i], b->distances[i]);
47 EXPECT_EQ(a->prevent_fling, b->prevent_fling); 47 EXPECT_EQ(a->prevent_fling, b->prevent_fling);
48 EXPECT_EQ(a->speed_in_pixels_s, b->speed_in_pixels_s); 48 EXPECT_EQ(a->speed_in_pixels_s, b->speed_in_pixels_s);
49 } 49 }
50 50
51 static void Compare(const SyntheticSmoothDragGestureParams* a,
52 const SyntheticSmoothDragGestureParams* b) {
53 EXPECT_EQ(a->gesture_source_type, b->gesture_source_type);
54 EXPECT_EQ(a->start_point, b->start_point);
55 EXPECT_EQ(a->distances.size(), b->distances.size());
56 for (size_t i = 0; i < a->distances.size(); i++)
57 EXPECT_EQ(a->distances[i], b->distances[i]);
Sami 2015/02/19 11:59:06 nit: indent -= 2
ssid 2015/02/20 10:58:55 Changed the previous function also.
58 EXPECT_EQ(a->speed_in_pixels_s, b->speed_in_pixels_s);
59 }
60
51 static void Compare(const SyntheticPinchGestureParams* a, 61 static void Compare(const SyntheticPinchGestureParams* a,
52 const SyntheticPinchGestureParams* b) { 62 const SyntheticPinchGestureParams* b) {
53 EXPECT_EQ(a->gesture_source_type, b->gesture_source_type); 63 EXPECT_EQ(a->gesture_source_type, b->gesture_source_type);
54 EXPECT_EQ(a->scale_factor, b->scale_factor); 64 EXPECT_EQ(a->scale_factor, b->scale_factor);
55 EXPECT_EQ(a->anchor, b->anchor); 65 EXPECT_EQ(a->anchor, b->anchor);
56 EXPECT_EQ(a->relative_pointer_speed_in_pixels_s, 66 EXPECT_EQ(a->relative_pointer_speed_in_pixels_s,
57 b->relative_pointer_speed_in_pixels_s); 67 b->relative_pointer_speed_in_pixels_s);
58 } 68 }
59 69
60 static void Compare(const SyntheticTapGestureParams* a, 70 static void Compare(const SyntheticTapGestureParams* a,
61 const SyntheticTapGestureParams* b) { 71 const SyntheticTapGestureParams* b) {
62 EXPECT_EQ(a->gesture_source_type, b->gesture_source_type); 72 EXPECT_EQ(a->gesture_source_type, b->gesture_source_type);
63 EXPECT_EQ(a->position, b->position); 73 EXPECT_EQ(a->position, b->position);
64 EXPECT_EQ(a->duration_ms, b->duration_ms); 74 EXPECT_EQ(a->duration_ms, b->duration_ms);
65 } 75 }
66 76
67 static void Compare(const SyntheticGesturePacket* a, 77 static void Compare(const SyntheticGesturePacket* a,
68 const SyntheticGesturePacket* b) { 78 const SyntheticGesturePacket* b) {
69 ASSERT_EQ(!!a, !!b); 79 ASSERT_EQ(!!a, !!b);
70 if (!a) return; 80 if (!a) return;
71 ASSERT_EQ(!!a->gesture_params(), !!b->gesture_params()); 81 ASSERT_EQ(!!a->gesture_params(), !!b->gesture_params());
72 if (!a->gesture_params()) return; 82 if (!a->gesture_params()) return;
73 ASSERT_EQ(a->gesture_params()->GetGestureType(), 83 ASSERT_EQ(a->gesture_params()->GetGestureType(),
74 b->gesture_params()->GetGestureType()); 84 b->gesture_params()->GetGestureType());
75 switch (a->gesture_params()->GetGestureType()) { 85 switch (a->gesture_params()->GetGestureType()) {
76 case SyntheticGestureParams::SMOOTH_SCROLL_GESTURE: 86 case SyntheticGestureParams::SMOOTH_SCROLL_GESTURE:
77 Compare(SyntheticSmoothScrollGestureParams::Cast(a->gesture_params()), 87 Compare(SyntheticSmoothScrollGestureParams::Cast(a->gesture_params()),
78 SyntheticSmoothScrollGestureParams::Cast(b->gesture_params())); 88 SyntheticSmoothScrollGestureParams::Cast(b->gesture_params()));
79 break; 89 break;
90 case SyntheticGestureParams::SMOOTH_DRAG_GESTURE:
91 Compare(SyntheticSmoothDragGestureParams::Cast(a->gesture_params()),
92 SyntheticSmoothDragGestureParams::Cast(b->gesture_params()));
93 break;
80 case SyntheticGestureParams::PINCH_GESTURE: 94 case SyntheticGestureParams::PINCH_GESTURE:
81 Compare(SyntheticPinchGestureParams::Cast(a->gesture_params()), 95 Compare(SyntheticPinchGestureParams::Cast(a->gesture_params()),
82 SyntheticPinchGestureParams::Cast(b->gesture_params())); 96 SyntheticPinchGestureParams::Cast(b->gesture_params()));
83 break; 97 break;
84 case SyntheticGestureParams::TAP_GESTURE: 98 case SyntheticGestureParams::TAP_GESTURE:
85 Compare(SyntheticTapGestureParams::Cast(a->gesture_params()), 99 Compare(SyntheticTapGestureParams::Cast(a->gesture_params()),
86 SyntheticTapGestureParams::Cast(b->gesture_params())); 100 SyntheticTapGestureParams::Cast(b->gesture_params()));
87 break; 101 break;
88 } 102 }
89 } 103 }
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 ASSERT_EQ(SyntheticGestureParams::TAP_GESTURE, 242 ASSERT_EQ(SyntheticGestureParams::TAP_GESTURE,
229 gesture_params->GetGestureType()); 243 gesture_params->GetGestureType());
230 SyntheticGesturePacket packet_in; 244 SyntheticGesturePacket packet_in;
231 packet_in.set_gesture_params(gesture_params.Pass()); 245 packet_in.set_gesture_params(gesture_params.Pass());
232 246
233 Verify(packet_in); 247 Verify(packet_in);
234 } 248 }
235 249
236 } // namespace 250 } // namespace
237 } // namespace content 251 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698