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

Side by Side Diff: ui/events/gesture_detection/velocity_tracker_unittest.cc

Issue 1109393002: Pass gfx structs by const ref (gfx::PointF) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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 | « cc/layers/texture_layer_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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 "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/logging.h" 6 #include "base/logging.h"
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/time/time.h" 8 #include "base/time/time.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "ui/events/gesture_detection/velocity_tracker_state.h" 10 #include "ui/events/gesture_detection/velocity_tracker_state.h"
(...skipping 30 matching lines...) Expand all
41 41
42 } // namespace 42 } // namespace
43 43
44 class VelocityTrackerTest : public testing::Test { 44 class VelocityTrackerTest : public testing::Test {
45 public: 45 public:
46 VelocityTrackerTest() {} 46 VelocityTrackerTest() {}
47 ~VelocityTrackerTest() override {} 47 ~VelocityTrackerTest() override {}
48 48
49 protected: 49 protected:
50 static MockMotionEvent Sample(MotionEvent::Action action, 50 static MockMotionEvent Sample(MotionEvent::Action action,
51 gfx::PointF p0, 51 const gfx::PointF& p0,
52 TimeTicks t0, 52 TimeTicks t0,
53 gfx::Vector2dF v, 53 gfx::Vector2dF v,
54 TimeDelta dt) { 54 TimeDelta dt) {
55 const gfx::PointF p = p0 + ScaleVector2d(v, dt.InSecondsF()); 55 const gfx::PointF p = p0 + ScaleVector2d(v, dt.InSecondsF());
56 return MockMotionEvent(action, t0 + dt, p.x(), p.y()); 56 return MockMotionEvent(action, t0 + dt, p.x(), p.y());
57 } 57 }
58 58
59 static void ApplyMovementSequence(VelocityTrackerState* state, 59 static void ApplyMovementSequence(VelocityTrackerState* state,
60 gfx::PointF p0, 60 const gfx::PointF& p0,
61 gfx::Vector2dF v, 61 gfx::Vector2dF v,
62 TimeTicks t0, 62 TimeTicks t0,
63 TimeDelta t, 63 TimeDelta t,
64 size_t samples) { 64 size_t samples) {
65 EXPECT_TRUE(!!samples); 65 EXPECT_TRUE(!!samples);
66 if (!samples) 66 if (!samples)
67 return; 67 return;
68 const base::TimeDelta dt = t / samples; 68 const base::TimeDelta dt = t / samples;
69 state->AddMovement(Sample(MotionEvent::ACTION_DOWN, p0, t0, v, dt * 0)); 69 state->AddMovement(Sample(MotionEvent::ACTION_DOWN, p0, t0, v, dt * 0));
70 ApplyMovement(state, p0, v, t0, t, samples); 70 ApplyMovement(state, p0, v, t0, t, samples);
71 state->AddMovement(Sample(MotionEvent::ACTION_UP, p0, t0, v, t)); 71 state->AddMovement(Sample(MotionEvent::ACTION_UP, p0, t0, v, t));
72 } 72 }
73 73
74 static void ApplyMovement(VelocityTrackerState* state, 74 static void ApplyMovement(VelocityTrackerState* state,
75 gfx::PointF p0, 75 const gfx::PointF& p0,
76 gfx::Vector2dF v, 76 gfx::Vector2dF v,
77 TimeTicks t0, 77 TimeTicks t0,
78 TimeDelta t, 78 TimeDelta t,
79 size_t samples) { 79 size_t samples) {
80 EXPECT_TRUE(!!samples); 80 EXPECT_TRUE(!!samples);
81 if (!samples) 81 if (!samples)
82 return; 82 return;
83 const base::TimeDelta dt = t / samples; 83 const base::TimeDelta dt = t / samples;
84 for (size_t i = 0; i < samples; ++i) 84 for (size_t i = 0; i < samples; ++i)
85 state->AddMovement(Sample(MotionEvent::ACTION_MOVE, p0, t0, v, dt * i)); 85 state->AddMovement(Sample(MotionEvent::ACTION_MOVE, p0, t0, v, dt * i));
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 253
254 // This does not hold for the unrestricted LSQ2 strategy. 254 // This does not hold for the unrestricted LSQ2 strategy.
255 state_unrestricted.ComputeCurrentVelocity(1000, 20000); 255 state_unrestricted.ComputeCurrentVelocity(1000, 20000);
256 EXPECT_EQ(0, state_unrestricted.GetXVelocity(0)); 256 EXPECT_EQ(0, state_unrestricted.GetXVelocity(0));
257 // Y velocity is negative, despite the fact that the finger only moved in the 257 // Y velocity is negative, despite the fact that the finger only moved in the
258 // positive y direction. 258 // positive y direction.
259 EXPECT_GT(0, state_unrestricted.GetYVelocity(0)); 259 EXPECT_GT(0, state_unrestricted.GetYVelocity(0));
260 } 260 }
261 261
262 } // namespace ui 262 } // namespace ui
OLDNEW
« no previous file with comments | « cc/layers/texture_layer_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698