forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
scrollbar_animation_controller_unittest.cc
1840 lines (1509 loc) · 68.9 KB
/
scrollbar_animation_controller_unittest.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "cc/input/scrollbar_animation_controller.h"
#include "cc/layers/solid_color_scrollbar_layer_impl.h"
#include "cc/test/fake_impl_task_runner_provider.h"
#include "cc/test/fake_layer_tree_host_impl.h"
#include "cc/test/geometry_test_utils.h"
#include "cc/test/test_task_graph_runner.h"
#include "cc/trees/layer_tree_impl.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
using testing::AtLeast;
using testing::Mock;
using testing::NiceMock;
using testing::_;
namespace cc {
namespace {
const float kIdleThicknessScale =
SingleScrollbarAnimationControllerThinning::kIdleThicknessScale;
const float kMouseMoveDistanceToTriggerFadeIn =
ScrollbarAnimationController::kMouseMoveDistanceToTriggerFadeIn;
const float kMouseMoveDistanceToTriggerExpand =
SingleScrollbarAnimationControllerThinning::
kMouseMoveDistanceToTriggerExpand;
const int kThumbThickness = 10;
class MockScrollbarAnimationControllerClient
: public ScrollbarAnimationControllerClient {
public:
explicit MockScrollbarAnimationControllerClient(LayerTreeHostImpl* host_impl)
: host_impl_(host_impl) {}
~MockScrollbarAnimationControllerClient() override = default;
void PostDelayedScrollbarAnimationTask(base::OnceClosure start_fade,
base::TimeDelta delay) override {
start_fade_ = std::move(start_fade);
delay_ = delay;
}
void SetNeedsRedrawForScrollbarAnimation() override {}
void SetNeedsAnimateForScrollbarAnimation() override {}
ScrollbarSet ScrollbarsFor(ElementId scroll_element_id) const override {
return host_impl_->ScrollbarsFor(scroll_element_id);
}
MOCK_METHOD0(DidChangeScrollbarVisibility, void());
base::OnceClosure& start_fade() { return start_fade_; }
base::TimeDelta& delay() { return delay_; }
private:
base::OnceClosure start_fade_;
base::TimeDelta delay_;
LayerTreeHostImpl* host_impl_;
};
class ScrollbarAnimationControllerAuraOverlayTest : public testing::Test {
public:
ScrollbarAnimationControllerAuraOverlayTest()
: host_impl_(&task_runner_provider_, &task_graph_runner_),
client_(&host_impl_) {}
void ExpectScrollbarsOpacity(float opacity) {
EXPECT_FLOAT_EQ(opacity, v_scrollbar_layer_->Opacity());
EXPECT_FLOAT_EQ(opacity, h_scrollbar_layer_->Opacity());
}
protected:
const base::TimeDelta kFadeDelay = base::TimeDelta::FromSeconds(4);
const base::TimeDelta kFadeDuration = base::TimeDelta::FromSeconds(3);
const base::TimeDelta kThinningDuration = base::TimeDelta::FromSeconds(2);
void SetUp() override {
std::unique_ptr<LayerImpl> scroll_layer =
LayerImpl::Create(host_impl_.active_tree(), 1);
std::unique_ptr<LayerImpl> clip =
LayerImpl::Create(host_impl_.active_tree(), 2);
clip_layer_ = clip.get();
scroll_layer->SetElementId(
LayerIdToElementIdForTesting(scroll_layer->id()));
LayerImpl* scroll_layer_ptr = scroll_layer.get();
const int kTrackStart = 0;
const int kTrackLength = 100;
const bool kIsLeftSideVerticalScrollbar = false;
const bool kIsOverlayScrollbar = true;
std::unique_ptr<SolidColorScrollbarLayerImpl> h_scrollbar =
SolidColorScrollbarLayerImpl::Create(
host_impl_.active_tree(), 3, HORIZONTAL, kThumbThickness,
kTrackStart, kIsLeftSideVerticalScrollbar, kIsOverlayScrollbar);
h_scrollbar->test_properties()->opacity = 0.0f;
std::unique_ptr<SolidColorScrollbarLayerImpl> v_scrollbar =
SolidColorScrollbarLayerImpl::Create(
host_impl_.active_tree(), 4, VERTICAL, kThumbThickness, kTrackStart,
kIsLeftSideVerticalScrollbar, kIsOverlayScrollbar);
v_scrollbar->test_properties()->opacity = 0.0f;
v_scrollbar_layer_ = v_scrollbar.get();
h_scrollbar_layer_ = h_scrollbar.get();
scroll_layer->test_properties()->AddChild(std::move(v_scrollbar));
scroll_layer->test_properties()->AddChild(std::move(h_scrollbar));
clip_layer_->test_properties()->AddChild(std::move(scroll_layer));
host_impl_.active_tree()->SetRootLayerForTesting(std::move(clip));
v_scrollbar_layer_->SetBounds(gfx::Size(kThumbThickness, kTrackLength));
v_scrollbar_layer_->test_properties()->position = gfx::PointF(90, 0);
v_scrollbar_layer_->SetScrollElementId(scroll_layer_ptr->element_id());
v_scrollbar_layer_->test_properties()->opacity_can_animate = true;
h_scrollbar_layer_->SetBounds(gfx::Size(kTrackLength, kThumbThickness));
h_scrollbar_layer_->test_properties()->position = gfx::PointF(0, 90);
h_scrollbar_layer_->SetScrollElementId(scroll_layer_ptr->element_id());
h_scrollbar_layer_->test_properties()->opacity_can_animate = true;
clip_layer_->SetBounds(gfx::Size(100, 100));
scroll_layer_ptr->SetScrollable(gfx::Size(100, 100));
scroll_layer_ptr->SetBounds(gfx::Size(200, 200));
host_impl_.active_tree()->BuildLayerListAndPropertyTreesForTesting();
host_impl_.active_tree()->UpdateScrollbarGeometries();
scrollbar_controller_ = ScrollbarAnimationController::
CreateScrollbarAnimationControllerAuraOverlay(
scroll_layer_ptr->element_id(), &client_, kFadeDelay, kFadeDuration,
kThinningDuration, 0.0f);
v_scrollbar_layer_->SetCurrentPos(0);
h_scrollbar_layer_->SetCurrentPos(0);
}
// Return a point with given offset from the top-left of vertical scrollbar.
gfx::PointF NearVerticalScrollbarBegin(float offset_x, float offset_y) {
gfx::PointF p(90, 0);
p.Offset(offset_x, offset_y);
return p;
}
// Return a point with given offset from the bottom-left of vertical
// scrollbar.
gfx::PointF NearVerticalScrollbarEnd(float offset_x, float offset_y) {
gfx::PointF p(90, 90);
p.Offset(offset_x, offset_y);
return p;
}
// Return a point with given offset from the top-left of horizontal scrollbar.
gfx::PointF NearHorizontalScrollbarBegin(float offset_x, float offset_y) {
gfx::PointF p(0, 90);
p.Offset(offset_x, offset_y);
return p;
}
FakeImplTaskRunnerProvider task_runner_provider_;
TestTaskGraphRunner task_graph_runner_;
FakeLayerTreeHostImpl host_impl_;
std::unique_ptr<ScrollbarAnimationController> scrollbar_controller_;
LayerImpl* clip_layer_;
SolidColorScrollbarLayerImpl* v_scrollbar_layer_;
SolidColorScrollbarLayerImpl* h_scrollbar_layer_;
NiceMock<MockScrollbarAnimationControllerClient> client_;
};
// Check initialization of scrollbar. Should start off invisible and thin.
TEST_F(ScrollbarAnimationControllerAuraOverlayTest, Idle) {
ExpectScrollbarsOpacity(0);
EXPECT_TRUE(scrollbar_controller_->ScrollbarsHidden());
EXPECT_FLOAT_EQ(kIdleThicknessScale,
v_scrollbar_layer_->thumb_thickness_scale_factor());
EXPECT_FLOAT_EQ(kIdleThicknessScale,
v_scrollbar_layer_->thumb_thickness_scale_factor());
}
// Check that scrollbar appears again when the layer becomes scrollable.
TEST_F(ScrollbarAnimationControllerAuraOverlayTest, AppearOnResize) {
base::TimeTicks time;
time += base::TimeDelta::FromSeconds(1);
scrollbar_controller_->DidScrollBegin();
scrollbar_controller_->DidScrollUpdate();
scrollbar_controller_->DidScrollEnd();
ExpectScrollbarsOpacity(1);
// Make the Layer non-scrollable, scrollbar disappears.
clip_layer_->SetBounds(gfx::Size(200, 200));
LayerImpl* scroll_layer = host_impl_.active_tree()->LayerById(1);
scroll_layer->SetScrollable(gfx::Size(200, 200));
host_impl_.active_tree()->BuildLayerListAndPropertyTreesForTesting();
scrollbar_controller_->DidScrollUpdate();
ExpectScrollbarsOpacity(0);
// Make the layer scrollable, scrollbar appears again.
clip_layer_->SetBounds(gfx::Size(100, 100));
scroll_layer->SetScrollable(gfx::Size(100, 100));
host_impl_.active_tree()->BuildLayerListAndPropertyTreesForTesting();
scrollbar_controller_->DidScrollUpdate();
ExpectScrollbarsOpacity(1);
}
// Check that scrollbar disappears when the layer becomes non-scrollable.
TEST_F(ScrollbarAnimationControllerAuraOverlayTest, HideOnResize) {
base::TimeTicks time;
time += base::TimeDelta::FromSeconds(1);
LayerImpl* scroll_layer = host_impl_.active_tree()->LayerById(1);
ASSERT_TRUE(scroll_layer);
EXPECT_EQ(gfx::Size(200, 200), scroll_layer->bounds());
// Shrink along X axis, horizontal scrollbar should appear.
clip_layer_->SetBounds(gfx::Size(100, 200));
EXPECT_EQ(gfx::Size(100, 200), clip_layer_->bounds());
scroll_layer->SetScrollable(gfx::Size(100, 200));
host_impl_.active_tree()->BuildLayerListAndPropertyTreesForTesting();
scrollbar_controller_->DidScrollBegin();
scrollbar_controller_->DidScrollUpdate();
EXPECT_FLOAT_EQ(1, h_scrollbar_layer_->Opacity());
scrollbar_controller_->DidScrollEnd();
// Shrink along Y axis and expand along X, horizontal scrollbar
// should disappear.
clip_layer_->SetBounds(gfx::Size(200, 100));
EXPECT_EQ(gfx::Size(200, 100), clip_layer_->bounds());
scroll_layer->SetScrollable(gfx::Size(200, 100));
host_impl_.active_tree()->BuildLayerListAndPropertyTreesForTesting();
scrollbar_controller_->DidScrollBegin();
scrollbar_controller_->DidScrollUpdate();
EXPECT_FLOAT_EQ(0.0f, h_scrollbar_layer_->Opacity());
scrollbar_controller_->DidScrollEnd();
}
// Scroll content. Confirm the scrollbar appears and fades out.
TEST_F(ScrollbarAnimationControllerAuraOverlayTest, BasicAppearAndFadeOut) {
base::TimeTicks time;
time += base::TimeDelta::FromSeconds(1);
// Scrollbar should be invisible.
ExpectScrollbarsOpacity(0);
EXPECT_TRUE(scrollbar_controller_->ScrollbarsHidden());
// Scrollbar should appear only on scroll update.
scrollbar_controller_->DidScrollBegin();
ExpectScrollbarsOpacity(0);
EXPECT_TRUE(scrollbar_controller_->ScrollbarsHidden());
scrollbar_controller_->DidScrollUpdate();
ExpectScrollbarsOpacity(1);
EXPECT_FALSE(scrollbar_controller_->ScrollbarsHidden());
scrollbar_controller_->DidScrollEnd();
ExpectScrollbarsOpacity(1);
EXPECT_FALSE(scrollbar_controller_->ScrollbarsHidden());
// An fade out animation should have been enqueued.
EXPECT_EQ(kFadeDelay, client_.delay());
EXPECT_FALSE(client_.start_fade().is_null());
std::move(client_.start_fade()).Run();
// Scrollbar should fade out over kFadeDuration.
scrollbar_controller_->Animate(time);
time += kFadeDuration;
scrollbar_controller_->Animate(time);
ExpectScrollbarsOpacity(0);
EXPECT_TRUE(scrollbar_controller_->ScrollbarsHidden());
}
// Confirm the scrollbar appears by WillUpdateScroll and fade out.
TEST_F(ScrollbarAnimationControllerAuraOverlayTest,
BasicAppearByWillUpdateScrollThenFadeOut) {
base::TimeTicks time;
time += base::TimeDelta::FromSeconds(1);
// Scrollbar should be invisible.
ExpectScrollbarsOpacity(0);
EXPECT_TRUE(scrollbar_controller_->ScrollbarsHidden());
// Scrollbar should appear when scroll will update.
scrollbar_controller_->WillUpdateScroll();
ExpectScrollbarsOpacity(1);
EXPECT_FALSE(scrollbar_controller_->ScrollbarsHidden());
// An fade out animation should have been enqueued.
EXPECT_EQ(kFadeDelay, client_.delay());
EXPECT_FALSE(client_.start_fade().is_null());
std::move(client_.start_fade()).Run();
// Scrollbar should fade out over kFadeDuration.
scrollbar_controller_->Animate(time);
time += kFadeDuration;
scrollbar_controller_->Animate(time);
ExpectScrollbarsOpacity(0);
EXPECT_TRUE(scrollbar_controller_->ScrollbarsHidden());
}
// Scroll content. Move the mouse near the scrollbar track but not near thumb
// and confirm it stay thin. Move the mouse near the scrollbar thumb and
// confirm it becomes thick.
TEST_F(ScrollbarAnimationControllerAuraOverlayTest,
MoveNearTrackThenNearThumb) {
base::TimeTicks time;
time += base::TimeDelta::FromSeconds(1);
scrollbar_controller_->DidScrollBegin();
scrollbar_controller_->DidScrollUpdate();
scrollbar_controller_->DidScrollEnd();
// An fade out animation should have been enqueued.
EXPECT_EQ(kFadeDelay, client_.delay());
EXPECT_FALSE(client_.start_fade().is_null());
EXPECT_FALSE(client_.start_fade().IsCancelled());
// Now move the mouse near the vertical scrollbar track. This should cancel
// the currently queued fading animation and stay scrollbar thin.
scrollbar_controller_->DidMouseMove(NearVerticalScrollbarEnd(-1, 0));
ExpectScrollbarsOpacity(1);
EXPECT_FLOAT_EQ(kIdleThicknessScale,
v_scrollbar_layer_->thumb_thickness_scale_factor());
EXPECT_FLOAT_EQ(kIdleThicknessScale,
h_scrollbar_layer_->thumb_thickness_scale_factor());
EXPECT_TRUE(client_.start_fade().IsCancelled());
scrollbar_controller_->Animate(time);
time += kThinningDuration;
scrollbar_controller_->Animate(time);
EXPECT_FLOAT_EQ(kIdleThicknessScale,
v_scrollbar_layer_->thumb_thickness_scale_factor());
EXPECT_FLOAT_EQ(kIdleThicknessScale,
h_scrollbar_layer_->thumb_thickness_scale_factor());
scrollbar_controller_->DidMouseMove(NearVerticalScrollbarBegin(-1, 0));
scrollbar_controller_->Animate(time);
time += kThinningDuration;
scrollbar_controller_->Animate(time);
EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor());
EXPECT_FLOAT_EQ(kIdleThicknessScale,
h_scrollbar_layer_->thumb_thickness_scale_factor());
scrollbar_controller_->DidMouseMove(NearVerticalScrollbarEnd(-1, 0));
EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor());
EXPECT_FLOAT_EQ(kIdleThicknessScale,
h_scrollbar_layer_->thumb_thickness_scale_factor());
EXPECT_TRUE(client_.start_fade().IsCancelled());
scrollbar_controller_->Animate(time);
time += kThinningDuration;
scrollbar_controller_->Animate(time);
EXPECT_FLOAT_EQ(kIdleThicknessScale,
v_scrollbar_layer_->thumb_thickness_scale_factor());
EXPECT_FLOAT_EQ(kIdleThicknessScale,
h_scrollbar_layer_->thumb_thickness_scale_factor());
}
// Scroll content. Move the mouse near the scrollbar thumb and confirm it
// becomes thick. Ensure it remains visible as long as the mouse is near the
// scrollbar.
TEST_F(ScrollbarAnimationControllerAuraOverlayTest, MoveNearAndDontFadeOut) {
base::TimeTicks time;
time += base::TimeDelta::FromSeconds(1);
scrollbar_controller_->DidScrollBegin();
scrollbar_controller_->DidScrollUpdate();
scrollbar_controller_->DidScrollEnd();
// An fade out animation should have been enqueued.
EXPECT_EQ(kFadeDelay, client_.delay());
EXPECT_FALSE(client_.start_fade().is_null());
EXPECT_FALSE(client_.start_fade().IsCancelled());
// Now move the mouse near the vertical scrollbar thumb. This should cancel
// the currently queued fading animation and start animating thickness.
scrollbar_controller_->DidMouseMove(NearVerticalScrollbarBegin(-1, 0));
ExpectScrollbarsOpacity(1);
EXPECT_FLOAT_EQ(kIdleThicknessScale,
v_scrollbar_layer_->thumb_thickness_scale_factor());
EXPECT_FLOAT_EQ(kIdleThicknessScale,
h_scrollbar_layer_->thumb_thickness_scale_factor());
EXPECT_TRUE(client_.start_fade().IsCancelled());
// Vertical scrollbar should become thick.
scrollbar_controller_->Animate(time);
time += kThinningDuration;
scrollbar_controller_->Animate(time);
ExpectScrollbarsOpacity(1);
EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor());
EXPECT_FLOAT_EQ(kIdleThicknessScale,
h_scrollbar_layer_->thumb_thickness_scale_factor());
// Mouse is still near the Scrollbar. Once the thickness animation is
// complete, the queued delayed fade out animation should be either cancelled
// or null.
EXPECT_TRUE(client_.start_fade().is_null() ||
client_.start_fade().IsCancelled());
}
// Scroll content. Move the mouse over the scrollbar and confirm it becomes
// thick. Ensure it remains visible as long as the mouse is over the scrollbar.
TEST_F(ScrollbarAnimationControllerAuraOverlayTest, MoveOverAndDontFadeOut) {
base::TimeTicks time;
time += base::TimeDelta::FromSeconds(1);
scrollbar_controller_->DidScrollBegin();
scrollbar_controller_->DidScrollUpdate();
scrollbar_controller_->DidScrollEnd();
// An fade out animation should have been enqueued.
EXPECT_EQ(kFadeDelay, client_.delay());
EXPECT_FALSE(client_.start_fade().is_null());
EXPECT_FALSE(client_.start_fade().IsCancelled());
// Now move the mouse over the vertical scrollbar thumb. This should cancel
// the currently queued fading animation and start animating thickness.
scrollbar_controller_->DidMouseMove(NearVerticalScrollbarBegin(0, 0));
ExpectScrollbarsOpacity(1);
EXPECT_FLOAT_EQ(kIdleThicknessScale,
v_scrollbar_layer_->thumb_thickness_scale_factor());
EXPECT_FLOAT_EQ(kIdleThicknessScale,
h_scrollbar_layer_->thumb_thickness_scale_factor());
EXPECT_TRUE(client_.start_fade().IsCancelled());
// Vertical scrollbar should become thick.
scrollbar_controller_->Animate(time);
time += kThinningDuration;
scrollbar_controller_->Animate(time);
ExpectScrollbarsOpacity(1);
EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor());
EXPECT_FLOAT_EQ(kIdleThicknessScale,
h_scrollbar_layer_->thumb_thickness_scale_factor());
// Mouse is still over the Scrollbar. Once the thickness animation is
// complete, the queued delayed fade out animation should be either cancelled
// or null.
EXPECT_TRUE(client_.start_fade().is_null() ||
client_.start_fade().IsCancelled());
}
// Make sure a scrollbar captured before the thickening animation doesn't try
// to fade out.
TEST_F(ScrollbarAnimationControllerAuraOverlayTest,
DontFadeWhileCapturedBeforeThick) {
base::TimeTicks time;
time += base::TimeDelta::FromSeconds(1);
scrollbar_controller_->DidScrollBegin();
scrollbar_controller_->DidScrollUpdate();
scrollbar_controller_->DidScrollEnd();
// An fade out animation should have been enqueued.
EXPECT_EQ(kFadeDelay, client_.delay());
EXPECT_FALSE(client_.start_fade().is_null());
// Now move the mouse over the vertical scrollbar thumb and capture it. It
// should become thick without need for an animation.
scrollbar_controller_->DidMouseMove(NearVerticalScrollbarBegin(0, 0));
scrollbar_controller_->DidMouseDown();
ExpectScrollbarsOpacity(1);
EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor());
EXPECT_FLOAT_EQ(kIdleThicknessScale,
h_scrollbar_layer_->thumb_thickness_scale_factor());
// The fade out animation should have been cleared or cancelled.
EXPECT_TRUE(client_.start_fade().is_null() ||
client_.start_fade().IsCancelled());
}
// Make sure a scrollbar captured then move mouse away doesn't try to fade out.
TEST_F(ScrollbarAnimationControllerAuraOverlayTest,
DontFadeWhileCapturedThenAway) {
base::TimeTicks time;
time += base::TimeDelta::FromSeconds(1);
scrollbar_controller_->DidScrollBegin();
scrollbar_controller_->DidScrollUpdate();
scrollbar_controller_->DidScrollEnd();
// An fade out animation should have been enqueued.
EXPECT_EQ(kFadeDelay, client_.delay());
EXPECT_FALSE(client_.start_fade().is_null());
// Now move the mouse over the vertical scrollbar and capture it. It should
// become thick without need for an animation.
scrollbar_controller_->DidMouseMove(NearVerticalScrollbarBegin(0, 0));
scrollbar_controller_->DidMouseDown();
ExpectScrollbarsOpacity(1);
EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor());
EXPECT_FLOAT_EQ(kIdleThicknessScale,
h_scrollbar_layer_->thumb_thickness_scale_factor());
// The fade out animation should have been cleared or cancelled.
EXPECT_TRUE(client_.start_fade().is_null() ||
client_.start_fade().IsCancelled());
// Then move mouse away, The fade out animation should have been cleared or
// cancelled.
scrollbar_controller_->DidMouseMove(
NearVerticalScrollbarBegin(-kMouseMoveDistanceToTriggerExpand, 0));
EXPECT_TRUE(client_.start_fade().is_null() ||
client_.start_fade().IsCancelled());
}
// Make sure a scrollbar captured after a thickening animation doesn't try to
// fade out.
TEST_F(ScrollbarAnimationControllerAuraOverlayTest, DontFadeWhileCaptured) {
base::TimeTicks time;
time += base::TimeDelta::FromSeconds(1);
scrollbar_controller_->DidScrollBegin();
scrollbar_controller_->DidScrollUpdate();
scrollbar_controller_->DidScrollEnd();
// An fade out animation should have been enqueued.
EXPECT_EQ(kFadeDelay, client_.delay());
EXPECT_FALSE(client_.start_fade().is_null());
EXPECT_FALSE(client_.start_fade().IsCancelled());
// Now move the mouse over the vertical scrollbar thumb and animate it until
// it's thick.
scrollbar_controller_->DidMouseMove(NearVerticalScrollbarBegin(0, 0));
scrollbar_controller_->Animate(time);
time += kThinningDuration;
scrollbar_controller_->Animate(time);
ExpectScrollbarsOpacity(1);
EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor());
EXPECT_FLOAT_EQ(kIdleThicknessScale,
h_scrollbar_layer_->thumb_thickness_scale_factor());
// Since the mouse is over the scrollbar, it should either clear or cancel the
// queued fade.
EXPECT_TRUE(client_.start_fade().is_null() ||
client_.start_fade().IsCancelled());
// Make sure the queued fade out animation is still null or cancelled after
// capturing the scrollbar.
scrollbar_controller_->DidMouseDown();
EXPECT_TRUE(client_.start_fade().is_null() ||
client_.start_fade().IsCancelled());
}
// Make sure releasing a captured scrollbar when the mouse isn't near it, causes
// the scrollbar to fade out.
TEST_F(ScrollbarAnimationControllerAuraOverlayTest, FadeAfterReleasedFar) {
base::TimeTicks time;
time += base::TimeDelta::FromSeconds(1);
scrollbar_controller_->DidScrollBegin();
scrollbar_controller_->DidScrollUpdate();
scrollbar_controller_->DidScrollEnd();
// An fade out animation should have been enqueued.
EXPECT_EQ(kFadeDelay, client_.delay());
EXPECT_FALSE(client_.start_fade().is_null());
EXPECT_FALSE(client_.start_fade().IsCancelled());
// Now move the mouse over the vertical scrollbar thumb and capture it.
scrollbar_controller_->DidMouseMove(NearVerticalScrollbarBegin(0, 0));
scrollbar_controller_->DidMouseDown();
ExpectScrollbarsOpacity(1);
EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor());
EXPECT_FLOAT_EQ(kIdleThicknessScale,
h_scrollbar_layer_->thumb_thickness_scale_factor());
// Since the mouse is still near the scrollbar, the queued fade should be
// either null or cancelled.
EXPECT_TRUE(client_.start_fade().is_null() ||
client_.start_fade().IsCancelled());
// Now move the mouse away from the scrollbar and release it.
scrollbar_controller_->DidMouseMove(
NearVerticalScrollbarBegin(-kMouseMoveDistanceToTriggerFadeIn, 0));
scrollbar_controller_->DidMouseUp();
scrollbar_controller_->Animate(time);
ExpectScrollbarsOpacity(1);
EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor());
EXPECT_FLOAT_EQ(kIdleThicknessScale,
h_scrollbar_layer_->thumb_thickness_scale_factor());
time += kThinningDuration;
scrollbar_controller_->Animate(time);
ExpectScrollbarsOpacity(1);
EXPECT_FLOAT_EQ(kIdleThicknessScale,
v_scrollbar_layer_->thumb_thickness_scale_factor());
EXPECT_FLOAT_EQ(kIdleThicknessScale,
h_scrollbar_layer_->thumb_thickness_scale_factor());
// The thickness animation is complete, a fade out must be queued.
EXPECT_FALSE(client_.start_fade().is_null());
EXPECT_FALSE(client_.start_fade().IsCancelled());
}
// Make sure releasing a captured scrollbar when the mouse is near/over it,
// doesn't cause the scrollbar to fade out.
TEST_F(ScrollbarAnimationControllerAuraOverlayTest, DontFadeAfterReleasedNear) {
base::TimeTicks time;
time += base::TimeDelta::FromSeconds(1);
scrollbar_controller_->DidScrollBegin();
scrollbar_controller_->DidScrollUpdate();
scrollbar_controller_->DidScrollEnd();
// An fade out animation should have been enqueued.
EXPECT_EQ(kFadeDelay, client_.delay());
EXPECT_FALSE(client_.start_fade().is_null());
EXPECT_FALSE(client_.start_fade().IsCancelled());
// Now move the mouse over the vertical scrollbar thumb and capture it.
scrollbar_controller_->DidMouseMove(NearVerticalScrollbarBegin(0, 0));
scrollbar_controller_->DidMouseDown();
ExpectScrollbarsOpacity(1);
EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor());
EXPECT_FLOAT_EQ(kIdleThicknessScale,
h_scrollbar_layer_->thumb_thickness_scale_factor());
// Since the mouse is over the scrollbar, the queued fade must be either
// null or cancelled.
EXPECT_TRUE(client_.start_fade().is_null() ||
client_.start_fade().IsCancelled());
// Mouse is still near the scrollbar, releasing it shouldn't do anything.
scrollbar_controller_->DidMouseUp();
EXPECT_TRUE(client_.start_fade().is_null() ||
client_.start_fade().IsCancelled());
ExpectScrollbarsOpacity(1);
EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor());
EXPECT_FLOAT_EQ(kIdleThicknessScale,
h_scrollbar_layer_->thumb_thickness_scale_factor());
}
// Make sure moving near a scrollbar while it's fading out causes it to reset
// the opacity and thicken.
TEST_F(ScrollbarAnimationControllerAuraOverlayTest,
MoveNearScrollbarWhileFading) {
base::TimeTicks time;
time += base::TimeDelta::FromSeconds(1);
scrollbar_controller_->DidScrollBegin();
scrollbar_controller_->DidScrollUpdate();
scrollbar_controller_->DidScrollEnd();
// A fade out animation should have been enqueued. Start it.
EXPECT_EQ(kFadeDelay, client_.delay());
EXPECT_FALSE(client_.start_fade().is_null());
std::move(client_.start_fade()).Run();
scrollbar_controller_->Animate(time);
ExpectScrollbarsOpacity(1);
// Proceed half way through the fade out animation.
time += kFadeDuration / 2;
scrollbar_controller_->Animate(time);
ExpectScrollbarsOpacity(.5f);
// Now move the mouse near the vertical scrollbar thumb. It should reset
// opacity to 1 instantly and start animating to thick.
scrollbar_controller_->DidMouseMove(NearVerticalScrollbarBegin(0, 0));
ExpectScrollbarsOpacity(1);
EXPECT_FLOAT_EQ(kIdleThicknessScale,
v_scrollbar_layer_->thumb_thickness_scale_factor());
EXPECT_FLOAT_EQ(kIdleThicknessScale,
h_scrollbar_layer_->thumb_thickness_scale_factor());
scrollbar_controller_->Animate(time);
time += kThinningDuration;
scrollbar_controller_->Animate(time);
ExpectScrollbarsOpacity(1);
EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor());
EXPECT_FLOAT_EQ(kIdleThicknessScale,
h_scrollbar_layer_->thumb_thickness_scale_factor());
}
// Make sure we can't capture scrollbar that's completely faded out.
TEST_F(ScrollbarAnimationControllerAuraOverlayTest, TestCantCaptureWhenFaded) {
base::TimeTicks time;
time += base::TimeDelta::FromSeconds(1);
scrollbar_controller_->DidScrollBegin();
scrollbar_controller_->DidScrollUpdate();
scrollbar_controller_->DidScrollEnd();
EXPECT_EQ(kFadeDelay, client_.delay());
EXPECT_FALSE(client_.start_fade().is_null());
EXPECT_FALSE(client_.start_fade().IsCancelled());
std::move(client_.start_fade()).Run();
scrollbar_controller_->Animate(time);
ExpectScrollbarsOpacity(1);
// Fade the scrollbar out completely.
time += kFadeDuration;
scrollbar_controller_->Animate(time);
ExpectScrollbarsOpacity(0);
// Move mouse over the vertical scrollbar thumb. It shouldn't thicken the
// scrollbar since it's completely faded out.
scrollbar_controller_->DidMouseMove(NearVerticalScrollbarBegin(0, 0));
scrollbar_controller_->Animate(time);
time += kThinningDuration;
scrollbar_controller_->Animate(time);
ExpectScrollbarsOpacity(0);
EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor());
EXPECT_FLOAT_EQ(kIdleThicknessScale,
h_scrollbar_layer_->thumb_thickness_scale_factor());
client_.start_fade().Reset();
// Now try to capture the scrollbar. It shouldn't do anything since it's
// completely faded out.
scrollbar_controller_->DidMouseDown();
ExpectScrollbarsOpacity(0);
EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor());
EXPECT_FLOAT_EQ(kIdleThicknessScale,
h_scrollbar_layer_->thumb_thickness_scale_factor());
EXPECT_TRUE(client_.start_fade().is_null());
// Similarly, releasing the scrollbar should have no effect but trigger a fade
// in.
scrollbar_controller_->DidMouseUp();
ExpectScrollbarsOpacity(0);
EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor());
EXPECT_FLOAT_EQ(kIdleThicknessScale,
h_scrollbar_layer_->thumb_thickness_scale_factor());
// An fade in animation should have been enqueued.
EXPECT_FALSE(client_.start_fade().is_null());
EXPECT_FALSE(client_.start_fade().IsCancelled());
EXPECT_EQ(kFadeDelay, client_.delay());
// Play the delay animation.
std::move(client_.start_fade()).Run();
scrollbar_controller_->Animate(time);
time += kFadeDuration;
scrollbar_controller_->Animate(time);
EXPECT_FALSE(scrollbar_controller_->ScrollbarsHidden());
}
// Initiate a scroll when the pointer is already near the scrollbar. It should
// appear thick and remain thick.
TEST_F(ScrollbarAnimationControllerAuraOverlayTest, ScrollWithMouseNear) {
base::TimeTicks time;
time += base::TimeDelta::FromSeconds(1);
scrollbar_controller_->DidMouseMove(NearVerticalScrollbarBegin(-1, 0));
scrollbar_controller_->Animate(time);
time += kThinningDuration;
// Since the scrollbar isn't visible yet (because we haven't scrolled), we
// shouldn't have applied the thickening.
scrollbar_controller_->Animate(time);
EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor());
EXPECT_FLOAT_EQ(kIdleThicknessScale,
h_scrollbar_layer_->thumb_thickness_scale_factor());
scrollbar_controller_->DidScrollBegin();
scrollbar_controller_->DidScrollUpdate();
// Now that we've received a scroll, we should be thick without an animation.
ExpectScrollbarsOpacity(1);
// An animation for the fade should be either null or cancelled, since
// mouse is still near the scrollbar.
scrollbar_controller_->DidScrollEnd();
EXPECT_TRUE(client_.start_fade().is_null() ||
client_.start_fade().IsCancelled());
scrollbar_controller_->Animate(time);
ExpectScrollbarsOpacity(1);
EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor());
EXPECT_FLOAT_EQ(kIdleThicknessScale,
h_scrollbar_layer_->thumb_thickness_scale_factor());
// Scrollbar should still be thick and visible.
time += kFadeDuration;
scrollbar_controller_->Animate(time);
ExpectScrollbarsOpacity(1);
EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor());
EXPECT_FLOAT_EQ(kIdleThicknessScale,
h_scrollbar_layer_->thumb_thickness_scale_factor());
}
// Tests that main thread scroll updates immediatley queue a fade out animation
// without requiring a ScrollEnd.
TEST_F(ScrollbarAnimationControllerAuraOverlayTest,
MainThreadScrollQueuesFade) {
ASSERT_TRUE(client_.start_fade().is_null());
// A ScrollUpdate without a ScrollBegin indicates a main thread scroll update
// so we should schedule a fade out animation without waiting for a ScrollEnd
// (which will never come).
scrollbar_controller_->DidScrollUpdate();
EXPECT_FALSE(client_.start_fade().is_null());
EXPECT_EQ(kFadeDelay, client_.delay());
client_.start_fade().Reset();
// If we got a ScrollBegin, we shouldn't schedule the fade out animation until
// we get a corresponding ScrollEnd.
scrollbar_controller_->DidScrollBegin();
scrollbar_controller_->DidScrollUpdate();
EXPECT_TRUE(client_.start_fade().is_null());
scrollbar_controller_->DidScrollEnd();
EXPECT_FALSE(client_.start_fade().is_null());
EXPECT_EQ(kFadeDelay, client_.delay());
}
// Tests that the fade effect is animated.
TEST_F(ScrollbarAnimationControllerAuraOverlayTest, FadeAnimated) {
base::TimeTicks time;
time += base::TimeDelta::FromSeconds(1);
// Scroll to make the scrollbars visible.
scrollbar_controller_->DidScrollBegin();
scrollbar_controller_->DidScrollUpdate();
scrollbar_controller_->DidScrollEnd();
// Appearance is instant.
ExpectScrollbarsOpacity(1);
// An fade out animation should have been enqueued.
EXPECT_EQ(kFadeDelay, client_.delay());
EXPECT_FALSE(client_.start_fade().is_null());
std::move(client_.start_fade()).Run();
// Test that at half the fade duration time, the opacity is at half.
scrollbar_controller_->Animate(time);
ExpectScrollbarsOpacity(1);
time += kFadeDuration / 2;
scrollbar_controller_->Animate(time);
ExpectScrollbarsOpacity(.5f);
time += kFadeDuration / 2;
scrollbar_controller_->Animate(time);
ExpectScrollbarsOpacity(0);
}
// Tests that the controller tells the client when the scrollbars hide/show.
TEST_F(ScrollbarAnimationControllerAuraOverlayTest, NotifyChangedVisibility) {
base::TimeTicks time;
time += base::TimeDelta::FromSeconds(1);
EXPECT_CALL(client_, DidChangeScrollbarVisibility()).Times(1);
// Scroll to make the scrollbars visible.
scrollbar_controller_->DidScrollBegin();
scrollbar_controller_->DidScrollUpdate();
EXPECT_FALSE(scrollbar_controller_->ScrollbarsHidden());
Mock::VerifyAndClearExpectations(&client_);
scrollbar_controller_->DidScrollEnd();
// Play out the fade out animation. We shouldn't notify that the scrollbars
// are hidden until the animation is completly over. We can (but don't have
// to) notify during the animation that the scrollbars are still visible.
EXPECT_CALL(client_, DidChangeScrollbarVisibility()).Times(0);
ASSERT_FALSE(client_.start_fade().is_null());
std::move(client_.start_fade()).Run();
scrollbar_controller_->Animate(time);
time += kFadeDuration / 4;
EXPECT_FALSE(scrollbar_controller_->ScrollbarsHidden());
scrollbar_controller_->Animate(time);
time += kFadeDuration / 4;
EXPECT_FALSE(scrollbar_controller_->ScrollbarsHidden());
scrollbar_controller_->Animate(time);
time += kFadeDuration / 4;
EXPECT_FALSE(scrollbar_controller_->ScrollbarsHidden());
scrollbar_controller_->Animate(time);
ExpectScrollbarsOpacity(.25f);
Mock::VerifyAndClearExpectations(&client_);
EXPECT_CALL(client_, DidChangeScrollbarVisibility()).Times(1);
time += kFadeDuration / 4;
scrollbar_controller_->Animate(time);
EXPECT_TRUE(scrollbar_controller_->ScrollbarsHidden());
ExpectScrollbarsOpacity(0);
Mock::VerifyAndClearExpectations(&client_);
// Calling DidScrollUpdate without a begin (i.e. update from commit) should
// also notify.
EXPECT_CALL(client_, DidChangeScrollbarVisibility()).Times(1);
scrollbar_controller_->DidScrollUpdate();
EXPECT_FALSE(scrollbar_controller_->ScrollbarsHidden());
Mock::VerifyAndClearExpectations(&client_);
}
// Move the pointer near each scrollbar. Confirm it gets thick and narrow when
// moved away.
TEST_F(ScrollbarAnimationControllerAuraOverlayTest, MouseNearEach) {
base::TimeTicks time;
time += base::TimeDelta::FromSeconds(1);
// Scroll to make the scrollbars visible.
scrollbar_controller_->DidScrollBegin();
scrollbar_controller_->DidScrollUpdate();
scrollbar_controller_->DidScrollEnd();
// Near vertical scrollbar.
scrollbar_controller_->DidMouseMove(NearVerticalScrollbarBegin(-1, 0));
scrollbar_controller_->Animate(time);
ExpectScrollbarsOpacity(1);
EXPECT_FLOAT_EQ(kIdleThicknessScale,
v_scrollbar_layer_->thumb_thickness_scale_factor());
EXPECT_FLOAT_EQ(kIdleThicknessScale,
h_scrollbar_layer_->thumb_thickness_scale_factor());
// Should animate to thickened.
time += kThinningDuration;
scrollbar_controller_->Animate(time);
ExpectScrollbarsOpacity(1);
EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor());
EXPECT_FLOAT_EQ(kIdleThicknessScale,
h_scrollbar_layer_->thumb_thickness_scale_factor());
// Subsequent moves within the nearness threshold should not change anything.
scrollbar_controller_->DidMouseMove(NearVerticalScrollbarBegin(-2, 0));
scrollbar_controller_->Animate(time);
time += base::TimeDelta::FromSeconds(10);
scrollbar_controller_->Animate(time);
ExpectScrollbarsOpacity(1);
EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor());
EXPECT_FLOAT_EQ(kIdleThicknessScale,
h_scrollbar_layer_->thumb_thickness_scale_factor());
// Now move away from bar.
scrollbar_controller_->DidMouseMove(
NearVerticalScrollbarBegin(-kMouseMoveDistanceToTriggerExpand, 0));
scrollbar_controller_->Animate(time);
time += kThinningDuration;
scrollbar_controller_->Animate(time);
ExpectScrollbarsOpacity(1);
EXPECT_FLOAT_EQ(kIdleThicknessScale,
v_scrollbar_layer_->thumb_thickness_scale_factor());
EXPECT_FLOAT_EQ(kIdleThicknessScale,
h_scrollbar_layer_->thumb_thickness_scale_factor());
// Near horizontal scrollbar
scrollbar_controller_->DidMouseMove(NearHorizontalScrollbarBegin(0, -1));
scrollbar_controller_->Animate(time);
ExpectScrollbarsOpacity(1);
EXPECT_FLOAT_EQ(kIdleThicknessScale,
v_scrollbar_layer_->thumb_thickness_scale_factor());
EXPECT_FLOAT_EQ(kIdleThicknessScale,
h_scrollbar_layer_->thumb_thickness_scale_factor());
// Should animate to thickened.
time += kThinningDuration;
scrollbar_controller_->Animate(time);
ExpectScrollbarsOpacity(1);
EXPECT_FLOAT_EQ(kIdleThicknessScale,
v_scrollbar_layer_->thumb_thickness_scale_factor());
EXPECT_FLOAT_EQ(1, h_scrollbar_layer_->thumb_thickness_scale_factor());
// Subsequent moves within the nearness threshold should not change anything.
scrollbar_controller_->DidMouseMove(NearHorizontalScrollbarBegin(0, -2));
scrollbar_controller_->Animate(time);
time += base::TimeDelta::FromSeconds(10);
scrollbar_controller_->Animate(time);
ExpectScrollbarsOpacity(1);
EXPECT_FLOAT_EQ(kIdleThicknessScale,
v_scrollbar_layer_->thumb_thickness_scale_factor());
EXPECT_FLOAT_EQ(1, h_scrollbar_layer_->thumb_thickness_scale_factor());
// Now move away from bar.
scrollbar_controller_->DidMouseMove(
NearHorizontalScrollbarBegin(0, -kMouseMoveDistanceToTriggerExpand));
scrollbar_controller_->Animate(time);
time += kThinningDuration;
scrollbar_controller_->Animate(time);
ExpectScrollbarsOpacity(1);
EXPECT_FLOAT_EQ(kIdleThicknessScale,
v_scrollbar_layer_->thumb_thickness_scale_factor());
EXPECT_FLOAT_EQ(kIdleThicknessScale,
h_scrollbar_layer_->thumb_thickness_scale_factor());
// An fade out animation should have been enqueued.
EXPECT_FALSE(client_.start_fade().is_null());
EXPECT_EQ(kFadeDelay, client_.delay());
}
// Move mouse near both scrollbars at the same time.
TEST_F(ScrollbarAnimationControllerAuraOverlayTest, MouseNearBoth) {
base::TimeTicks time;
time += base::TimeDelta::FromSeconds(1);
// Scroll to make the scrollbars visible.
scrollbar_controller_->DidScrollBegin();
scrollbar_controller_->DidScrollUpdate();
scrollbar_controller_->DidScrollEnd();
// Move scrollbar thumb to the end of track.