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

Side by Side Diff: ui/events/blink/input_scroll_elasticity_controller_unittest.cc

Issue 2194833002: Overscroll and Elasticity for views::ScrollView Base URL: https://chromium.googlesource.com/chromium/src.git@20160728-MacViews-RouteThroughInputHandler
Patch Set: Restore functionality and fix bugs \o/ Created 4 years, 1 month 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 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 "ui/events/blink/input_scroll_elasticity_controller.h" 5 #include "ui/events/blink/input_scroll_elasticity_controller.h"
6 6
7 #include "cc/input/input_handler.h" 7 #include "cc/input/input_handler.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "third_party/WebKit/public/platform/WebInputEvent.h" 9 #include "third_party/WebKit/public/platform/WebInputEvent.h"
10 10
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 } 46 }
47 gfx::ScrollOffset ScrollOffset() const override { return scroll_offset_; } 47 gfx::ScrollOffset ScrollOffset() const override { return scroll_offset_; }
48 gfx::ScrollOffset MaxScrollOffset() const override { 48 gfx::ScrollOffset MaxScrollOffset() const override {
49 return max_scroll_offset_; 49 return max_scroll_offset_;
50 } 50 }
51 void ScrollBy(const gfx::Vector2dF& delta) override { 51 void ScrollBy(const gfx::Vector2dF& delta) override {
52 scroll_offset_ += gfx::ScrollOffset(delta); 52 scroll_offset_ += gfx::ScrollOffset(delta);
53 } 53 }
54 void RequestOneBeginFrame() override { request_begin_frame_count_ += 1; } 54 void RequestOneBeginFrame() override { request_begin_frame_count_ += 1; }
55 55
56 base::WeakPtr<ScrollElasticityHelper> GetWeakPtr() override {
57 return nullptr;
58 }
59
56 // Counters for number of times functions were called. 60 // Counters for number of times functions were called.
57 int request_begin_frame_count() const { return request_begin_frame_count_; } 61 int request_begin_frame_count() const { return request_begin_frame_count_; }
58 int set_stretch_amount_count() const { return set_stretch_amount_count_; } 62 int set_stretch_amount_count() const { return set_stretch_amount_count_; }
59 63
60 void SetScrollOffsetAndMaxScrollOffset( 64 void SetScrollOffsetAndMaxScrollOffset(
61 const gfx::ScrollOffset& scroll_offset, 65 const gfx::ScrollOffset& scroll_offset,
62 const gfx::ScrollOffset& max_scroll_offset) { 66 const gfx::ScrollOffset& max_scroll_offset) {
63 scroll_offset_ = scroll_offset; 67 scroll_offset_ = scroll_offset;
64 max_scroll_offset_ = max_scroll_offset; 68 max_scroll_offset_ = max_scroll_offset;
65 } 69 }
66 void SetUserScrollable(bool is_user_scrollable) { 70 void SetUserScrollable(bool is_user_scrollable) {
67 is_user_scrollable_ = is_user_scrollable; 71 is_user_scrollable_ = is_user_scrollable;
68 } 72 }
69 73
70 private: 74 private:
71 bool is_user_scrollable_; 75 bool is_user_scrollable_;
72 gfx::Vector2dF stretch_amount_; 76 gfx::Vector2dF stretch_amount_;
73 int set_stretch_amount_count_; 77 int set_stretch_amount_count_;
74 int request_begin_frame_count_; 78 int request_begin_frame_count_;
75 79
76 gfx::ScrollOffset scroll_offset_; 80 gfx::ScrollOffset scroll_offset_;
77 gfx::ScrollOffset max_scroll_offset_; 81 gfx::ScrollOffset max_scroll_offset_;
78 }; 82 };
79 83
80 class ScrollElasticityControllerTest : public testing::Test { 84 class ScrollElasticityControllerTest : public testing::Test {
81 public: 85 public:
82 ScrollElasticityControllerTest() 86 ScrollElasticityControllerTest()
83 : controller_(&helper_), 87 : input_event_count_(0),
84 input_event_count_(0),
85 current_time_(base::TimeTicks::FromInternalValue(100000000ull)) {} 88 current_time_(base::TimeTicks::FromInternalValue(100000000ull)) {}
86 ~ScrollElasticityControllerTest() override {} 89 ~ScrollElasticityControllerTest() override {}
87 90
88 91
89 void SendGestureScrollBegin(InertialPhaseState inertialPhase) { 92 void SendGestureScrollBegin(InertialPhaseState inertialPhase) {
90 blink::WebGestureEvent event; 93 blink::WebGestureEvent event;
91 event.sourceDevice = blink::WebGestureDeviceTouchpad; 94 event.sourceDevice = blink::WebGestureDeviceTouchpad;
92 event.type = blink::WebInputEvent::GestureScrollBegin; 95 event.type = blink::WebInputEvent::GestureScrollBegin;
93 event.data.scrollBegin.inertialPhase = 96 event.data.scrollBegin.inertialPhase =
94 static_cast<blink::WebGestureEvent::InertialPhaseState>(inertialPhase); 97 static_cast<blink::WebGestureEvent::InertialPhaseState>(inertialPhase);
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 TickCurrentTimeAndAnimate(); 418 TickCurrentTimeAndAnimate();
416 if (helper_.StretchAmount().IsZero()) 419 if (helper_.StretchAmount().IsZero())
417 break; 420 break;
418 ticks_to_zero += 1; 421 ticks_to_zero += 1;
419 } 422 }
420 EXPECT_GT(ticks_to_zero, 3); 423 EXPECT_GT(ticks_to_zero, 3);
421 } 424 }
422 425
423 } // namespace 426 } // namespace
424 } // namespace ui 427 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/blink/input_scroll_elasticity_controller.cc ('k') | ui/views/examples/scroll_view_example.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698