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

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

Issue 2742473002: gpu benchmarking swipe for touchpad
Patch Set: swipe direction fixed Created 3 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 "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 Compare((*a)[i], (*b)[i]); 47 Compare((*a)[i], (*b)[i]);
48 } 48 }
49 49
50 static void Compare(const SyntheticSmoothScrollGestureParams* a, 50 static void Compare(const SyntheticSmoothScrollGestureParams* a,
51 const SyntheticSmoothScrollGestureParams* b) { 51 const SyntheticSmoothScrollGestureParams* b) {
52 EXPECT_EQ(a->gesture_source_type, b->gesture_source_type); 52 EXPECT_EQ(a->gesture_source_type, b->gesture_source_type);
53 EXPECT_EQ(a->anchor, b->anchor); 53 EXPECT_EQ(a->anchor, b->anchor);
54 EXPECT_EQ(a->distances.size(), b->distances.size()); 54 EXPECT_EQ(a->distances.size(), b->distances.size());
55 for (size_t i = 0; i < a->distances.size(); i++) 55 for (size_t i = 0; i < a->distances.size(); i++)
56 EXPECT_EQ(a->distances[i], b->distances[i]); 56 EXPECT_EQ(a->distances[i], b->distances[i]);
57 EXPECT_EQ(a->velocity, b->velocity);
57 EXPECT_EQ(a->prevent_fling, b->prevent_fling); 58 EXPECT_EQ(a->prevent_fling, b->prevent_fling);
58 EXPECT_EQ(a->speed_in_pixels_s, b->speed_in_pixels_s); 59 EXPECT_EQ(a->speed_in_pixels_s, b->speed_in_pixels_s);
59 } 60 }
60 61
61 static void Compare(const SyntheticSmoothDragGestureParams* a, 62 static void Compare(const SyntheticSmoothDragGestureParams* a,
62 const SyntheticSmoothDragGestureParams* b) { 63 const SyntheticSmoothDragGestureParams* b) {
63 EXPECT_EQ(a->gesture_source_type, b->gesture_source_type); 64 EXPECT_EQ(a->gesture_source_type, b->gesture_source_type);
64 EXPECT_EQ(a->start_point, b->start_point); 65 EXPECT_EQ(a->start_point, b->start_point);
65 EXPECT_EQ(a->distances.size(), b->distances.size()); 66 EXPECT_EQ(a->distances.size(), b->distances.size());
66 for (size_t i = 0; i < a->distances.size(); i++) 67 for (size_t i = 0; i < a->distances.size(); i++)
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 gesture_params->prevent_fling = false; 256 gesture_params->prevent_fling = false;
256 gesture_params->speed_in_pixels_s = 456; 257 gesture_params->speed_in_pixels_s = 456;
257 ASSERT_EQ(SyntheticGestureParams::SMOOTH_SCROLL_GESTURE, 258 ASSERT_EQ(SyntheticGestureParams::SMOOTH_SCROLL_GESTURE,
258 gesture_params->GetGestureType()); 259 gesture_params->GetGestureType());
259 SyntheticGesturePacket packet_in; 260 SyntheticGesturePacket packet_in;
260 packet_in.set_gesture_params(std::move(gesture_params)); 261 packet_in.set_gesture_params(std::move(gesture_params));
261 262
262 Verify(packet_in); 263 Verify(packet_in);
263 } 264 }
264 265
266 TEST_F(InputParamTraitsTest, SyntheticSmoothScrollGestureParamsWithVelocity) {
267 std::unique_ptr<SyntheticSmoothScrollGestureParams> gesture_params(
268 new SyntheticSmoothScrollGestureParams);
269 gesture_params->gesture_source_type = SyntheticGestureParams::MOUSE_INPUT;
270 gesture_params->anchor.SetPoint(234, 345);
271 gesture_params->distances.push_back(gfx::Vector2d(123, -789));
272 gesture_params->distances.push_back(gfx::Vector2d(-78, 43));
273 gesture_params->velocity = gfx::Vector2d(-45, 76);
274 gesture_params->prevent_fling = false;
275 gesture_params->speed_in_pixels_s = 456;
276 ASSERT_EQ(SyntheticGestureParams::SMOOTH_SCROLL_GESTURE,
277 gesture_params->GetGestureType());
278 SyntheticGesturePacket packet_in;
279 packet_in.set_gesture_params(std::move(gesture_params));
280
281 Verify(packet_in);
282 }
283
265 TEST_F(InputParamTraitsTest, SyntheticPinchGestureParams) { 284 TEST_F(InputParamTraitsTest, SyntheticPinchGestureParams) {
266 std::unique_ptr<SyntheticPinchGestureParams> gesture_params( 285 std::unique_ptr<SyntheticPinchGestureParams> gesture_params(
267 new SyntheticPinchGestureParams); 286 new SyntheticPinchGestureParams);
268 gesture_params->gesture_source_type = SyntheticGestureParams::TOUCH_INPUT; 287 gesture_params->gesture_source_type = SyntheticGestureParams::TOUCH_INPUT;
269 gesture_params->scale_factor = 2.3f; 288 gesture_params->scale_factor = 2.3f;
270 gesture_params->anchor.SetPoint(234, 345); 289 gesture_params->anchor.SetPoint(234, 345);
271 gesture_params->relative_pointer_speed_in_pixels_s = 456; 290 gesture_params->relative_pointer_speed_in_pixels_s = 456;
272 ASSERT_EQ(SyntheticGestureParams::PINCH_GESTURE, 291 ASSERT_EQ(SyntheticGestureParams::PINCH_GESTURE,
273 gesture_params->GetGestureType()); 292 gesture_params->GetGestureType());
274 SyntheticGesturePacket packet_in; 293 SyntheticGesturePacket packet_in;
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 376
358 ASSERT_EQ(SyntheticGestureParams::POINTER_ACTION_LIST, 377 ASSERT_EQ(SyntheticGestureParams::POINTER_ACTION_LIST,
359 gesture_params->GetGestureType()); 378 gesture_params->GetGestureType());
360 SyntheticGesturePacket packet_in; 379 SyntheticGesturePacket packet_in;
361 packet_in.set_gesture_params(std::move(gesture_params)); 380 packet_in.set_gesture_params(std::move(gesture_params));
362 Verify(packet_in); 381 Verify(packet_in);
363 } 382 }
364 383
365 } // namespace 384 } // namespace
366 } // namespace content 385 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698