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

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

Issue 2716453005: Aura Overlay Scrollbars appear when mouse hovers over scroller edge (Closed)
Patch Set: rebase Created 3 years, 9 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/scrollbar_animation_controller.h" 5 #include "cc/input/scrollbar_animation_controller.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"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 ScrollbarAnimationControllerAuraOverlayTest() 60 ScrollbarAnimationControllerAuraOverlayTest()
61 : host_impl_(&task_runner_provider_, &task_graph_runner_), 61 : host_impl_(&task_runner_provider_, &task_graph_runner_),
62 client_(&host_impl_) {} 62 client_(&host_impl_) {}
63 63
64 void ExpectScrollbarsOpacity(float opacity) { 64 void ExpectScrollbarsOpacity(float opacity) {
65 EXPECT_FLOAT_EQ(opacity, v_scrollbar_layer_->Opacity()); 65 EXPECT_FLOAT_EQ(opacity, v_scrollbar_layer_->Opacity());
66 EXPECT_FLOAT_EQ(opacity, h_scrollbar_layer_->Opacity()); 66 EXPECT_FLOAT_EQ(opacity, h_scrollbar_layer_->Opacity());
67 } 67 }
68 68
69 protected: 69 protected:
70 const base::TimeDelta kDelayBeforeStarting = base::TimeDelta::FromSeconds(2); 70 const base::TimeDelta kFadeInDelay = base::TimeDelta::FromSeconds(4);
71 const base::TimeDelta kResizeDelayBeforeStarting = 71 const base::TimeDelta kFadeOutDelay = base::TimeDelta::FromSeconds(2);
72 base::TimeDelta::FromSeconds(5); 72 const base::TimeDelta kResizeFadeOutDelay = base::TimeDelta::FromSeconds(5);
73 const base::TimeDelta kFadeDuration = base::TimeDelta::FromSeconds(3); 73 const base::TimeDelta kFadeOutDuration = base::TimeDelta::FromSeconds(3);
74 const base::TimeDelta kThinningDuration = base::TimeDelta::FromSeconds(2); 74 const base::TimeDelta kThinningDuration = base::TimeDelta::FromSeconds(2);
75 75
76 void SetUp() override { 76 void SetUp() override {
77 std::unique_ptr<LayerImpl> scroll_layer = 77 std::unique_ptr<LayerImpl> scroll_layer =
78 LayerImpl::Create(host_impl_.active_tree(), 1); 78 LayerImpl::Create(host_impl_.active_tree(), 1);
79 std::unique_ptr<LayerImpl> clip = 79 std::unique_ptr<LayerImpl> clip =
80 LayerImpl::Create(host_impl_.active_tree(), 2); 80 LayerImpl::Create(host_impl_.active_tree(), 2);
81 clip_layer_ = clip.get(); 81 clip_layer_ = clip.get();
82 scroll_layer->SetScrollClipLayer(clip_layer_->id()); 82 scroll_layer->SetScrollClipLayer(clip_layer_->id());
83 LayerImpl* scroll_layer_ptr = scroll_layer.get(); 83 LayerImpl* scroll_layer_ptr = scroll_layer.get();
(...skipping 22 matching lines...) Expand all
106 v_scrollbar_layer_->SetScrollLayerId(scroll_layer_ptr->id()); 106 v_scrollbar_layer_->SetScrollLayerId(scroll_layer_ptr->id());
107 h_scrollbar_layer_->SetScrollLayerId(scroll_layer_ptr->id()); 107 h_scrollbar_layer_->SetScrollLayerId(scroll_layer_ptr->id());
108 v_scrollbar_layer_->test_properties()->opacity_can_animate = true; 108 v_scrollbar_layer_->test_properties()->opacity_can_animate = true;
109 h_scrollbar_layer_->test_properties()->opacity_can_animate = true; 109 h_scrollbar_layer_->test_properties()->opacity_can_animate = true;
110 clip_layer_->SetBounds(gfx::Size(100, 100)); 110 clip_layer_->SetBounds(gfx::Size(100, 100));
111 scroll_layer_ptr->SetBounds(gfx::Size(200, 200)); 111 scroll_layer_ptr->SetBounds(gfx::Size(200, 200));
112 host_impl_.active_tree()->BuildLayerListAndPropertyTreesForTesting(); 112 host_impl_.active_tree()->BuildLayerListAndPropertyTreesForTesting();
113 113
114 scrollbar_controller_ = ScrollbarAnimationController:: 114 scrollbar_controller_ = ScrollbarAnimationController::
115 CreateScrollbarAnimationControllerAuraOverlay( 115 CreateScrollbarAnimationControllerAuraOverlay(
116 scroll_layer_ptr->id(), &client_, kDelayBeforeStarting, 116 scroll_layer_ptr->id(), &client_, kFadeInDelay, kFadeOutDelay,
117 kResizeDelayBeforeStarting, kFadeDuration, kThinningDuration); 117 kResizeFadeOutDelay, kFadeOutDuration, kThinningDuration);
118 } 118 }
119 119
120 FakeImplTaskRunnerProvider task_runner_provider_; 120 FakeImplTaskRunnerProvider task_runner_provider_;
121 TestTaskGraphRunner task_graph_runner_; 121 TestTaskGraphRunner task_graph_runner_;
122 FakeLayerTreeHostImpl host_impl_; 122 FakeLayerTreeHostImpl host_impl_;
123 std::unique_ptr<ScrollbarAnimationController> scrollbar_controller_; 123 std::unique_ptr<ScrollbarAnimationController> scrollbar_controller_;
124 LayerImpl* clip_layer_; 124 LayerImpl* clip_layer_;
125 SolidColorScrollbarLayerImpl* v_scrollbar_layer_; 125 SolidColorScrollbarLayerImpl* v_scrollbar_layer_;
126 SolidColorScrollbarLayerImpl* h_scrollbar_layer_; 126 SolidColorScrollbarLayerImpl* h_scrollbar_layer_;
127 NiceMock<MockScrollbarAnimationControllerClient> client_; 127 NiceMock<MockScrollbarAnimationControllerClient> client_;
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 EXPECT_TRUE(scrollbar_controller_->ScrollbarsHidden()); 206 EXPECT_TRUE(scrollbar_controller_->ScrollbarsHidden());
207 207
208 scrollbar_controller_->DidScrollUpdate(false); 208 scrollbar_controller_->DidScrollUpdate(false);
209 ExpectScrollbarsOpacity(1); 209 ExpectScrollbarsOpacity(1);
210 EXPECT_FALSE(scrollbar_controller_->ScrollbarsHidden()); 210 EXPECT_FALSE(scrollbar_controller_->ScrollbarsHidden());
211 211
212 scrollbar_controller_->DidScrollEnd(); 212 scrollbar_controller_->DidScrollEnd();
213 ExpectScrollbarsOpacity(1); 213 ExpectScrollbarsOpacity(1);
214 EXPECT_FALSE(scrollbar_controller_->ScrollbarsHidden()); 214 EXPECT_FALSE(scrollbar_controller_->ScrollbarsHidden());
215 215
216 // An animation should have been enqueued. 216 // An fade out animation should have been enqueued.
217 EXPECT_EQ(kDelayBeforeStarting, client_.delay()); 217 EXPECT_EQ(kFadeOutDelay, client_.delay());
218 EXPECT_FALSE(client_.start_fade().is_null()); 218 EXPECT_FALSE(client_.start_fade().is_null());
219 client_.start_fade().Run(); 219 client_.start_fade().Run();
220 220
221 // Scrollbar should fade out over kFadeDuration. 221 // Scrollbar should fade out over kFadeOutDuration.
222 scrollbar_controller_->Animate(time); 222 scrollbar_controller_->Animate(time);
223 time += kFadeDuration; 223 time += kFadeOutDuration;
224 scrollbar_controller_->Animate(time); 224 scrollbar_controller_->Animate(time);
225 225
226 ExpectScrollbarsOpacity(0); 226 ExpectScrollbarsOpacity(0);
227 EXPECT_TRUE(scrollbar_controller_->ScrollbarsHidden()); 227 EXPECT_TRUE(scrollbar_controller_->ScrollbarsHidden());
228 } 228 }
229 229
230 // Scroll content. Move the mouse near the scrollbar and confirm it becomes 230 // Scroll content. Move the mouse near the scrollbar and confirm it becomes
231 // thick. Ensure it remains visible as long as the mouse is near the scrollbar. 231 // thick. Ensure it remains visible as long as the mouse is near the scrollbar.
232 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, MoveNearAndDontFadeOut) { 232 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, MoveNearAndDontFadeOut) {
233 base::TimeTicks time; 233 base::TimeTicks time;
234 time += base::TimeDelta::FromSeconds(1); 234 time += base::TimeDelta::FromSeconds(1);
235 235
236 scrollbar_controller_->DidScrollBegin(); 236 scrollbar_controller_->DidScrollBegin();
237 scrollbar_controller_->DidScrollUpdate(false); 237 scrollbar_controller_->DidScrollUpdate(false);
238 scrollbar_controller_->DidScrollEnd(); 238 scrollbar_controller_->DidScrollEnd();
239 239
240 // An animation should have been enqueued. 240 // An fade out animation should have been enqueued.
241 EXPECT_EQ(kDelayBeforeStarting, client_.delay()); 241 EXPECT_EQ(kFadeOutDelay, client_.delay());
242 EXPECT_FALSE(client_.start_fade().is_null()); 242 EXPECT_FALSE(client_.start_fade().is_null());
243 EXPECT_FALSE(client_.start_fade().IsCancelled()); 243 EXPECT_FALSE(client_.start_fade().IsCancelled());
244 244
245 // Now move the mouse near the scrollbar. This should cancel the currently 245 // Now move the mouse near the scrollbar. This should cancel the currently
246 // queued fading animation and start animating thickness. 246 // queued fading animation and start animating thickness.
247 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 1); 247 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 1);
248 ExpectScrollbarsOpacity(1); 248 ExpectScrollbarsOpacity(1);
249 EXPECT_FLOAT_EQ(kIdleThicknessScale, 249 EXPECT_FLOAT_EQ(kIdleThicknessScale,
250 v_scrollbar_layer_->thumb_thickness_scale_factor()); 250 v_scrollbar_layer_->thumb_thickness_scale_factor());
251 EXPECT_FLOAT_EQ(kIdleThicknessScale, 251 EXPECT_FLOAT_EQ(kIdleThicknessScale,
252 h_scrollbar_layer_->thumb_thickness_scale_factor()); 252 h_scrollbar_layer_->thumb_thickness_scale_factor());
253 EXPECT_TRUE(client_.start_fade().IsCancelled()); 253 EXPECT_TRUE(client_.start_fade().IsCancelled());
254 254
255 // Vertical scrollbar should become thick. 255 // Vertical scrollbar should become thick.
256 scrollbar_controller_->Animate(time); 256 scrollbar_controller_->Animate(time);
257 time += kThinningDuration; 257 time += kThinningDuration;
258 scrollbar_controller_->Animate(time); 258 scrollbar_controller_->Animate(time);
259 ExpectScrollbarsOpacity(1); 259 ExpectScrollbarsOpacity(1);
260 EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor()); 260 EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor());
261 EXPECT_FLOAT_EQ(kIdleThicknessScale, 261 EXPECT_FLOAT_EQ(kIdleThicknessScale,
262 h_scrollbar_layer_->thumb_thickness_scale_factor()); 262 h_scrollbar_layer_->thumb_thickness_scale_factor());
263 263
264 // Mouse is still near the Scrollbar. Once the thickness animation is 264 // Mouse is still near the Scrollbar. Once the thickness animation is
265 // complete, the queued delayed fade animation should be either cancelled or 265 // complete, the queued delayed fade out animation should be either cancelled
266 // null. 266 // or null.
267 EXPECT_TRUE(client_.start_fade().is_null() || 267 EXPECT_TRUE(client_.start_fade().is_null() ||
268 client_.start_fade().IsCancelled()); 268 client_.start_fade().IsCancelled());
269 } 269 }
270 270
271 // Scroll content. Move the mouse over the scrollbar and confirm it becomes 271 // Scroll content. Move the mouse over the scrollbar and confirm it becomes
272 // thick. Ensure it remains visible as long as the mouse is over the scrollbar. 272 // thick. Ensure it remains visible as long as the mouse is over the scrollbar.
273 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, MoveOverAndDontFadeOut) { 273 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, MoveOverAndDontFadeOut) {
274 base::TimeTicks time; 274 base::TimeTicks time;
275 time += base::TimeDelta::FromSeconds(1); 275 time += base::TimeDelta::FromSeconds(1);
276 276
277 scrollbar_controller_->DidScrollBegin(); 277 scrollbar_controller_->DidScrollBegin();
278 scrollbar_controller_->DidScrollUpdate(false); 278 scrollbar_controller_->DidScrollUpdate(false);
279 scrollbar_controller_->DidScrollEnd(); 279 scrollbar_controller_->DidScrollEnd();
280 280
281 // An animation should have been enqueued. 281 // An fade out animation should have been enqueued.
282 EXPECT_EQ(kDelayBeforeStarting, client_.delay()); 282 EXPECT_EQ(kFadeOutDelay, client_.delay());
283 EXPECT_FALSE(client_.start_fade().is_null()); 283 EXPECT_FALSE(client_.start_fade().is_null());
284 EXPECT_FALSE(client_.start_fade().IsCancelled()); 284 EXPECT_FALSE(client_.start_fade().IsCancelled());
285 285
286 // Now move the mouse over the scrollbar. This should cancel the currently 286 // Now move the mouse over the scrollbar. This should cancel the currently
287 // queued fading animation and start animating thickness. 287 // queued fading animation and start animating thickness.
288 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 0); 288 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 0);
289 ExpectScrollbarsOpacity(1); 289 ExpectScrollbarsOpacity(1);
290 EXPECT_FLOAT_EQ(kIdleThicknessScale, 290 EXPECT_FLOAT_EQ(kIdleThicknessScale,
291 v_scrollbar_layer_->thumb_thickness_scale_factor()); 291 v_scrollbar_layer_->thumb_thickness_scale_factor());
292 EXPECT_FLOAT_EQ(kIdleThicknessScale, 292 EXPECT_FLOAT_EQ(kIdleThicknessScale,
293 h_scrollbar_layer_->thumb_thickness_scale_factor()); 293 h_scrollbar_layer_->thumb_thickness_scale_factor());
294 EXPECT_TRUE(client_.start_fade().IsCancelled()); 294 EXPECT_TRUE(client_.start_fade().IsCancelled());
295 295
296 // Vertical scrollbar should become thick. 296 // Vertical scrollbar should become thick.
297 scrollbar_controller_->Animate(time); 297 scrollbar_controller_->Animate(time);
298 time += kThinningDuration; 298 time += kThinningDuration;
299 scrollbar_controller_->Animate(time); 299 scrollbar_controller_->Animate(time);
300 ExpectScrollbarsOpacity(1); 300 ExpectScrollbarsOpacity(1);
301 EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor()); 301 EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor());
302 EXPECT_FLOAT_EQ(kIdleThicknessScale, 302 EXPECT_FLOAT_EQ(kIdleThicknessScale,
303 h_scrollbar_layer_->thumb_thickness_scale_factor()); 303 h_scrollbar_layer_->thumb_thickness_scale_factor());
304 304
305 // Mouse is still over the Scrollbar. Once the thickness animation is 305 // Mouse is still over the Scrollbar. Once the thickness animation is
306 // complete, the queued delayed fade animation should be either cancelled or 306 // complete, the queued delayed fade out animation should be either cancelled
307 // null. 307 // or null.
308 EXPECT_TRUE(client_.start_fade().is_null() || 308 EXPECT_TRUE(client_.start_fade().is_null() ||
309 client_.start_fade().IsCancelled()); 309 client_.start_fade().IsCancelled());
310 } 310 }
311 311
312 // Make sure a scrollbar captured before the thickening animation doesn't try 312 // Make sure a scrollbar captured before the thickening animation doesn't try
313 // to fade out. 313 // to fade out.
314 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, 314 TEST_F(ScrollbarAnimationControllerAuraOverlayTest,
315 DontFadeWhileCapturedBeforeThick) { 315 DontFadeWhileCapturedBeforeThick) {
316 base::TimeTicks time; 316 base::TimeTicks time;
317 time += base::TimeDelta::FromSeconds(1); 317 time += base::TimeDelta::FromSeconds(1);
318 318
319 scrollbar_controller_->DidScrollBegin(); 319 scrollbar_controller_->DidScrollBegin();
320 scrollbar_controller_->DidScrollUpdate(false); 320 scrollbar_controller_->DidScrollUpdate(false);
321 scrollbar_controller_->DidScrollEnd(); 321 scrollbar_controller_->DidScrollEnd();
322 322
323 // An animation should have been enqueued. 323 // An fade out animation should have been enqueued.
324 EXPECT_EQ(kDelayBeforeStarting, client_.delay()); 324 EXPECT_EQ(kFadeOutDelay, client_.delay());
325 EXPECT_FALSE(client_.start_fade().is_null()); 325 EXPECT_FALSE(client_.start_fade().is_null());
326 326
327 // Now move the mouse over the scrollbar and capture it. It should become 327 // Now move the mouse over the scrollbar and capture it. It should become
328 // thick without need for an animation. 328 // thick without need for an animation.
329 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 0); 329 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 0);
330 scrollbar_controller_->DidMouseDown(); 330 scrollbar_controller_->DidMouseDown();
331 ExpectScrollbarsOpacity(1); 331 ExpectScrollbarsOpacity(1);
332 EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor()); 332 EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor());
333 EXPECT_FLOAT_EQ(kIdleThicknessScale, 333 EXPECT_FLOAT_EQ(kIdleThicknessScale,
334 h_scrollbar_layer_->thumb_thickness_scale_factor()); 334 h_scrollbar_layer_->thumb_thickness_scale_factor());
335 335
336 // The fade animation should have been cleared or cancelled. 336 // The fade out animation should have been cleared or cancelled.
337 EXPECT_TRUE(client_.start_fade().is_null() || 337 EXPECT_TRUE(client_.start_fade().is_null() ||
338 client_.start_fade().IsCancelled()); 338 client_.start_fade().IsCancelled());
339 } 339 }
340 340
341 // Make sure a scrollbar captured then move mouse away doesn't try to fade out. 341 // Make sure a scrollbar captured then move mouse away doesn't try to fade out.
342 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, 342 TEST_F(ScrollbarAnimationControllerAuraOverlayTest,
343 DontFadeWhileCapturedThenAway) { 343 DontFadeWhileCapturedThenAway) {
344 base::TimeTicks time; 344 base::TimeTicks time;
345 time += base::TimeDelta::FromSeconds(1); 345 time += base::TimeDelta::FromSeconds(1);
346 346
347 scrollbar_controller_->DidScrollBegin(); 347 scrollbar_controller_->DidScrollBegin();
348 scrollbar_controller_->DidScrollUpdate(false); 348 scrollbar_controller_->DidScrollUpdate(false);
349 scrollbar_controller_->DidScrollEnd(); 349 scrollbar_controller_->DidScrollEnd();
350 350
351 // An animation should have been enqueued. 351 // An fade out animation should have been enqueued.
352 EXPECT_EQ(kDelayBeforeStarting, client_.delay()); 352 EXPECT_EQ(kFadeOutDelay, client_.delay());
353 EXPECT_FALSE(client_.start_fade().is_null()); 353 EXPECT_FALSE(client_.start_fade().is_null());
354 354
355 // Now move the mouse over the scrollbar and capture it. It should become 355 // Now move the mouse over the scrollbar and capture it. It should become
356 // thick without need for an animation. 356 // thick without need for an animation.
357 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 0); 357 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 0);
358 scrollbar_controller_->DidMouseDown(); 358 scrollbar_controller_->DidMouseDown();
359 ExpectScrollbarsOpacity(1); 359 ExpectScrollbarsOpacity(1);
360 EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor()); 360 EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor());
361 EXPECT_FLOAT_EQ(kIdleThicknessScale, 361 EXPECT_FLOAT_EQ(kIdleThicknessScale,
362 h_scrollbar_layer_->thumb_thickness_scale_factor()); 362 h_scrollbar_layer_->thumb_thickness_scale_factor());
363 363
364 // The fade animation should have been cleared or cancelled. 364 // The fade out animation should have been cleared or cancelled.
365 EXPECT_TRUE(client_.start_fade().is_null() || 365 EXPECT_TRUE(client_.start_fade().is_null() ||
366 client_.start_fade().IsCancelled()); 366 client_.start_fade().IsCancelled());
367 367
368 // Then move mouse away, The fade animation should have been cleared or 368 // Then move mouse away, The fade out animation should have been cleared or
369 // cancelled. 369 // cancelled.
370 scrollbar_controller_->DidMouseMoveNear( 370 scrollbar_controller_->DidMouseMoveNear(
371 VERTICAL, kDefaultMouseMoveDistanceToTriggerAnimation); 371 VERTICAL, kDefaultMouseMoveDistanceToTriggerAnimation);
372 372
373 EXPECT_TRUE(client_.start_fade().is_null() || 373 EXPECT_TRUE(client_.start_fade().is_null() ||
374 client_.start_fade().IsCancelled()); 374 client_.start_fade().IsCancelled());
375 } 375 }
376 376
377 // Make sure a scrollbar captured after a thickening animation doesn't try to 377 // Make sure a scrollbar captured after a thickening animation doesn't try to
378 // fade out. 378 // fade out.
379 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, DontFadeWhileCaptured) { 379 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, DontFadeWhileCaptured) {
380 base::TimeTicks time; 380 base::TimeTicks time;
381 time += base::TimeDelta::FromSeconds(1); 381 time += base::TimeDelta::FromSeconds(1);
382 382
383 scrollbar_controller_->DidScrollBegin(); 383 scrollbar_controller_->DidScrollBegin();
384 scrollbar_controller_->DidScrollUpdate(false); 384 scrollbar_controller_->DidScrollUpdate(false);
385 scrollbar_controller_->DidScrollEnd(); 385 scrollbar_controller_->DidScrollEnd();
386 386
387 // An animation should have been enqueued. 387 // An fade out animation should have been enqueued.
388 EXPECT_EQ(kDelayBeforeStarting, client_.delay()); 388 EXPECT_EQ(kFadeOutDelay, client_.delay());
389 EXPECT_FALSE(client_.start_fade().is_null()); 389 EXPECT_FALSE(client_.start_fade().is_null());
390 EXPECT_FALSE(client_.start_fade().IsCancelled()); 390 EXPECT_FALSE(client_.start_fade().IsCancelled());
391 391
392 // Now move the mouse over the scrollbar and animate it until it's thick. 392 // Now move the mouse over the scrollbar and animate it until it's thick.
393 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 0); 393 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 0);
394 scrollbar_controller_->Animate(time); 394 scrollbar_controller_->Animate(time);
395 time += kThinningDuration; 395 time += kThinningDuration;
396 scrollbar_controller_->Animate(time); 396 scrollbar_controller_->Animate(time);
397 ExpectScrollbarsOpacity(1); 397 ExpectScrollbarsOpacity(1);
398 EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor()); 398 EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor());
399 EXPECT_FLOAT_EQ(kIdleThicknessScale, 399 EXPECT_FLOAT_EQ(kIdleThicknessScale,
400 h_scrollbar_layer_->thumb_thickness_scale_factor()); 400 h_scrollbar_layer_->thumb_thickness_scale_factor());
401 401
402 // Since the mouse is over the scrollbar, it should either clear or cancel the 402 // Since the mouse is over the scrollbar, it should either clear or cancel the
403 // queued fade. 403 // queued fade.
404 EXPECT_TRUE(client_.start_fade().is_null() || 404 EXPECT_TRUE(client_.start_fade().is_null() ||
405 client_.start_fade().IsCancelled()); 405 client_.start_fade().IsCancelled());
406 406
407 // Make sure the queued fade animation is still null or cancelled after 407 // Make sure the queued fade out animation is still null or cancelled after
408 // capturing the scrollbar. 408 // capturing the scrollbar.
409 scrollbar_controller_->DidMouseDown(); 409 scrollbar_controller_->DidMouseDown();
410 EXPECT_TRUE(client_.start_fade().is_null() || 410 EXPECT_TRUE(client_.start_fade().is_null() ||
411 client_.start_fade().IsCancelled()); 411 client_.start_fade().IsCancelled());
412 } 412 }
413 413
414 // Make sure releasing a captured scrollbar when the mouse isn't near it, causes 414 // Make sure releasing a captured scrollbar when the mouse isn't near it, causes
415 // the scrollbar to fade out. 415 // the scrollbar to fade out.
416 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, FadeAfterReleasedFar) { 416 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, FadeAfterReleasedFar) {
417 base::TimeTicks time; 417 base::TimeTicks time;
418 time += base::TimeDelta::FromSeconds(1); 418 time += base::TimeDelta::FromSeconds(1);
419 419
420 scrollbar_controller_->DidScrollBegin(); 420 scrollbar_controller_->DidScrollBegin();
421 scrollbar_controller_->DidScrollUpdate(false); 421 scrollbar_controller_->DidScrollUpdate(false);
422 scrollbar_controller_->DidScrollEnd(); 422 scrollbar_controller_->DidScrollEnd();
423 423
424 // An animation should have been enqueued. 424 // An fade out animation should have been enqueued.
425 EXPECT_EQ(kDelayBeforeStarting, client_.delay()); 425 EXPECT_EQ(kFadeOutDelay, client_.delay());
426 EXPECT_FALSE(client_.start_fade().is_null()); 426 EXPECT_FALSE(client_.start_fade().is_null());
427 EXPECT_FALSE(client_.start_fade().IsCancelled()); 427 EXPECT_FALSE(client_.start_fade().IsCancelled());
428 428
429 // Now move the mouse over the scrollbar and capture it. 429 // Now move the mouse over the scrollbar and capture it.
430 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 0); 430 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 0);
431 scrollbar_controller_->DidMouseDown(); 431 scrollbar_controller_->DidMouseDown();
432 ExpectScrollbarsOpacity(1); 432 ExpectScrollbarsOpacity(1);
433 EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor()); 433 EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor());
434 EXPECT_FLOAT_EQ(kIdleThicknessScale, 434 EXPECT_FLOAT_EQ(kIdleThicknessScale,
435 h_scrollbar_layer_->thumb_thickness_scale_factor()); 435 h_scrollbar_layer_->thumb_thickness_scale_factor());
(...skipping 29 matching lines...) Expand all
465 // Make sure releasing a captured scrollbar when the mouse is near/over it, 465 // Make sure releasing a captured scrollbar when the mouse is near/over it,
466 // doesn't cause the scrollbar to fade out. 466 // doesn't cause the scrollbar to fade out.
467 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, DontFadeAfterReleasedNear) { 467 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, DontFadeAfterReleasedNear) {
468 base::TimeTicks time; 468 base::TimeTicks time;
469 time += base::TimeDelta::FromSeconds(1); 469 time += base::TimeDelta::FromSeconds(1);
470 470
471 scrollbar_controller_->DidScrollBegin(); 471 scrollbar_controller_->DidScrollBegin();
472 scrollbar_controller_->DidScrollUpdate(false); 472 scrollbar_controller_->DidScrollUpdate(false);
473 scrollbar_controller_->DidScrollEnd(); 473 scrollbar_controller_->DidScrollEnd();
474 474
475 // An animation should have been enqueued. 475 // An fade out animation should have been enqueued.
476 EXPECT_EQ(kDelayBeforeStarting, client_.delay()); 476 EXPECT_EQ(kFadeOutDelay, client_.delay());
477 EXPECT_FALSE(client_.start_fade().is_null()); 477 EXPECT_FALSE(client_.start_fade().is_null());
478 EXPECT_FALSE(client_.start_fade().IsCancelled()); 478 EXPECT_FALSE(client_.start_fade().IsCancelled());
479 479
480 // Now move the mouse over the scrollbar and capture it. 480 // Now move the mouse over the scrollbar and capture it.
481 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 0); 481 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 0);
482 scrollbar_controller_->DidMouseDown(); 482 scrollbar_controller_->DidMouseDown();
483 ExpectScrollbarsOpacity(1); 483 ExpectScrollbarsOpacity(1);
484 EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor()); 484 EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor());
485 EXPECT_FLOAT_EQ(kIdleThicknessScale, 485 EXPECT_FLOAT_EQ(kIdleThicknessScale,
486 h_scrollbar_layer_->thumb_thickness_scale_factor()); 486 h_scrollbar_layer_->thumb_thickness_scale_factor());
(...skipping 17 matching lines...) Expand all
504 // the opacity and thicken. 504 // the opacity and thicken.
505 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, 505 TEST_F(ScrollbarAnimationControllerAuraOverlayTest,
506 MoveNearScrollbarWhileFading) { 506 MoveNearScrollbarWhileFading) {
507 base::TimeTicks time; 507 base::TimeTicks time;
508 time += base::TimeDelta::FromSeconds(1); 508 time += base::TimeDelta::FromSeconds(1);
509 509
510 scrollbar_controller_->DidScrollBegin(); 510 scrollbar_controller_->DidScrollBegin();
511 scrollbar_controller_->DidScrollUpdate(false); 511 scrollbar_controller_->DidScrollUpdate(false);
512 scrollbar_controller_->DidScrollEnd(); 512 scrollbar_controller_->DidScrollEnd();
513 513
514 // A fade animation should have been enqueued. Start it. 514 // A fade out animation should have been enqueued. Start it.
515 EXPECT_EQ(kDelayBeforeStarting, client_.delay()); 515 EXPECT_EQ(kFadeOutDelay, client_.delay());
516 EXPECT_FALSE(client_.start_fade().is_null()); 516 EXPECT_FALSE(client_.start_fade().is_null());
517 client_.start_fade().Run(); 517 client_.start_fade().Run();
518 518
519 scrollbar_controller_->Animate(time); 519 scrollbar_controller_->Animate(time);
520 ExpectScrollbarsOpacity(1); 520 ExpectScrollbarsOpacity(1);
521 521
522 // Proceed half way through the fade out animation. 522 // Proceed half way through the fade out animation.
523 time += kFadeDuration / 2; 523 time += kFadeOutDuration / 2;
524 scrollbar_controller_->Animate(time); 524 scrollbar_controller_->Animate(time);
525 ExpectScrollbarsOpacity(.5f); 525 ExpectScrollbarsOpacity(.5f);
526 526
527 // Now move the mouse near the scrollbar. It should reset opacity to 1 527 // Now move the mouse near the scrollbar. It should reset opacity to 1
528 // instantly and start animating to thick. 528 // instantly and start animating to thick.
529 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 1); 529 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 1);
530 ExpectScrollbarsOpacity(1); 530 ExpectScrollbarsOpacity(1);
531 EXPECT_FLOAT_EQ(kIdleThicknessScale, 531 EXPECT_FLOAT_EQ(kIdleThicknessScale,
532 v_scrollbar_layer_->thumb_thickness_scale_factor()); 532 v_scrollbar_layer_->thumb_thickness_scale_factor());
533 EXPECT_FLOAT_EQ(kIdleThicknessScale, 533 EXPECT_FLOAT_EQ(kIdleThicknessScale,
(...skipping 10 matching lines...) Expand all
544 544
545 // Make sure we can't capture scrollbar that's completely faded out. 545 // Make sure we can't capture scrollbar that's completely faded out.
546 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, TestCantCaptureWhenFaded) { 546 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, TestCantCaptureWhenFaded) {
547 base::TimeTicks time; 547 base::TimeTicks time;
548 time += base::TimeDelta::FromSeconds(1); 548 time += base::TimeDelta::FromSeconds(1);
549 549
550 scrollbar_controller_->DidScrollBegin(); 550 scrollbar_controller_->DidScrollBegin();
551 scrollbar_controller_->DidScrollUpdate(false); 551 scrollbar_controller_->DidScrollUpdate(false);
552 scrollbar_controller_->DidScrollEnd(); 552 scrollbar_controller_->DidScrollEnd();
553 553
554 EXPECT_EQ(kDelayBeforeStarting, client_.delay()); 554 EXPECT_EQ(kFadeOutDelay, client_.delay());
555 EXPECT_FALSE(client_.start_fade().is_null()); 555 EXPECT_FALSE(client_.start_fade().is_null());
556 EXPECT_FALSE(client_.start_fade().IsCancelled()); 556 EXPECT_FALSE(client_.start_fade().IsCancelled());
557 client_.start_fade().Run(); 557 client_.start_fade().Run();
558 scrollbar_controller_->Animate(time); 558 scrollbar_controller_->Animate(time);
559 ExpectScrollbarsOpacity(1); 559 ExpectScrollbarsOpacity(1);
560 560
561 // Fade the scrollbar out completely. 561 // Fade the scrollbar out completely.
562 time += kFadeDuration; 562 time += kFadeOutDuration;
563 scrollbar_controller_->Animate(time); 563 scrollbar_controller_->Animate(time);
564 ExpectScrollbarsOpacity(0); 564 ExpectScrollbarsOpacity(0);
565 565
566 // Move mouse over the scrollbar. It shouldn't thicken the scrollbar since 566 // Move mouse over the scrollbar. It shouldn't thicken the scrollbar since
567 // it's completely faded out. 567 // it's completely faded out.
568 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 0); 568 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 0);
569 scrollbar_controller_->Animate(time); 569 scrollbar_controller_->Animate(time);
570 time += kThinningDuration; 570 time += kThinningDuration;
571 scrollbar_controller_->Animate(time); 571 scrollbar_controller_->Animate(time);
572 ExpectScrollbarsOpacity(0); 572 ExpectScrollbarsOpacity(0);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 EXPECT_TRUE(client_.start_fade().is_null() || 623 EXPECT_TRUE(client_.start_fade().is_null() ||
624 client_.start_fade().IsCancelled()); 624 client_.start_fade().IsCancelled());
625 625
626 scrollbar_controller_->Animate(time); 626 scrollbar_controller_->Animate(time);
627 ExpectScrollbarsOpacity(1); 627 ExpectScrollbarsOpacity(1);
628 EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor()); 628 EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor());
629 EXPECT_FLOAT_EQ(kIdleThicknessScale, 629 EXPECT_FLOAT_EQ(kIdleThicknessScale,
630 h_scrollbar_layer_->thumb_thickness_scale_factor()); 630 h_scrollbar_layer_->thumb_thickness_scale_factor());
631 631
632 // Scrollbar should still be thick and visible. 632 // Scrollbar should still be thick and visible.
633 time += kFadeDuration; 633 time += kFadeOutDuration;
634 scrollbar_controller_->Animate(time); 634 scrollbar_controller_->Animate(time);
635 ExpectScrollbarsOpacity(1); 635 ExpectScrollbarsOpacity(1);
636 EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor()); 636 EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor());
637 EXPECT_FLOAT_EQ(kIdleThicknessScale, 637 EXPECT_FLOAT_EQ(kIdleThicknessScale,
638 h_scrollbar_layer_->thumb_thickness_scale_factor()); 638 h_scrollbar_layer_->thumb_thickness_scale_factor());
639 } 639 }
640 640
641 // Tests that main thread scroll updates immediatley queue a fade animation 641 // Tests that main thread scroll updates immediatley queue a fade out animation
642 // without requiring a ScrollEnd. 642 // without requiring a ScrollEnd.
643 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, 643 TEST_F(ScrollbarAnimationControllerAuraOverlayTest,
644 MainThreadScrollQueuesFade) { 644 MainThreadScrollQueuesFade) {
645 ASSERT_TRUE(client_.start_fade().is_null()); 645 ASSERT_TRUE(client_.start_fade().is_null());
646 646
647 // A ScrollUpdate without a ScrollBegin indicates a main thread scroll update 647 // A ScrollUpdate without a ScrollBegin indicates a main thread scroll update
648 // so we should schedule a fade animation without waiting for a ScrollEnd 648 // so we should schedule a fade out animation without waiting for a ScrollEnd
649 // (which will never come). 649 // (which will never come).
650 scrollbar_controller_->DidScrollUpdate(false); 650 scrollbar_controller_->DidScrollUpdate(false);
651 EXPECT_FALSE(client_.start_fade().is_null()); 651 EXPECT_FALSE(client_.start_fade().is_null());
652 EXPECT_EQ(kDelayBeforeStarting, client_.delay()); 652 EXPECT_EQ(kFadeOutDelay, client_.delay());
653 653
654 client_.start_fade().Reset(); 654 client_.start_fade().Reset();
655 655
656 // If we got a ScrollBegin, we shouldn't schedule the fade animation until we 656 // If we got a ScrollBegin, we shouldn't schedule the fade out animation until
657 // get a corresponding ScrollEnd. 657 // we get a corresponding ScrollEnd.
658 scrollbar_controller_->DidScrollBegin(); 658 scrollbar_controller_->DidScrollBegin();
659 scrollbar_controller_->DidScrollUpdate(false); 659 scrollbar_controller_->DidScrollUpdate(false);
660 EXPECT_TRUE(client_.start_fade().is_null()); 660 EXPECT_TRUE(client_.start_fade().is_null());
661 scrollbar_controller_->DidScrollEnd(); 661 scrollbar_controller_->DidScrollEnd();
662 EXPECT_FALSE(client_.start_fade().is_null()); 662 EXPECT_FALSE(client_.start_fade().is_null());
663 EXPECT_EQ(kDelayBeforeStarting, client_.delay()); 663 EXPECT_EQ(kFadeOutDelay, client_.delay());
664 } 664 }
665 665
666 // Make sure that if the scroll update is as a result of a resize, we use the 666 // Make sure that if the scroll update is as a result of a resize, we use the
667 // resize delay time instead of the default one. 667 // resize delay time instead of the default one.
668 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, ResizeFadeDuration) { 668 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, ResizeFadeDuration) {
669 ASSERT_TRUE(client_.delay().is_zero()); 669 ASSERT_TRUE(client_.delay().is_zero());
670 670
671 scrollbar_controller_->DidScrollUpdate(true); 671 scrollbar_controller_->DidScrollUpdate(true);
672 EXPECT_FALSE(client_.start_fade().is_null()); 672 EXPECT_FALSE(client_.start_fade().is_null());
673 EXPECT_EQ(kResizeDelayBeforeStarting, client_.delay()); 673 EXPECT_EQ(kResizeFadeOutDelay, client_.delay());
674 674
675 client_.delay() = base::TimeDelta(); 675 client_.delay() = base::TimeDelta();
676 676
677 // We should use the gesture delay rather than the resize delay if we're in a 677 // We should use the gesture delay rather than the resize delay if we're in a
678 // gesture scroll, even if the resize param is set. 678 // gesture scroll, even if the resize param is set.
679 scrollbar_controller_->DidScrollBegin(); 679 scrollbar_controller_->DidScrollBegin();
680 scrollbar_controller_->DidScrollUpdate(true); 680 scrollbar_controller_->DidScrollUpdate(true);
681 scrollbar_controller_->DidScrollEnd(); 681 scrollbar_controller_->DidScrollEnd();
682 682
683 EXPECT_FALSE(client_.start_fade().is_null()); 683 EXPECT_FALSE(client_.start_fade().is_null());
684 EXPECT_EQ(kDelayBeforeStarting, client_.delay()); 684 EXPECT_EQ(kFadeOutDelay, client_.delay());
685 } 685 }
686 686
687 // Tests that the fade effect is animated. 687 // Tests that the fade effect is animated.
688 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, FadeAnimated) { 688 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, FadeAnimated) {
689 base::TimeTicks time; 689 base::TimeTicks time;
690 time += base::TimeDelta::FromSeconds(1); 690 time += base::TimeDelta::FromSeconds(1);
691 691
692 // Scroll to make the scrollbars visible. 692 // Scroll to make the scrollbars visible.
693 scrollbar_controller_->DidScrollBegin(); 693 scrollbar_controller_->DidScrollBegin();
694 scrollbar_controller_->DidScrollUpdate(false); 694 scrollbar_controller_->DidScrollUpdate(false);
695 scrollbar_controller_->DidScrollEnd(); 695 scrollbar_controller_->DidScrollEnd();
696 696
697 // Appearance is instant. 697 // Appearance is instant.
698 ExpectScrollbarsOpacity(1); 698 ExpectScrollbarsOpacity(1);
699 699
700 // An animation should have been enqueued. 700 // An fade out animation should have been enqueued.
701 EXPECT_EQ(kDelayBeforeStarting, client_.delay()); 701 EXPECT_EQ(kFadeOutDelay, client_.delay());
702 EXPECT_FALSE(client_.start_fade().is_null()); 702 EXPECT_FALSE(client_.start_fade().is_null());
703 client_.start_fade().Run(); 703 client_.start_fade().Run();
704 704
705 // Test that at half the fade duration time, the opacity is at half. 705 // Test that at half the fade duration time, the opacity is at half.
706 scrollbar_controller_->Animate(time); 706 scrollbar_controller_->Animate(time);
707 ExpectScrollbarsOpacity(1); 707 ExpectScrollbarsOpacity(1);
708 708
709 time += kFadeDuration / 2; 709 time += kFadeOutDuration / 2;
710 scrollbar_controller_->Animate(time); 710 scrollbar_controller_->Animate(time);
711 ExpectScrollbarsOpacity(.5f); 711 ExpectScrollbarsOpacity(.5f);
712 712
713 time += kFadeDuration / 2; 713 time += kFadeOutDuration / 2;
714 scrollbar_controller_->Animate(time); 714 scrollbar_controller_->Animate(time);
715 ExpectScrollbarsOpacity(0); 715 ExpectScrollbarsOpacity(0);
716 } 716 }
717 717
718 // Tests that the controller tells the client when the scrollbars hide/show. 718 // Tests that the controller tells the client when the scrollbars hide/show.
719 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, NotifyChangedVisibility) { 719 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, NotifyChangedVisibility) {
720 base::TimeTicks time; 720 base::TimeTicks time;
721 time += base::TimeDelta::FromSeconds(1); 721 time += base::TimeDelta::FromSeconds(1);
722 722
723 EXPECT_CALL(client_, DidChangeScrollbarVisibility()).Times(1); 723 EXPECT_CALL(client_, DidChangeScrollbarVisibility()).Times(1);
724 // Scroll to make the scrollbars visible. 724 // Scroll to make the scrollbars visible.
725 scrollbar_controller_->DidScrollBegin(); 725 scrollbar_controller_->DidScrollBegin();
726 scrollbar_controller_->DidScrollUpdate(false); 726 scrollbar_controller_->DidScrollUpdate(false);
727 EXPECT_FALSE(scrollbar_controller_->ScrollbarsHidden()); 727 EXPECT_FALSE(scrollbar_controller_->ScrollbarsHidden());
728 Mock::VerifyAndClearExpectations(&client_); 728 Mock::VerifyAndClearExpectations(&client_);
729 729
730 scrollbar_controller_->DidScrollEnd(); 730 scrollbar_controller_->DidScrollEnd();
731 731
732 // Play out the fade animation. We shouldn't notify that the scrollbars are 732 // Play out the fade out animation. We shouldn't notify that the scrollbars
733 // hidden until the animation is completly over. We can (but don't have to) 733 // are hidden until the animation is completly over. We can (but don't have
734 // notify during the animation that the scrollbars are still visible. 734 // to) notify during the animation that the scrollbars are still visible.
735 EXPECT_CALL(client_, DidChangeScrollbarVisibility()).Times(0); 735 EXPECT_CALL(client_, DidChangeScrollbarVisibility()).Times(0);
736 ASSERT_FALSE(client_.start_fade().is_null()); 736 ASSERT_FALSE(client_.start_fade().is_null());
737 client_.start_fade().Run(); 737 client_.start_fade().Run();
738 scrollbar_controller_->Animate(time); 738 scrollbar_controller_->Animate(time);
739 time += kFadeDuration / 4; 739 time += kFadeOutDuration / 4;
740 EXPECT_FALSE(scrollbar_controller_->ScrollbarsHidden()); 740 EXPECT_FALSE(scrollbar_controller_->ScrollbarsHidden());
741 scrollbar_controller_->Animate(time); 741 scrollbar_controller_->Animate(time);
742 time += kFadeDuration / 4; 742 time += kFadeOutDuration / 4;
743 EXPECT_FALSE(scrollbar_controller_->ScrollbarsHidden()); 743 EXPECT_FALSE(scrollbar_controller_->ScrollbarsHidden());
744 scrollbar_controller_->Animate(time); 744 scrollbar_controller_->Animate(time);
745 time += kFadeDuration / 4; 745 time += kFadeOutDuration / 4;
746 EXPECT_FALSE(scrollbar_controller_->ScrollbarsHidden()); 746 EXPECT_FALSE(scrollbar_controller_->ScrollbarsHidden());
747 scrollbar_controller_->Animate(time); 747 scrollbar_controller_->Animate(time);
748 ExpectScrollbarsOpacity(.25f); 748 ExpectScrollbarsOpacity(.25f);
749 Mock::VerifyAndClearExpectations(&client_); 749 Mock::VerifyAndClearExpectations(&client_);
750 750
751 EXPECT_CALL(client_, DidChangeScrollbarVisibility()).Times(1); 751 EXPECT_CALL(client_, DidChangeScrollbarVisibility()).Times(1);
752 time += kFadeDuration / 4; 752 time += kFadeOutDuration / 4;
753 scrollbar_controller_->Animate(time); 753 scrollbar_controller_->Animate(time);
754 EXPECT_TRUE(scrollbar_controller_->ScrollbarsHidden()); 754 EXPECT_TRUE(scrollbar_controller_->ScrollbarsHidden());
755 ExpectScrollbarsOpacity(0); 755 ExpectScrollbarsOpacity(0);
756 Mock::VerifyAndClearExpectations(&client_); 756 Mock::VerifyAndClearExpectations(&client_);
757 757
758 // Calling DidScrollUpdate without a begin (i.e. update from commit) should 758 // Calling DidScrollUpdate without a begin (i.e. update from commit) should
759 // also notify. 759 // also notify.
760 EXPECT_CALL(client_, DidChangeScrollbarVisibility()).Times(1); 760 EXPECT_CALL(client_, DidChangeScrollbarVisibility()).Times(1);
761 scrollbar_controller_->DidScrollUpdate(false); 761 scrollbar_controller_->DidScrollUpdate(false);
762 EXPECT_FALSE(scrollbar_controller_->ScrollbarsHidden()); 762 EXPECT_FALSE(scrollbar_controller_->ScrollbarsHidden());
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
845 HORIZONTAL, kDefaultMouseMoveDistanceToTriggerAnimation); 845 HORIZONTAL, kDefaultMouseMoveDistanceToTriggerAnimation);
846 scrollbar_controller_->Animate(time); 846 scrollbar_controller_->Animate(time);
847 time += kThinningDuration; 847 time += kThinningDuration;
848 scrollbar_controller_->Animate(time); 848 scrollbar_controller_->Animate(time);
849 ExpectScrollbarsOpacity(1); 849 ExpectScrollbarsOpacity(1);
850 EXPECT_FLOAT_EQ(kIdleThicknessScale, 850 EXPECT_FLOAT_EQ(kIdleThicknessScale,
851 v_scrollbar_layer_->thumb_thickness_scale_factor()); 851 v_scrollbar_layer_->thumb_thickness_scale_factor());
852 EXPECT_FLOAT_EQ(kIdleThicknessScale, 852 EXPECT_FLOAT_EQ(kIdleThicknessScale,
853 h_scrollbar_layer_->thumb_thickness_scale_factor()); 853 h_scrollbar_layer_->thumb_thickness_scale_factor());
854 854
855 // An animation should have been enqueued. 855 // An fade out animation should have been enqueued.
856 EXPECT_FALSE(client_.start_fade().is_null()); 856 EXPECT_FALSE(client_.start_fade().is_null());
857 EXPECT_EQ(kDelayBeforeStarting, client_.delay()); 857 EXPECT_EQ(kFadeOutDelay, client_.delay());
858 } 858 }
859 859
860 // Move mouse near both scrollbars at the same time. 860 // Move mouse near both scrollbars at the same time.
861 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, MouseNearBoth) { 861 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, MouseNearBoth) {
862 base::TimeTicks time; 862 base::TimeTicks time;
863 time += base::TimeDelta::FromSeconds(1); 863 time += base::TimeDelta::FromSeconds(1);
864 864
865 // Scroll to make the scrollbars visible. 865 // Scroll to make the scrollbars visible.
866 scrollbar_controller_->DidScrollBegin(); 866 scrollbar_controller_->DidScrollBegin();
867 scrollbar_controller_->DidScrollUpdate(false); 867 scrollbar_controller_->DidScrollUpdate(false);
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
937 937
938 // Horizontal scrollbar animate to thin. 938 // Horizontal scrollbar animate to thin.
939 time += kThinningDuration; 939 time += kThinningDuration;
940 scrollbar_controller_->Animate(time); 940 scrollbar_controller_->Animate(time);
941 ExpectScrollbarsOpacity(1); 941 ExpectScrollbarsOpacity(1);
942 EXPECT_FLOAT_EQ(kIdleThicknessScale, 942 EXPECT_FLOAT_EQ(kIdleThicknessScale,
943 v_scrollbar_layer_->thumb_thickness_scale_factor()); 943 v_scrollbar_layer_->thumb_thickness_scale_factor());
944 EXPECT_FLOAT_EQ(kIdleThicknessScale, 944 EXPECT_FLOAT_EQ(kIdleThicknessScale,
945 h_scrollbar_layer_->thumb_thickness_scale_factor()); 945 h_scrollbar_layer_->thumb_thickness_scale_factor());
946 946
947 // An animation should have been enqueued. 947 // An fade out animation should have been enqueued.
948 EXPECT_FALSE(client_.start_fade().is_null()); 948 EXPECT_FALSE(client_.start_fade().is_null());
949 EXPECT_EQ(kDelayBeforeStarting, client_.delay()); 949 EXPECT_EQ(kFadeOutDelay, client_.delay());
950 } 950 }
951 951
952 // Ensure we have a delay fadeout animation after mouse leave without a mouse 952 // Ensure we have a delay fadeout animation after mouse leave without a mouse
953 // move. 953 // move.
954 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, MouseLeaveFadeOut) { 954 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, MouseLeaveFadeOut) {
955 base::TimeTicks time; 955 base::TimeTicks time;
956 time += base::TimeDelta::FromSeconds(1); 956 time += base::TimeDelta::FromSeconds(1);
957 957
958 // Move mouse near scrollbar. 958 // Move mouse near scrollbar.
959 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 1); 959 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 1);
960 960
961 // Scroll to make the scrollbars visible. 961 // Scroll to make the scrollbars visible.
962 scrollbar_controller_->DidScrollBegin(); 962 scrollbar_controller_->DidScrollBegin();
963 scrollbar_controller_->DidScrollUpdate(false); 963 scrollbar_controller_->DidScrollUpdate(false);
964 scrollbar_controller_->DidScrollEnd(); 964 scrollbar_controller_->DidScrollEnd();
965 965
966 // Should not have delay fadeout animation. 966 // Should not have delay fadeout animation.
967 EXPECT_TRUE(client_.start_fade().is_null() || 967 EXPECT_TRUE(client_.start_fade().is_null() ||
968 client_.start_fade().IsCancelled()); 968 client_.start_fade().IsCancelled());
969 969
970 // Mouse leave. 970 // Mouse leave.
971 scrollbar_controller_->DidMouseLeave(); 971 scrollbar_controller_->DidMouseLeave();
972 972
973 // An animation should have been enqueued. 973 // An fade out animation should have been enqueued.
974 EXPECT_FALSE(client_.start_fade().is_null()); 974 EXPECT_FALSE(client_.start_fade().is_null());
975 EXPECT_EQ(kDelayBeforeStarting, client_.delay()); 975 EXPECT_EQ(kFadeOutDelay, client_.delay());
976 }
977
978 // Scrollbars should schedule a delay fade in when mouse hover hidden scrollbar.
979 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, BasicMouseHoverFadeIn) {
980 base::TimeTicks time;
981 time += base::TimeDelta::FromSeconds(1);
982
983 // Move mouse over scrollbar.
984 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 0);
985
986 // An fade in animation should have been enqueued.
987 EXPECT_FALSE(client_.start_fade().is_null());
988 EXPECT_EQ(kFadeInDelay, client_.delay());
989
990 // Play the delay animation.
991 client_.start_fade().Run();
992 EXPECT_FALSE(scrollbar_controller_->ScrollbarsHidden());
993 }
994
995 // Scrollbars should cancel delay fade in when mouse hover hidden scrollbar then
996 // move out.
997 TEST_F(ScrollbarAnimationControllerAuraOverlayTest,
bokan 2017/02/27 23:13:56 Please add another test that moving the mouse with
998 MouseHoverThenOutShouldCancelFadeIn) {
999 base::TimeTicks time;
1000 time += base::TimeDelta::FromSeconds(1);
1001
1002 // Move mouse over scrollbar.
1003 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 0);
1004
1005 // An fade in animation should have been enqueued.
1006 EXPECT_FALSE(client_.start_fade().is_null());
1007 EXPECT_EQ(kFadeInDelay, client_.delay());
1008
1009 // Move mouse out of scrollbar,delay fade in should be canceled.
1010 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 1);
1011 EXPECT_TRUE(client_.start_fade().is_null() ||
1012 client_.start_fade().IsCancelled());
976 } 1013 }
977 1014
978 class ScrollbarAnimationControllerAndroidTest 1015 class ScrollbarAnimationControllerAndroidTest
979 : public testing::Test, 1016 : public testing::Test,
980 public ScrollbarAnimationControllerClient { 1017 public ScrollbarAnimationControllerClient {
981 public: 1018 public:
982 ScrollbarAnimationControllerAndroidTest() 1019 ScrollbarAnimationControllerAndroidTest()
983 : host_impl_(&task_runner_provider_, &task_graph_runner_), 1020 : host_impl_(&task_runner_provider_, &task_graph_runner_),
984 did_request_redraw_(false), 1021 did_request_redraw_(false),
985 did_request_animate_(false) {} 1022 did_request_animate_(false) {}
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
1454 EXPECT_FLOAT_EQ(1, scrollbar_layer_->Opacity()); 1491 EXPECT_FLOAT_EQ(1, scrollbar_layer_->Opacity());
1455 1492
1456 time += base::TimeDelta::FromSeconds(1); 1493 time += base::TimeDelta::FromSeconds(1);
1457 scrollbar_controller_->DidScrollEnd(); 1494 scrollbar_controller_->DidScrollEnd();
1458 EXPECT_FALSE(did_request_animate_); 1495 EXPECT_FALSE(did_request_animate_);
1459 EXPECT_FLOAT_EQ(1, scrollbar_layer_->Opacity()); 1496 EXPECT_FLOAT_EQ(1, scrollbar_layer_->Opacity());
1460 } 1497 }
1461 1498
1462 } // namespace 1499 } // namespace
1463 } // namespace cc 1500 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698