| OLD | NEW |
| 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/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
| 6 #include "base/time/time.h" | 6 #include "base/time/time.h" |
| 7 #include "content/browser/renderer_host/input/synthetic_gesture_controller_new.h
" | 7 #include "content/browser/renderer_host/input/synthetic_gesture.h" |
| 8 #include "content/browser/renderer_host/input/synthetic_gesture_new.h" | 8 #include "content/browser/renderer_host/input/synthetic_gesture_controller.h" |
| 9 #include "content/browser/renderer_host/input/synthetic_gesture_target.h" | 9 #include "content/browser/renderer_host/input/synthetic_gesture_target.h" |
| 10 #include "content/browser/renderer_host/input/synthetic_pinch_gesture_new.h" | 10 #include "content/browser/renderer_host/input/synthetic_pinch_gesture.h" |
| 11 #include "content/browser/renderer_host/input/synthetic_smooth_scroll_gesture_ne
w.h" | 11 #include "content/browser/renderer_host/input/synthetic_smooth_scroll_gesture.h" |
| 12 #include "content/browser/renderer_host/render_widget_host_delegate.h" | 12 #include "content/browser/renderer_host/render_widget_host_delegate.h" |
| 13 #include "content/browser/renderer_host/test_render_view_host.h" | 13 #include "content/browser/renderer_host/test_render_view_host.h" |
| 14 #include "content/common/input/input_event.h" | 14 #include "content/common/input/input_event.h" |
| 15 #include "content/common/input/synthetic_smooth_scroll_gesture_params.h" | 15 #include "content/common/input/synthetic_smooth_scroll_gesture_params.h" |
| 16 #include "content/public/test/mock_render_process_host.h" | 16 #include "content/public/test/mock_render_process_host.h" |
| 17 #include "content/public/test/test_browser_context.h" | 17 #include "content/public/test/test_browser_context.h" |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 19 #include "third_party/WebKit/public/web/WebInputEvent.h" | 19 #include "third_party/WebKit/public/web/WebInputEvent.h" |
| 20 #include "ui/gfx/point_f.h" | 20 #include "ui/gfx/point_f.h" |
| 21 | 21 |
| 22 namespace content { | 22 namespace content { |
| 23 | 23 |
| 24 namespace { | 24 namespace { |
| 25 | 25 |
| 26 const int kFlushInputRateInMs = 16; | 26 const int kFlushInputRateInMs = 16; |
| 27 | 27 |
| 28 class MockSyntheticGesture : public SyntheticGestureNew { | 28 class MockSyntheticGesture : public SyntheticGesture { |
| 29 public: | 29 public: |
| 30 MockSyntheticGesture(bool* finished, int num_steps) | 30 MockSyntheticGesture(bool* finished, int num_steps) |
| 31 : finished_(finished), | 31 : finished_(finished), |
| 32 num_steps_(num_steps), | 32 num_steps_(num_steps), |
| 33 step_count_(0) { | 33 step_count_(0) { |
| 34 *finished_ = false; | 34 *finished_ = false; |
| 35 } | 35 } |
| 36 virtual ~MockSyntheticGesture() {} | 36 virtual ~MockSyntheticGesture() {} |
| 37 | 37 |
| 38 virtual Result ForwardInputEvents(const base::TimeDelta& interval, | 38 virtual Result ForwardInputEvents(const base::TimeDelta& interval, |
| 39 SyntheticGestureTarget* target) OVERRIDE { | 39 SyntheticGestureTarget* target) OVERRIDE { |
| 40 step_count_++; | 40 step_count_++; |
| 41 if (step_count_ == num_steps_) { | 41 if (step_count_ == num_steps_) { |
| 42 *finished_ = true; | 42 *finished_ = true; |
| 43 return SyntheticGestureNew::GESTURE_FINISHED; | 43 return SyntheticGesture::GESTURE_FINISHED; |
| 44 } else if (step_count_ > num_steps_) { | 44 } else if (step_count_ > num_steps_) { |
| 45 *finished_ = true; | 45 *finished_ = true; |
| 46 // Return arbitrary failure. | 46 // Return arbitrary failure. |
| 47 return SyntheticGestureNew::GESTURE_SOURCE_TYPE_NOT_IMPLEMENTED; | 47 return SyntheticGesture::GESTURE_SOURCE_TYPE_NOT_IMPLEMENTED; |
| 48 } else { | |
| 49 return SyntheticGestureNew::GESTURE_RUNNING; | |
| 50 } | 48 } |
| 49 |
| 50 return SyntheticGesture::GESTURE_RUNNING; |
| 51 } | 51 } |
| 52 | 52 |
| 53 protected: | 53 protected: |
| 54 bool* finished_; | 54 bool* finished_; |
| 55 int num_steps_; | 55 int num_steps_; |
| 56 int step_count_; | 56 int step_count_; |
| 57 }; | 57 }; |
| 58 | 58 |
| 59 class MockSyntheticGestureTarget : public SyntheticGestureTarget { | 59 class MockSyntheticGestureTarget : public SyntheticGestureTarget { |
| 60 public: | 60 public: |
| 61 MockSyntheticGestureTarget() | 61 MockSyntheticGestureTarget() |
| 62 : num_success_(0), | 62 : num_success_(0), |
| 63 num_failure_(0), | 63 num_failure_(0), |
| 64 flush_requested_(false) {} | 64 flush_requested_(false) {} |
| 65 virtual ~MockSyntheticGestureTarget() {} | 65 virtual ~MockSyntheticGestureTarget() {} |
| 66 | 66 |
| 67 // SyntheticGestureTarget: | 67 // SyntheticGestureTarget: |
| 68 virtual void DispatchInputEventToPlatform(const InputEvent& event) OVERRIDE {} | 68 virtual void DispatchInputEventToPlatform(const InputEvent& event) OVERRIDE {} |
| 69 | 69 |
| 70 virtual void OnSyntheticGestureCompleted( | 70 virtual void OnSyntheticGestureCompleted( |
| 71 SyntheticGestureNew::Result result) OVERRIDE { | 71 SyntheticGesture::Result result) OVERRIDE { |
| 72 DCHECK_NE(result, SyntheticGestureNew::GESTURE_RUNNING); | 72 DCHECK_NE(result, SyntheticGesture::GESTURE_RUNNING); |
| 73 if (result == SyntheticGestureNew::GESTURE_FINISHED) | 73 if (result == SyntheticGesture::GESTURE_FINISHED) |
| 74 num_success_++; | 74 num_success_++; |
| 75 else | 75 else |
| 76 num_failure_++; | 76 num_failure_++; |
| 77 } | 77 } |
| 78 | 78 |
| 79 virtual void SetNeedsFlush() OVERRIDE { | 79 virtual void SetNeedsFlush() OVERRIDE { |
| 80 flush_requested_ = true; | 80 flush_requested_ = true; |
| 81 } | 81 } |
| 82 | 82 |
| 83 virtual SyntheticGestureParams::GestureSourceType | 83 virtual SyntheticGestureParams::GestureSourceType |
| (...skipping 19 matching lines...) Expand all Loading... |
| 103 bool flush_requested_; | 103 bool flush_requested_; |
| 104 }; | 104 }; |
| 105 | 105 |
| 106 class MockSyntheticSmoothScrollMouseTarget : public MockSyntheticGestureTarget { | 106 class MockSyntheticSmoothScrollMouseTarget : public MockSyntheticGestureTarget { |
| 107 public: | 107 public: |
| 108 MockSyntheticSmoothScrollMouseTarget() : scroll_distance_(0) {} | 108 MockSyntheticSmoothScrollMouseTarget() : scroll_distance_(0) {} |
| 109 virtual ~MockSyntheticSmoothScrollMouseTarget() {} | 109 virtual ~MockSyntheticSmoothScrollMouseTarget() {} |
| 110 | 110 |
| 111 virtual void DispatchInputEventToPlatform(const InputEvent& event) OVERRIDE { | 111 virtual void DispatchInputEventToPlatform(const InputEvent& event) OVERRIDE { |
| 112 const blink::WebInputEvent* web_event = event.web_event.get(); | 112 const blink::WebInputEvent* web_event = event.web_event.get(); |
| 113 DCHECK_EQ(web_event->type, blink::WebInputEvent::MouseWheel); | 113 ASSERT_EQ(web_event->type, blink::WebInputEvent::MouseWheel); |
| 114 const blink::WebMouseWheelEvent* mouse_wheel_event = | 114 const blink::WebMouseWheelEvent* mouse_wheel_event = |
| 115 static_cast<const blink::WebMouseWheelEvent*>(web_event); | 115 static_cast<const blink::WebMouseWheelEvent*>(web_event); |
| 116 DCHECK_EQ(mouse_wheel_event->deltaX, 0); | 116 ASSERT_EQ(mouse_wheel_event->deltaX, 0); |
| 117 scroll_distance_ -= mouse_wheel_event->deltaY; | 117 scroll_distance_ -= mouse_wheel_event->deltaY; |
| 118 } | 118 } |
| 119 | 119 |
| 120 float scroll_distance() const { return scroll_distance_; } | 120 float scroll_distance() const { return scroll_distance_; } |
| 121 | 121 |
| 122 private: | 122 private: |
| 123 float scroll_distance_; | 123 float scroll_distance_; |
| 124 }; | 124 }; |
| 125 | 125 |
| 126 class MockSyntheticSmoothScrollTouchTarget : public MockSyntheticGestureTarget { | 126 class MockSyntheticSmoothScrollTouchTarget : public MockSyntheticGestureTarget { |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 float total_num_pixels_covered() const { return total_num_pixels_covered_; } | 216 float total_num_pixels_covered() const { return total_num_pixels_covered_; } |
| 217 ZoomDirection zoom_direction() const { return zoom_direction_; } | 217 ZoomDirection zoom_direction() const { return zoom_direction_; } |
| 218 | 218 |
| 219 private: | 219 private: |
| 220 ZoomDirection ComputeZoomDirection(float last_pointer_distance, | 220 ZoomDirection ComputeZoomDirection(float last_pointer_distance, |
| 221 float current_pointer_distance) { | 221 float current_pointer_distance) { |
| 222 DCHECK_NE(last_pointer_distance, current_pointer_distance); | 222 DCHECK_NE(last_pointer_distance, current_pointer_distance); |
| 223 return last_pointer_distance < current_pointer_distance ? ZOOM_IN | 223 return last_pointer_distance < current_pointer_distance ? ZOOM_IN |
| 224 : ZOOM_OUT; | 224 : ZOOM_OUT; |
| 225 } | 225 } |
| 226 |
| 226 float total_num_pixels_covered_; | 227 float total_num_pixels_covered_; |
| 227 float last_pointer_distance_; | 228 float last_pointer_distance_; |
| 228 ZoomDirection zoom_direction_; | 229 ZoomDirection zoom_direction_; |
| 229 gfx::PointF start_0_; | 230 gfx::PointF start_0_; |
| 230 gfx::PointF start_1_; | 231 gfx::PointF start_1_; |
| 231 bool started_; | 232 bool started_; |
| 232 }; | 233 }; |
| 233 | 234 |
| 234 class SyntheticGestureControllerNewTest : public testing::Test { | 235 class SyntheticGestureControllerTest : public testing::Test { |
| 235 public: | 236 public: |
| 236 SyntheticGestureControllerNewTest() {} | 237 SyntheticGestureControllerTest() {} |
| 237 virtual ~SyntheticGestureControllerNewTest() {} | 238 virtual ~SyntheticGestureControllerTest() {} |
| 238 | 239 |
| 239 protected: | 240 protected: |
| 240 template<typename MockGestureTarget> | 241 template<typename MockGestureTarget> |
| 241 void CreateControllerAndTarget() { | 242 void CreateControllerAndTarget() { |
| 242 target_ = new MockGestureTarget(); | 243 target_ = new MockGestureTarget(); |
| 243 | 244 |
| 244 controller_.reset(new SyntheticGestureControllerNew( | 245 controller_.reset(new SyntheticGestureController( |
| 245 scoped_ptr<SyntheticGestureTarget>(target_))); | 246 scoped_ptr<SyntheticGestureTarget>(target_))); |
| 246 } | 247 } |
| 247 | 248 |
| 248 virtual void SetUp() OVERRIDE { | 249 virtual void SetUp() OVERRIDE { |
| 249 time_ = base::TimeTicks::Now(); | 250 time_ = base::TimeTicks::Now(); |
| 250 } | 251 } |
| 251 | 252 |
| 252 virtual void TearDown() OVERRIDE { | 253 virtual void TearDown() OVERRIDE { |
| 253 controller_.reset(); | 254 controller_.reset(); |
| 254 target_ = NULL; | 255 target_ = NULL; |
| 255 time_ = base::TimeTicks(); | 256 time_ = base::TimeTicks(); |
| 256 } | 257 } |
| 257 | 258 |
| 258 void FlushInputUntilComplete() { | 259 void FlushInputUntilComplete() { |
| 259 while (target_->flush_requested()) { | 260 while (target_->flush_requested()) { |
| 260 target_->ClearFlushRequest(); | 261 target_->ClearFlushRequest(); |
| 261 time_ += base::TimeDelta::FromMilliseconds(kFlushInputRateInMs); | 262 time_ += base::TimeDelta::FromMilliseconds(kFlushInputRateInMs); |
| 262 controller_->Flush(time_); | 263 controller_->Flush(time_); |
| 263 } | 264 } |
| 264 } | 265 } |
| 265 | 266 |
| 266 MockSyntheticGestureTarget* target_; | 267 MockSyntheticGestureTarget* target_; |
| 267 scoped_ptr<SyntheticGestureControllerNew> controller_; | 268 scoped_ptr<SyntheticGestureController> controller_; |
| 268 base::TimeTicks time_; | 269 base::TimeTicks time_; |
| 269 }; | 270 }; |
| 270 | 271 |
| 271 TEST_F(SyntheticGestureControllerNewTest, SingleGesture) { | 272 TEST_F(SyntheticGestureControllerTest, SingleGesture) { |
| 272 CreateControllerAndTarget<MockSyntheticGestureTarget>(); | 273 CreateControllerAndTarget<MockSyntheticGestureTarget>(); |
| 273 | 274 |
| 274 bool finished; | 275 bool finished; |
| 275 scoped_ptr<MockSyntheticGesture> gesture( | 276 scoped_ptr<MockSyntheticGesture> gesture( |
| 276 new MockSyntheticGesture(&finished, 3)); | 277 new MockSyntheticGesture(&finished, 3)); |
| 277 controller_->QueueSyntheticGesture(gesture.PassAs<SyntheticGestureNew>()); | 278 controller_->QueueSyntheticGesture(gesture.PassAs<SyntheticGesture>()); |
| 278 FlushInputUntilComplete(); | 279 FlushInputUntilComplete(); |
| 279 | 280 |
| 280 EXPECT_TRUE(finished); | 281 EXPECT_TRUE(finished); |
| 281 EXPECT_EQ(1, target_->num_success()); | 282 EXPECT_EQ(1, target_->num_success()); |
| 282 EXPECT_EQ(0, target_->num_failure()); | 283 EXPECT_EQ(0, target_->num_failure()); |
| 283 } | 284 } |
| 284 | 285 |
| 285 TEST_F(SyntheticGestureControllerNewTest, GestureFailed) { | 286 TEST_F(SyntheticGestureControllerTest, GestureFailed) { |
| 286 CreateControllerAndTarget<MockSyntheticGestureTarget>(); | 287 CreateControllerAndTarget<MockSyntheticGestureTarget>(); |
| 287 | 288 |
| 288 bool finished; | 289 bool finished; |
| 289 scoped_ptr<MockSyntheticGesture> gesture( | 290 scoped_ptr<MockSyntheticGesture> gesture( |
| 290 new MockSyntheticGesture(&finished, 0)); | 291 new MockSyntheticGesture(&finished, 0)); |
| 291 controller_->QueueSyntheticGesture(gesture.PassAs<SyntheticGestureNew>()); | 292 controller_->QueueSyntheticGesture(gesture.PassAs<SyntheticGesture>()); |
| 292 FlushInputUntilComplete(); | 293 FlushInputUntilComplete(); |
| 293 | 294 |
| 294 EXPECT_TRUE(finished); | 295 EXPECT_TRUE(finished); |
| 295 EXPECT_EQ(1, target_->num_failure()); | 296 EXPECT_EQ(1, target_->num_failure()); |
| 296 EXPECT_EQ(0, target_->num_success()); | 297 EXPECT_EQ(0, target_->num_success()); |
| 297 } | 298 } |
| 298 | 299 |
| 299 TEST_F(SyntheticGestureControllerNewTest, SuccessiveGestures) { | 300 TEST_F(SyntheticGestureControllerTest, SuccessiveGestures) { |
| 300 CreateControllerAndTarget<MockSyntheticGestureTarget>(); | 301 CreateControllerAndTarget<MockSyntheticGestureTarget>(); |
| 301 | 302 |
| 302 bool finished_1, finished_2; | 303 bool finished_1, finished_2; |
| 303 scoped_ptr<MockSyntheticGesture> gesture_1( | 304 scoped_ptr<MockSyntheticGesture> gesture_1( |
| 304 new MockSyntheticGesture(&finished_1, 2)); | 305 new MockSyntheticGesture(&finished_1, 2)); |
| 305 scoped_ptr<MockSyntheticGesture> gesture_2( | 306 scoped_ptr<MockSyntheticGesture> gesture_2( |
| 306 new MockSyntheticGesture(&finished_2, 4)); | 307 new MockSyntheticGesture(&finished_2, 4)); |
| 307 | 308 |
| 308 // Queue first gesture and wait for it to finish | 309 // Queue first gesture and wait for it to finish |
| 309 controller_->QueueSyntheticGesture(gesture_1.PassAs<SyntheticGestureNew>()); | 310 controller_->QueueSyntheticGesture(gesture_1.PassAs<SyntheticGesture>()); |
| 310 FlushInputUntilComplete(); | 311 FlushInputUntilComplete(); |
| 311 | 312 |
| 312 EXPECT_TRUE(finished_1); | 313 EXPECT_TRUE(finished_1); |
| 313 EXPECT_EQ(1, target_->num_success()); | 314 EXPECT_EQ(1, target_->num_success()); |
| 314 EXPECT_EQ(0, target_->num_failure()); | 315 EXPECT_EQ(0, target_->num_failure()); |
| 315 | 316 |
| 316 // Queue second gesture. | 317 // Queue second gesture. |
| 317 controller_->QueueSyntheticGesture(gesture_2.PassAs<SyntheticGestureNew>()); | 318 controller_->QueueSyntheticGesture(gesture_2.PassAs<SyntheticGesture>()); |
| 318 FlushInputUntilComplete(); | 319 FlushInputUntilComplete(); |
| 319 | 320 |
| 320 EXPECT_TRUE(finished_2); | 321 EXPECT_TRUE(finished_2); |
| 321 EXPECT_EQ(2, target_->num_success()); | 322 EXPECT_EQ(2, target_->num_success()); |
| 322 EXPECT_EQ(0, target_->num_failure()); | 323 EXPECT_EQ(0, target_->num_failure()); |
| 323 } | 324 } |
| 324 | 325 |
| 325 TEST_F(SyntheticGestureControllerNewTest, TwoGesturesInFlight) { | 326 TEST_F(SyntheticGestureControllerTest, TwoGesturesInFlight) { |
| 326 CreateControllerAndTarget<MockSyntheticGestureTarget>(); | 327 CreateControllerAndTarget<MockSyntheticGestureTarget>(); |
| 327 | 328 |
| 328 bool finished_1, finished_2; | 329 bool finished_1, finished_2; |
| 329 scoped_ptr<MockSyntheticGesture> gesture_1( | 330 scoped_ptr<MockSyntheticGesture> gesture_1( |
| 330 new MockSyntheticGesture(&finished_1, 2)); | 331 new MockSyntheticGesture(&finished_1, 2)); |
| 331 scoped_ptr<MockSyntheticGesture> gesture_2( | 332 scoped_ptr<MockSyntheticGesture> gesture_2( |
| 332 new MockSyntheticGesture(&finished_2, 4)); | 333 new MockSyntheticGesture(&finished_2, 4)); |
| 333 | 334 |
| 334 controller_->QueueSyntheticGesture(gesture_1.PassAs<SyntheticGestureNew>()); | 335 controller_->QueueSyntheticGesture(gesture_1.PassAs<SyntheticGesture>()); |
| 335 controller_->QueueSyntheticGesture(gesture_2.PassAs<SyntheticGestureNew>()); | 336 controller_->QueueSyntheticGesture(gesture_2.PassAs<SyntheticGesture>()); |
| 336 FlushInputUntilComplete(); | 337 FlushInputUntilComplete(); |
| 337 | 338 |
| 338 EXPECT_TRUE(finished_1); | 339 EXPECT_TRUE(finished_1); |
| 339 EXPECT_TRUE(finished_2); | 340 EXPECT_TRUE(finished_2); |
| 340 | 341 |
| 341 EXPECT_EQ(2, target_->num_success()); | 342 EXPECT_EQ(2, target_->num_success()); |
| 342 EXPECT_EQ(0, target_->num_failure()); | 343 EXPECT_EQ(0, target_->num_failure()); |
| 343 } | 344 } |
| 344 | 345 |
| 345 TEST_F(SyntheticGestureControllerNewTest, SmoothScrollGestureTouch) { | 346 TEST_F(SyntheticGestureControllerTest, SmoothScrollGestureTouch) { |
| 346 CreateControllerAndTarget<MockSyntheticSmoothScrollTouchTarget>(); | 347 CreateControllerAndTarget<MockSyntheticSmoothScrollTouchTarget>(); |
| 347 | 348 |
| 348 SyntheticSmoothScrollGestureParams params; | 349 SyntheticSmoothScrollGestureParams params; |
| 349 params.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT; | 350 params.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT; |
| 350 params.distance = 100; | 351 params.distance = 100; |
| 351 | 352 |
| 352 scoped_ptr<SyntheticSmoothScrollGestureNew> gesture( | 353 scoped_ptr<SyntheticSmoothScrollGesture> gesture( |
| 353 new SyntheticSmoothScrollGestureNew(params)); | 354 new SyntheticSmoothScrollGesture(params)); |
| 354 controller_->QueueSyntheticGesture(gesture.PassAs<SyntheticGestureNew>()); | 355 controller_->QueueSyntheticGesture(gesture.PassAs<SyntheticGesture>()); |
| 355 FlushInputUntilComplete(); | 356 FlushInputUntilComplete(); |
| 356 | 357 |
| 357 EXPECT_EQ(1, target_->num_success()); | 358 EXPECT_EQ(1, target_->num_success()); |
| 358 EXPECT_EQ(0, target_->num_failure()); | 359 EXPECT_EQ(0, target_->num_failure()); |
| 359 EXPECT_LE(params.distance, static_cast<MockSyntheticSmoothScrollTouchTarget*>( | 360 EXPECT_LE(params.distance, static_cast<MockSyntheticSmoothScrollTouchTarget*>( |
| 360 target_)->scroll_distance()); | 361 target_)->scroll_distance()); |
| 361 } | 362 } |
| 362 | 363 |
| 363 TEST_F(SyntheticGestureControllerNewTest, SmoothScrollGestureMouse) { | 364 TEST_F(SyntheticGestureControllerTest, SmoothScrollGestureMouse) { |
| 364 CreateControllerAndTarget<MockSyntheticSmoothScrollMouseTarget>(); | 365 CreateControllerAndTarget<MockSyntheticSmoothScrollMouseTarget>(); |
| 365 | 366 |
| 366 SyntheticSmoothScrollGestureParams params; | 367 SyntheticSmoothScrollGestureParams params; |
| 367 params.gesture_source_type = SyntheticGestureParams::MOUSE_INPUT; | 368 params.gesture_source_type = SyntheticGestureParams::MOUSE_INPUT; |
| 368 params.distance = -100; | 369 params.distance = -100; |
| 369 | 370 |
| 370 scoped_ptr<SyntheticSmoothScrollGestureNew> gesture( | 371 scoped_ptr<SyntheticSmoothScrollGesture> gesture( |
| 371 new SyntheticSmoothScrollGestureNew(params)); | 372 new SyntheticSmoothScrollGesture(params)); |
| 372 controller_->QueueSyntheticGesture(gesture.PassAs<SyntheticGestureNew>()); | 373 controller_->QueueSyntheticGesture(gesture.PassAs<SyntheticGesture>()); |
| 373 FlushInputUntilComplete(); | 374 FlushInputUntilComplete(); |
| 374 | 375 |
| 375 EXPECT_EQ(1, target_->num_success()); | 376 EXPECT_EQ(1, target_->num_success()); |
| 376 EXPECT_EQ(0, target_->num_failure()); | 377 EXPECT_EQ(0, target_->num_failure()); |
| 377 EXPECT_GE(params.distance, static_cast<MockSyntheticSmoothScrollTouchTarget*>( | 378 EXPECT_GE(params.distance, static_cast<MockSyntheticSmoothScrollTouchTarget*>( |
| 378 target_)->scroll_distance()); | 379 target_)->scroll_distance()); |
| 379 } | 380 } |
| 380 | 381 |
| 381 TEST_F(SyntheticGestureControllerNewTest, PinchGestureTouchZoomIn) { | 382 TEST_F(SyntheticGestureControllerTest, PinchGestureTouchZoomIn) { |
| 382 CreateControllerAndTarget<MockSyntheticPinchTouchTarget>(); | 383 CreateControllerAndTarget<MockSyntheticPinchTouchTarget>(); |
| 383 | 384 |
| 384 SyntheticPinchGestureParams params; | 385 SyntheticPinchGestureParams params; |
| 385 params.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT; | 386 params.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT; |
| 386 params.zoom_in = true; | 387 params.zoom_in = true; |
| 387 params.total_num_pixels_covered = 100; | 388 params.total_num_pixels_covered = 100; |
| 388 | 389 |
| 389 scoped_ptr<SyntheticPinchGestureNew> gesture( | 390 scoped_ptr<SyntheticPinchGesture> gesture( |
| 390 new SyntheticPinchGestureNew(params)); | 391 new SyntheticPinchGesture(params)); |
| 391 controller_->QueueSyntheticGesture(gesture.PassAs<SyntheticGestureNew>()); | 392 controller_->QueueSyntheticGesture(gesture.PassAs<SyntheticGesture>()); |
| 392 FlushInputUntilComplete(); | 393 FlushInputUntilComplete(); |
| 393 | 394 |
| 394 EXPECT_EQ(1, target_->num_success()); | 395 EXPECT_EQ(1, target_->num_success()); |
| 395 EXPECT_EQ(0, target_->num_failure()); | 396 EXPECT_EQ(0, target_->num_failure()); |
| 396 EXPECT_EQ( | 397 EXPECT_EQ( |
| 397 static_cast<MockSyntheticPinchTouchTarget*>(target_)->zoom_direction(), | 398 static_cast<MockSyntheticPinchTouchTarget*>(target_)->zoom_direction(), |
| 398 MockSyntheticPinchTouchTarget::ZOOM_IN); | 399 MockSyntheticPinchTouchTarget::ZOOM_IN); |
| 399 EXPECT_LE( | 400 EXPECT_LE( |
| 400 params.total_num_pixels_covered, | 401 params.total_num_pixels_covered, |
| 401 static_cast<MockSyntheticPinchTouchTarget*>(target_) | 402 static_cast<MockSyntheticPinchTouchTarget*>(target_) |
| 402 ->total_num_pixels_covered()); | 403 ->total_num_pixels_covered()); |
| 403 } | 404 } |
| 404 | 405 |
| 405 TEST_F(SyntheticGestureControllerNewTest, PinchGestureTouchZoomOut) { | 406 TEST_F(SyntheticGestureControllerTest, PinchGestureTouchZoomOut) { |
| 406 CreateControllerAndTarget<MockSyntheticPinchTouchTarget>(); | 407 CreateControllerAndTarget<MockSyntheticPinchTouchTarget>(); |
| 407 | 408 |
| 408 SyntheticPinchGestureParams params; | 409 SyntheticPinchGestureParams params; |
| 409 params.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT; | 410 params.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT; |
| 410 params.zoom_in = false; | 411 params.zoom_in = false; |
| 411 params.total_num_pixels_covered = 100; | 412 params.total_num_pixels_covered = 100; |
| 412 | 413 |
| 413 scoped_ptr<SyntheticPinchGestureNew> gesture( | 414 scoped_ptr<SyntheticPinchGesture> gesture( |
| 414 new SyntheticPinchGestureNew(params)); | 415 new SyntheticPinchGesture(params)); |
| 415 controller_->QueueSyntheticGesture(gesture.PassAs<SyntheticGestureNew>()); | 416 controller_->QueueSyntheticGesture(gesture.PassAs<SyntheticGesture>()); |
| 416 FlushInputUntilComplete(); | 417 FlushInputUntilComplete(); |
| 417 | 418 |
| 418 EXPECT_EQ(1, target_->num_success()); | 419 EXPECT_EQ(1, target_->num_success()); |
| 419 EXPECT_EQ(0, target_->num_failure()); | 420 EXPECT_EQ(0, target_->num_failure()); |
| 420 EXPECT_EQ( | 421 EXPECT_EQ( |
| 421 static_cast<MockSyntheticPinchTouchTarget*>(target_)->zoom_direction(), | 422 static_cast<MockSyntheticPinchTouchTarget*>(target_)->zoom_direction(), |
| 422 MockSyntheticPinchTouchTarget::ZOOM_OUT); | 423 MockSyntheticPinchTouchTarget::ZOOM_OUT); |
| 423 EXPECT_LE( | 424 EXPECT_LE( |
| 424 params.total_num_pixels_covered, | 425 params.total_num_pixels_covered, |
| 425 static_cast<MockSyntheticPinchTouchTarget*>(target_) | 426 static_cast<MockSyntheticPinchTouchTarget*>(target_) |
| 426 ->total_num_pixels_covered()); | 427 ->total_num_pixels_covered()); |
| 427 } | 428 } |
| 428 | 429 |
| 429 } // namespace | 430 } // namespace |
| 430 | 431 |
| 431 } // namespace content | 432 } // namespace content |
| OLD | NEW |