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

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

Powered by Google App Engine
This is Rietveld 408576698