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

Side by Side Diff: cc/input/single_scrollbar_animation_controller_thinning_unittest.cc

Issue 2841943002: Overlay scrollbars expand only when mouse is near thumb (Closed)
Patch Set: add tests Created 3 years, 7 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 "cc/input/single_scrollbar_animation_controller_thinning.h" 5 #include "cc/input/single_scrollbar_animation_controller_thinning.h"
6 6
7 #include "cc/layers/solid_color_scrollbar_layer_impl.h" 7 #include "cc/layers/solid_color_scrollbar_layer_impl.h"
8 #include "cc/test/fake_impl_task_runner_provider.h" 8 #include "cc/test/fake_impl_task_runner_provider.h"
9 #include "cc/test/fake_layer_tree_host_impl.h" 9 #include "cc/test/fake_layer_tree_host_impl.h"
10 #include "cc/test/geometry_test_utils.h" 10 #include "cc/test/geometry_test_utils.h"
11 #include "cc/test/test_task_graph_runner.h" 11 #include "cc/test/test_task_graph_runner.h"
12 #include "cc/trees/layer_tree_impl.h" 12 #include "cc/trees/layer_tree_impl.h"
13 #include "testing/gmock/include/gmock/gmock.h" 13 #include "testing/gmock/include/gmock/gmock.h"
14 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
15 15
16 using testing::AtLeast; 16 using testing::AtLeast;
17 using testing::Mock; 17 using testing::Mock;
18 using testing::NiceMock; 18 using testing::NiceMock;
19 using testing::_; 19 using testing::_;
20 20
21 namespace cc { 21 namespace cc {
22 namespace { 22 namespace {
23 23
24 const float kIdleThicknessScale = 24 const float kIdleThicknessScale =
25 SingleScrollbarAnimationControllerThinning::kIdleThicknessScale; 25 SingleScrollbarAnimationControllerThinning::kIdleThicknessScale;
26 const float kDefaultMouseMoveDistanceToTriggerAnimation = 26 const float kMouseMoveDistanceToTriggerExpand =
27 SingleScrollbarAnimationControllerThinning:: 27 SingleScrollbarAnimationControllerThinning::
28 kDefaultMouseMoveDistanceToTriggerAnimation; 28 kMouseMoveDistanceToTriggerExpand;
29 29
30 class MockSingleScrollbarAnimationControllerClient 30 class MockSingleScrollbarAnimationControllerClient
31 : public ScrollbarAnimationControllerClient { 31 : public ScrollbarAnimationControllerClient {
32 public: 32 public:
33 explicit MockSingleScrollbarAnimationControllerClient( 33 explicit MockSingleScrollbarAnimationControllerClient(
34 LayerTreeHostImpl* host_impl) 34 LayerTreeHostImpl* host_impl)
35 : host_impl_(host_impl) {} 35 : host_impl_(host_impl) {}
36 virtual ~MockSingleScrollbarAnimationControllerClient() {} 36 virtual ~MockSingleScrollbarAnimationControllerClient() {}
37 37
38 ScrollbarSet ScrollbarsFor(ElementId scroll_element_id) const override { 38 ScrollbarSet ScrollbarsFor(ElementId scroll_element_id) const override {
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 EXPECT_FLOAT_EQ(kIdleThicknessScale, 113 EXPECT_FLOAT_EQ(kIdleThicknessScale,
114 scrollbar_layer_->thumb_thickness_scale_factor()); 114 scrollbar_layer_->thumb_thickness_scale_factor());
115 } 115 }
116 116
117 // Move the pointer near the scrollbar. Confirm it gets thick and narrow when 117 // Move the pointer near the scrollbar. Confirm it gets thick and narrow when
118 // moved away. 118 // moved away.
119 TEST_F(SingleScrollbarAnimationControllerThinningTest, MouseNear) { 119 TEST_F(SingleScrollbarAnimationControllerThinningTest, MouseNear) {
120 base::TimeTicks time; 120 base::TimeTicks time;
121 time += base::TimeDelta::FromSeconds(1); 121 time += base::TimeDelta::FromSeconds(1);
122 122
123 scrollbar_controller_->DidMouseMoveNear(1); 123 scrollbar_controller_->DidMouseMove(1);
124 scrollbar_controller_->Animate(time); 124 scrollbar_controller_->Animate(time);
125 EXPECT_FLOAT_EQ(kIdleThicknessScale, 125 EXPECT_FLOAT_EQ(kIdleThicknessScale,
126 scrollbar_layer_->thumb_thickness_scale_factor()); 126 scrollbar_layer_->thumb_thickness_scale_factor());
127 127
128 // Should animate to thickened. 128 // Should animate to thickened.
129 time += kThinningDuration; 129 time += kThinningDuration;
130 scrollbar_controller_->Animate(time); 130 scrollbar_controller_->Animate(time);
131 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor()); 131 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
132 132
133 // Subsequent moves within the nearness threshold should not change anything. 133 // Subsequent moves within the nearness threshold should not change anything.
134 scrollbar_controller_->DidMouseMoveNear(2); 134 scrollbar_controller_->DidMouseMove(2);
135 scrollbar_controller_->Animate(time); 135 scrollbar_controller_->Animate(time);
136 time += base::TimeDelta::FromSeconds(10); 136 time += base::TimeDelta::FromSeconds(10);
137 scrollbar_controller_->Animate(time); 137 scrollbar_controller_->Animate(time);
138 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor()); 138 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
139 139
140 // Now move away from bar. 140 // Now move away from bar.
141 scrollbar_controller_->DidMouseMoveNear( 141 scrollbar_controller_->DidMouseMove(kMouseMoveDistanceToTriggerExpand);
142 kDefaultMouseMoveDistanceToTriggerAnimation);
143 scrollbar_controller_->Animate(time); 142 scrollbar_controller_->Animate(time);
144 time += kThinningDuration; 143 time += kThinningDuration;
145 scrollbar_controller_->Animate(time); 144 scrollbar_controller_->Animate(time);
146 EXPECT_FLOAT_EQ(kIdleThicknessScale, 145 EXPECT_FLOAT_EQ(kIdleThicknessScale,
147 scrollbar_layer_->thumb_thickness_scale_factor()); 146 scrollbar_layer_->thumb_thickness_scale_factor());
148 } 147 }
149 148
150 // Move the pointer over the scrollbar. Make sure it gets thick that it gets 149 // Move the pointer over the scrollbar. Make sure it gets thick that it gets
151 // thin when moved away. 150 // thin when moved away.
152 TEST_F(SingleScrollbarAnimationControllerThinningTest, MouseOver) { 151 TEST_F(SingleScrollbarAnimationControllerThinningTest, MouseOver) {
153 base::TimeTicks time; 152 base::TimeTicks time;
154 time += base::TimeDelta::FromSeconds(1); 153 time += base::TimeDelta::FromSeconds(1);
155 154
156 scrollbar_controller_->DidMouseMoveNear(0); 155 scrollbar_controller_->DidMouseMove(0);
157 scrollbar_controller_->Animate(time); 156 scrollbar_controller_->Animate(time);
158 EXPECT_FLOAT_EQ(kIdleThicknessScale, 157 EXPECT_FLOAT_EQ(kIdleThicknessScale,
159 scrollbar_layer_->thumb_thickness_scale_factor()); 158 scrollbar_layer_->thumb_thickness_scale_factor());
160 159
161 // Should animate to thickened. 160 // Should animate to thickened.
162 time += kThinningDuration; 161 time += kThinningDuration;
163 scrollbar_controller_->Animate(time); 162 scrollbar_controller_->Animate(time);
164 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor()); 163 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
165 164
166 // Subsequent moves should not change anything. 165 // Subsequent moves should not change anything.
167 scrollbar_controller_->DidMouseMoveNear(0); 166 scrollbar_controller_->DidMouseMove(0);
168 scrollbar_controller_->Animate(time); 167 scrollbar_controller_->Animate(time);
169 time += base::TimeDelta::FromSeconds(10); 168 time += base::TimeDelta::FromSeconds(10);
170 scrollbar_controller_->Animate(time); 169 scrollbar_controller_->Animate(time);
171 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor()); 170 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
172 171
173 // Moving off the scrollbar but still withing the "near" threshold should do 172 // Moving off the scrollbar but still withing the "near" threshold should do
174 // nothing. 173 // nothing.
175 scrollbar_controller_->DidMouseMoveNear( 174 scrollbar_controller_->DidMouseMove(kMouseMoveDistanceToTriggerExpand - 1.f);
176 kDefaultMouseMoveDistanceToTriggerAnimation - 1.f);
177 scrollbar_controller_->Animate(time); 175 scrollbar_controller_->Animate(time);
178 time += base::TimeDelta::FromSeconds(10); 176 time += base::TimeDelta::FromSeconds(10);
179 scrollbar_controller_->Animate(time); 177 scrollbar_controller_->Animate(time);
180 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor()); 178 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
181 179
182 // Now move away from bar. 180 // Now move away from bar.
183 scrollbar_controller_->DidMouseMoveNear( 181 scrollbar_controller_->DidMouseMove(kMouseMoveDistanceToTriggerExpand);
184 kDefaultMouseMoveDistanceToTriggerAnimation);
185 scrollbar_controller_->Animate(time); 182 scrollbar_controller_->Animate(time);
186 time += kThinningDuration; 183 time += kThinningDuration;
187 scrollbar_controller_->Animate(time); 184 scrollbar_controller_->Animate(time);
188 EXPECT_FLOAT_EQ(kIdleThicknessScale, 185 EXPECT_FLOAT_EQ(kIdleThicknessScale,
189 scrollbar_layer_->thumb_thickness_scale_factor()); 186 scrollbar_layer_->thumb_thickness_scale_factor());
190 } 187 }
191 188
192 // First move the pointer over the scrollbar off of it. Make sure the thinning 189 // First move the pointer over the scrollbar off of it. Make sure the thinning
193 // animation kicked off in DidMouseMoveOffScrollbar gets overridden by the 190 // animation kicked off in DidMouseMoveOffScrollbar gets overridden by the
194 // thickening animation in the DidMouseMoveNear call. 191 // thickening animation in the DidMouseMove call.
195 TEST_F(SingleScrollbarAnimationControllerThinningTest, 192 TEST_F(SingleScrollbarAnimationControllerThinningTest,
196 MouseNearThenAwayWhileAnimating) { 193 MouseNearThenAwayWhileAnimating) {
197 base::TimeTicks time; 194 base::TimeTicks time;
198 time += base::TimeDelta::FromSeconds(1); 195 time += base::TimeDelta::FromSeconds(1);
199 196
200 scrollbar_controller_->DidMouseMoveNear(0); 197 scrollbar_controller_->DidMouseMove(0);
201 scrollbar_controller_->Animate(time); 198 scrollbar_controller_->Animate(time);
202 EXPECT_FLOAT_EQ(kIdleThicknessScale, 199 EXPECT_FLOAT_EQ(kIdleThicknessScale,
203 scrollbar_layer_->thumb_thickness_scale_factor()); 200 scrollbar_layer_->thumb_thickness_scale_factor());
204 201
205 // Should animate to thickened. 202 // Should animate to thickened.
206 time += kThinningDuration; 203 time += kThinningDuration;
207 scrollbar_controller_->Animate(time); 204 scrollbar_controller_->Animate(time);
208 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor()); 205 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
209 206
210 // This is tricky. The DidMouseLeave() is sent before the 207 // This is tricky. The DidMouseLeave() is sent before the
211 // subsequent DidMouseMoveNear(), if the mouse moves in that direction. 208 // subsequent DidMouseMove(), if the mouse moves in that direction.
212 // This results in the thumb thinning. We want to make sure that when the 209 // This results in the thumb thinning. We want to make sure that when the
213 // thumb starts expanding it doesn't first narrow to the idle thinness. 210 // thumb starts expanding it doesn't first narrow to the idle thinness.
214 time += base::TimeDelta::FromSeconds(1); 211 time += base::TimeDelta::FromSeconds(1);
215 scrollbar_controller_->DidMouseLeave(); 212 scrollbar_controller_->DidMouseLeave();
216 scrollbar_controller_->Animate(time); 213 scrollbar_controller_->Animate(time);
217 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor()); 214 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
218 215
219 // Let the animation run half of the way through the thinning animation. 216 // Let the animation run half of the way through the thinning animation.
220 time += kThinningDuration / 2; 217 time += kThinningDuration / 2;
221 scrollbar_controller_->Animate(time); 218 scrollbar_controller_->Animate(time);
222 EXPECT_FLOAT_EQ(1.0f - (1.0f - kIdleThicknessScale) / 2.0f, 219 EXPECT_FLOAT_EQ(1.0f - (1.0f - kIdleThicknessScale) / 2.0f,
223 scrollbar_layer_->thumb_thickness_scale_factor()); 220 scrollbar_layer_->thumb_thickness_scale_factor());
224 221
225 // Now we get a notification for the mouse moving over the scroller. The 222 // Now we get a notification for the mouse moving over the scroller. The
226 // animation is reset to the thickening direction but we won't start 223 // animation is reset to the thickening direction but we won't start
227 // thickening until the new animation catches up to the current thickness. 224 // thickening until the new animation catches up to the current thickness.
228 scrollbar_controller_->DidMouseMoveNear(1); 225 scrollbar_controller_->DidMouseMove(1);
229 scrollbar_controller_->Animate(time); 226 scrollbar_controller_->Animate(time);
230 EXPECT_FLOAT_EQ(1.0f - (1.0f - kIdleThicknessScale) / 2.0f, 227 EXPECT_FLOAT_EQ(1.0f - (1.0f - kIdleThicknessScale) / 2.0f,
231 scrollbar_layer_->thumb_thickness_scale_factor()); 228 scrollbar_layer_->thumb_thickness_scale_factor());
232 229
233 // Until we reach the half way point, the animation will have no effect. 230 // Until we reach the half way point, the animation will have no effect.
234 time += kThinningDuration / 4; 231 time += kThinningDuration / 4;
235 scrollbar_controller_->Animate(time); 232 scrollbar_controller_->Animate(time);
236 EXPECT_FLOAT_EQ(1.0f - (1.0f - kIdleThicknessScale) / 2.0f, 233 EXPECT_FLOAT_EQ(1.0f - (1.0f - kIdleThicknessScale) / 2.0f,
237 scrollbar_layer_->thumb_thickness_scale_factor()); 234 scrollbar_layer_->thumb_thickness_scale_factor());
238 235
(...skipping 17 matching lines...) Expand all
256 253
257 // First move the pointer on the scrollbar, then press it, then away. 254 // First move the pointer on the scrollbar, then press it, then away.
258 // Confirm that the bar gets thick. Then mouse up. Confirm that 255 // Confirm that the bar gets thick. Then mouse up. Confirm that
259 // the bar gets thin. 256 // the bar gets thin.
260 TEST_F(SingleScrollbarAnimationControllerThinningTest, 257 TEST_F(SingleScrollbarAnimationControllerThinningTest,
261 MouseCaptureAndReleaseOutOfBar) { 258 MouseCaptureAndReleaseOutOfBar) {
262 base::TimeTicks time; 259 base::TimeTicks time;
263 time += base::TimeDelta::FromSeconds(1); 260 time += base::TimeDelta::FromSeconds(1);
264 261
265 // Move over the scrollbar. 262 // Move over the scrollbar.
266 scrollbar_controller_->DidMouseMoveNear(0); 263 scrollbar_controller_->DidMouseMove(0);
267 scrollbar_controller_->Animate(time); 264 scrollbar_controller_->Animate(time);
268 time += kThinningDuration; 265 time += kThinningDuration;
269 scrollbar_controller_->Animate(time); 266 scrollbar_controller_->Animate(time);
270 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor()); 267 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
271 268
272 // Capture 269 // Capture
273 scrollbar_controller_->DidMouseDown(); 270 scrollbar_controller_->DidMouseDown();
274 time += base::TimeDelta::FromSeconds(1); 271 time += base::TimeDelta::FromSeconds(1);
275 scrollbar_controller_->Animate(time); 272 scrollbar_controller_->Animate(time);
276 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor()); 273 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
277 274
278 // Should stay thick for a while. 275 // Should stay thick for a while.
279 time += base::TimeDelta::FromSeconds(10); 276 time += base::TimeDelta::FromSeconds(10);
280 scrollbar_controller_->Animate(time); 277 scrollbar_controller_->Animate(time);
281 278
282 // Move outside the "near" threshold. Because the scrollbar is captured it 279 // Move outside the "near" threshold. Because the scrollbar is captured it
283 // should remain thick. 280 // should remain thick.
284 scrollbar_controller_->DidMouseMoveNear( 281 scrollbar_controller_->DidMouseMove(kMouseMoveDistanceToTriggerExpand);
285 kDefaultMouseMoveDistanceToTriggerAnimation);
286 time += kThinningDuration; 282 time += kThinningDuration;
287 scrollbar_controller_->Animate(time); 283 scrollbar_controller_->Animate(time);
288 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor()); 284 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
289 285
290 // Release. 286 // Release.
291 scrollbar_controller_->DidMouseUp(); 287 scrollbar_controller_->DidMouseUp();
292 288
293 // Should become thin. 289 // Should become thin.
294 time += base::TimeDelta::FromSeconds(1); 290 time += base::TimeDelta::FromSeconds(1);
295 scrollbar_controller_->Animate(time); 291 scrollbar_controller_->Animate(time);
296 time += kThinningDuration; 292 time += kThinningDuration;
297 scrollbar_controller_->Animate(time); 293 scrollbar_controller_->Animate(time);
298 EXPECT_FLOAT_EQ(kIdleThicknessScale, 294 EXPECT_FLOAT_EQ(kIdleThicknessScale,
299 scrollbar_layer_->thumb_thickness_scale_factor()); 295 scrollbar_layer_->thumb_thickness_scale_factor());
300 } 296 }
301 297
302 // First move the pointer on the scrollbar, then press it, then away. Confirm 298 // First move the pointer on the scrollbar, then press it, then away. Confirm
303 // that the bar gets thick. Then move point on the scrollbar and mouse up. 299 // that the bar gets thick. Then move point on the scrollbar and mouse up.
304 // Confirm that the bar stays thick. 300 // Confirm that the bar stays thick.
305 TEST_F(SingleScrollbarAnimationControllerThinningTest, 301 TEST_F(SingleScrollbarAnimationControllerThinningTest,
306 MouseCaptureAndReleaseOnBar) { 302 MouseCaptureAndReleaseOnBar) {
307 base::TimeTicks time; 303 base::TimeTicks time;
308 time += base::TimeDelta::FromSeconds(1); 304 time += base::TimeDelta::FromSeconds(1);
309 305
310 // Move over scrollbar. 306 // Move over scrollbar.
311 scrollbar_controller_->DidMouseMoveNear(0); 307 scrollbar_controller_->DidMouseMove(0);
312 scrollbar_controller_->Animate(time); 308 scrollbar_controller_->Animate(time);
313 time += kThinningDuration; 309 time += kThinningDuration;
314 scrollbar_controller_->Animate(time); 310 scrollbar_controller_->Animate(time);
315 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor()); 311 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
316 312
317 // Capture. Nothing should change. 313 // Capture. Nothing should change.
318 scrollbar_controller_->DidMouseDown(); 314 scrollbar_controller_->DidMouseDown();
319 time += base::TimeDelta::FromSeconds(1); 315 time += base::TimeDelta::FromSeconds(1);
320 scrollbar_controller_->Animate(time); 316 scrollbar_controller_->Animate(time);
321 time += base::TimeDelta::FromSeconds(10); 317 time += base::TimeDelta::FromSeconds(10);
322 scrollbar_controller_->Animate(time); 318 scrollbar_controller_->Animate(time);
323 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor()); 319 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
324 320
325 // Move away from scrollbar. Nothing should change. 321 // Move away from scrollbar. Nothing should change.
326 scrollbar_controller_->DidMouseMoveNear( 322 scrollbar_controller_->DidMouseMove(kMouseMoveDistanceToTriggerExpand);
327 kDefaultMouseMoveDistanceToTriggerAnimation);
328 time += base::TimeDelta::FromSeconds(1); 323 time += base::TimeDelta::FromSeconds(1);
329 scrollbar_controller_->Animate(time); 324 scrollbar_controller_->Animate(time);
330 time += base::TimeDelta::FromSeconds(10); 325 time += base::TimeDelta::FromSeconds(10);
331 scrollbar_controller_->Animate(time); 326 scrollbar_controller_->Animate(time);
332 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor()); 327 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
333 328
334 // Move over scrollbar and release. Since we're near the scrollbar, it should 329 // Move over scrollbar and release. Since we're near the scrollbar, it should
335 // remain thick. 330 // remain thick.
336 scrollbar_controller_->DidMouseMoveNear(0); 331 scrollbar_controller_->DidMouseMove(0);
337 scrollbar_controller_->DidMouseUp(); 332 scrollbar_controller_->DidMouseUp();
338 time += base::TimeDelta::FromSeconds(1); 333 time += base::TimeDelta::FromSeconds(1);
339 scrollbar_controller_->Animate(time); 334 scrollbar_controller_->Animate(time);
340 time += base::TimeDelta::FromSeconds(10); 335 time += base::TimeDelta::FromSeconds(10);
341 scrollbar_controller_->Animate(time); 336 scrollbar_controller_->Animate(time);
342 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor()); 337 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
343 } 338 }
344 339
345 // Tests that the thickening/thinning effects are animated. 340 // Tests that the thickening/thinning effects are animated.
346 TEST_F(SingleScrollbarAnimationControllerThinningTest, ThicknessAnimated) { 341 TEST_F(SingleScrollbarAnimationControllerThinningTest, ThicknessAnimated) {
347 base::TimeTicks time; 342 base::TimeTicks time;
348 time += base::TimeDelta::FromSeconds(1); 343 time += base::TimeDelta::FromSeconds(1);
349 344
350 // Move mouse near scrollbar. Test that at half the duration time, the 345 // Move mouse near scrollbar. Test that at half the duration time, the
351 // thickness is half way through its animation. 346 // thickness is half way through its animation.
352 scrollbar_controller_->DidMouseMoveNear(1); 347 scrollbar_controller_->DidMouseMove(1);
353 scrollbar_controller_->Animate(time); 348 scrollbar_controller_->Animate(time);
354 EXPECT_FLOAT_EQ(kIdleThicknessScale, 349 EXPECT_FLOAT_EQ(kIdleThicknessScale,
355 scrollbar_layer_->thumb_thickness_scale_factor()); 350 scrollbar_layer_->thumb_thickness_scale_factor());
356 351
357 time += kThinningDuration / 2; 352 time += kThinningDuration / 2;
358 scrollbar_controller_->Animate(time); 353 scrollbar_controller_->Animate(time);
359 EXPECT_FLOAT_EQ(kIdleThicknessScale + (1.0f - kIdleThicknessScale) / 2.0f, 354 EXPECT_FLOAT_EQ(kIdleThicknessScale + (1.0f - kIdleThicknessScale) / 2.0f,
360 scrollbar_layer_->thumb_thickness_scale_factor()); 355 scrollbar_layer_->thumb_thickness_scale_factor());
361 356
362 time += kThinningDuration / 2; 357 time += kThinningDuration / 2;
363 scrollbar_controller_->Animate(time); 358 scrollbar_controller_->Animate(time);
364 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor()); 359 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
365 360
366 // Move mouse away from scrollbar. Same check. 361 // Move mouse away from scrollbar. Same check.
367 time += base::TimeDelta::FromSeconds(1); 362 time += base::TimeDelta::FromSeconds(1);
368 scrollbar_controller_->DidMouseMoveNear( 363 scrollbar_controller_->DidMouseMove(kMouseMoveDistanceToTriggerExpand);
369 kDefaultMouseMoveDistanceToTriggerAnimation);
370 scrollbar_controller_->Animate(time); 364 scrollbar_controller_->Animate(time);
371 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor()); 365 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
372 366
373 time += kThinningDuration / 2; 367 time += kThinningDuration / 2;
374 scrollbar_controller_->Animate(time); 368 scrollbar_controller_->Animate(time);
375 EXPECT_FLOAT_EQ(1.0f - (1.0f - kIdleThicknessScale) / 2.0f, 369 EXPECT_FLOAT_EQ(1.0f - (1.0f - kIdleThicknessScale) / 2.0f,
376 scrollbar_layer_->thumb_thickness_scale_factor()); 370 scrollbar_layer_->thumb_thickness_scale_factor());
377 371
378 time += kThinningDuration / 2; 372 time += kThinningDuration / 2;
379 scrollbar_controller_->Animate(time); 373 scrollbar_controller_->Animate(time);
380 EXPECT_FLOAT_EQ(kIdleThicknessScale, 374 EXPECT_FLOAT_EQ(kIdleThicknessScale,
381 scrollbar_layer_->thumb_thickness_scale_factor()); 375 scrollbar_layer_->thumb_thickness_scale_factor());
382 } 376 }
383 377
384 } // namespace 378 } // namespace
385 } // namespace cc 379 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698