| OLD | NEW |
| 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 "cc/input/input_handler.h" | 5 #include "cc/input/input_handler.h" |
| 6 #include "content/renderer/input/input_scroll_elasticity_controller.h" | 6 #include "content/renderer/input/input_scroll_elasticity_controller.h" |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 #include "third_party/WebKit/public/web/WebInputEvent.h" | 8 #include "third_party/WebKit/public/web/WebInputEvent.h" |
| 9 | 9 |
| 10 namespace content { | 10 namespace content { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 | 22 |
| 23 class MockScrollElasticityHelper : public cc::ScrollElasticityHelper { | 23 class MockScrollElasticityHelper : public cc::ScrollElasticityHelper { |
| 24 public: | 24 public: |
| 25 MockScrollElasticityHelper() | 25 MockScrollElasticityHelper() |
| 26 : set_stretch_amount_count_(0), | 26 : set_stretch_amount_count_(0), |
| 27 request_animate_count_(0), | 27 request_animate_count_(0), |
| 28 pinned_neg_x_(false), | 28 pinned_neg_x_(false), |
| 29 pinned_pos_x_(false), | 29 pinned_pos_x_(false), |
| 30 pinned_neg_y_(false), | 30 pinned_neg_y_(false), |
| 31 pinned_pos_y_(false) {} | 31 pinned_pos_y_(false) {} |
| 32 virtual ~MockScrollElasticityHelper() {} | 32 ~MockScrollElasticityHelper() override {} |
| 33 | 33 |
| 34 // cc::ScrollElasticityHelper implementation: | 34 // cc::ScrollElasticityHelper implementation: |
| 35 gfx::Vector2dF StretchAmount() override { return stretch_amount_; } | 35 gfx::Vector2dF StretchAmount() override { return stretch_amount_; } |
| 36 void SetStretchAmount(const gfx::Vector2dF& stretch_amount) override { | 36 void SetStretchAmount(const gfx::Vector2dF& stretch_amount) override { |
| 37 set_stretch_amount_count_ += 1; | 37 set_stretch_amount_count_ += 1; |
| 38 stretch_amount_ = stretch_amount; | 38 stretch_amount_ = stretch_amount; |
| 39 } | 39 } |
| 40 bool PinnedInDirection(const gfx::Vector2dF& direction) override { | 40 bool PinnedInDirection(const gfx::Vector2dF& direction) override { |
| 41 if (pinned_neg_x_ && direction.x() < 0) | 41 if (pinned_neg_x_ && direction.x() < 0) |
| 42 return true; | 42 return true; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 71 bool pinned_neg_y_; | 71 bool pinned_neg_y_; |
| 72 bool pinned_pos_y_; | 72 bool pinned_pos_y_; |
| 73 }; | 73 }; |
| 74 | 74 |
| 75 class ScrollElasticityControllerTest : public testing::Test { | 75 class ScrollElasticityControllerTest : public testing::Test { |
| 76 public: | 76 public: |
| 77 ScrollElasticityControllerTest() | 77 ScrollElasticityControllerTest() |
| 78 : controller_(&helper_), | 78 : controller_(&helper_), |
| 79 input_event_count_(0), | 79 input_event_count_(0), |
| 80 current_time_(base::TimeTicks::FromInternalValue(100000000ull)) {} | 80 current_time_(base::TimeTicks::FromInternalValue(100000000ull)) {} |
| 81 virtual ~ScrollElasticityControllerTest() {} | 81 ~ScrollElasticityControllerTest() override {} |
| 82 | 82 |
| 83 void SendMouseWheelEvent( | 83 void SendMouseWheelEvent( |
| 84 Phase phase, | 84 Phase phase, |
| 85 Phase momentum_phase, | 85 Phase momentum_phase, |
| 86 const gfx::Vector2dF& event_delta = gfx::Vector2dF(), | 86 const gfx::Vector2dF& event_delta = gfx::Vector2dF(), |
| 87 const gfx::Vector2dF& overscroll_delta = gfx::Vector2dF()) { | 87 const gfx::Vector2dF& overscroll_delta = gfx::Vector2dF()) { |
| 88 blink::WebMouseWheelEvent event; | 88 blink::WebMouseWheelEvent event; |
| 89 event.phase = static_cast<blink::WebMouseWheelEvent::Phase>(phase); | 89 event.phase = static_cast<blink::WebMouseWheelEvent::Phase>(phase); |
| 90 event.momentumPhase = | 90 event.momentumPhase = |
| 91 static_cast<blink::WebMouseWheelEvent::Phase>(momentum_phase); | 91 static_cast<blink::WebMouseWheelEvent::Phase>(momentum_phase); |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 } | 290 } |
| 291 | 291 |
| 292 // After coming to rest, no subsequent animate calls change anything. | 292 // After coming to rest, no subsequent animate calls change anything. |
| 293 TickCurrentTimeAndAnimate(); | 293 TickCurrentTimeAndAnimate(); |
| 294 EXPECT_EQ(stretch_count, helper_.set_stretch_amount_count()); | 294 EXPECT_EQ(stretch_count, helper_.set_stretch_amount_count()); |
| 295 EXPECT_EQ(animate_count, helper_.request_animate_count()); | 295 EXPECT_EQ(animate_count, helper_.request_animate_count()); |
| 296 } | 296 } |
| 297 | 297 |
| 298 } // namespace | 298 } // namespace |
| 299 } // namespace content | 299 } // namespace content |
| OLD | NEW |