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

Side by Side Diff: content/browser/renderer_host/input/synthetic_gesture_controller_unittest.cc

Issue 616603004: Replacing the OVERRIDE with override and FINAL with final in content/browser/renderer_host (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased the patch Created 6 years, 2 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/memory/scoped_ptr.h" 6 #include "base/memory/scoped_ptr.h"
7 #include "base/time/time.h" 7 #include "base/time/time.h"
8 #include "content/browser/renderer_host/input/synthetic_gesture.h" 8 #include "content/browser/renderer_host/input/synthetic_gesture.h"
9 #include "content/browser/renderer_host/input/synthetic_gesture_controller.h" 9 #include "content/browser/renderer_host/input/synthetic_gesture_controller.h"
10 #include "content/browser/renderer_host/input/synthetic_gesture_target.h" 10 #include "content/browser/renderer_host/input/synthetic_gesture_target.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 public: 43 public:
44 MockSyntheticGesture(bool* finished, int num_steps) 44 MockSyntheticGesture(bool* finished, int num_steps)
45 : finished_(finished), 45 : finished_(finished),
46 num_steps_(num_steps), 46 num_steps_(num_steps),
47 step_count_(0) { 47 step_count_(0) {
48 *finished_ = false; 48 *finished_ = false;
49 } 49 }
50 virtual ~MockSyntheticGesture() {} 50 virtual ~MockSyntheticGesture() {}
51 51
52 virtual Result ForwardInputEvents(const base::TimeTicks& timestamp, 52 virtual Result ForwardInputEvents(const base::TimeTicks& timestamp,
53 SyntheticGestureTarget* target) OVERRIDE { 53 SyntheticGestureTarget* target) override {
54 step_count_++; 54 step_count_++;
55 if (step_count_ == num_steps_) { 55 if (step_count_ == num_steps_) {
56 *finished_ = true; 56 *finished_ = true;
57 return SyntheticGesture::GESTURE_FINISHED; 57 return SyntheticGesture::GESTURE_FINISHED;
58 } else if (step_count_ > num_steps_) { 58 } else if (step_count_ > num_steps_) {
59 *finished_ = true; 59 *finished_ = true;
60 // Return arbitrary failure. 60 // Return arbitrary failure.
61 return SyntheticGesture::GESTURE_SOURCE_TYPE_NOT_IMPLEMENTED; 61 return SyntheticGesture::GESTURE_SOURCE_TYPE_NOT_IMPLEMENTED;
62 } 62 }
63 63
64 return SyntheticGesture::GESTURE_RUNNING; 64 return SyntheticGesture::GESTURE_RUNNING;
65 } 65 }
66 66
67 protected: 67 protected:
68 bool* finished_; 68 bool* finished_;
69 int num_steps_; 69 int num_steps_;
70 int step_count_; 70 int step_count_;
71 }; 71 };
72 72
73 class MockSyntheticGestureTarget : public SyntheticGestureTarget { 73 class MockSyntheticGestureTarget : public SyntheticGestureTarget {
74 public: 74 public:
75 MockSyntheticGestureTarget() 75 MockSyntheticGestureTarget()
76 : flush_requested_(false), 76 : flush_requested_(false),
77 pointer_assumed_stopped_time_ms_(kPointerAssumedStoppedTimeMs) {} 77 pointer_assumed_stopped_time_ms_(kPointerAssumedStoppedTimeMs) {}
78 virtual ~MockSyntheticGestureTarget() {} 78 virtual ~MockSyntheticGestureTarget() {}
79 79
80 // SyntheticGestureTarget: 80 // SyntheticGestureTarget:
81 virtual void DispatchInputEventToPlatform( 81 virtual void DispatchInputEventToPlatform(
82 const WebInputEvent& event) OVERRIDE {} 82 const WebInputEvent& event) override {}
83 83
84 virtual void SetNeedsFlush() OVERRIDE { 84 virtual void SetNeedsFlush() override {
85 flush_requested_ = true; 85 flush_requested_ = true;
86 } 86 }
87 87
88 virtual SyntheticGestureParams::GestureSourceType 88 virtual SyntheticGestureParams::GestureSourceType
89 GetDefaultSyntheticGestureSourceType() const OVERRIDE { 89 GetDefaultSyntheticGestureSourceType() const override {
90 return SyntheticGestureParams::TOUCH_INPUT; 90 return SyntheticGestureParams::TOUCH_INPUT;
91 } 91 }
92 92
93 virtual base::TimeDelta PointerAssumedStoppedTime() const OVERRIDE { 93 virtual base::TimeDelta PointerAssumedStoppedTime() const override {
94 return base::TimeDelta::FromMilliseconds(pointer_assumed_stopped_time_ms_); 94 return base::TimeDelta::FromMilliseconds(pointer_assumed_stopped_time_ms_);
95 } 95 }
96 96
97 void set_pointer_assumed_stopped_time_ms(int time_ms) { 97 void set_pointer_assumed_stopped_time_ms(int time_ms) {
98 pointer_assumed_stopped_time_ms_ = time_ms; 98 pointer_assumed_stopped_time_ms_ = time_ms;
99 } 99 }
100 100
101 virtual float GetTouchSlopInDips() const OVERRIDE { 101 virtual float GetTouchSlopInDips() const override {
102 return kTouchSlopInDips; 102 return kTouchSlopInDips;
103 } 103 }
104 104
105 virtual float GetMinScalingSpanInDips() const OVERRIDE { 105 virtual float GetMinScalingSpanInDips() const override {
106 return kMinScalingSpanInDips; 106 return kMinScalingSpanInDips;
107 } 107 }
108 108
109 bool flush_requested() const { return flush_requested_; } 109 bool flush_requested() const { return flush_requested_; }
110 void ClearFlushRequest() { flush_requested_ = false; } 110 void ClearFlushRequest() { flush_requested_ = false; }
111 111
112 private: 112 private:
113 bool flush_requested_; 113 bool flush_requested_;
114 114
115 int pointer_assumed_stopped_time_ms_; 115 int pointer_assumed_stopped_time_ms_;
(...skipping 15 matching lines...) Expand all
131 gfx::Vector2dF start_to_end_distance_; 131 gfx::Vector2dF start_to_end_distance_;
132 float total_abs_scroll_distance_length_; 132 float total_abs_scroll_distance_length_;
133 }; 133 };
134 134
135 class MockScrollMouseTarget : public MockScrollGestureTarget { 135 class MockScrollMouseTarget : public MockScrollGestureTarget {
136 public: 136 public:
137 MockScrollMouseTarget() {} 137 MockScrollMouseTarget() {}
138 virtual ~MockScrollMouseTarget() {} 138 virtual ~MockScrollMouseTarget() {}
139 139
140 virtual void DispatchInputEventToPlatform( 140 virtual void DispatchInputEventToPlatform(
141 const WebInputEvent& event) OVERRIDE { 141 const WebInputEvent& event) override {
142 ASSERT_EQ(event.type, WebInputEvent::MouseWheel); 142 ASSERT_EQ(event.type, WebInputEvent::MouseWheel);
143 const WebMouseWheelEvent& mouse_wheel_event = 143 const WebMouseWheelEvent& mouse_wheel_event =
144 static_cast<const WebMouseWheelEvent&>(event); 144 static_cast<const WebMouseWheelEvent&>(event);
145 gfx::Vector2dF delta(mouse_wheel_event.deltaX, mouse_wheel_event.deltaY); 145 gfx::Vector2dF delta(mouse_wheel_event.deltaX, mouse_wheel_event.deltaY);
146 start_to_end_distance_ += delta; 146 start_to_end_distance_ += delta;
147 total_abs_scroll_distance_length_ += delta.Length(); 147 total_abs_scroll_distance_length_ += delta.Length();
148 } 148 }
149 }; 149 };
150 150
151 class MockScrollTouchTarget : public MockScrollGestureTarget { 151 class MockScrollTouchTarget : public MockScrollGestureTarget {
152 public: 152 public:
153 MockScrollTouchTarget() : started_(false) {} 153 MockScrollTouchTarget() : started_(false) {}
154 virtual ~MockScrollTouchTarget() {} 154 virtual ~MockScrollTouchTarget() {}
155 155
156 virtual void DispatchInputEventToPlatform( 156 virtual void DispatchInputEventToPlatform(
157 const WebInputEvent& event) OVERRIDE { 157 const WebInputEvent& event) override {
158 ASSERT_TRUE(WebInputEvent::isTouchEventType(event.type)); 158 ASSERT_TRUE(WebInputEvent::isTouchEventType(event.type));
159 const WebTouchEvent& touch_event = static_cast<const WebTouchEvent&>(event); 159 const WebTouchEvent& touch_event = static_cast<const WebTouchEvent&>(event);
160 ASSERT_EQ(touch_event.touchesLength, 1U); 160 ASSERT_EQ(touch_event.touchesLength, 1U);
161 161
162 if (!started_) { 162 if (!started_) {
163 ASSERT_EQ(touch_event.type, WebInputEvent::TouchStart); 163 ASSERT_EQ(touch_event.type, WebInputEvent::TouchStart);
164 start_.SetPoint(touch_event.touches[0].position.x, 164 start_.SetPoint(touch_event.touches[0].position.x,
165 touch_event.touches[0].position.y); 165 touch_event.touches[0].position.y);
166 last_touch_point_ = start_; 166 last_touch_point_ = start_;
167 started_ = true; 167 started_ = true;
(...skipping 28 matching lines...) Expand all
196 }; 196 };
197 197
198 MockSyntheticPinchTouchTarget() 198 MockSyntheticPinchTouchTarget()
199 : initial_pointer_distance_(0), 199 : initial_pointer_distance_(0),
200 last_pointer_distance_(0), 200 last_pointer_distance_(0),
201 zoom_direction_(ZOOM_DIRECTION_UNKNOWN), 201 zoom_direction_(ZOOM_DIRECTION_UNKNOWN),
202 started_(false) {} 202 started_(false) {}
203 virtual ~MockSyntheticPinchTouchTarget() {} 203 virtual ~MockSyntheticPinchTouchTarget() {}
204 204
205 virtual void DispatchInputEventToPlatform( 205 virtual void DispatchInputEventToPlatform(
206 const WebInputEvent& event) OVERRIDE { 206 const WebInputEvent& event) override {
207 ASSERT_TRUE(WebInputEvent::isTouchEventType(event.type)); 207 ASSERT_TRUE(WebInputEvent::isTouchEventType(event.type));
208 const WebTouchEvent& touch_event = static_cast<const WebTouchEvent&>(event); 208 const WebTouchEvent& touch_event = static_cast<const WebTouchEvent&>(event);
209 ASSERT_EQ(touch_event.touchesLength, 2U); 209 ASSERT_EQ(touch_event.touchesLength, 2U);
210 210
211 if (!started_) { 211 if (!started_) {
212 ASSERT_EQ(touch_event.type, WebInputEvent::TouchStart); 212 ASSERT_EQ(touch_event.type, WebInputEvent::TouchStart);
213 213
214 start_0_ = gfx::PointF(touch_event.touches[0].position); 214 start_0_ = gfx::PointF(touch_event.touches[0].position);
215 start_1_ = gfx::PointF(touch_event.touches[1].position); 215 start_1_ = gfx::PointF(touch_event.touches[1].position);
216 last_pointer_distance_ = (start_0_ - start_1_).Length(); 216 last_pointer_distance_ = (start_0_ - start_1_).Length();
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 base::TimeDelta stop_time_; 296 base::TimeDelta stop_time_;
297 GestureState state_; 297 GestureState state_;
298 }; 298 };
299 299
300 class MockSyntheticTapTouchTarget : public MockSyntheticTapGestureTarget { 300 class MockSyntheticTapTouchTarget : public MockSyntheticTapGestureTarget {
301 public: 301 public:
302 MockSyntheticTapTouchTarget() {} 302 MockSyntheticTapTouchTarget() {}
303 virtual ~MockSyntheticTapTouchTarget() {} 303 virtual ~MockSyntheticTapTouchTarget() {}
304 304
305 virtual void DispatchInputEventToPlatform( 305 virtual void DispatchInputEventToPlatform(
306 const WebInputEvent& event) OVERRIDE { 306 const WebInputEvent& event) override {
307 ASSERT_TRUE(WebInputEvent::isTouchEventType(event.type)); 307 ASSERT_TRUE(WebInputEvent::isTouchEventType(event.type));
308 const WebTouchEvent& touch_event = static_cast<const WebTouchEvent&>(event); 308 const WebTouchEvent& touch_event = static_cast<const WebTouchEvent&>(event);
309 ASSERT_EQ(touch_event.touchesLength, 1U); 309 ASSERT_EQ(touch_event.touchesLength, 1U);
310 310
311 switch (state_) { 311 switch (state_) {
312 case NOT_STARTED: 312 case NOT_STARTED:
313 EXPECT_EQ(touch_event.type, WebInputEvent::TouchStart); 313 EXPECT_EQ(touch_event.type, WebInputEvent::TouchStart);
314 position_ = gfx::PointF(touch_event.touches[0].position); 314 position_ = gfx::PointF(touch_event.touches[0].position);
315 start_time_ = base::TimeDelta::FromMilliseconds( 315 start_time_ = base::TimeDelta::FromMilliseconds(
316 static_cast<int64>(touch_event.timeStampSeconds * 1000)); 316 static_cast<int64>(touch_event.timeStampSeconds * 1000));
(...skipping 12 matching lines...) Expand all
329 } 329 }
330 } 330 }
331 }; 331 };
332 332
333 class MockSyntheticTapMouseTarget : public MockSyntheticTapGestureTarget { 333 class MockSyntheticTapMouseTarget : public MockSyntheticTapGestureTarget {
334 public: 334 public:
335 MockSyntheticTapMouseTarget() {} 335 MockSyntheticTapMouseTarget() {}
336 virtual ~MockSyntheticTapMouseTarget() {} 336 virtual ~MockSyntheticTapMouseTarget() {}
337 337
338 virtual void DispatchInputEventToPlatform( 338 virtual void DispatchInputEventToPlatform(
339 const WebInputEvent& event) OVERRIDE { 339 const WebInputEvent& event) override {
340 ASSERT_TRUE(WebInputEvent::isMouseEventType(event.type)); 340 ASSERT_TRUE(WebInputEvent::isMouseEventType(event.type));
341 const WebMouseEvent& mouse_event = static_cast<const WebMouseEvent&>(event); 341 const WebMouseEvent& mouse_event = static_cast<const WebMouseEvent&>(event);
342 342
343 switch (state_) { 343 switch (state_) {
344 case NOT_STARTED: 344 case NOT_STARTED:
345 EXPECT_EQ(mouse_event.type, WebInputEvent::MouseDown); 345 EXPECT_EQ(mouse_event.type, WebInputEvent::MouseDown);
346 EXPECT_EQ(mouse_event.button, WebMouseEvent::ButtonLeft); 346 EXPECT_EQ(mouse_event.button, WebMouseEvent::ButtonLeft);
347 EXPECT_EQ(mouse_event.clickCount, 1); 347 EXPECT_EQ(mouse_event.clickCount, 1);
348 position_ = gfx::PointF(mouse_event.x, mouse_event.y); 348 position_ = gfx::PointF(mouse_event.x, mouse_event.y);
349 start_time_ = base::TimeDelta::FromMilliseconds( 349 start_time_ = base::TimeDelta::FromMilliseconds(
(...skipping 22 matching lines...) Expand all
372 virtual ~SyntheticGestureControllerTest() {} 372 virtual ~SyntheticGestureControllerTest() {}
373 373
374 protected: 374 protected:
375 template<typename MockGestureTarget> 375 template<typename MockGestureTarget>
376 void CreateControllerAndTarget() { 376 void CreateControllerAndTarget() {
377 target_ = new MockGestureTarget(); 377 target_ = new MockGestureTarget();
378 controller_.reset(new SyntheticGestureController( 378 controller_.reset(new SyntheticGestureController(
379 scoped_ptr<SyntheticGestureTarget>(target_))); 379 scoped_ptr<SyntheticGestureTarget>(target_)));
380 } 380 }
381 381
382 virtual void SetUp() OVERRIDE { 382 virtual void SetUp() override {
383 start_time_ = base::TimeTicks::Now(); 383 start_time_ = base::TimeTicks::Now();
384 time_ = start_time_; 384 time_ = start_time_;
385 num_success_ = 0; 385 num_success_ = 0;
386 num_failure_ = 0; 386 num_failure_ = 0;
387 } 387 }
388 388
389 virtual void TearDown() OVERRIDE { 389 virtual void TearDown() override {
390 controller_.reset(); 390 controller_.reset();
391 target_ = NULL; 391 target_ = NULL;
392 time_ = base::TimeTicks(); 392 time_ = base::TimeTicks();
393 } 393 }
394 394
395 void QueueSyntheticGesture(scoped_ptr<SyntheticGesture> gesture) { 395 void QueueSyntheticGesture(scoped_ptr<SyntheticGesture> gesture) {
396 controller_->QueueSyntheticGesture(gesture.Pass(), 396 controller_->QueueSyntheticGesture(gesture.Pass(),
397 base::Bind(&SyntheticGestureControllerTest::OnSyntheticGestureCompleted, 397 base::Bind(&SyntheticGestureControllerTest::OnSyntheticGestureCompleted,
398 base::Unretained(this))); 398 base::Unretained(this)));
399 } 399 }
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after
995 EXPECT_TRUE(tap_target->GestureFinished()); 995 EXPECT_TRUE(tap_target->GestureFinished());
996 EXPECT_EQ(tap_target->position(), params.position); 996 EXPECT_EQ(tap_target->position(), params.position);
997 EXPECT_EQ(tap_target->GetDuration().InMilliseconds(), params.duration_ms); 997 EXPECT_EQ(tap_target->GetDuration().InMilliseconds(), params.duration_ms);
998 EXPECT_GE(GetTotalTime(), 998 EXPECT_GE(GetTotalTime(),
999 base::TimeDelta::FromMilliseconds(params.duration_ms)); 999 base::TimeDelta::FromMilliseconds(params.duration_ms));
1000 } 1000 }
1001 1001
1002 } // namespace 1002 } // namespace
1003 1003
1004 } // namespace content 1004 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698