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

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

Issue 2841943002: Overlay scrollbars expand only when mouse is near thumb (Closed)
Patch Set: bokan comments#8 addressed 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/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"
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 =
27 SingleScrollbarAnimationControllerThinning::
28 kDefaultMouseMoveDistanceToTriggerAnimation;
29 const float kMouseMoveDistanceToTriggerFadeIn = 26 const float kMouseMoveDistanceToTriggerFadeIn =
30 ScrollbarAnimationController::kMouseMoveDistanceToTriggerFadeIn; 27 ScrollbarAnimationController::kMouseMoveDistanceToTriggerFadeIn;
28 const float kMouseMoveDistanceToTriggerExpand =
29 SingleScrollbarAnimationControllerThinning::
30 kMouseMoveDistanceToTriggerExpand;
31 const int kThumbThickness = 10; 31 const int kThumbThickness = 10;
32 32
33 class MockScrollbarAnimationControllerClient 33 class MockScrollbarAnimationControllerClient
34 : public ScrollbarAnimationControllerClient { 34 : public ScrollbarAnimationControllerClient {
35 public: 35 public:
36 explicit MockScrollbarAnimationControllerClient(LayerTreeHostImpl* host_impl) 36 explicit MockScrollbarAnimationControllerClient(LayerTreeHostImpl* host_impl)
37 : host_impl_(host_impl) {} 37 : host_impl_(host_impl) {}
38 virtual ~MockScrollbarAnimationControllerClient() {} 38 virtual ~MockScrollbarAnimationControllerClient() {}
39 39
40 void PostDelayedScrollbarAnimationTask(const base::Closure& start_fade, 40 void PostDelayedScrollbarAnimationTask(const base::Closure& start_fade,
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 LayerImpl::Create(host_impl_.active_tree(), 1); 80 LayerImpl::Create(host_impl_.active_tree(), 1);
81 std::unique_ptr<LayerImpl> clip = 81 std::unique_ptr<LayerImpl> clip =
82 LayerImpl::Create(host_impl_.active_tree(), 2); 82 LayerImpl::Create(host_impl_.active_tree(), 2);
83 clip_layer_ = clip.get(); 83 clip_layer_ = clip.get();
84 scroll_layer->SetElementId( 84 scroll_layer->SetElementId(
85 LayerIdToElementIdForTesting(scroll_layer->id())); 85 LayerIdToElementIdForTesting(scroll_layer->id()));
86 scroll_layer->SetScrollClipLayer(clip_layer_->id()); 86 scroll_layer->SetScrollClipLayer(clip_layer_->id());
87 LayerImpl* scroll_layer_ptr = scroll_layer.get(); 87 LayerImpl* scroll_layer_ptr = scroll_layer.get();
88 88
89 const int kTrackStart = 0; 89 const int kTrackStart = 0;
90 const int kTrackLength = 100;
90 const bool kIsLeftSideVerticalScrollbar = false; 91 const bool kIsLeftSideVerticalScrollbar = false;
91 const bool kIsOverlayScrollbar = true; 92 const bool kIsOverlayScrollbar = true;
92 93
93 std::unique_ptr<SolidColorScrollbarLayerImpl> h_scrollbar = 94 std::unique_ptr<SolidColorScrollbarLayerImpl> h_scrollbar =
94 SolidColorScrollbarLayerImpl::Create( 95 SolidColorScrollbarLayerImpl::Create(
95 host_impl_.active_tree(), 3, HORIZONTAL, kThumbThickness, 96 host_impl_.active_tree(), 3, HORIZONTAL, kThumbThickness,
96 kTrackStart, kIsLeftSideVerticalScrollbar, kIsOverlayScrollbar); 97 kTrackStart, kIsLeftSideVerticalScrollbar, kIsOverlayScrollbar);
97 std::unique_ptr<SolidColorScrollbarLayerImpl> v_scrollbar = 98 std::unique_ptr<SolidColorScrollbarLayerImpl> v_scrollbar =
98 SolidColorScrollbarLayerImpl::Create( 99 SolidColorScrollbarLayerImpl::Create(
99 host_impl_.active_tree(), 4, VERTICAL, kThumbThickness, kTrackStart, 100 host_impl_.active_tree(), 4, VERTICAL, kThumbThickness, kTrackStart,
100 kIsLeftSideVerticalScrollbar, kIsOverlayScrollbar); 101 kIsLeftSideVerticalScrollbar, kIsOverlayScrollbar);
101 v_scrollbar_layer_ = v_scrollbar.get(); 102 v_scrollbar_layer_ = v_scrollbar.get();
102 h_scrollbar_layer_ = h_scrollbar.get(); 103 h_scrollbar_layer_ = h_scrollbar.get();
103 104
104 scroll_layer->test_properties()->AddChild(std::move(v_scrollbar)); 105 scroll_layer->test_properties()->AddChild(std::move(v_scrollbar));
105 scroll_layer->test_properties()->AddChild(std::move(h_scrollbar)); 106 scroll_layer->test_properties()->AddChild(std::move(h_scrollbar));
106 clip_layer_->test_properties()->AddChild(std::move(scroll_layer)); 107 clip_layer_->test_properties()->AddChild(std::move(scroll_layer));
107 host_impl_.active_tree()->SetRootLayerForTesting(std::move(clip)); 108 host_impl_.active_tree()->SetRootLayerForTesting(std::move(clip));
108 109
110 v_scrollbar_layer_->SetBounds(gfx::Size(kThumbThickness, kTrackLength));
111 v_scrollbar_layer_->SetPosition(gfx::PointF(90, 0));
109 v_scrollbar_layer_->SetScrollElementId(scroll_layer_ptr->element_id()); 112 v_scrollbar_layer_->SetScrollElementId(scroll_layer_ptr->element_id());
113 v_scrollbar_layer_->test_properties()->opacity_can_animate = true;
114
115 h_scrollbar_layer_->SetBounds(gfx::Size(kTrackLength, kThumbThickness));
116 h_scrollbar_layer_->SetPosition(gfx::PointF(0, 90));
110 h_scrollbar_layer_->SetScrollElementId(scroll_layer_ptr->element_id()); 117 h_scrollbar_layer_->SetScrollElementId(scroll_layer_ptr->element_id());
111 v_scrollbar_layer_->test_properties()->opacity_can_animate = true;
112 h_scrollbar_layer_->test_properties()->opacity_can_animate = true; 118 h_scrollbar_layer_->test_properties()->opacity_can_animate = true;
119
113 clip_layer_->SetBounds(gfx::Size(100, 100)); 120 clip_layer_->SetBounds(gfx::Size(100, 100));
114 scroll_layer_ptr->SetBounds(gfx::Size(200, 200)); 121 scroll_layer_ptr->SetBounds(gfx::Size(200, 200));
115 host_impl_.active_tree()->BuildLayerListAndPropertyTreesForTesting(); 122 host_impl_.active_tree()->BuildLayerListAndPropertyTreesForTesting();
116 123
117 scrollbar_controller_ = ScrollbarAnimationController:: 124 scrollbar_controller_ = ScrollbarAnimationController::
118 CreateScrollbarAnimationControllerAuraOverlay( 125 CreateScrollbarAnimationControllerAuraOverlay(
119 scroll_layer_ptr->element_id(), &client_, kFadeDelay, 126 scroll_layer_ptr->element_id(), &client_, kFadeDelay,
120 kResizeFadeOutDelay, kFadeDuration, kThinningDuration); 127 kResizeFadeOutDelay, kFadeDuration, kThinningDuration);
128
129 v_scrollbar_layer_->SetCurrentPos(0);
130 h_scrollbar_layer_->SetCurrentPos(0);
131 }
132
133 // Return a point with given offset from the top-left of vertical scrollbar.
134 gfx::PointF NearVerticalScrollbarBegin(float offset_x, float offset_y) {
135 gfx::PointF p(90, 0);
136 p.Offset(offset_x, offset_y);
137 return p;
138 }
139
140 // Return a point with given offset from the bottom-left of vertical
141 // scrollbar.
142 gfx::PointF NearVerticalScrollbarEnd(float offset_x, float offset_y) {
143 gfx::PointF p(90, 90);
144 p.Offset(offset_x, offset_y);
145 return p;
146 }
147
148 // Return a point with given offset from the top-left of horizontal scrollbar.
149 gfx::PointF NearHorizontalScrollbarBegin(float offset_x, float offset_y) {
150 gfx::PointF p(0, 90);
151 p.Offset(offset_x, offset_y);
152 return p;
121 } 153 }
122 154
123 FakeImplTaskRunnerProvider task_runner_provider_; 155 FakeImplTaskRunnerProvider task_runner_provider_;
124 TestTaskGraphRunner task_graph_runner_; 156 TestTaskGraphRunner task_graph_runner_;
125 FakeLayerTreeHostImpl host_impl_; 157 FakeLayerTreeHostImpl host_impl_;
126 std::unique_ptr<ScrollbarAnimationController> scrollbar_controller_; 158 std::unique_ptr<ScrollbarAnimationController> scrollbar_controller_;
127 LayerImpl* clip_layer_; 159 LayerImpl* clip_layer_;
128 SolidColorScrollbarLayerImpl* v_scrollbar_layer_; 160 SolidColorScrollbarLayerImpl* v_scrollbar_layer_;
129 SolidColorScrollbarLayerImpl* h_scrollbar_layer_; 161 SolidColorScrollbarLayerImpl* h_scrollbar_layer_;
130 NiceMock<MockScrollbarAnimationControllerClient> client_; 162 NiceMock<MockScrollbarAnimationControllerClient> client_;
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 284
253 // Scrollbar should fade out over kFadeDuration. 285 // Scrollbar should fade out over kFadeDuration.
254 scrollbar_controller_->Animate(time); 286 scrollbar_controller_->Animate(time);
255 time += kFadeDuration; 287 time += kFadeDuration;
256 scrollbar_controller_->Animate(time); 288 scrollbar_controller_->Animate(time);
257 289
258 ExpectScrollbarsOpacity(0); 290 ExpectScrollbarsOpacity(0);
259 EXPECT_TRUE(scrollbar_controller_->ScrollbarsHidden()); 291 EXPECT_TRUE(scrollbar_controller_->ScrollbarsHidden());
260 } 292 }
261 293
262 // Scroll content. Move the mouse near the scrollbar and confirm it becomes 294 // Scroll content. Move the mouse near the scrollbar track but not near thumb
263 // thick. Ensure it remains visible as long as the mouse is near the scrollbar. 295 // and confirm it stay thin. Move the mouse near the scrollbar thumb and
296 // confirm it becomes thick.
297 TEST_F(ScrollbarAnimationControllerAuraOverlayTest,
298 MoveNearTrackThenNearThumb) {
299 base::TimeTicks time;
300 time += base::TimeDelta::FromSeconds(1);
301
302 scrollbar_controller_->DidScrollBegin();
303 scrollbar_controller_->DidScrollUpdate();
304 scrollbar_controller_->DidScrollEnd();
305
306 // An fade out animation should have been enqueued.
307 EXPECT_EQ(kFadeDelay, client_.delay());
308 EXPECT_FALSE(client_.start_fade().is_null());
309 EXPECT_FALSE(client_.start_fade().IsCancelled());
310
311 // Now move the mouse near the vertical scrollbar track. This should cancel
312 // the currently queued fading animation and stay scrollbar thin.
313 scrollbar_controller_->DidMouseMove(NearVerticalScrollbarEnd(-1, 0));
314 ExpectScrollbarsOpacity(1);
315 EXPECT_FLOAT_EQ(kIdleThicknessScale,
316 v_scrollbar_layer_->thumb_thickness_scale_factor());
317 EXPECT_FLOAT_EQ(kIdleThicknessScale,
318 h_scrollbar_layer_->thumb_thickness_scale_factor());
319 EXPECT_TRUE(client_.start_fade().IsCancelled());
320
321 scrollbar_controller_->Animate(time);
322 time += kThinningDuration;
323 scrollbar_controller_->Animate(time);
324
325 EXPECT_FLOAT_EQ(kIdleThicknessScale,
326 v_scrollbar_layer_->thumb_thickness_scale_factor());
327 EXPECT_FLOAT_EQ(kIdleThicknessScale,
328 h_scrollbar_layer_->thumb_thickness_scale_factor());
329
330 scrollbar_controller_->DidMouseMove(NearVerticalScrollbarBegin(-1, 0));
331 scrollbar_controller_->Animate(time);
332 time += kThinningDuration;
333 scrollbar_controller_->Animate(time);
334
335 EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor());
336 EXPECT_FLOAT_EQ(kIdleThicknessScale,
337 h_scrollbar_layer_->thumb_thickness_scale_factor());
338
339 scrollbar_controller_->DidMouseMove(NearVerticalScrollbarEnd(-1, 0));
340 EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor());
341 EXPECT_FLOAT_EQ(kIdleThicknessScale,
342 h_scrollbar_layer_->thumb_thickness_scale_factor());
343 EXPECT_TRUE(client_.start_fade().IsCancelled());
344
345 scrollbar_controller_->Animate(time);
346 time += kThinningDuration;
347 scrollbar_controller_->Animate(time);
348
349 EXPECT_FLOAT_EQ(kIdleThicknessScale,
350 v_scrollbar_layer_->thumb_thickness_scale_factor());
351 EXPECT_FLOAT_EQ(kIdleThicknessScale,
352 h_scrollbar_layer_->thumb_thickness_scale_factor());
353 }
354
355 // Scroll content. Move the mouse near the scrollbar thumb and confirm it
356 // becomes thick. Ensure it remains visible as long as the mouse is near the
357 // scrollbar.
264 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, MoveNearAndDontFadeOut) { 358 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, MoveNearAndDontFadeOut) {
265 base::TimeTicks time; 359 base::TimeTicks time;
266 time += base::TimeDelta::FromSeconds(1); 360 time += base::TimeDelta::FromSeconds(1);
267 361
268 scrollbar_controller_->DidScrollBegin(); 362 scrollbar_controller_->DidScrollBegin();
269 scrollbar_controller_->DidScrollUpdate(); 363 scrollbar_controller_->DidScrollUpdate();
270 scrollbar_controller_->DidScrollEnd(); 364 scrollbar_controller_->DidScrollEnd();
271 365
272 // An fade out animation should have been enqueued. 366 // An fade out animation should have been enqueued.
273 EXPECT_EQ(kFadeDelay, client_.delay()); 367 EXPECT_EQ(kFadeDelay, client_.delay());
274 EXPECT_FALSE(client_.start_fade().is_null()); 368 EXPECT_FALSE(client_.start_fade().is_null());
275 EXPECT_FALSE(client_.start_fade().IsCancelled()); 369 EXPECT_FALSE(client_.start_fade().IsCancelled());
276 370
277 // Now move the mouse near the scrollbar. This should cancel the currently 371 // Now move the mouse near the vertical scrollbar thumb. This should cancel
278 // queued fading animation and start animating thickness. 372 // the currently queued fading animation and start animating thickness.
279 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 1); 373 scrollbar_controller_->DidMouseMove(NearVerticalScrollbarBegin(-1, 0));
280 ExpectScrollbarsOpacity(1); 374 ExpectScrollbarsOpacity(1);
281 EXPECT_FLOAT_EQ(kIdleThicknessScale, 375 EXPECT_FLOAT_EQ(kIdleThicknessScale,
282 v_scrollbar_layer_->thumb_thickness_scale_factor()); 376 v_scrollbar_layer_->thumb_thickness_scale_factor());
283 EXPECT_FLOAT_EQ(kIdleThicknessScale, 377 EXPECT_FLOAT_EQ(kIdleThicknessScale,
284 h_scrollbar_layer_->thumb_thickness_scale_factor()); 378 h_scrollbar_layer_->thumb_thickness_scale_factor());
285 EXPECT_TRUE(client_.start_fade().IsCancelled()); 379 EXPECT_TRUE(client_.start_fade().IsCancelled());
286 380
287 // Vertical scrollbar should become thick. 381 // Vertical scrollbar should become thick.
288 scrollbar_controller_->Animate(time); 382 scrollbar_controller_->Animate(time);
289 time += kThinningDuration; 383 time += kThinningDuration;
(...skipping 18 matching lines...) Expand all
308 402
309 scrollbar_controller_->DidScrollBegin(); 403 scrollbar_controller_->DidScrollBegin();
310 scrollbar_controller_->DidScrollUpdate(); 404 scrollbar_controller_->DidScrollUpdate();
311 scrollbar_controller_->DidScrollEnd(); 405 scrollbar_controller_->DidScrollEnd();
312 406
313 // An fade out animation should have been enqueued. 407 // An fade out animation should have been enqueued.
314 EXPECT_EQ(kFadeDelay, client_.delay()); 408 EXPECT_EQ(kFadeDelay, client_.delay());
315 EXPECT_FALSE(client_.start_fade().is_null()); 409 EXPECT_FALSE(client_.start_fade().is_null());
316 EXPECT_FALSE(client_.start_fade().IsCancelled()); 410 EXPECT_FALSE(client_.start_fade().IsCancelled());
317 411
318 // Now move the mouse over the scrollbar. This should cancel the currently 412 // Now move the mouse over the vertical scrollbar thumb. This should cancel
319 // queued fading animation and start animating thickness. 413 // the currently queued fading animation and start animating thickness.
320 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 0); 414 scrollbar_controller_->DidMouseMove(NearVerticalScrollbarBegin(0, 0));
321 ExpectScrollbarsOpacity(1); 415 ExpectScrollbarsOpacity(1);
322 EXPECT_FLOAT_EQ(kIdleThicknessScale, 416 EXPECT_FLOAT_EQ(kIdleThicknessScale,
323 v_scrollbar_layer_->thumb_thickness_scale_factor()); 417 v_scrollbar_layer_->thumb_thickness_scale_factor());
324 EXPECT_FLOAT_EQ(kIdleThicknessScale, 418 EXPECT_FLOAT_EQ(kIdleThicknessScale,
325 h_scrollbar_layer_->thumb_thickness_scale_factor()); 419 h_scrollbar_layer_->thumb_thickness_scale_factor());
326 EXPECT_TRUE(client_.start_fade().IsCancelled()); 420 EXPECT_TRUE(client_.start_fade().IsCancelled());
327 421
328 // Vertical scrollbar should become thick. 422 // Vertical scrollbar should become thick.
329 scrollbar_controller_->Animate(time); 423 scrollbar_controller_->Animate(time);
330 time += kThinningDuration; 424 time += kThinningDuration;
(...skipping 18 matching lines...) Expand all
349 time += base::TimeDelta::FromSeconds(1); 443 time += base::TimeDelta::FromSeconds(1);
350 444
351 scrollbar_controller_->DidScrollBegin(); 445 scrollbar_controller_->DidScrollBegin();
352 scrollbar_controller_->DidScrollUpdate(); 446 scrollbar_controller_->DidScrollUpdate();
353 scrollbar_controller_->DidScrollEnd(); 447 scrollbar_controller_->DidScrollEnd();
354 448
355 // An fade out animation should have been enqueued. 449 // An fade out animation should have been enqueued.
356 EXPECT_EQ(kFadeDelay, client_.delay()); 450 EXPECT_EQ(kFadeDelay, client_.delay());
357 EXPECT_FALSE(client_.start_fade().is_null()); 451 EXPECT_FALSE(client_.start_fade().is_null());
358 452
359 // Now move the mouse over the scrollbar and capture it. It should become 453 // Now move the mouse over the vertical scrollbar thumb and capture it. It
360 // thick without need for an animation. 454 // should become thick without need for an animation.
361 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 0); 455 scrollbar_controller_->DidMouseMove(NearVerticalScrollbarBegin(0, 0));
362 scrollbar_controller_->DidMouseDown(); 456 scrollbar_controller_->DidMouseDown();
363 ExpectScrollbarsOpacity(1); 457 ExpectScrollbarsOpacity(1);
364 EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor()); 458 EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor());
365 EXPECT_FLOAT_EQ(kIdleThicknessScale, 459 EXPECT_FLOAT_EQ(kIdleThicknessScale,
366 h_scrollbar_layer_->thumb_thickness_scale_factor()); 460 h_scrollbar_layer_->thumb_thickness_scale_factor());
367 461
368 // The fade out animation should have been cleared or cancelled. 462 // The fade out animation should have been cleared or cancelled.
369 EXPECT_TRUE(client_.start_fade().is_null() || 463 EXPECT_TRUE(client_.start_fade().is_null() ||
370 client_.start_fade().IsCancelled()); 464 client_.start_fade().IsCancelled());
371 } 465 }
372 466
373 // Make sure a scrollbar captured then move mouse away doesn't try to fade out. 467 // Make sure a scrollbar captured then move mouse away doesn't try to fade out.
374 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, 468 TEST_F(ScrollbarAnimationControllerAuraOverlayTest,
375 DontFadeWhileCapturedThenAway) { 469 DontFadeWhileCapturedThenAway) {
376 base::TimeTicks time; 470 base::TimeTicks time;
377 time += base::TimeDelta::FromSeconds(1); 471 time += base::TimeDelta::FromSeconds(1);
378 472
379 scrollbar_controller_->DidScrollBegin(); 473 scrollbar_controller_->DidScrollBegin();
380 scrollbar_controller_->DidScrollUpdate(); 474 scrollbar_controller_->DidScrollUpdate();
381 scrollbar_controller_->DidScrollEnd(); 475 scrollbar_controller_->DidScrollEnd();
382 476
383 // An fade out animation should have been enqueued. 477 // An fade out animation should have been enqueued.
384 EXPECT_EQ(kFadeDelay, client_.delay()); 478 EXPECT_EQ(kFadeDelay, client_.delay());
385 EXPECT_FALSE(client_.start_fade().is_null()); 479 EXPECT_FALSE(client_.start_fade().is_null());
386 480
387 // Now move the mouse over the scrollbar and capture it. It should become 481 // Now move the mouse over the vertical scrollbar and capture it. It should
388 // thick without need for an animation. 482 // become thick without need for an animation.
389 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 0); 483 scrollbar_controller_->DidMouseMove(NearVerticalScrollbarBegin(0, 0));
390 scrollbar_controller_->DidMouseDown(); 484 scrollbar_controller_->DidMouseDown();
391 ExpectScrollbarsOpacity(1); 485 ExpectScrollbarsOpacity(1);
392 EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor()); 486 EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor());
393 EXPECT_FLOAT_EQ(kIdleThicknessScale, 487 EXPECT_FLOAT_EQ(kIdleThicknessScale,
394 h_scrollbar_layer_->thumb_thickness_scale_factor()); 488 h_scrollbar_layer_->thumb_thickness_scale_factor());
395 489
396 // The fade out animation should have been cleared or cancelled. 490 // The fade out animation should have been cleared or cancelled.
397 EXPECT_TRUE(client_.start_fade().is_null() || 491 EXPECT_TRUE(client_.start_fade().is_null() ||
398 client_.start_fade().IsCancelled()); 492 client_.start_fade().IsCancelled());
399 493
400 // Then move mouse away, The fade out animation should have been cleared or 494 // Then move mouse away, The fade out animation should have been cleared or
401 // cancelled. 495 // cancelled.
402 scrollbar_controller_->DidMouseMoveNear( 496 scrollbar_controller_->DidMouseMove(
403 VERTICAL, kDefaultMouseMoveDistanceToTriggerAnimation); 497 NearVerticalScrollbarBegin(-kMouseMoveDistanceToTriggerExpand, 0));
404 498
405 EXPECT_TRUE(client_.start_fade().is_null() || 499 EXPECT_TRUE(client_.start_fade().is_null() ||
406 client_.start_fade().IsCancelled()); 500 client_.start_fade().IsCancelled());
407 } 501 }
408 502
409 // Make sure a scrollbar captured after a thickening animation doesn't try to 503 // Make sure a scrollbar captured after a thickening animation doesn't try to
410 // fade out. 504 // fade out.
411 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, DontFadeWhileCaptured) { 505 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, DontFadeWhileCaptured) {
412 base::TimeTicks time; 506 base::TimeTicks time;
413 time += base::TimeDelta::FromSeconds(1); 507 time += base::TimeDelta::FromSeconds(1);
414 508
415 scrollbar_controller_->DidScrollBegin(); 509 scrollbar_controller_->DidScrollBegin();
416 scrollbar_controller_->DidScrollUpdate(); 510 scrollbar_controller_->DidScrollUpdate();
417 scrollbar_controller_->DidScrollEnd(); 511 scrollbar_controller_->DidScrollEnd();
418 512
419 // An fade out animation should have been enqueued. 513 // An fade out animation should have been enqueued.
420 EXPECT_EQ(kFadeDelay, client_.delay()); 514 EXPECT_EQ(kFadeDelay, client_.delay());
421 EXPECT_FALSE(client_.start_fade().is_null()); 515 EXPECT_FALSE(client_.start_fade().is_null());
422 EXPECT_FALSE(client_.start_fade().IsCancelled()); 516 EXPECT_FALSE(client_.start_fade().IsCancelled());
423 517
424 // Now move the mouse over the scrollbar and animate it until it's thick. 518 // Now move the mouse over the vertical scrollbar thumb and animate it until
425 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 0); 519 // it's thick.
520 scrollbar_controller_->DidMouseMove(NearVerticalScrollbarBegin(0, 0));
426 scrollbar_controller_->Animate(time); 521 scrollbar_controller_->Animate(time);
427 time += kThinningDuration; 522 time += kThinningDuration;
428 scrollbar_controller_->Animate(time); 523 scrollbar_controller_->Animate(time);
429 ExpectScrollbarsOpacity(1); 524 ExpectScrollbarsOpacity(1);
430 EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor()); 525 EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor());
431 EXPECT_FLOAT_EQ(kIdleThicknessScale, 526 EXPECT_FLOAT_EQ(kIdleThicknessScale,
432 h_scrollbar_layer_->thumb_thickness_scale_factor()); 527 h_scrollbar_layer_->thumb_thickness_scale_factor());
433 528
434 // Since the mouse is over the scrollbar, it should either clear or cancel the 529 // Since the mouse is over the scrollbar, it should either clear or cancel the
435 // queued fade. 530 // queued fade.
(...skipping 15 matching lines...) Expand all
451 546
452 scrollbar_controller_->DidScrollBegin(); 547 scrollbar_controller_->DidScrollBegin();
453 scrollbar_controller_->DidScrollUpdate(); 548 scrollbar_controller_->DidScrollUpdate();
454 scrollbar_controller_->DidScrollEnd(); 549 scrollbar_controller_->DidScrollEnd();
455 550
456 // An fade out animation should have been enqueued. 551 // An fade out animation should have been enqueued.
457 EXPECT_EQ(kFadeDelay, client_.delay()); 552 EXPECT_EQ(kFadeDelay, client_.delay());
458 EXPECT_FALSE(client_.start_fade().is_null()); 553 EXPECT_FALSE(client_.start_fade().is_null());
459 EXPECT_FALSE(client_.start_fade().IsCancelled()); 554 EXPECT_FALSE(client_.start_fade().IsCancelled());
460 555
461 // Now move the mouse over the scrollbar and capture it. 556 // Now move the mouse over the vertical scrollbar thumb and capture it.
462 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 0); 557 scrollbar_controller_->DidMouseMove(NearVerticalScrollbarBegin(0, 0));
463 scrollbar_controller_->DidMouseDown(); 558 scrollbar_controller_->DidMouseDown();
464 ExpectScrollbarsOpacity(1); 559 ExpectScrollbarsOpacity(1);
465 EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor()); 560 EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor());
466 EXPECT_FLOAT_EQ(kIdleThicknessScale, 561 EXPECT_FLOAT_EQ(kIdleThicknessScale,
467 h_scrollbar_layer_->thumb_thickness_scale_factor()); 562 h_scrollbar_layer_->thumb_thickness_scale_factor());
468 563
469 // Since the mouse is still near the scrollbar, the queued fade should be 564 // Since the mouse is still near the scrollbar, the queued fade should be
470 // either null or cancelled. 565 // either null or cancelled.
471 EXPECT_TRUE(client_.start_fade().is_null() || 566 EXPECT_TRUE(client_.start_fade().is_null() ||
472 client_.start_fade().IsCancelled()); 567 client_.start_fade().IsCancelled());
473 568
474 // Now move the mouse away from the scrollbar and release it. 569 // Now move the mouse away from the scrollbar and release it.
475 scrollbar_controller_->DidMouseMoveNear( 570 scrollbar_controller_->DidMouseMove(
476 VERTICAL, kDefaultMouseMoveDistanceToTriggerAnimation); 571 NearVerticalScrollbarBegin(-kMouseMoveDistanceToTriggerFadeIn, 0));
477 scrollbar_controller_->DidMouseUp(); 572 scrollbar_controller_->DidMouseUp();
478 573
479 scrollbar_controller_->Animate(time); 574 scrollbar_controller_->Animate(time);
480 ExpectScrollbarsOpacity(1); 575 ExpectScrollbarsOpacity(1);
481 EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor()); 576 EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor());
482 EXPECT_FLOAT_EQ(kIdleThicknessScale, 577 EXPECT_FLOAT_EQ(kIdleThicknessScale,
483 h_scrollbar_layer_->thumb_thickness_scale_factor()); 578 h_scrollbar_layer_->thumb_thickness_scale_factor());
484 time += kThinningDuration; 579 time += kThinningDuration;
485 scrollbar_controller_->Animate(time); 580 scrollbar_controller_->Animate(time);
486 ExpectScrollbarsOpacity(1); 581 ExpectScrollbarsOpacity(1);
(...skipping 15 matching lines...) Expand all
502 597
503 scrollbar_controller_->DidScrollBegin(); 598 scrollbar_controller_->DidScrollBegin();
504 scrollbar_controller_->DidScrollUpdate(); 599 scrollbar_controller_->DidScrollUpdate();
505 scrollbar_controller_->DidScrollEnd(); 600 scrollbar_controller_->DidScrollEnd();
506 601
507 // An fade out animation should have been enqueued. 602 // An fade out animation should have been enqueued.
508 EXPECT_EQ(kFadeDelay, client_.delay()); 603 EXPECT_EQ(kFadeDelay, client_.delay());
509 EXPECT_FALSE(client_.start_fade().is_null()); 604 EXPECT_FALSE(client_.start_fade().is_null());
510 EXPECT_FALSE(client_.start_fade().IsCancelled()); 605 EXPECT_FALSE(client_.start_fade().IsCancelled());
511 606
512 // Now move the mouse over the scrollbar and capture it. 607 // Now move the mouse over the vertical scrollbar thumb and capture it.
513 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 0); 608 scrollbar_controller_->DidMouseMove(NearVerticalScrollbarBegin(0, 0));
514 scrollbar_controller_->DidMouseDown(); 609 scrollbar_controller_->DidMouseDown();
515 ExpectScrollbarsOpacity(1); 610 ExpectScrollbarsOpacity(1);
516 EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor()); 611 EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor());
517 EXPECT_FLOAT_EQ(kIdleThicknessScale, 612 EXPECT_FLOAT_EQ(kIdleThicknessScale,
518 h_scrollbar_layer_->thumb_thickness_scale_factor()); 613 h_scrollbar_layer_->thumb_thickness_scale_factor());
519 614
520 // Since the mouse is over the scrollbar, the queued fade must be either 615 // Since the mouse is over the scrollbar, the queued fade must be either
521 // null or cancelled. 616 // null or cancelled.
522 EXPECT_TRUE(client_.start_fade().is_null() || 617 EXPECT_TRUE(client_.start_fade().is_null() ||
523 client_.start_fade().IsCancelled()); 618 client_.start_fade().IsCancelled());
(...skipping 25 matching lines...) Expand all
549 client_.start_fade().Run(); 644 client_.start_fade().Run();
550 645
551 scrollbar_controller_->Animate(time); 646 scrollbar_controller_->Animate(time);
552 ExpectScrollbarsOpacity(1); 647 ExpectScrollbarsOpacity(1);
553 648
554 // Proceed half way through the fade out animation. 649 // Proceed half way through the fade out animation.
555 time += kFadeDuration / 2; 650 time += kFadeDuration / 2;
556 scrollbar_controller_->Animate(time); 651 scrollbar_controller_->Animate(time);
557 ExpectScrollbarsOpacity(.5f); 652 ExpectScrollbarsOpacity(.5f);
558 653
559 // Now move the mouse near the scrollbar. It should reset opacity to 1 654 // Now move the mouse near the vertical scrollbar thumb. It should reset
560 // instantly and start animating to thick. 655 // opacity to 1 instantly and start animating to thick.
561 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 1); 656 scrollbar_controller_->DidMouseMove(NearVerticalScrollbarBegin(0, 0));
562 ExpectScrollbarsOpacity(1); 657 ExpectScrollbarsOpacity(1);
563 EXPECT_FLOAT_EQ(kIdleThicknessScale, 658 EXPECT_FLOAT_EQ(kIdleThicknessScale,
564 v_scrollbar_layer_->thumb_thickness_scale_factor()); 659 v_scrollbar_layer_->thumb_thickness_scale_factor());
565 EXPECT_FLOAT_EQ(kIdleThicknessScale, 660 EXPECT_FLOAT_EQ(kIdleThicknessScale,
566 h_scrollbar_layer_->thumb_thickness_scale_factor()); 661 h_scrollbar_layer_->thumb_thickness_scale_factor());
567 662
568 scrollbar_controller_->Animate(time); 663 scrollbar_controller_->Animate(time);
569 time += kThinningDuration; 664 time += kThinningDuration;
570 scrollbar_controller_->Animate(time); 665 scrollbar_controller_->Animate(time);
571 ExpectScrollbarsOpacity(1); 666 ExpectScrollbarsOpacity(1);
(...skipping 16 matching lines...) Expand all
588 EXPECT_FALSE(client_.start_fade().IsCancelled()); 683 EXPECT_FALSE(client_.start_fade().IsCancelled());
589 client_.start_fade().Run(); 684 client_.start_fade().Run();
590 scrollbar_controller_->Animate(time); 685 scrollbar_controller_->Animate(time);
591 ExpectScrollbarsOpacity(1); 686 ExpectScrollbarsOpacity(1);
592 687
593 // Fade the scrollbar out completely. 688 // Fade the scrollbar out completely.
594 time += kFadeDuration; 689 time += kFadeDuration;
595 scrollbar_controller_->Animate(time); 690 scrollbar_controller_->Animate(time);
596 ExpectScrollbarsOpacity(0); 691 ExpectScrollbarsOpacity(0);
597 692
598 // Move mouse over the scrollbar. It shouldn't thicken the scrollbar since 693 // Move mouse over the vertical scrollbar thumb. It shouldn't thicken the
599 // it's completely faded out. 694 // scrollbar since it's completely faded out.
600 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 0); 695 scrollbar_controller_->DidMouseMove(NearVerticalScrollbarBegin(0, 0));
601 scrollbar_controller_->Animate(time); 696 scrollbar_controller_->Animate(time);
602 time += kThinningDuration; 697 time += kThinningDuration;
603 scrollbar_controller_->Animate(time); 698 scrollbar_controller_->Animate(time);
604 ExpectScrollbarsOpacity(0); 699 ExpectScrollbarsOpacity(0);
605 EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor()); 700 EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor());
606 EXPECT_FLOAT_EQ(kIdleThicknessScale, 701 EXPECT_FLOAT_EQ(kIdleThicknessScale,
607 h_scrollbar_layer_->thumb_thickness_scale_factor()); 702 h_scrollbar_layer_->thumb_thickness_scale_factor());
608 703
609 client_.start_fade().Reset(); 704 client_.start_fade().Reset();
610 705
(...skipping 14 matching lines...) Expand all
625 h_scrollbar_layer_->thumb_thickness_scale_factor()); 720 h_scrollbar_layer_->thumb_thickness_scale_factor());
626 EXPECT_TRUE(client_.start_fade().is_null()); 721 EXPECT_TRUE(client_.start_fade().is_null());
627 } 722 }
628 723
629 // Initiate a scroll when the pointer is already near the scrollbar. It should 724 // Initiate a scroll when the pointer is already near the scrollbar. It should
630 // appear thick and remain thick. 725 // appear thick and remain thick.
631 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, ScrollWithMouseNear) { 726 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, ScrollWithMouseNear) {
632 base::TimeTicks time; 727 base::TimeTicks time;
633 time += base::TimeDelta::FromSeconds(1); 728 time += base::TimeDelta::FromSeconds(1);
634 729
635 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 1); 730 scrollbar_controller_->DidMouseMove(NearVerticalScrollbarBegin(-1, 0));
636 scrollbar_controller_->Animate(time); 731 scrollbar_controller_->Animate(time);
637 time += kThinningDuration; 732 time += kThinningDuration;
638 733
639 // Since the scrollbar isn't visible yet (because we haven't scrolled), we 734 // Since the scrollbar isn't visible yet (because we haven't scrolled), we
640 // shouldn't have applied the thickening. 735 // shouldn't have applied the thickening.
641 scrollbar_controller_->Animate(time); 736 scrollbar_controller_->Animate(time);
642 EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor()); 737 EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor());
643 EXPECT_FLOAT_EQ(kIdleThicknessScale, 738 EXPECT_FLOAT_EQ(kIdleThicknessScale,
644 h_scrollbar_layer_->thumb_thickness_scale_factor()); 739 h_scrollbar_layer_->thumb_thickness_scale_factor());
645 740
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
799 // moved away. 894 // moved away.
800 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, MouseNearEach) { 895 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, MouseNearEach) {
801 base::TimeTicks time; 896 base::TimeTicks time;
802 time += base::TimeDelta::FromSeconds(1); 897 time += base::TimeDelta::FromSeconds(1);
803 898
804 // Scroll to make the scrollbars visible. 899 // Scroll to make the scrollbars visible.
805 scrollbar_controller_->DidScrollBegin(); 900 scrollbar_controller_->DidScrollBegin();
806 scrollbar_controller_->DidScrollUpdate(); 901 scrollbar_controller_->DidScrollUpdate();
807 scrollbar_controller_->DidScrollEnd(); 902 scrollbar_controller_->DidScrollEnd();
808 903
809 // Near vertical scrollbar 904 // Near vertical scrollbar.
810 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 1); 905 scrollbar_controller_->DidMouseMove(NearVerticalScrollbarBegin(-1, 0));
811 scrollbar_controller_->Animate(time); 906 scrollbar_controller_->Animate(time);
812 ExpectScrollbarsOpacity(1); 907 ExpectScrollbarsOpacity(1);
813 EXPECT_FLOAT_EQ(kIdleThicknessScale, 908 EXPECT_FLOAT_EQ(kIdleThicknessScale,
814 v_scrollbar_layer_->thumb_thickness_scale_factor()); 909 v_scrollbar_layer_->thumb_thickness_scale_factor());
815 EXPECT_FLOAT_EQ(kIdleThicknessScale, 910 EXPECT_FLOAT_EQ(kIdleThicknessScale,
816 h_scrollbar_layer_->thumb_thickness_scale_factor()); 911 h_scrollbar_layer_->thumb_thickness_scale_factor());
817 912
818 // Should animate to thickened. 913 // Should animate to thickened.
819 time += kThinningDuration; 914 time += kThinningDuration;
820 scrollbar_controller_->Animate(time); 915 scrollbar_controller_->Animate(time);
821 ExpectScrollbarsOpacity(1); 916 ExpectScrollbarsOpacity(1);
822 EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor()); 917 EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor());
823 EXPECT_FLOAT_EQ(kIdleThicknessScale, 918 EXPECT_FLOAT_EQ(kIdleThicknessScale,
824 h_scrollbar_layer_->thumb_thickness_scale_factor()); 919 h_scrollbar_layer_->thumb_thickness_scale_factor());
825 920
826 // Subsequent moves within the nearness threshold should not change anything. 921 // Subsequent moves within the nearness threshold should not change anything.
827 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 2); 922 scrollbar_controller_->DidMouseMove(NearVerticalScrollbarBegin(-2, 0));
828 scrollbar_controller_->Animate(time); 923 scrollbar_controller_->Animate(time);
829 time += base::TimeDelta::FromSeconds(10); 924 time += base::TimeDelta::FromSeconds(10);
830 scrollbar_controller_->Animate(time); 925 scrollbar_controller_->Animate(time);
831 ExpectScrollbarsOpacity(1); 926 ExpectScrollbarsOpacity(1);
832 EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor()); 927 EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor());
833 EXPECT_FLOAT_EQ(kIdleThicknessScale, 928 EXPECT_FLOAT_EQ(kIdleThicknessScale,
834 h_scrollbar_layer_->thumb_thickness_scale_factor()); 929 h_scrollbar_layer_->thumb_thickness_scale_factor());
835 930
836 // Now move away from bar. 931 // Now move away from bar.
837 scrollbar_controller_->DidMouseMoveNear( 932 scrollbar_controller_->DidMouseMove(
838 VERTICAL, kDefaultMouseMoveDistanceToTriggerAnimation); 933 NearVerticalScrollbarBegin(-kMouseMoveDistanceToTriggerExpand, 0));
839 scrollbar_controller_->Animate(time); 934 scrollbar_controller_->Animate(time);
840 time += kThinningDuration; 935 time += kThinningDuration;
841 scrollbar_controller_->Animate(time); 936 scrollbar_controller_->Animate(time);
842 ExpectScrollbarsOpacity(1); 937 ExpectScrollbarsOpacity(1);
843 EXPECT_FLOAT_EQ(kIdleThicknessScale, 938 EXPECT_FLOAT_EQ(kIdleThicknessScale,
844 v_scrollbar_layer_->thumb_thickness_scale_factor()); 939 v_scrollbar_layer_->thumb_thickness_scale_factor());
845 EXPECT_FLOAT_EQ(kIdleThicknessScale, 940 EXPECT_FLOAT_EQ(kIdleThicknessScale,
846 h_scrollbar_layer_->thumb_thickness_scale_factor()); 941 h_scrollbar_layer_->thumb_thickness_scale_factor());
847 942
848 // Near horizontal scrollbar 943 // Near horizontal scrollbar
849 scrollbar_controller_->DidMouseMoveNear(HORIZONTAL, 2); 944 scrollbar_controller_->DidMouseMove(NearHorizontalScrollbarBegin(0, -1));
850 scrollbar_controller_->Animate(time); 945 scrollbar_controller_->Animate(time);
851 ExpectScrollbarsOpacity(1); 946 ExpectScrollbarsOpacity(1);
852 EXPECT_FLOAT_EQ(kIdleThicknessScale, 947 EXPECT_FLOAT_EQ(kIdleThicknessScale,
853 v_scrollbar_layer_->thumb_thickness_scale_factor()); 948 v_scrollbar_layer_->thumb_thickness_scale_factor());
854 EXPECT_FLOAT_EQ(kIdleThicknessScale, 949 EXPECT_FLOAT_EQ(kIdleThicknessScale,
855 h_scrollbar_layer_->thumb_thickness_scale_factor()); 950 h_scrollbar_layer_->thumb_thickness_scale_factor());
856 951
857 // Should animate to thickened. 952 // Should animate to thickened.
858 time += kThinningDuration; 953 time += kThinningDuration;
859 scrollbar_controller_->Animate(time); 954 scrollbar_controller_->Animate(time);
860 ExpectScrollbarsOpacity(1); 955 ExpectScrollbarsOpacity(1);
861 EXPECT_FLOAT_EQ(kIdleThicknessScale, 956 EXPECT_FLOAT_EQ(kIdleThicknessScale,
862 v_scrollbar_layer_->thumb_thickness_scale_factor()); 957 v_scrollbar_layer_->thumb_thickness_scale_factor());
863 EXPECT_FLOAT_EQ(1, h_scrollbar_layer_->thumb_thickness_scale_factor()); 958 EXPECT_FLOAT_EQ(1, h_scrollbar_layer_->thumb_thickness_scale_factor());
864 959
865 // Subsequent moves within the nearness threshold should not change anything. 960 // Subsequent moves within the nearness threshold should not change anything.
866 scrollbar_controller_->DidMouseMoveNear(HORIZONTAL, 1); 961 scrollbar_controller_->DidMouseMove(NearHorizontalScrollbarBegin(0, -2));
867 scrollbar_controller_->Animate(time); 962 scrollbar_controller_->Animate(time);
868 time += base::TimeDelta::FromSeconds(10); 963 time += base::TimeDelta::FromSeconds(10);
869 scrollbar_controller_->Animate(time); 964 scrollbar_controller_->Animate(time);
870 ExpectScrollbarsOpacity(1); 965 ExpectScrollbarsOpacity(1);
871 EXPECT_FLOAT_EQ(kIdleThicknessScale, 966 EXPECT_FLOAT_EQ(kIdleThicknessScale,
872 v_scrollbar_layer_->thumb_thickness_scale_factor()); 967 v_scrollbar_layer_->thumb_thickness_scale_factor());
873 EXPECT_FLOAT_EQ(1, h_scrollbar_layer_->thumb_thickness_scale_factor()); 968 EXPECT_FLOAT_EQ(1, h_scrollbar_layer_->thumb_thickness_scale_factor());
874 969
875 // Now move away from bar. 970 // Now move away from bar.
876 scrollbar_controller_->DidMouseMoveNear( 971 scrollbar_controller_->DidMouseMove(
877 HORIZONTAL, kDefaultMouseMoveDistanceToTriggerAnimation); 972 NearHorizontalScrollbarBegin(0, -kMouseMoveDistanceToTriggerExpand));
878 scrollbar_controller_->Animate(time); 973 scrollbar_controller_->Animate(time);
879 time += kThinningDuration; 974 time += kThinningDuration;
880 scrollbar_controller_->Animate(time); 975 scrollbar_controller_->Animate(time);
881 ExpectScrollbarsOpacity(1); 976 ExpectScrollbarsOpacity(1);
882 EXPECT_FLOAT_EQ(kIdleThicknessScale, 977 EXPECT_FLOAT_EQ(kIdleThicknessScale,
883 v_scrollbar_layer_->thumb_thickness_scale_factor()); 978 v_scrollbar_layer_->thumb_thickness_scale_factor());
884 EXPECT_FLOAT_EQ(kIdleThicknessScale, 979 EXPECT_FLOAT_EQ(kIdleThicknessScale,
885 h_scrollbar_layer_->thumb_thickness_scale_factor()); 980 h_scrollbar_layer_->thumb_thickness_scale_factor());
886 981
887 // An fade out animation should have been enqueued. 982 // An fade out animation should have been enqueued.
888 EXPECT_FALSE(client_.start_fade().is_null()); 983 EXPECT_FALSE(client_.start_fade().is_null());
889 EXPECT_EQ(kFadeDelay, client_.delay()); 984 EXPECT_EQ(kFadeDelay, client_.delay());
890 } 985 }
891 986
892 // Move mouse near both scrollbars at the same time. 987 // Move mouse near both scrollbars at the same time.
893 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, MouseNearBoth) { 988 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, MouseNearBoth) {
894 base::TimeTicks time; 989 base::TimeTicks time;
895 time += base::TimeDelta::FromSeconds(1); 990 time += base::TimeDelta::FromSeconds(1);
896 991
897 // Scroll to make the scrollbars visible. 992 // Scroll to make the scrollbars visible.
898 scrollbar_controller_->DidScrollBegin(); 993 scrollbar_controller_->DidScrollBegin();
899 scrollbar_controller_->DidScrollUpdate(); 994 scrollbar_controller_->DidScrollUpdate();
900 scrollbar_controller_->DidScrollEnd(); 995 scrollbar_controller_->DidScrollEnd();
901 996
997 // Move scrollbar thumb to the end of track.
998 v_scrollbar_layer_->SetCurrentPos(100);
999 h_scrollbar_layer_->SetCurrentPos(100);
1000
902 // Near both Scrollbar 1001 // Near both Scrollbar
903 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 1); 1002 scrollbar_controller_->DidMouseMove(NearVerticalScrollbarEnd(-1, -1));
904 scrollbar_controller_->DidMouseMoveNear(HORIZONTAL, 1);
905 scrollbar_controller_->Animate(time); 1003 scrollbar_controller_->Animate(time);
906 ExpectScrollbarsOpacity(1); 1004 ExpectScrollbarsOpacity(1);
907 EXPECT_FLOAT_EQ(kIdleThicknessScale, 1005 EXPECT_FLOAT_EQ(kIdleThicknessScale,
908 v_scrollbar_layer_->thumb_thickness_scale_factor()); 1006 v_scrollbar_layer_->thumb_thickness_scale_factor());
909 EXPECT_FLOAT_EQ(kIdleThicknessScale, 1007 EXPECT_FLOAT_EQ(kIdleThicknessScale,
910 h_scrollbar_layer_->thumb_thickness_scale_factor()); 1008 h_scrollbar_layer_->thumb_thickness_scale_factor());
911 1009
912 // Should animate to thickened. 1010 // Should animate to thickened.
913 time += kThinningDuration; 1011 time += kThinningDuration;
914 scrollbar_controller_->Animate(time); 1012 scrollbar_controller_->Animate(time);
915 ExpectScrollbarsOpacity(1); 1013 ExpectScrollbarsOpacity(1);
916 EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor()); 1014 EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor());
917 EXPECT_FLOAT_EQ(1, h_scrollbar_layer_->thumb_thickness_scale_factor()); 1015 EXPECT_FLOAT_EQ(1, h_scrollbar_layer_->thumb_thickness_scale_factor());
918 } 1016 }
919 1017
920 // Move mouse from one to the other scrollbar before animation is finished, then 1018 // Move mouse from one to the other scrollbar before animation is finished, then
921 // away before animation finished. 1019 // away before animation finished.
922 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, 1020 TEST_F(ScrollbarAnimationControllerAuraOverlayTest,
923 MouseNearOtherBeforeAnimationFinished) { 1021 MouseNearOtherBeforeAnimationFinished) {
924 base::TimeTicks time; 1022 base::TimeTicks time;
925 time += base::TimeDelta::FromSeconds(1); 1023 time += base::TimeDelta::FromSeconds(1);
926 1024
927 // Scroll to make the scrollbars visible. 1025 // Scroll to make the scrollbars visible.
928 scrollbar_controller_->DidScrollBegin(); 1026 scrollbar_controller_->DidScrollBegin();
929 scrollbar_controller_->DidScrollUpdate(); 1027 scrollbar_controller_->DidScrollUpdate();
930 scrollbar_controller_->DidScrollEnd(); 1028 scrollbar_controller_->DidScrollEnd();
931 1029
932 // Near vertical scrollbar. 1030 // Near vertical scrollbar.
933 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 1); 1031 scrollbar_controller_->DidMouseMove(NearVerticalScrollbarBegin(-1, 0));
934 scrollbar_controller_->Animate(time); 1032 scrollbar_controller_->Animate(time);
935 ExpectScrollbarsOpacity(1); 1033 ExpectScrollbarsOpacity(1);
936 EXPECT_FLOAT_EQ(kIdleThicknessScale, 1034 EXPECT_FLOAT_EQ(kIdleThicknessScale,
937 v_scrollbar_layer_->thumb_thickness_scale_factor()); 1035 v_scrollbar_layer_->thumb_thickness_scale_factor());
938 EXPECT_FLOAT_EQ(kIdleThicknessScale, 1036 EXPECT_FLOAT_EQ(kIdleThicknessScale,
939 h_scrollbar_layer_->thumb_thickness_scale_factor()); 1037 h_scrollbar_layer_->thumb_thickness_scale_factor());
940 1038
941 // Vertical scrollbar animate to half thickened. 1039 // Vertical scrollbar animate to half thickened.
942 time += kThinningDuration / 2; 1040 time += kThinningDuration / 2;
943 scrollbar_controller_->Animate(time); 1041 scrollbar_controller_->Animate(time);
944 ExpectScrollbarsOpacity(1); 1042 ExpectScrollbarsOpacity(1);
945 EXPECT_FLOAT_EQ(kIdleThicknessScale + (1.0f - kIdleThicknessScale) / 2, 1043 EXPECT_FLOAT_EQ(kIdleThicknessScale + (1.0f - kIdleThicknessScale) / 2,
946 v_scrollbar_layer_->thumb_thickness_scale_factor()); 1044 v_scrollbar_layer_->thumb_thickness_scale_factor());
947 EXPECT_FLOAT_EQ(kIdleThicknessScale, 1045 EXPECT_FLOAT_EQ(kIdleThicknessScale,
948 h_scrollbar_layer_->thumb_thickness_scale_factor()); 1046 h_scrollbar_layer_->thumb_thickness_scale_factor());
949 1047
950 // Away vertical scrollbar and near horizontal scrollbar. 1048 // Away vertical scrollbar and near horizontal scrollbar.
951 scrollbar_controller_->DidMouseMoveNear( 1049 scrollbar_controller_->DidMouseMove(gfx::PointF(0, 0));
952 VERTICAL, kDefaultMouseMoveDistanceToTriggerAnimation); 1050 scrollbar_controller_->DidMouseMove(NearHorizontalScrollbarBegin(0, -1));
953 scrollbar_controller_->DidMouseMoveNear(HORIZONTAL, 1);
954 scrollbar_controller_->Animate(time); 1051 scrollbar_controller_->Animate(time);
955 1052
956 // Vertical scrollbar animate to thin. horizontal scrollbar animate to 1053 // Vertical scrollbar animate to thin. horizontal scrollbar animate to
957 // thickened. 1054 // thickened.
958 time += kThinningDuration; 1055 time += kThinningDuration;
959 scrollbar_controller_->Animate(time); 1056 scrollbar_controller_->Animate(time);
960 ExpectScrollbarsOpacity(1); 1057 ExpectScrollbarsOpacity(1);
961 EXPECT_FLOAT_EQ(kIdleThicknessScale, 1058 EXPECT_FLOAT_EQ(kIdleThicknessScale,
962 v_scrollbar_layer_->thumb_thickness_scale_factor()); 1059 v_scrollbar_layer_->thumb_thickness_scale_factor());
963 EXPECT_FLOAT_EQ(1, h_scrollbar_layer_->thumb_thickness_scale_factor()); 1060 EXPECT_FLOAT_EQ(1, h_scrollbar_layer_->thumb_thickness_scale_factor());
964 1061
965 // Away horizontal scrollbar. 1062 // Away horizontal scrollbar.
966 scrollbar_controller_->DidMouseMoveNear( 1063 scrollbar_controller_->DidMouseMove(gfx::PointF(0, 0));
967 HORIZONTAL, kDefaultMouseMoveDistanceToTriggerAnimation);
968 scrollbar_controller_->Animate(time); 1064 scrollbar_controller_->Animate(time);
969 1065
970 // Horizontal scrollbar animate to thin. 1066 // Horizontal scrollbar animate to thin.
971 time += kThinningDuration; 1067 time += kThinningDuration;
972 scrollbar_controller_->Animate(time); 1068 scrollbar_controller_->Animate(time);
973 ExpectScrollbarsOpacity(1); 1069 ExpectScrollbarsOpacity(1);
974 EXPECT_FLOAT_EQ(kIdleThicknessScale, 1070 EXPECT_FLOAT_EQ(kIdleThicknessScale,
975 v_scrollbar_layer_->thumb_thickness_scale_factor()); 1071 v_scrollbar_layer_->thumb_thickness_scale_factor());
976 EXPECT_FLOAT_EQ(kIdleThicknessScale, 1072 EXPECT_FLOAT_EQ(kIdleThicknessScale,
977 h_scrollbar_layer_->thumb_thickness_scale_factor()); 1073 h_scrollbar_layer_->thumb_thickness_scale_factor());
978 1074
979 // An fade out animation should have been enqueued. 1075 // An fade out animation should have been enqueued.
980 EXPECT_FALSE(client_.start_fade().is_null()); 1076 EXPECT_FALSE(client_.start_fade().is_null());
981 EXPECT_EQ(kFadeDelay, client_.delay()); 1077 EXPECT_EQ(kFadeDelay, client_.delay());
982 } 1078 }
983 1079
984 // Ensure we have a delay fadeout animation after mouse leave without a mouse 1080 // Ensure we have a delay fadeout animation after mouse leave without a mouse
985 // move. 1081 // move.
986 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, MouseLeaveFadeOut) { 1082 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, MouseLeaveFadeOut) {
987 base::TimeTicks time; 1083 base::TimeTicks time;
988 time += base::TimeDelta::FromSeconds(1); 1084 time += base::TimeDelta::FromSeconds(1);
989 1085
990 // Move mouse near scrollbar. 1086 // Move mouse near scrollbar.
991 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 1); 1087 scrollbar_controller_->DidMouseMove(NearVerticalScrollbarBegin(-1, 0));
992 1088
993 // Scroll to make the scrollbars visible. 1089 // Scroll to make the scrollbars visible.
994 scrollbar_controller_->DidScrollBegin(); 1090 scrollbar_controller_->DidScrollBegin();
995 scrollbar_controller_->DidScrollUpdate(); 1091 scrollbar_controller_->DidScrollUpdate();
996 scrollbar_controller_->DidScrollEnd(); 1092 scrollbar_controller_->DidScrollEnd();
997 1093
998 // Should not have delay fadeout animation. 1094 // Should not have delay fadeout animation.
999 EXPECT_TRUE(client_.start_fade().is_null() || 1095 EXPECT_TRUE(client_.start_fade().is_null() ||
1000 client_.start_fade().IsCancelled()); 1096 client_.start_fade().IsCancelled());
1001 1097
1002 // Mouse leave. 1098 // Mouse leave.
1003 scrollbar_controller_->DidMouseLeave(); 1099 scrollbar_controller_->DidMouseLeave();
1004 1100
1005 // An fade out animation should have been enqueued. 1101 // An fade out animation should have been enqueued.
1006 EXPECT_FALSE(client_.start_fade().is_null()); 1102 EXPECT_FALSE(client_.start_fade().is_null());
1007 EXPECT_EQ(kFadeDelay, client_.delay()); 1103 EXPECT_EQ(kFadeDelay, client_.delay());
1008 } 1104 }
1009 1105
1010 // Scrollbars should schedule a delay fade in when mouse hover the show 1106 // Scrollbars should schedule a delay fade in when mouse hover the show
1011 // scrollbar region of a hidden scrollbar. 1107 // scrollbar region of a hidden scrollbar.
1012 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, BasicMouseHoverFadeIn) { 1108 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, BasicMouseHoverFadeIn) {
1013 base::TimeTicks time; 1109 base::TimeTicks time;
1014 time += base::TimeDelta::FromSeconds(1); 1110 time += base::TimeDelta::FromSeconds(1);
1015 1111
1016 // Move mouse hover the fade in scrollbar region of scrollbar. 1112 // Move mouse hover the fade in scrollbar region of scrollbar.
1017 scrollbar_controller_->DidMouseMoveNear( 1113 scrollbar_controller_->DidMouseMove(
1018 VERTICAL, kMouseMoveDistanceToTriggerFadeIn - 1); 1114 NearVerticalScrollbarBegin(-kMouseMoveDistanceToTriggerFadeIn + 1, 0));
1019 1115
1020 // An fade in animation should have been enqueued. 1116 // An fade in animation should have been enqueued.
1021 EXPECT_FALSE(client_.start_fade().is_null()); 1117 EXPECT_FALSE(client_.start_fade().is_null());
1022 EXPECT_FALSE(client_.start_fade().IsCancelled()); 1118 EXPECT_FALSE(client_.start_fade().IsCancelled());
1023 EXPECT_EQ(kFadeDelay, client_.delay()); 1119 EXPECT_EQ(kFadeDelay, client_.delay());
1024 1120
1025 // Play the delay animation. 1121 // Play the delay animation.
1026 client_.start_fade().Run(); 1122 client_.start_fade().Run();
1027 EXPECT_TRUE(client_.start_fade().IsCancelled()); 1123 EXPECT_TRUE(client_.start_fade().IsCancelled());
1028 1124
(...skipping 12 matching lines...) Expand all
1041 } 1137 }
1042 1138
1043 // Scrollbars should not schedule a new delay fade in when the mouse hovers 1139 // Scrollbars should not schedule a new delay fade in when the mouse hovers
1044 // inside a scrollbar already scheduled a delay fade in. 1140 // inside a scrollbar already scheduled a delay fade in.
1045 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, 1141 TEST_F(ScrollbarAnimationControllerAuraOverlayTest,
1046 MouseHoverScrollbarAndMoveInside) { 1142 MouseHoverScrollbarAndMoveInside) {
1047 base::TimeTicks time; 1143 base::TimeTicks time;
1048 time += base::TimeDelta::FromSeconds(1); 1144 time += base::TimeDelta::FromSeconds(1);
1049 1145
1050 // Move mouse hover the fade in scrollbar region of scrollbar. 1146 // Move mouse hover the fade in scrollbar region of scrollbar.
1051 scrollbar_controller_->DidMouseMoveNear( 1147 scrollbar_controller_->DidMouseMove(
1052 VERTICAL, kMouseMoveDistanceToTriggerFadeIn - 1); 1148 NearVerticalScrollbarBegin(-kMouseMoveDistanceToTriggerFadeIn + 1, 0));
1053 1149
1054 // An fade in animation should have been enqueued. 1150 // An fade in animation should have been enqueued.
1055 EXPECT_FALSE(client_.start_fade().is_null()); 1151 EXPECT_FALSE(client_.start_fade().is_null());
1056 EXPECT_FALSE(client_.start_fade().IsCancelled()); 1152 EXPECT_FALSE(client_.start_fade().IsCancelled());
1057 EXPECT_EQ(kFadeDelay, client_.delay()); 1153 EXPECT_EQ(kFadeDelay, client_.delay());
1058 1154
1059 base::Closure& fade = client_.start_fade(); 1155 base::Closure& fade = client_.start_fade();
1060 // Move mouse still hover the fade in scrollbar region of scrollbar should not 1156 // Move mouse still hover the fade in scrollbar region of scrollbar should not
1061 // post a new fade in. 1157 // post a new fade in.
1062 scrollbar_controller_->DidMouseMoveNear( 1158 scrollbar_controller_->DidMouseMove(
1063 VERTICAL, kMouseMoveDistanceToTriggerFadeIn - 2); 1159 NearVerticalScrollbarBegin(-kMouseMoveDistanceToTriggerFadeIn + 2, 0));
1064 1160
1065 EXPECT_TRUE(fade.Equals(client_.start_fade())); 1161 EXPECT_TRUE(fade.Equals(client_.start_fade()));
1066 } 1162 }
1067 1163
1068 // Scrollbars should cancel delay fade in when mouse hover hidden scrollbar then 1164 // Scrollbars should cancel delay fade in when mouse hover hidden scrollbar then
1069 // move far away. 1165 // move far away.
1070 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, 1166 TEST_F(ScrollbarAnimationControllerAuraOverlayTest,
1071 MouseHoverThenOutShouldCancelFadeIn) { 1167 MouseHoverThenOutShouldCancelFadeIn) {
1072 base::TimeTicks time; 1168 base::TimeTicks time;
1073 time += base::TimeDelta::FromSeconds(1); 1169 time += base::TimeDelta::FromSeconds(1);
1074 1170
1075 // Move mouse hover the fade in scrollbar region of scrollbar. 1171 // Move mouse hover the fade in scrollbar region of scrollbar.
1076 scrollbar_controller_->DidMouseMoveNear( 1172 scrollbar_controller_->DidMouseMove(
1077 VERTICAL, kMouseMoveDistanceToTriggerFadeIn - 1); 1173 NearVerticalScrollbarBegin(-kMouseMoveDistanceToTriggerFadeIn + 1, 0));
1078 1174
1079 // An fade in animation should have been enqueued. 1175 // An fade in animation should have been enqueued.
1080 EXPECT_FALSE(client_.start_fade().is_null()); 1176 EXPECT_FALSE(client_.start_fade().is_null());
1081 EXPECT_FALSE(client_.start_fade().IsCancelled()); 1177 EXPECT_FALSE(client_.start_fade().IsCancelled());
1082 EXPECT_EQ(kFadeDelay, client_.delay()); 1178 EXPECT_EQ(kFadeDelay, client_.delay());
1083 1179
1084 // Move mouse far away,delay fade in should be canceled. 1180 // Move mouse far away,delay fade in should be canceled.
1085 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 1181 scrollbar_controller_->DidMouseMove(
1086 kMouseMoveDistanceToTriggerFadeIn); 1182 NearVerticalScrollbarBegin(-kMouseMoveDistanceToTriggerFadeIn, 0));
1183
1087 EXPECT_TRUE(client_.start_fade().is_null() || 1184 EXPECT_TRUE(client_.start_fade().is_null() ||
1088 client_.start_fade().IsCancelled()); 1185 client_.start_fade().IsCancelled());
1089 } 1186 }
1090 1187
1091 // Scrollbars should cancel delay fade in when mouse hover hidden scrollbar then 1188 // Scrollbars should cancel delay fade in when mouse hover hidden scrollbar then
1092 // move out of window. 1189 // move out of window.
1093 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, 1190 TEST_F(ScrollbarAnimationControllerAuraOverlayTest,
1094 MouseHoverThenLeaveShouldCancelShowThenEnterShouldFadeIn) { 1191 MouseHoverThenLeaveShouldCancelShowThenEnterShouldFadeIn) {
1095 base::TimeTicks time; 1192 base::TimeTicks time;
1096 time += base::TimeDelta::FromSeconds(1); 1193 time += base::TimeDelta::FromSeconds(1);
1097 1194
1098 // Move mouse hover the fade in scrollbar region of scrollbar. 1195 // Move mouse hover the fade in scrollbar region of scrollbar.
1099 scrollbar_controller_->DidMouseMoveNear( 1196 scrollbar_controller_->DidMouseMove(
1100 VERTICAL, kMouseMoveDistanceToTriggerFadeIn - 1); 1197 NearVerticalScrollbarBegin(-kMouseMoveDistanceToTriggerFadeIn + 1, 0));
1101 1198
1102 // An fade in animation should have been enqueued. 1199 // An fade in animation should have been enqueued.
1103 EXPECT_FALSE(client_.start_fade().is_null()); 1200 EXPECT_FALSE(client_.start_fade().is_null());
1104 EXPECT_FALSE(client_.start_fade().IsCancelled()); 1201 EXPECT_FALSE(client_.start_fade().IsCancelled());
1105 EXPECT_EQ(kFadeDelay, client_.delay()); 1202 EXPECT_EQ(kFadeDelay, client_.delay());
1106 1203
1107 // Move mouse out of window,delay fade in should be canceled. 1204 // Move mouse out of window,delay fade in should be canceled.
1108 scrollbar_controller_->DidMouseLeave(); 1205 scrollbar_controller_->DidMouseLeave();
1109 EXPECT_TRUE(client_.start_fade().is_null() || 1206 EXPECT_TRUE(client_.start_fade().is_null() ||
1110 client_.start_fade().IsCancelled()); 1207 client_.start_fade().IsCancelled());
1111 1208
1112 // Move mouse hover the fade in scrollbar region of scrollbar. 1209 // Move mouse hover the fade in scrollbar region of scrollbar.
1113 scrollbar_controller_->DidMouseMoveNear( 1210 scrollbar_controller_->DidMouseMove(
1114 VERTICAL, kMouseMoveDistanceToTriggerFadeIn - 1); 1211 NearVerticalScrollbarBegin(-kMouseMoveDistanceToTriggerFadeIn + 1, 0));
1115 1212
1116 // An fade in animation should have been enqueued. 1213 // An fade in animation should have been enqueued.
1117 EXPECT_FALSE(client_.start_fade().is_null()); 1214 EXPECT_FALSE(client_.start_fade().is_null());
1118 EXPECT_FALSE(client_.start_fade().IsCancelled()); 1215 EXPECT_FALSE(client_.start_fade().IsCancelled());
1119 EXPECT_EQ(kFadeDelay, client_.delay()); 1216 EXPECT_EQ(kFadeDelay, client_.delay());
1120 1217
1121 // Play the delay animation. 1218 // Play the delay animation.
1122 client_.start_fade().Run(); 1219 client_.start_fade().Run();
1123 EXPECT_TRUE(client_.start_fade().IsCancelled()); 1220 EXPECT_TRUE(client_.start_fade().IsCancelled());
1124 1221
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after
1616 EXPECT_FLOAT_EQ(1, scrollbar_layer_->Opacity()); 1713 EXPECT_FLOAT_EQ(1, scrollbar_layer_->Opacity());
1617 1714
1618 time += base::TimeDelta::FromSeconds(1); 1715 time += base::TimeDelta::FromSeconds(1);
1619 scrollbar_controller_->DidScrollEnd(); 1716 scrollbar_controller_->DidScrollEnd();
1620 EXPECT_FALSE(did_request_animate_); 1717 EXPECT_FALSE(did_request_animate_);
1621 EXPECT_FLOAT_EQ(1, scrollbar_layer_->Opacity()); 1718 EXPECT_FLOAT_EQ(1, scrollbar_layer_->Opacity());
1622 } 1719 }
1623 1720
1624 } // namespace 1721 } // namespace
1625 } // namespace cc 1722 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698