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

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

Issue 2442573002: Implement fade-out animation for Aura overlay scrollbars (CC only). (Closed)
Patch Set: Address aelias@'s feedback Created 4 years, 2 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
« no previous file with comments | « cc/input/scrollbar_animation_controller_thinning.cc ('k') | cc/trees/layer_tree_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_thinning.h" 5 #include "cc/input/scrollbar_animation_controller_thinning.h"
6 6
7 #include "cc/layers/solid_color_scrollbar_layer_impl.h" 7 #include "cc/layers/solid_color_scrollbar_layer_impl.h"
8 #include "cc/test/fake_impl_task_runner_provider.h" 8 #include "cc/test/fake_impl_task_runner_provider.h"
9 #include "cc/test/fake_layer_tree_host_impl.h" 9 #include "cc/test/fake_layer_tree_host_impl.h"
10 #include "cc/test/geometry_test_utils.h" 10 #include "cc/test/geometry_test_utils.h"
11 #include "cc/test/test_shared_bitmap_manager.h" 11 #include "cc/test/test_shared_bitmap_manager.h"
12 #include "cc/test/test_task_graph_runner.h" 12 #include "cc/test/test_task_graph_runner.h"
13 #include "cc/trees/layer_tree_impl.h" 13 #include "cc/trees/layer_tree_impl.h"
14 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
15 15
16 namespace cc { 16 namespace cc {
17 namespace { 17 namespace {
18 18
19 // These constants are hard-coded and should match the values in
20 // scrollbar_animation_controller_thinning.cc.
21 const float kIdleThicknessScale = 0.4f;
22 const float kDefaultMouseMoveDistanceToTriggerAnimation = 25.f;
23
19 class ScrollbarAnimationControllerThinningTest 24 class ScrollbarAnimationControllerThinningTest
20 : public testing::Test, 25 : public testing::Test,
21 public ScrollbarAnimationControllerClient { 26 public ScrollbarAnimationControllerClient {
22 public: 27 public:
23 ScrollbarAnimationControllerThinningTest() 28 ScrollbarAnimationControllerThinningTest()
24 : host_impl_(&task_runner_provider_, 29 : host_impl_(&task_runner_provider_,
25 &shared_bitmap_manager_, 30 &shared_bitmap_manager_,
26 &task_graph_runner_) {} 31 &task_graph_runner_) {}
27 32
28 void PostDelayedScrollbarAnimationTask(const base::Closure& start_fade, 33 void PostDelayedScrollbarAnimationTask(const base::Closure& start_fade,
29 base::TimeDelta delay) override { 34 base::TimeDelta delay) override {
30 start_fade_ = start_fade; 35 start_fade_ = start_fade;
31 delay_ = delay; 36 delay_ = delay;
32 } 37 }
33 void SetNeedsRedrawForScrollbarAnimation() override { 38 void SetNeedsRedrawForScrollbarAnimation() override {
34 did_request_redraw_ = true; 39 did_request_redraw_ = true;
35 } 40 }
36 void SetNeedsAnimateForScrollbarAnimation() override { 41 void SetNeedsAnimateForScrollbarAnimation() override {
37 did_request_animate_ = true; 42 did_request_animate_ = true;
38 } 43 }
39 ScrollbarSet ScrollbarsFor(int scroll_layer_id) const override { 44 ScrollbarSet ScrollbarsFor(int scroll_layer_id) const override {
40 return host_impl_.ScrollbarsFor(scroll_layer_id); 45 return host_impl_.ScrollbarsFor(scroll_layer_id);
41 } 46 }
42 47
43 protected: 48 protected:
44 const int kDelayBeforeStarting = 2; 49 const base::TimeDelta kDelayBeforeStarting = base::TimeDelta::FromSeconds(2);
45 const int kResizeDelayBeforeStarting = 5; 50 const base::TimeDelta kResizeDelayBeforeStarting =
46 const int kDuration = 3; 51 base::TimeDelta::FromSeconds(5);
52 const base::TimeDelta kFadeDuration = base::TimeDelta::FromSeconds(3);
53 const base::TimeDelta kThinningDuration = base::TimeDelta::FromSeconds(2);
47 54
48 void SetUp() override { 55 void SetUp() override {
49 std::unique_ptr<LayerImpl> scroll_layer = 56 std::unique_ptr<LayerImpl> scroll_layer =
50 LayerImpl::Create(host_impl_.active_tree(), 1); 57 LayerImpl::Create(host_impl_.active_tree(), 1);
51 std::unique_ptr<LayerImpl> clip = 58 std::unique_ptr<LayerImpl> clip =
52 LayerImpl::Create(host_impl_.active_tree(), 3); 59 LayerImpl::Create(host_impl_.active_tree(), 3);
53 clip_layer_ = clip.get(); 60 clip_layer_ = clip.get();
54 scroll_layer->SetScrollClipLayer(clip_layer_->id()); 61 scroll_layer->SetScrollClipLayer(clip_layer_->id());
55 LayerImpl* scroll_layer_ptr = scroll_layer.get(); 62 LayerImpl* scroll_layer_ptr = scroll_layer.get();
56 63
(...skipping 13 matching lines...) Expand all
70 clip_layer_->test_properties()->AddChild(std::move(scroll_layer)); 77 clip_layer_->test_properties()->AddChild(std::move(scroll_layer));
71 host_impl_.active_tree()->SetRootLayerForTesting(std::move(clip)); 78 host_impl_.active_tree()->SetRootLayerForTesting(std::move(clip));
72 79
73 scrollbar_layer_->SetScrollLayerId(scroll_layer_ptr->id()); 80 scrollbar_layer_->SetScrollLayerId(scroll_layer_ptr->id());
74 scrollbar_layer_->test_properties()->opacity_can_animate = true; 81 scrollbar_layer_->test_properties()->opacity_can_animate = true;
75 clip_layer_->SetBounds(gfx::Size(100, 100)); 82 clip_layer_->SetBounds(gfx::Size(100, 100));
76 scroll_layer_ptr->SetBounds(gfx::Size(200, 200)); 83 scroll_layer_ptr->SetBounds(gfx::Size(200, 200));
77 host_impl_.active_tree()->BuildLayerListAndPropertyTreesForTesting(); 84 host_impl_.active_tree()->BuildLayerListAndPropertyTreesForTesting();
78 85
79 scrollbar_controller_ = ScrollbarAnimationControllerThinning::Create( 86 scrollbar_controller_ = ScrollbarAnimationControllerThinning::Create(
80 scroll_layer_ptr->id(), this, 87 scroll_layer_ptr->id(), this, kDelayBeforeStarting,
81 base::TimeDelta::FromSeconds(kDelayBeforeStarting), 88 kResizeDelayBeforeStarting, kFadeDuration, kThinningDuration);
82 base::TimeDelta::FromSeconds(kResizeDelayBeforeStarting),
83 base::TimeDelta::FromSeconds(kDuration));
84 } 89 }
85 90
86 FakeImplTaskRunnerProvider task_runner_provider_; 91 FakeImplTaskRunnerProvider task_runner_provider_;
87 TestSharedBitmapManager shared_bitmap_manager_; 92 TestSharedBitmapManager shared_bitmap_manager_;
88 TestTaskGraphRunner task_graph_runner_; 93 TestTaskGraphRunner task_graph_runner_;
89 FakeLayerTreeHostImpl host_impl_; 94 FakeLayerTreeHostImpl host_impl_;
90 std::unique_ptr<ScrollbarAnimationControllerThinning> scrollbar_controller_; 95 std::unique_ptr<ScrollbarAnimationControllerThinning> scrollbar_controller_;
91 LayerImpl* clip_layer_; 96 LayerImpl* clip_layer_;
92 SolidColorScrollbarLayerImpl* scrollbar_layer_; 97 SolidColorScrollbarLayerImpl* scrollbar_layer_;
93 98
94 base::Closure start_fade_; 99 base::Closure start_fade_;
95 base::TimeDelta delay_; 100 base::TimeDelta delay_;
96 bool did_request_redraw_; 101 bool did_request_redraw_;
97 bool did_request_animate_; 102 bool did_request_animate_;
98 }; 103 };
99 104
100 // Check initialization of scrollbar. 105 // Check initialization of scrollbar. Should start off invisible and thin.
101 TEST_F(ScrollbarAnimationControllerThinningTest, Idle) { 106 TEST_F(ScrollbarAnimationControllerThinningTest, Idle) {
102 scrollbar_controller_->Animate(base::TimeTicks()); 107 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity());
103 EXPECT_FLOAT_EQ(0.7f, scrollbar_layer_->Opacity());
104 EXPECT_FLOAT_EQ(0.4f, scrollbar_layer_->thumb_thickness_scale_factor()); 108 EXPECT_FLOAT_EQ(0.4f, scrollbar_layer_->thumb_thickness_scale_factor());
105 } 109 }
106 110
107 // Check that scrollbar appears again, when the layer becomes scrollable. 111 // Check that scrollbar appears again when the layer becomes scrollable.
108 TEST_F(ScrollbarAnimationControllerThinningTest, AppearOnResize) { 112 TEST_F(ScrollbarAnimationControllerThinningTest, AppearOnResize) {
113 scrollbar_controller_->DidScrollBegin();
109 scrollbar_controller_->DidScrollUpdate(false); 114 scrollbar_controller_->DidScrollUpdate(false);
115 scrollbar_controller_->DidScrollEnd();
116 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
117
110 // Make the Layer non-scrollable, scrollbar disappears. 118 // Make the Layer non-scrollable, scrollbar disappears.
111 clip_layer_->SetBounds(gfx::Size(200, 200)); 119 clip_layer_->SetBounds(gfx::Size(200, 200));
112 scrollbar_controller_->DidScrollUpdate(false); 120 scrollbar_controller_->DidScrollUpdate(false);
113 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity()); 121 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity());
122
114 // Make the layer scrollable, scrollbar appears again. 123 // Make the layer scrollable, scrollbar appears again.
115 clip_layer_->SetBounds(gfx::Size(100, 100)); 124 clip_layer_->SetBounds(gfx::Size(100, 100));
116 scrollbar_controller_->DidScrollUpdate(false); 125 scrollbar_controller_->DidScrollUpdate(false);
117 EXPECT_FLOAT_EQ(0.7f, scrollbar_layer_->Opacity()); 126 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
118 } 127 }
119 128
120 // Check that scrollbar disappears when the layer becomes non-scrollable. 129 // Check that scrollbar disappears when the layer becomes non-scrollable.
121 TEST_F(ScrollbarAnimationControllerThinningTest, HideOnResize) { 130 TEST_F(ScrollbarAnimationControllerThinningTest, HideOnResize) {
122 LayerImpl* scroll_layer = host_impl_.active_tree()->LayerById(1); 131 LayerImpl* scroll_layer = host_impl_.active_tree()->LayerById(1);
123 ASSERT_TRUE(scroll_layer); 132 ASSERT_TRUE(scroll_layer);
124 EXPECT_EQ(gfx::Size(200, 200), scroll_layer->bounds()); 133 EXPECT_EQ(gfx::Size(200, 200), scroll_layer->bounds());
125 134
126 EXPECT_EQ(HORIZONTAL, scrollbar_layer_->orientation()); 135 EXPECT_EQ(HORIZONTAL, scrollbar_layer_->orientation());
127 136
(...skipping 14 matching lines...) Expand all
142 EXPECT_EQ(gfx::Size(200, 100), clip_layer_->bounds()); 151 EXPECT_EQ(gfx::Size(200, 100), clip_layer_->bounds());
143 152
144 scrollbar_controller_->DidScrollBegin(); 153 scrollbar_controller_->DidScrollBegin();
145 154
146 scrollbar_controller_->DidScrollUpdate(false); 155 scrollbar_controller_->DidScrollUpdate(false);
147 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity()); 156 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity());
148 157
149 scrollbar_controller_->DidScrollEnd(); 158 scrollbar_controller_->DidScrollEnd();
150 } 159 }
151 160
152 // Scroll content. Confirm the scrollbar gets dark and then becomes light 161 // Scroll content. Confirm the scrollbar appears and fades out.
153 // after stopping. 162 TEST_F(ScrollbarAnimationControllerThinningTest, BasicAppearAndFadeOut) {
154 TEST_F(ScrollbarAnimationControllerThinningTest, AwakenByProgrammaticScroll) { 163 base::TimeTicks time;
155 base::TimeTicks time; 164 time += base::TimeDelta::FromSeconds(1);
156 time += base::TimeDelta::FromSeconds(1); 165
157 scrollbar_controller_->DidScrollUpdate(false); 166 // Scrollbar should be invisible by default.
158 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); 167 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity());
159 // Scrollbar doesn't change size if triggered by scroll. 168
160 EXPECT_FLOAT_EQ(0.4f, scrollbar_layer_->thumb_thickness_scale_factor()); 169 // Scrollbar should appear only on scroll update.
161 170 scrollbar_controller_->DidScrollBegin();
171 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity());
172
173 scrollbar_controller_->DidScrollUpdate(false);
174 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
175
176 scrollbar_controller_->DidScrollEnd();
177 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
178
179 // An animation should have been enqueued.
180 EXPECT_EQ(kDelayBeforeStarting, delay_);
181 EXPECT_FALSE(start_fade_.is_null());
162 start_fade_.Run(); 182 start_fade_.Run();
163 183
164 time += base::TimeDelta::FromSeconds(1); 184 // Scrollbar should fade out over kFadeDuration.
165 scrollbar_controller_->Animate(time); 185 scrollbar_controller_->Animate(time);
166 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); 186 time += kFadeDuration;
167 EXPECT_FLOAT_EQ(0.4f, scrollbar_layer_->thumb_thickness_scale_factor()); 187 scrollbar_controller_->Animate(time);
168 188
169 // Subsequent scroll restarts animation. 189 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity());
170 scrollbar_controller_->DidScrollUpdate(false); 190 }
171 191
192 // Scroll content. Move the mouse near the scrollbar and confirm it becomes
193 // thick. Ensure it fades out after that.
194 TEST_F(ScrollbarAnimationControllerThinningTest, MoveNearAndFadeOut) {
195 base::TimeTicks time;
196 time += base::TimeDelta::FromSeconds(1);
197
198 scrollbar_controller_->DidScrollBegin();
199 scrollbar_controller_->DidScrollUpdate(false);
200 scrollbar_controller_->DidScrollEnd();
201
202 // An animation should have been enqueued.
203 EXPECT_EQ(kDelayBeforeStarting, delay_);
204 EXPECT_FALSE(start_fade_.is_null());
205
206 // Now move the mouse near the scrollbar. This should cancel the currently
207 // queued fading animation and start animating thickness.
208 scrollbar_controller_->DidMouseMoveNear(1);
209 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
210 EXPECT_FLOAT_EQ(kIdleThicknessScale,
211 scrollbar_layer_->thumb_thickness_scale_factor());
212 EXPECT_TRUE(start_fade_.IsCancelled());
213
214 // Scrollbar should become thick.
215 scrollbar_controller_->Animate(time);
216 time += kThinningDuration;
217 scrollbar_controller_->Animate(time);
218 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
219 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
220
221 // Once the thickening animation is complete, it should enqueue the delayed
222 // fade animation.
223 EXPECT_FALSE(start_fade_.is_null());
224 EXPECT_FALSE(start_fade_.IsCancelled());
225 }
226
227 // Scroll content. Move the mouse over the scrollbar and confirm it becomes
228 // thick. Ensure it fades out after that.
229 TEST_F(ScrollbarAnimationControllerThinningTest, MoveOverAndFadeOut) {
230 base::TimeTicks time;
231 time += base::TimeDelta::FromSeconds(1);
232
233 scrollbar_controller_->DidScrollBegin();
234 scrollbar_controller_->DidScrollUpdate(false);
235 scrollbar_controller_->DidScrollEnd();
236
237 // An animation should have been enqueued.
238 EXPECT_EQ(kDelayBeforeStarting, delay_);
239 EXPECT_FALSE(start_fade_.is_null());
240
241 // Now move the mouse over the scrollbar. This should cancel the currently
242 // queued fading animation and start animating thickness.
243 scrollbar_controller_->DidMouseMoveNear(0);
244 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
245 EXPECT_FLOAT_EQ(kIdleThicknessScale,
246 scrollbar_layer_->thumb_thickness_scale_factor());
247 EXPECT_TRUE(start_fade_.IsCancelled());
248
249 // Scrollbar should become thick.
250 scrollbar_controller_->Animate(time);
251 time += kThinningDuration;
252 scrollbar_controller_->Animate(time);
253 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
254 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
255
256 // Once the thickening animation is complete, it should enqueue the delayed
257 // fade animation.
258 EXPECT_FALSE(start_fade_.is_null());
259 EXPECT_FALSE(start_fade_.IsCancelled());
260 }
261
262 // Make sure a scrollbar captured before the thickening animation doesn't try
263 // to fade out.
264 TEST_F(ScrollbarAnimationControllerThinningTest,
265 DontFadeWhileCapturedBeforeThick) {
266 base::TimeTicks time;
267 time += base::TimeDelta::FromSeconds(1);
268
269 scrollbar_controller_->DidScrollBegin();
270 scrollbar_controller_->DidScrollUpdate(false);
271 scrollbar_controller_->DidScrollEnd();
272
273 // An animation should have been enqueued.
274 EXPECT_EQ(kDelayBeforeStarting, delay_);
275 EXPECT_FALSE(start_fade_.is_null());
276
277 // Now move the mouse over the scrollbar and capture it. It should become
278 // thick without need for an animation.
279 scrollbar_controller_->DidMouseMoveNear(0);
280 scrollbar_controller_->DidCaptureScrollbarBegin();
281 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
282 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
283
284 // The fade animation should have been cancelled.
285 EXPECT_FALSE(start_fade_.is_null());
286 EXPECT_TRUE(start_fade_.IsCancelled());
287 }
288
289 // Make sure a scrollbar captured after a thickening animation doesn't try to
290 // fade out.
291 TEST_F(ScrollbarAnimationControllerThinningTest, DontFadeWhileCaptured) {
292 base::TimeTicks time;
293 time += base::TimeDelta::FromSeconds(1);
294
295 scrollbar_controller_->DidScrollBegin();
296 scrollbar_controller_->DidScrollUpdate(false);
297 scrollbar_controller_->DidScrollEnd();
298
299 // An animation should have been enqueued.
300 EXPECT_EQ(kDelayBeforeStarting, delay_);
301 EXPECT_FALSE(start_fade_.is_null());
302
303 // Now move the mouse over the scrollbar and animate it until it's thick.
304 scrollbar_controller_->DidMouseMoveNear(0);
305 scrollbar_controller_->Animate(time);
306 time += kThinningDuration;
307 scrollbar_controller_->Animate(time);
308 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
309 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
310
311 // Since the scrollbar became thick, it should have queued up a fade.
312 EXPECT_FALSE(start_fade_.is_null());
313 EXPECT_FALSE(start_fade_.IsCancelled());
314
315 // Make sure capturing the scrollbar stops the fade.
316 scrollbar_controller_->DidCaptureScrollbarBegin();
317 EXPECT_FALSE(start_fade_.is_null());
318 EXPECT_TRUE(start_fade_.IsCancelled());
319 }
320
321 // Make sure releasing a captured scrollbar causes it to fade out.
322 TEST_F(ScrollbarAnimationControllerThinningTest, FadeAfterReleased) {
323 base::TimeTicks time;
324 time += base::TimeDelta::FromSeconds(1);
325
326 scrollbar_controller_->DidScrollBegin();
327 scrollbar_controller_->DidScrollUpdate(false);
328 scrollbar_controller_->DidScrollEnd();
329
330 // An animation should have been enqueued.
331 EXPECT_EQ(kDelayBeforeStarting, delay_);
332 EXPECT_FALSE(start_fade_.is_null());
333
334 // Now move the mouse over the scrollbar and capture it.
335 scrollbar_controller_->DidMouseMoveNear(0);
336 scrollbar_controller_->DidCaptureScrollbarBegin();
337 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
338 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
339
340 // Since the scrollbar became thick, it should have queued up a fade.
341 EXPECT_FALSE(start_fade_.is_null());
342 EXPECT_TRUE(start_fade_.IsCancelled());
343
344 scrollbar_controller_->DidCaptureScrollbarEnd();
345 EXPECT_FALSE(start_fade_.is_null());
346 EXPECT_FALSE(start_fade_.IsCancelled());
347 }
348
349 // Make sure moving near a scrollbar while it's fading out causes it to reset
350 // the opacity and thicken.
351 TEST_F(ScrollbarAnimationControllerThinningTest, MoveNearScrollbarWhileFading) {
352 base::TimeTicks time;
353 time += base::TimeDelta::FromSeconds(1);
354
355 scrollbar_controller_->DidScrollBegin();
356 scrollbar_controller_->DidScrollUpdate(false);
357 scrollbar_controller_->DidScrollEnd();
358
359 // An animation should have been enqueued. Start it.
360 EXPECT_EQ(kDelayBeforeStarting, delay_);
361 EXPECT_FALSE(start_fade_.is_null());
172 start_fade_.Run(); 362 start_fade_.Run();
173 363
174 time += base::TimeDelta::FromSeconds(2); 364 scrollbar_controller_->Animate(time);
175 scrollbar_controller_->Animate(time); 365 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
176 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); 366
177 EXPECT_FLOAT_EQ(0.4f, scrollbar_layer_->thumb_thickness_scale_factor()); 367 // Proceed half way through the fade out animation.
178 368 time += kFadeDuration / 2;
179 time += base::TimeDelta::FromSeconds(1); 369 scrollbar_controller_->Animate(time);
180 scrollbar_controller_->Animate(time); 370 EXPECT_FLOAT_EQ(0.5f, scrollbar_layer_->Opacity());
181 EXPECT_FLOAT_EQ(0.9f, scrollbar_layer_->Opacity()); 371
182 EXPECT_FLOAT_EQ(0.4f, scrollbar_layer_->thumb_thickness_scale_factor()); 372 // Now move the mouse near the scrollbar. It should reset opacity to 1
183 373 // instantly and start animating to thick.
184 time += base::TimeDelta::FromSeconds(1); 374 scrollbar_controller_->DidMouseMoveNear(1);
185 scrollbar_controller_->Animate(time); 375 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
186 EXPECT_FLOAT_EQ(0.8f, scrollbar_layer_->Opacity()); 376 EXPECT_FLOAT_EQ(kIdleThicknessScale,
187 EXPECT_FLOAT_EQ(0.4f, scrollbar_layer_->thumb_thickness_scale_factor()); 377 scrollbar_layer_->thumb_thickness_scale_factor());
188 378
189 time += base::TimeDelta::FromSeconds(1); 379 scrollbar_controller_->Animate(time);
190 scrollbar_controller_->Animate(time); 380 time += kThinningDuration;
191 EXPECT_FLOAT_EQ(0.7f, scrollbar_layer_->Opacity()); 381 scrollbar_controller_->Animate(time);
192 EXPECT_FLOAT_EQ(0.4f, scrollbar_layer_->thumb_thickness_scale_factor()); 382 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
383 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
384 }
385
386 // Make sure capturing a scrollbar while it's fading out causes it to reset the
387 // opacity and thicken instantly.
388 TEST_F(ScrollbarAnimationControllerThinningTest, CaptureScrollbarWhileFading) {
389 base::TimeTicks time;
390 time += base::TimeDelta::FromSeconds(1);
391
392 scrollbar_controller_->DidScrollBegin();
393 scrollbar_controller_->DidScrollUpdate(false);
394 scrollbar_controller_->DidScrollEnd();
395
396 // Move mouse over the scrollbar.
397 scrollbar_controller_->DidMouseMoveNear(0);
398 scrollbar_controller_->Animate(time);
399 time += kThinningDuration;
400 scrollbar_controller_->Animate(time);
401 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
402 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
403
404 // A fade animation should have been enqueued. Start it.
405 EXPECT_EQ(kDelayBeforeStarting, delay_);
406 EXPECT_FALSE(start_fade_.is_null());
407 start_fade_.Run();
408
409 scrollbar_controller_->Animate(time);
410 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
411
412 // Proceed half way through the fade out animation.
413 time += kFadeDuration / 2;
414 scrollbar_controller_->Animate(time);
415 EXPECT_FLOAT_EQ(0.5f, scrollbar_layer_->Opacity());
416
417 // Now capture the scrollbar. It should reset opacity to 1 instantly.
418 scrollbar_controller_->DidCaptureScrollbarBegin();
419 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
420 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
421 }
422
423 // Make sure we can't capture scrollbar that's completely faded out
424 TEST_F(ScrollbarAnimationControllerThinningTest, TestCantCaptureWhenFaded) {
425 base::TimeTicks time;
426 time += base::TimeDelta::FromSeconds(1);
427
428 scrollbar_controller_->DidScrollBegin();
429 scrollbar_controller_->DidScrollUpdate(false);
430 scrollbar_controller_->DidScrollEnd();
431
432 // Move mouse over the scrollbar.
433 scrollbar_controller_->DidMouseMoveNear(0);
434 scrollbar_controller_->Animate(time);
435 time += kThinningDuration;
436 scrollbar_controller_->Animate(time);
437 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
438 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
439
440 // A fade animation should have been enqueued. Start it.
441 EXPECT_EQ(kDelayBeforeStarting, delay_);
442 EXPECT_FALSE(start_fade_.is_null());
443 start_fade_.Run();
444 scrollbar_controller_->Animate(time);
445 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
446
447 // Fade the scrollbar out completely.
448 time += kFadeDuration;
449 scrollbar_controller_->Animate(time);
450 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity());
451 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
452
453 start_fade_.Reset();
454
455 // Now try to capture the scrollbar. It shouldn't do anything since it's
456 // completely faded out.
457 scrollbar_controller_->DidCaptureScrollbarBegin();
458 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity());
459 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
460 EXPECT_TRUE(start_fade_.is_null());
461
462 // Similarly, releasing the scrollbar should have no effect.
463 scrollbar_controller_->DidCaptureScrollbarEnd();
464 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity());
465 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
466 EXPECT_TRUE(start_fade_.is_null());
193 } 467 }
194 468
195 // Initiate a scroll when the pointer is already near the scrollbar. It should 469 // Initiate a scroll when the pointer is already near the scrollbar. It should
196 // remain thick. 470 // appear thick and remain thick.
197 TEST_F(ScrollbarAnimationControllerThinningTest, ScrollWithMouseNear) { 471 TEST_F(ScrollbarAnimationControllerThinningTest, ScrollWithMouseNear) {
198 base::TimeTicks time; 472 base::TimeTicks time;
199 time += base::TimeDelta::FromSeconds(1); 473 time += base::TimeDelta::FromSeconds(1);
200 474
201 scrollbar_controller_->DidMouseMoveNear(1); 475 scrollbar_controller_->DidMouseMoveNear(1);
202 scrollbar_controller_->Animate(time); 476 scrollbar_controller_->Animate(time);
203 time += base::TimeDelta::FromSeconds(3); 477 time += kThinningDuration;
204 478
205 scrollbar_controller_->Animate(time); 479 // Since the scrollbar isn't visible yet (because we haven't scrolled), we
206 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor()); 480 // shouldn't have applied the thickening.
207 481 scrollbar_controller_->Animate(time);
208 scrollbar_controller_->DidScrollUpdate(false); 482 EXPECT_FLOAT_EQ(kIdleThicknessScale,
483 scrollbar_layer_->thumb_thickness_scale_factor());
484
485 scrollbar_controller_->DidScrollBegin();
486 scrollbar_controller_->DidScrollUpdate(false);
487
488 // Now that we've received a scroll, we should be thick without an animation.
489 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
490
491 // An animation for the fade should have been enqueued.
492 scrollbar_controller_->DidScrollEnd();
493 EXPECT_EQ(kDelayBeforeStarting, delay_);
494 EXPECT_FALSE(start_fade_.is_null());
495
209 start_fade_.Run(); 496 start_fade_.Run();
210 scrollbar_controller_->Animate(time); 497 scrollbar_controller_->Animate(time);
211 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); 498 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
212 // Scrollbar should still be thick. 499 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
213 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor()); 500
214 501 // Scrollbar should still be thick, even though the scrollbar fades out.
215 time += base::TimeDelta::FromSeconds(5); 502 time += kFadeDuration;
216 scrollbar_controller_->Animate(time); 503 scrollbar_controller_->Animate(time);
217 EXPECT_FLOAT_EQ(0.7f, scrollbar_layer_->Opacity()); 504 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity());
218 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor()); 505 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
219 } 506 }
220 507
221 // Move the pointer near the scrollbar. Confirm it gets thick and narrow when 508 // Move the pointer near the scrollbar. Confirm it gets thick and narrow when
222 // moved away. 509 // moved away.
223 TEST_F(ScrollbarAnimationControllerThinningTest, MouseNear) { 510 TEST_F(ScrollbarAnimationControllerThinningTest, MouseNear) {
224 base::TimeTicks time; 511 base::TimeTicks time;
225 time += base::TimeDelta::FromSeconds(1); 512 time += base::TimeDelta::FromSeconds(1);
513
514 // Scroll to make the scrollbars visible.
515 scrollbar_controller_->DidScrollBegin();
516 scrollbar_controller_->DidScrollUpdate(false);
517 scrollbar_controller_->DidScrollEnd();
518
226 scrollbar_controller_->DidMouseMoveNear(1); 519 scrollbar_controller_->DidMouseMoveNear(1);
227 scrollbar_controller_->Animate(time); 520 scrollbar_controller_->Animate(time);
228 EXPECT_FLOAT_EQ(0.7f, scrollbar_layer_->Opacity()); 521 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
229 EXPECT_FLOAT_EQ(0.4f, scrollbar_layer_->thumb_thickness_scale_factor()); 522 EXPECT_FLOAT_EQ(kIdleThicknessScale,
230 523 scrollbar_layer_->thumb_thickness_scale_factor());
231 // Should animate to thickened but not darken. 524
232 time += base::TimeDelta::FromSeconds(1); 525 // Should animate to thickened.
233 scrollbar_controller_->Animate(time); 526 time += kThinningDuration;
234 EXPECT_FLOAT_EQ(0.7f, scrollbar_layer_->Opacity()); 527 scrollbar_controller_->Animate(time);
235 EXPECT_FLOAT_EQ(0.6f, scrollbar_layer_->thumb_thickness_scale_factor()); 528 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
236 529 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
237 time += base::TimeDelta::FromSeconds(1); 530
238 scrollbar_controller_->Animate(time); 531 // Subsequent moves within the nearness threshold should not change anything.
239 EXPECT_FLOAT_EQ(0.7f, scrollbar_layer_->Opacity()); 532 scrollbar_controller_->DidMouseMoveNear(2);
240 EXPECT_FLOAT_EQ(0.8f, scrollbar_layer_->thumb_thickness_scale_factor()); 533 scrollbar_controller_->Animate(time);
241 534 time += base::TimeDelta::FromSeconds(10);
242 time += base::TimeDelta::FromSeconds(1); 535 scrollbar_controller_->Animate(time);
243 scrollbar_controller_->Animate(time); 536 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
244 EXPECT_FLOAT_EQ(0.7f, scrollbar_layer_->Opacity()); 537 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
538
539 // Now move away from bar.
540 scrollbar_controller_->DidMouseMoveNear(
541 kDefaultMouseMoveDistanceToTriggerAnimation);
542 scrollbar_controller_->Animate(time);
543 time += kThinningDuration;
544 scrollbar_controller_->Animate(time);
545 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
546 EXPECT_FLOAT_EQ(kIdleThicknessScale,
547 scrollbar_layer_->thumb_thickness_scale_factor());
548 }
549
550 // Move the pointer over the scrollbar. Make sure it gets thick that it gets
551 // thin when moved away.
552 TEST_F(ScrollbarAnimationControllerThinningTest, MouseOver) {
553 // Scroll to make the scrollbars visible.
554 scrollbar_controller_->DidScrollBegin();
555 scrollbar_controller_->DidScrollUpdate(false);
556 scrollbar_controller_->DidScrollEnd();
557
558 base::TimeTicks time;
559 time += base::TimeDelta::FromSeconds(1);
560
561 scrollbar_controller_->DidMouseMoveNear(0);
562 scrollbar_controller_->Animate(time);
563 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
564 EXPECT_FLOAT_EQ(kIdleThicknessScale,
565 scrollbar_layer_->thumb_thickness_scale_factor());
566
567 // Should animate to thickened.
568 time += kThinningDuration;
569 scrollbar_controller_->Animate(time);
570 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
245 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor()); 571 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
246 572
247 // Subsequent moves should not change anything. 573 // Subsequent moves should not change anything.
248 scrollbar_controller_->DidMouseMoveNear(1); 574 scrollbar_controller_->DidMouseMoveNear(0);
249 scrollbar_controller_->Animate(time); 575 scrollbar_controller_->Animate(time);
250 EXPECT_FLOAT_EQ(0.7f, scrollbar_layer_->Opacity()); 576 time += base::TimeDelta::FromSeconds(10);
577 scrollbar_controller_->Animate(time);
578 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
579 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
580
581 // Moving off the scrollbar but still withing the "near" threshold should do
582 // nothing.
583 scrollbar_controller_->DidMouseMoveNear(
584 kDefaultMouseMoveDistanceToTriggerAnimation - 1.f);
585 scrollbar_controller_->Animate(time);
586 time += base::TimeDelta::FromSeconds(10);
587 scrollbar_controller_->Animate(time);
588 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
251 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor()); 589 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
252 590
253 // Now move away from bar. 591 // Now move away from bar.
254 time += base::TimeDelta::FromSeconds(1); 592 scrollbar_controller_->DidMouseMoveNear(
255 scrollbar_controller_->DidMouseMoveNear(26); 593 kDefaultMouseMoveDistanceToTriggerAnimation);
256 scrollbar_controller_->Animate(time); 594 scrollbar_controller_->Animate(time);
257 EXPECT_FLOAT_EQ(0.7f, scrollbar_layer_->Opacity()); 595 time += kThinningDuration;
258 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor()); 596 scrollbar_controller_->Animate(time);
259 597 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
260 // Animate to narrow. 598 EXPECT_FLOAT_EQ(kIdleThicknessScale,
261 time += base::TimeDelta::FromSeconds(1); 599 scrollbar_layer_->thumb_thickness_scale_factor());
262 scrollbar_controller_->Animate(time); 600 }
263 EXPECT_FLOAT_EQ(0.7f, scrollbar_layer_->Opacity()); 601
264 EXPECT_FLOAT_EQ(0.8f, scrollbar_layer_->thumb_thickness_scale_factor()); 602 // First move the pointer over the scrollbar off of it. Make sure the thinning
265 603 // animation kicked off in DidMouseMoveOffScrollbar gets overridden by the
266 time += base::TimeDelta::FromSeconds(1); 604 // thickening animation in the DidMouseMoveNear call.
267 scrollbar_controller_->Animate(time); 605 TEST_F(ScrollbarAnimationControllerThinningTest,
268 EXPECT_FLOAT_EQ(0.7f, scrollbar_layer_->Opacity()); 606 MouseNearThenAwayWhileAnimating) {
269 EXPECT_FLOAT_EQ(0.6f, scrollbar_layer_->thumb_thickness_scale_factor()); 607 // Scroll to make the scrollbars visible.
270 608 scrollbar_controller_->DidScrollBegin();
271 time += base::TimeDelta::FromSeconds(1); 609 scrollbar_controller_->DidScrollUpdate(false);
272 scrollbar_controller_->Animate(time); 610 scrollbar_controller_->DidScrollEnd();
273 EXPECT_FLOAT_EQ(0.7f, scrollbar_layer_->Opacity()); 611
274 EXPECT_FLOAT_EQ(0.4f, scrollbar_layer_->thumb_thickness_scale_factor()); 612 base::TimeTicks time;
275 } 613 time += base::TimeDelta::FromSeconds(1);
276 614
277 // Move the pointer over the scrollbar. Make sure it gets thick and dark 615 scrollbar_controller_->DidMouseMoveNear(0);
278 // and that it gets thin and light when moved away. 616 scrollbar_controller_->Animate(time);
279 TEST_F(ScrollbarAnimationControllerThinningTest, MouseOver) { 617 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
280 base::TimeTicks time; 618 EXPECT_FLOAT_EQ(kIdleThicknessScale,
281 time += base::TimeDelta::FromSeconds(1); 619 scrollbar_layer_->thumb_thickness_scale_factor());
282 scrollbar_controller_->DidMouseMoveNear(0); 620
283 scrollbar_controller_->Animate(time); 621 // Should animate to thickened.
284 EXPECT_FLOAT_EQ(0.7f, scrollbar_layer_->Opacity()); 622 time += kThinningDuration;
285 EXPECT_FLOAT_EQ(0.4f, scrollbar_layer_->thumb_thickness_scale_factor()); 623 scrollbar_controller_->Animate(time);
286 624 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
287 // Should animate to thickened and darkened. 625 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
288 time += base::TimeDelta::FromSeconds(1);
289 scrollbar_controller_->Animate(time);
290 EXPECT_FLOAT_EQ(0.8f, scrollbar_layer_->Opacity());
291 EXPECT_FLOAT_EQ(0.6f, scrollbar_layer_->thumb_thickness_scale_factor());
292
293 time += base::TimeDelta::FromSeconds(1);
294 scrollbar_controller_->Animate(time);
295 EXPECT_FLOAT_EQ(0.9f, scrollbar_layer_->Opacity());
296 EXPECT_FLOAT_EQ(0.8f, scrollbar_layer_->thumb_thickness_scale_factor());
297
298 time += base::TimeDelta::FromSeconds(1);
299 scrollbar_controller_->Animate(time);
300 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
301 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
302
303 // Subsequent moves should not change anything.
304 scrollbar_controller_->DidMouseMoveNear(0);
305 scrollbar_controller_->Animate(time);
306 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
307 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
308
309 // Now move away from bar.
310 time += base::TimeDelta::FromSeconds(1);
311 scrollbar_controller_->DidMouseMoveNear(26);
312 scrollbar_controller_->Animate(time);
313 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
314 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
315
316 // Animate to narrow.
317 time += base::TimeDelta::FromSeconds(1);
318 scrollbar_controller_->Animate(time);
319 EXPECT_FLOAT_EQ(0.9f, scrollbar_layer_->Opacity());
320 EXPECT_FLOAT_EQ(0.8f, scrollbar_layer_->thumb_thickness_scale_factor());
321
322 time += base::TimeDelta::FromSeconds(1);
323 scrollbar_controller_->Animate(time);
324 EXPECT_FLOAT_EQ(0.8f, scrollbar_layer_->Opacity());
325 EXPECT_FLOAT_EQ(0.6f, scrollbar_layer_->thumb_thickness_scale_factor());
326
327 time += base::TimeDelta::FromSeconds(1);
328 scrollbar_controller_->Animate(time);
329 EXPECT_FLOAT_EQ(0.7f, scrollbar_layer_->Opacity());
330 EXPECT_FLOAT_EQ(0.4f, scrollbar_layer_->thumb_thickness_scale_factor());
331 }
332
333 // First move the pointer near the scrollbar, then over it, then back near
334 // then far away. Confirm that first the bar gets thick, then dark, then light,
335 // then narrow.
336 TEST_F(ScrollbarAnimationControllerThinningTest, MouseNearThenOver) {
337 base::TimeTicks time;
338 time += base::TimeDelta::FromSeconds(1);
339 scrollbar_controller_->DidMouseMoveNear(1);
340 scrollbar_controller_->Animate(time);
341 EXPECT_FLOAT_EQ(0.7f, scrollbar_layer_->Opacity());
342 EXPECT_FLOAT_EQ(0.4f, scrollbar_layer_->thumb_thickness_scale_factor());
343
344 // Should animate to thickened but not darken.
345 time += base::TimeDelta::FromSeconds(3);
346 scrollbar_controller_->Animate(time);
347 EXPECT_FLOAT_EQ(0.7f, scrollbar_layer_->Opacity());
348 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
349
350 // Now move over.
351 scrollbar_controller_->DidMouseMoveNear(0);
352 scrollbar_controller_->Animate(time);
353
354 // Should animate to darkened.
355 time += base::TimeDelta::FromSeconds(1);
356 scrollbar_controller_->Animate(time);
357 EXPECT_FLOAT_EQ(0.8f, scrollbar_layer_->Opacity());
358 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
359
360 time += base::TimeDelta::FromSeconds(1);
361 scrollbar_controller_->Animate(time);
362 EXPECT_FLOAT_EQ(0.9f, scrollbar_layer_->Opacity());
363 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
364
365 time += base::TimeDelta::FromSeconds(1);
366 scrollbar_controller_->Animate(time);
367 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
368 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
369 626
370 // This is tricky. The DidMouseMoveOffScrollbar() is sent before the 627 // This is tricky. The DidMouseMoveOffScrollbar() is sent before the
371 // subsequent DidMouseMoveNear(), if the mouse moves in that direction. 628 // subsequent DidMouseMoveNear(), if the mouse moves in that direction.
372 // This results in the thumb thinning. We want to make sure that when the 629 // This results in the thumb thinning. We want to make sure that when the
373 // thumb starts expanding it doesn't first narrow to the idle thinness. 630 // thumb starts expanding it doesn't first narrow to the idle thinness.
374 time += base::TimeDelta::FromSeconds(1); 631 time += base::TimeDelta::FromSeconds(1);
375 scrollbar_controller_->DidMouseMoveOffScrollbar(); 632 scrollbar_controller_->DidMouseMoveOffScrollbar();
376 scrollbar_controller_->Animate(time); 633 scrollbar_controller_->Animate(time);
377 634 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
378 time += base::TimeDelta::FromSeconds(1); 635
379 scrollbar_controller_->Animate(time); 636 // Let the animation run half of the way through the thinning animation.
380 EXPECT_FLOAT_EQ(0.9f, scrollbar_layer_->Opacity()); 637 time += kThinningDuration / 2;
381 EXPECT_FLOAT_EQ(0.8f, scrollbar_layer_->thumb_thickness_scale_factor()); 638 scrollbar_controller_->Animate(time);
382 639 EXPECT_FLOAT_EQ(1.0f - (1.0f - kIdleThicknessScale) / 2.0f,
640 scrollbar_layer_->thumb_thickness_scale_factor());
641
642 // Now we get a notification for the mouse moving over the scroller. The
643 // animation is reset to the thickening direction but we won't start
644 // thickening until the new animation catches up to the current thickness.
383 scrollbar_controller_->DidMouseMoveNear(1); 645 scrollbar_controller_->DidMouseMoveNear(1);
384 scrollbar_controller_->Animate(time); 646 scrollbar_controller_->Animate(time);
385 // A new animation is kicked off. 647 EXPECT_FLOAT_EQ(1.0f - (1.0f - kIdleThicknessScale) / 2.0f,
386 648 scrollbar_layer_->thumb_thickness_scale_factor());
387 time += base::TimeDelta::FromSeconds(1); 649
388 scrollbar_controller_->Animate(time); 650 // Until we reach the half way point, the animation will have no effect.
389 // We will initiate the narrowing again, but it won't get decremented until 651 time += kThinningDuration / 4;
390 // the new animation catches up to it. 652 scrollbar_controller_->Animate(time);
391 EXPECT_FLOAT_EQ(0.9f, scrollbar_layer_->Opacity()); 653 EXPECT_FLOAT_EQ(1.0f - (1.0f - kIdleThicknessScale) / 2.0f,
392 // Now the thickness should be increasing, but it shouldn't happen until the 654 scrollbar_layer_->thumb_thickness_scale_factor());
393 // animation catches up. 655
394 EXPECT_FLOAT_EQ(0.8f, scrollbar_layer_->thumb_thickness_scale_factor()); 656 time += kThinningDuration / 4;
395 657 scrollbar_controller_->Animate(time);
396 time += base::TimeDelta::FromSeconds(1); 658 EXPECT_FLOAT_EQ(1.0f - (1.0f - kIdleThicknessScale) / 2.0f,
397 scrollbar_controller_->Animate(time); 659 scrollbar_layer_->thumb_thickness_scale_factor());
398 EXPECT_FLOAT_EQ(0.8f, scrollbar_layer_->Opacity()); 660
399 // The thickness now gets big again. 661 // We're now at three quarters of the way through so it should now started
400 EXPECT_FLOAT_EQ(0.8f, scrollbar_layer_->thumb_thickness_scale_factor()); 662 // thickening again.
401 663 time += kThinningDuration / 4;
402 time += base::TimeDelta::FromSeconds(1); 664 scrollbar_controller_->Animate(time);
403 scrollbar_controller_->Animate(time); 665 EXPECT_FLOAT_EQ(kIdleThicknessScale + 3 * (1.0f - kIdleThicknessScale) / 4.0f,
404 EXPECT_FLOAT_EQ(0.7f, scrollbar_layer_->Opacity()); 666 scrollbar_layer_->thumb_thickness_scale_factor());
405 // The thickness now gets big again. 667
668 // And all the way to the end.
669 time += kThinningDuration / 4;
670 scrollbar_controller_->Animate(time);
406 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor()); 671 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
407 } 672 }
408 673
409 // First move the pointer on the scrollbar, then press it, then away. 674 // First move the pointer on the scrollbar, then press it, then away.
410 // Confirm that the bar gets thick and dark. Then mouse up. Confirm that 675 // Confirm that the bar gets thick. Then mouse up. Confirm that
411 // the bar gets thin and light. 676 // the bar gets thin.
412 TEST_F(ScrollbarAnimationControllerThinningTest, 677 TEST_F(ScrollbarAnimationControllerThinningTest,
413 MouseCaptureAndReleaseOutOfBar) { 678 MouseCaptureAndReleaseOutOfBar) {
414 base::TimeTicks time; 679 // Scroll to make the scrollbars visible.
415 time += base::TimeDelta::FromSeconds(1); 680 scrollbar_controller_->DidScrollBegin();
416 681 scrollbar_controller_->DidScrollUpdate(false);
417 // Move in 682 scrollbar_controller_->DidScrollEnd();
683
684 base::TimeTicks time;
685 time += base::TimeDelta::FromSeconds(1);
686
687 // Move over the scrollbar.
418 scrollbar_controller_->DidMouseMoveNear(0); 688 scrollbar_controller_->DidMouseMoveNear(0);
419 689 scrollbar_controller_->Animate(time);
420 // Jump X seconds, first we need to make the time not 0, second we need to 690 time += kFadeDuration;
421 // call Animate once to start the animation(initial the last_awaken_time_), 691 scrollbar_controller_->Animate(time);
422 // now you can jump x seconds. 692 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
423 scrollbar_controller_->Animate(time); 693 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
424 time += base::TimeDelta::FromSeconds(kDuration); 694
425 scrollbar_controller_->Animate(time); 695 // Capture.
426
427 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
428 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
429
430 // Capture
431 scrollbar_controller_->DidCaptureScrollbarBegin(); 696 scrollbar_controller_->DidCaptureScrollbarBegin();
432 time += base::TimeDelta::FromSeconds(1); 697 time += base::TimeDelta::FromSeconds(1);
433 scrollbar_controller_->Animate(time); 698 scrollbar_controller_->Animate(time);
434 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); 699 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
435 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor()); 700 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
436 701
437 // test for 10 seconds, stay thick and dark 702 // Should stay thick for a while.
438 for (int i = 0; i < 10; ++i) { 703 time += base::TimeDelta::FromSeconds(10);
439 // move away from bar. 704 scrollbar_controller_->Animate(time);
440 scrollbar_controller_->DidMouseMoveNear(26 + i); 705
441 time += base::TimeDelta::FromSeconds(1); 706 // Move outside the "near" threshold. Because the scrollbar is captured it
442 scrollbar_controller_->Animate(time); 707 // should remain thick.
443 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); 708 scrollbar_controller_->DidMouseMoveNear(
444 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor()); 709 kDefaultMouseMoveDistanceToTriggerAnimation);
445 } 710 time += kThinningDuration;
446 711 scrollbar_controller_->Animate(time);
447 // release 712 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
713 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
714
715 // Release.
448 scrollbar_controller_->DidCaptureScrollbarEnd(); 716 scrollbar_controller_->DidCaptureScrollbarEnd();
449 717
450 // get thickness and light 718 // Should become thin.
451 time += base::TimeDelta::FromSeconds(1); 719 time += base::TimeDelta::FromSeconds(1);
452 scrollbar_controller_->Animate(time); 720 scrollbar_controller_->Animate(time);
453 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); 721 time += kThinningDuration;
454 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor()); 722 scrollbar_controller_->Animate(time);
455 723 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
456 time += base::TimeDelta::FromSeconds(1); 724 EXPECT_FLOAT_EQ(kIdleThicknessScale,
457 scrollbar_controller_->Animate(time); 725 scrollbar_layer_->thumb_thickness_scale_factor());
458 EXPECT_FLOAT_EQ(0.9f, scrollbar_layer_->Opacity()); 726 }
459 EXPECT_FLOAT_EQ(0.8f, scrollbar_layer_->thumb_thickness_scale_factor()); 727
460 728 // First move the pointer on the scrollbar, then press it, then away. Confirm
461 time += base::TimeDelta::FromSeconds(1); 729 // that the bar gets thick. Then move point on the scrollbar and mouse up.
462 scrollbar_controller_->Animate(time); 730 // Confirm that the bar stays thick.
463 EXPECT_FLOAT_EQ(0.8f, scrollbar_layer_->Opacity());
464 EXPECT_FLOAT_EQ(0.6f, scrollbar_layer_->thumb_thickness_scale_factor());
465
466 time += base::TimeDelta::FromSeconds(1);
467 scrollbar_controller_->Animate(time);
468 EXPECT_FLOAT_EQ(0.7f, scrollbar_layer_->Opacity());
469 EXPECT_FLOAT_EQ(0.4f, scrollbar_layer_->thumb_thickness_scale_factor());
470 }
471
472 // First move the pointer on the scrollbar, then press it, then away.
473 // Confirm that the bar gets thick and dark. Then move point on the
474 // scrollbar and mouse up. Confirm that the bar gets thick and dark.
475 TEST_F(ScrollbarAnimationControllerThinningTest, MouseCaptureAndReleaseOnBar) { 731 TEST_F(ScrollbarAnimationControllerThinningTest, MouseCaptureAndReleaseOnBar) {
476 base::TimeTicks time; 732 // Scroll to make the scrollbars visible.
477 time += base::TimeDelta::FromSeconds(1); 733 scrollbar_controller_->DidScrollBegin();
478 734 scrollbar_controller_->DidScrollUpdate(false);
479 // Move in 735 scrollbar_controller_->DidScrollEnd();
736
737 base::TimeTicks time;
738 time += base::TimeDelta::FromSeconds(1);
739
740 // Move over scrollbar.
480 scrollbar_controller_->DidMouseMoveNear(0); 741 scrollbar_controller_->DidMouseMoveNear(0);
481 742 scrollbar_controller_->Animate(time);
482 scrollbar_controller_->Animate(time); 743 time += kThinningDuration;
483 time += base::TimeDelta::FromSeconds(kDuration); 744 scrollbar_controller_->Animate(time);
484 scrollbar_controller_->Animate(time); 745 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
485 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); 746 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
486 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor()); 747
487 748 // Capture. Nothing should change.
488 // Capture
489 scrollbar_controller_->DidCaptureScrollbarBegin(); 749 scrollbar_controller_->DidCaptureScrollbarBegin();
490 time += base::TimeDelta::FromSeconds(1); 750 time += base::TimeDelta::FromSeconds(1);
491 scrollbar_controller_->Animate(time); 751 scrollbar_controller_->Animate(time);
492 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); 752 time += base::TimeDelta::FromSeconds(10);
493 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor()); 753 scrollbar_controller_->Animate(time);
494 754 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
495 // test for 10 seconds, stay thick and dark 755 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
496 for (int i = 0; i < 10; ++i) { 756
497 // move away from bar. 757 // Move away from scrollbar. Nothing should change.
498 scrollbar_controller_->DidMouseMoveNear(26 + i); 758 scrollbar_controller_->DidMouseMoveNear(
499 time += base::TimeDelta::FromSeconds(1); 759 kDefaultMouseMoveDistanceToTriggerAnimation);
500 scrollbar_controller_->Animate(time); 760 time += base::TimeDelta::FromSeconds(1);
501 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); 761 scrollbar_controller_->Animate(time);
502 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor()); 762 time += base::TimeDelta::FromSeconds(10);
503 } 763 scrollbar_controller_->Animate(time);
504 764 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
505 // move to the bar. 765 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
766
767 // Move over scrollbar and release. Since we're near the scrollbar, it should
768 // remain thick.
506 scrollbar_controller_->DidMouseMoveNear(0); 769 scrollbar_controller_->DidMouseMoveNear(0);
507
508 // release
509 scrollbar_controller_->DidCaptureScrollbarEnd(); 770 scrollbar_controller_->DidCaptureScrollbarEnd();
510 771 time += base::TimeDelta::FromSeconds(1);
511 // stay thick and dark 772 scrollbar_controller_->Animate(time);
512 // test for 10 seconds, stay thick and dark 773 time += base::TimeDelta::FromSeconds(10);
513 for (int i = 0; i < 10; ++i) { 774 scrollbar_controller_->Animate(time);
514 time += base::TimeDelta::FromSeconds(1); 775 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
515 scrollbar_controller_->Animate(time); 776 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
516 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
517 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
518 }
519 } 777 }
520 778
521 // Move mouse on scrollbar and capture then move out of window. Confirm that 779 // Move mouse on scrollbar and capture then move out of window. Confirm that
522 // the bar stays thick and dark. 780 // the bar stays thick.
523 TEST_F(ScrollbarAnimationControllerThinningTest, 781 TEST_F(ScrollbarAnimationControllerThinningTest,
524 MouseCapturedAndExitWindowFromScrollbar) { 782 MouseCapturedAndExitWindowFromScrollbar) {
525 base::TimeTicks time; 783 // Scroll to make the scrollbars visible.
526 time += base::TimeDelta::FromSeconds(1); 784 scrollbar_controller_->DidScrollBegin();
527 785 scrollbar_controller_->DidScrollUpdate(false);
528 // Move in 786 scrollbar_controller_->DidScrollEnd();
787
788 base::TimeTicks time;
789 time += base::TimeDelta::FromSeconds(1);
790
791 // Move mouse over scrollbar.
529 scrollbar_controller_->DidMouseMoveNear(0); 792 scrollbar_controller_->DidMouseMoveNear(0);
530 793 scrollbar_controller_->Animate(time);
531 scrollbar_controller_->Animate(time); 794 time += kThinningDuration;
532 time += base::TimeDelta::FromSeconds(kDuration); 795 scrollbar_controller_->Animate(time);
533 scrollbar_controller_->Animate(time); 796 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
534 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); 797 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
535 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor()); 798
536 799 // Capture.
537 // Capture
538 scrollbar_controller_->DidCaptureScrollbarBegin(); 800 scrollbar_controller_->DidCaptureScrollbarBegin();
539 time += base::TimeDelta::FromSeconds(1); 801 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
540 scrollbar_controller_->Animate(time); 802 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
541 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); 803
542 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor()); 804 // Move out of window. Since the scrollbar is capture, it shouldn't change in
543 805 // any way.
544 // move out of window
545 scrollbar_controller_->DidMouseMoveOffScrollbar(); 806 scrollbar_controller_->DidMouseMoveOffScrollbar();
546 807 scrollbar_controller_->Animate(time);
547 // test for 10 seconds, stay thick and dark 808 time += kThinningDuration;
548 for (int i = 0; i < 10; ++i) { 809 scrollbar_controller_->Animate(time);
549 time += base::TimeDelta::FromSeconds(1); 810 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
550 scrollbar_controller_->Animate(time); 811 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
551 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); 812 }
552 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor()); 813
553 } 814 // Tests that the thickening/thinning effects are animated.
815 TEST_F(ScrollbarAnimationControllerThinningTest, ThicknessAnimated) {
816 // Scroll to make the scrollbars visible.
817 scrollbar_controller_->DidScrollBegin();
818 scrollbar_controller_->DidScrollUpdate(false);
819 scrollbar_controller_->DidScrollEnd();
820
821 base::TimeTicks time;
822 time += base::TimeDelta::FromSeconds(1);
823
824 // Move mouse near scrollbar. Test that at half the duration time, the
825 // thickness is half way through its animation.
826 scrollbar_controller_->DidMouseMoveNear(1);
827 scrollbar_controller_->Animate(time);
828 EXPECT_FLOAT_EQ(kIdleThicknessScale,
829 scrollbar_layer_->thumb_thickness_scale_factor());
830
831 time += kThinningDuration / 2;
832 scrollbar_controller_->Animate(time);
833 EXPECT_FLOAT_EQ(kIdleThicknessScale + (1.0f - kIdleThicknessScale) / 2.0f,
834 scrollbar_layer_->thumb_thickness_scale_factor());
835
836 time += kThinningDuration / 2;
837 scrollbar_controller_->Animate(time);
838 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
839
840 // Move mouse away from scrollbar. Same check.
841 time += base::TimeDelta::FromSeconds(1);
842 scrollbar_controller_->DidMouseMoveNear(
843 kDefaultMouseMoveDistanceToTriggerAnimation);
844 scrollbar_controller_->Animate(time);
845 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
846
847 time += kThinningDuration / 2;
848 scrollbar_controller_->Animate(time);
849 EXPECT_FLOAT_EQ(1.0f - (1.0f - kIdleThicknessScale) / 2.0f,
850 scrollbar_layer_->thumb_thickness_scale_factor());
851
852 time += kThinningDuration / 2;
853 scrollbar_controller_->Animate(time);
854 EXPECT_FLOAT_EQ(kIdleThicknessScale,
855 scrollbar_layer_->thumb_thickness_scale_factor());
856 }
857
858 // Tests that main thread scroll updates immediatley queue a fade animation
859 // without requiring a ScrollEnd.
860 TEST_F(ScrollbarAnimationControllerThinningTest, MainThreadScrollQueuesFade) {
861 ASSERT_TRUE(start_fade_.is_null());
862
863 // A ScrollUpdate without a ScrollBegin indicates a main thread scroll update
864 // so we should schedule a fade animation without waiting for a ScrollEnd
865 // (which will never come).
866 scrollbar_controller_->DidScrollUpdate(false);
867 EXPECT_FALSE(start_fade_.is_null());
868 EXPECT_EQ(kDelayBeforeStarting, delay_);
869
870 start_fade_.Reset();
871
872 // If we got a ScrollBegin, we shouldn't schedule the fade animation until we
873 // get a corresponding ScrollEnd.
874 scrollbar_controller_->DidScrollBegin();
875 scrollbar_controller_->DidScrollUpdate(false);
876 EXPECT_TRUE(start_fade_.is_null());
877 scrollbar_controller_->DidScrollEnd();
878 EXPECT_FALSE(start_fade_.is_null());
879 EXPECT_EQ(kDelayBeforeStarting, delay_);
880 }
881
882 // Make sure that if the scroll update is as a result of a resize, we use the
883 // resize delay time instead of the default one.
884 TEST_F(ScrollbarAnimationControllerThinningTest, ResizeFadeDuration) {
885 ASSERT_TRUE(delay_.is_zero());
886
887 scrollbar_controller_->DidScrollUpdate(true);
888 EXPECT_FALSE(start_fade_.is_null());
889 EXPECT_EQ(kResizeDelayBeforeStarting, delay_);
890
891 delay_ = base::TimeDelta();
892
893 // We should use the gesture delay rather than the resize delay if we're in a
894 // gesture scroll, even if the resize param is set.
895 scrollbar_controller_->DidScrollBegin();
896 scrollbar_controller_->DidScrollUpdate(true);
897 scrollbar_controller_->DidScrollEnd();
898
899 EXPECT_FALSE(start_fade_.is_null());
900 EXPECT_EQ(kDelayBeforeStarting, delay_);
901 }
902
903 // Tests that the fade effect is animated.
904 TEST_F(ScrollbarAnimationControllerThinningTest, FadeAnimated) {
905 // Scroll to make the scrollbars visible.
906 scrollbar_controller_->DidScrollBegin();
907 scrollbar_controller_->DidScrollUpdate(false);
908 scrollbar_controller_->DidScrollEnd();
909
910 // Appearance is instant.
911 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
912
913 // An animation should have been enqueued.
914 EXPECT_EQ(kDelayBeforeStarting, delay_);
915 EXPECT_FALSE(start_fade_.is_null());
916 start_fade_.Run();
917
918 base::TimeTicks time;
919 time += base::TimeDelta::FromSeconds(1);
920
921 // Test that at half the fade duration time, the opacity is at half.
922 scrollbar_controller_->Animate(time);
923 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
924
925 time += kFadeDuration / 2;
926 scrollbar_controller_->Animate(time);
927 EXPECT_FLOAT_EQ(0.5f, scrollbar_layer_->Opacity());
928
929 time += kFadeDuration / 2;
930 scrollbar_controller_->Animate(time);
931 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity());
554 } 932 }
555 933
556 } // namespace 934 } // namespace
557 } // namespace cc 935 } // namespace cc
OLDNEW
« no previous file with comments | « cc/input/scrollbar_animation_controller_thinning.cc ('k') | cc/trees/layer_tree_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698