Lines Matching refs:Scroller
7 #include "ui/gfx/android/scroller.h"
21 Scroller::Config DefaultConfig() {
22 return Scroller::Config();
30 Scroller scroller(DefaultConfig());
34 scroller.StartScroll(kDefaultStartX,
40 EXPECT_EQ(kDefaultStartX, scroller.GetStartX());
41 EXPECT_EQ(kDefaultStartY, scroller.GetStartY());
42 EXPECT_EQ(kDefaultStartX, scroller.GetCurrX());
43 EXPECT_EQ(kDefaultStartY, scroller.GetCurrY());
44 EXPECT_EQ(kDefaultStartX + kDefaultDeltaX, scroller.GetFinalX());
45 EXPECT_EQ(kDefaultStartY + kDefaultDeltaY, scroller.GetFinalY());
46 EXPECT_FALSE(scroller.IsFinished());
47 EXPECT_EQ(base::TimeDelta(), scroller.GetTimePassed());
50 const base::TimeDelta scroll_duration = scroller.GetDuration();
51 scroller.ComputeScrollOffset(start_time + scroll_duration / 2);
55 EXPECT_GT(kDefaultStartX, scroller.GetCurrX());
56 EXPECT_LT(kDefaultStartY, scroller.GetCurrY());
57 EXPECT_LT(scroller.GetFinalX(), scroller.GetCurrX());
58 EXPECT_GT(scroller.GetFinalY(), scroller.GetCurrY());
59 EXPECT_FALSE(scroller.IsFinished());
62 EXPECT_GT(0.f, scroller.GetCurrVelocityX() * kDefaultDeltaX);
63 EXPECT_GT(0.f, scroller.GetCurrVelocityY() * kDefaultDeltaY);
64 EXPECT_TRUE(scroller.IsScrollingInDirection(kDefaultDeltaX, kDefaultDeltaY));
68 float curr_x = scroller.GetCurrX();
69 float curr_y = scroller.GetCurrY();
70 float curr_velocity_x = scroller.GetCurrVelocityX();
71 float curr_velocity_y = scroller.GetCurrVelocityY();
72 scroller.ComputeScrollOffset(start_time + scroll_duration / 2);
73 EXPECT_EQ(curr_x, scroller.GetCurrX());
74 EXPECT_EQ(curr_y, scroller.GetCurrY());
75 EXPECT_EQ(curr_velocity_x, scroller.GetCurrVelocityX());
76 EXPECT_EQ(curr_velocity_y, scroller.GetCurrVelocityY());
79 scroller.ComputeScrollOffset(start_time + scroll_duration);
80 EXPECT_EQ(scroller.GetFinalX(), scroller.GetCurrX());
81 EXPECT_EQ(scroller.GetFinalY(), scroller.GetCurrY());
82 EXPECT_TRUE(scroller.IsFinished());
83 EXPECT_EQ(scroll_duration, scroller.GetTimePassed());
84 EXPECT_NEAR(0.f, scroller.GetCurrVelocityX(), kEpsilon);
85 EXPECT_NEAR(0.f, scroller.GetCurrVelocityY(), kEpsilon);
88 scroller.ComputeScrollOffset(start_time + scroll_duration * 2);
89 EXPECT_EQ(scroller.GetFinalX(), scroller.GetCurrX());
90 EXPECT_EQ(scroller.GetFinalY(), scroller.GetCurrY());
91 EXPECT_TRUE(scroller.IsFinished());
92 EXPECT_EQ(scroll_duration, scroller.GetTimePassed());
96 Scroller scroller(DefaultConfig());
100 scroller.Fling(kDefaultStartX,
110 EXPECT_EQ(kDefaultStartX, scroller.GetStartX());
111 EXPECT_EQ(kDefaultStartY, scroller.GetStartY());
112 EXPECT_EQ(kDefaultStartX, scroller.GetCurrX());
113 EXPECT_EQ(kDefaultStartY, scroller.GetCurrY());
114 EXPECT_GT(kDefaultStartX, scroller.GetFinalX());
115 EXPECT_LT(kDefaultStartY, scroller.GetFinalY());
116 EXPECT_FALSE(scroller.IsFinished());
117 EXPECT_EQ(base::TimeDelta(), scroller.GetTimePassed());
120 const base::TimeDelta scroll_duration = scroller.GetDuration();
121 scroller.ComputeScrollOffset(start_time + scroll_duration / 2);
125 EXPECT_GT(kDefaultStartX, scroller.GetCurrX());
126 EXPECT_LT(kDefaultStartY, scroller.GetCurrY());
127 EXPECT_LT(scroller.GetFinalX(), scroller.GetCurrX());
128 EXPECT_GT(scroller.GetFinalY(), scroller.GetCurrY());
129 EXPECT_FALSE(scroller.IsFinished());
133 EXPECT_LT(0.f, scroller.GetCurrVelocityX() * kDefaultVelocityX);
134 EXPECT_LT(0.f, scroller.GetCurrVelocityY() * kDefaultVelocityY);
136 scroller.IsScrollingInDirection(kDefaultVelocityX, kDefaultVelocityY));
140 float curr_x = scroller.GetCurrX();
141 float curr_y = scroller.GetCurrY();
142 float curr_velocity_x = scroller.GetCurrVelocityX();
143 float curr_velocity_y = scroller.GetCurrVelocityY();
144 scroller.ComputeScrollOffset(start_time + scroll_duration / 2);
145 EXPECT_EQ(curr_x, scroller.GetCurrX());
146 EXPECT_EQ(curr_y, scroller.GetCurrY());
147 EXPECT_EQ(curr_velocity_x, scroller.GetCurrVelocityX());
148 EXPECT_EQ(curr_velocity_y, scroller.GetCurrVelocityY());
151 scroller.ComputeScrollOffset(start_time + scroll_duration);
152 EXPECT_EQ(scroller.GetFinalX(), scroller.GetCurrX());
153 EXPECT_EQ(scroller.GetFinalY(), scroller.GetCurrY());
154 EXPECT_TRUE(scroller.IsFinished());
155 EXPECT_EQ(scroll_duration, scroller.GetTimePassed());
156 EXPECT_NEAR(0.f, scroller.GetCurrVelocityX(), kEpsilon);
157 EXPECT_NEAR(0.f, scroller.GetCurrVelocityY(), kEpsilon);
160 scroller.ComputeScrollOffset(start_time + scroll_duration * 2);
161 EXPECT_EQ(scroller.GetFinalX(), scroller.GetCurrX());
162 EXPECT_EQ(scroller.GetFinalY(), scroller.GetCurrY());
163 EXPECT_TRUE(scroller.IsFinished());
164 EXPECT_EQ(scroll_duration, scroller.GetTimePassed());