OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/input/scrollbar_animation_controller.h" | 5 #include "cc/input/scrollbar_animation_controller.h" |
6 | 6 |
7 #include "cc/layers/solid_color_scrollbar_layer_impl.h" | 7 #include "cc/layers/solid_color_scrollbar_layer_impl.h" |
8 #include "cc/test/fake_impl_task_runner_provider.h" | 8 #include "cc/test/fake_impl_task_runner_provider.h" |
9 #include "cc/test/fake_layer_tree_host_impl.h" | 9 #include "cc/test/fake_layer_tree_host_impl.h" |
10 #include "cc/test/geometry_test_utils.h" | 10 #include "cc/test/geometry_test_utils.h" |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 EXPECT_FLOAT_EQ(kIdleThicknessScale, | 136 EXPECT_FLOAT_EQ(kIdleThicknessScale, |
137 v_scrollbar_layer_->thumb_thickness_scale_factor()); | 137 v_scrollbar_layer_->thumb_thickness_scale_factor()); |
138 } | 138 } |
139 | 139 |
140 // Check that scrollbar appears again when the layer becomes scrollable. | 140 // Check that scrollbar appears again when the layer becomes scrollable. |
141 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, AppearOnResize) { | 141 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, AppearOnResize) { |
142 base::TimeTicks time; | 142 base::TimeTicks time; |
143 time += base::TimeDelta::FromSeconds(1); | 143 time += base::TimeDelta::FromSeconds(1); |
144 | 144 |
145 scrollbar_controller_->DidScrollBegin(); | 145 scrollbar_controller_->DidScrollBegin(); |
146 scrollbar_controller_->DidScrollUpdate(false); | 146 scrollbar_controller_->WillUpdateScroll(); |
147 scrollbar_controller_->DidScrollEnd(); | 147 scrollbar_controller_->DidScrollEnd(); |
148 ExpectScrollbarsOpacity(1); | 148 ExpectScrollbarsOpacity(1); |
149 | 149 |
150 // Make the Layer non-scrollable, scrollbar disappears. | 150 // Make the Layer non-scrollable, scrollbar disappears. |
151 clip_layer_->SetBounds(gfx::Size(200, 200)); | 151 clip_layer_->SetBounds(gfx::Size(200, 200)); |
152 scrollbar_controller_->DidScrollUpdate(false); | 152 scrollbar_controller_->WillUpdateScroll(); |
153 ExpectScrollbarsOpacity(0); | 153 ExpectScrollbarsOpacity(0); |
154 | 154 |
155 // Make the layer scrollable, scrollbar appears again. | 155 // Make the layer scrollable, scrollbar appears again. |
156 clip_layer_->SetBounds(gfx::Size(100, 100)); | 156 clip_layer_->SetBounds(gfx::Size(100, 100)); |
157 scrollbar_controller_->DidScrollUpdate(false); | 157 scrollbar_controller_->WillUpdateScroll(); |
158 ExpectScrollbarsOpacity(1); | 158 ExpectScrollbarsOpacity(1); |
159 } | 159 } |
160 | 160 |
161 // Check that scrollbar disappears when the layer becomes non-scrollable. | 161 // Check that scrollbar disappears when the layer becomes non-scrollable. |
162 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, HideOnResize) { | 162 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, HideOnResize) { |
163 base::TimeTicks time; | 163 base::TimeTicks time; |
164 time += base::TimeDelta::FromSeconds(1); | 164 time += base::TimeDelta::FromSeconds(1); |
165 | 165 |
166 LayerImpl* scroll_layer = host_impl_.active_tree()->LayerById(1); | 166 LayerImpl* scroll_layer = host_impl_.active_tree()->LayerById(1); |
167 ASSERT_TRUE(scroll_layer); | 167 ASSERT_TRUE(scroll_layer); |
168 EXPECT_EQ(gfx::Size(200, 200), scroll_layer->bounds()); | 168 EXPECT_EQ(gfx::Size(200, 200), scroll_layer->bounds()); |
169 | 169 |
170 // Shrink along X axis, horizontal scrollbar should appear. | 170 // Shrink along X axis, horizontal scrollbar should appear. |
171 clip_layer_->SetBounds(gfx::Size(100, 200)); | 171 clip_layer_->SetBounds(gfx::Size(100, 200)); |
172 EXPECT_EQ(gfx::Size(100, 200), clip_layer_->bounds()); | 172 EXPECT_EQ(gfx::Size(100, 200), clip_layer_->bounds()); |
173 | 173 |
174 scrollbar_controller_->DidScrollBegin(); | 174 scrollbar_controller_->DidScrollBegin(); |
175 | 175 |
176 scrollbar_controller_->DidScrollUpdate(false); | 176 scrollbar_controller_->WillUpdateScroll(); |
177 EXPECT_FLOAT_EQ(1, h_scrollbar_layer_->Opacity()); | 177 EXPECT_FLOAT_EQ(1, h_scrollbar_layer_->Opacity()); |
178 | 178 |
179 scrollbar_controller_->DidScrollEnd(); | 179 scrollbar_controller_->DidScrollEnd(); |
180 | 180 |
181 // Shrink along Y axis and expand along X, horizontal scrollbar | 181 // Shrink along Y axis and expand along X, horizontal scrollbar |
182 // should disappear. | 182 // should disappear. |
183 clip_layer_->SetBounds(gfx::Size(200, 100)); | 183 clip_layer_->SetBounds(gfx::Size(200, 100)); |
184 EXPECT_EQ(gfx::Size(200, 100), clip_layer_->bounds()); | 184 EXPECT_EQ(gfx::Size(200, 100), clip_layer_->bounds()); |
185 | 185 |
186 scrollbar_controller_->DidScrollBegin(); | 186 scrollbar_controller_->DidScrollBegin(); |
187 | 187 |
188 scrollbar_controller_->DidScrollUpdate(false); | 188 scrollbar_controller_->WillUpdateScroll(); |
189 EXPECT_FLOAT_EQ(0.0f, h_scrollbar_layer_->Opacity()); | 189 EXPECT_FLOAT_EQ(0.0f, h_scrollbar_layer_->Opacity()); |
190 | 190 |
191 scrollbar_controller_->DidScrollEnd(); | 191 scrollbar_controller_->DidScrollEnd(); |
192 } | 192 } |
193 | 193 |
194 // Scroll content. Confirm the scrollbar appears and fades out. | 194 // Scroll content. Confirm the scrollbar appears and fades out. |
195 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, BasicAppearAndFadeOut) { | 195 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, BasicAppearAndFadeOut) { |
196 base::TimeTicks time; | 196 base::TimeTicks time; |
197 time += base::TimeDelta::FromSeconds(1); | 197 time += base::TimeDelta::FromSeconds(1); |
198 | 198 |
199 // Scrollbar should be invisible. | 199 // Scrollbar should be invisible. |
200 ExpectScrollbarsOpacity(0); | 200 ExpectScrollbarsOpacity(0); |
201 EXPECT_TRUE(scrollbar_controller_->ScrollbarsHidden()); | 201 EXPECT_TRUE(scrollbar_controller_->ScrollbarsHidden()); |
202 | 202 |
203 // Scrollbar should appear only on scroll update. | 203 // Scrollbar should appear only on scroll update. |
204 scrollbar_controller_->DidScrollBegin(); | 204 scrollbar_controller_->DidScrollBegin(); |
205 ExpectScrollbarsOpacity(0); | 205 ExpectScrollbarsOpacity(0); |
206 EXPECT_TRUE(scrollbar_controller_->ScrollbarsHidden()); | 206 EXPECT_TRUE(scrollbar_controller_->ScrollbarsHidden()); |
207 | 207 |
208 scrollbar_controller_->DidScrollUpdate(false); | 208 scrollbar_controller_->WillUpdateScroll(); |
209 ExpectScrollbarsOpacity(1); | 209 ExpectScrollbarsOpacity(1); |
210 EXPECT_FALSE(scrollbar_controller_->ScrollbarsHidden()); | 210 EXPECT_FALSE(scrollbar_controller_->ScrollbarsHidden()); |
211 | 211 |
212 scrollbar_controller_->DidScrollEnd(); | 212 scrollbar_controller_->DidScrollEnd(); |
213 ExpectScrollbarsOpacity(1); | 213 ExpectScrollbarsOpacity(1); |
214 EXPECT_FALSE(scrollbar_controller_->ScrollbarsHidden()); | 214 EXPECT_FALSE(scrollbar_controller_->ScrollbarsHidden()); |
215 | 215 |
216 // An fade out animation should have been enqueued. | 216 // An fade out animation should have been enqueued. |
217 EXPECT_EQ(kFadeOutDelay, client_.delay()); | 217 EXPECT_EQ(kFadeOutDelay, client_.delay()); |
218 EXPECT_FALSE(client_.start_fade().is_null()); | 218 EXPECT_FALSE(client_.start_fade().is_null()); |
219 client_.start_fade().Run(); | 219 client_.start_fade().Run(); |
220 | 220 |
221 // Scrollbar should fade out over kFadeOutDuration. | 221 // Scrollbar should fade out over kFadeOutDuration. |
222 scrollbar_controller_->Animate(time); | 222 scrollbar_controller_->Animate(time); |
223 time += kFadeOutDuration; | 223 time += kFadeOutDuration; |
224 scrollbar_controller_->Animate(time); | 224 scrollbar_controller_->Animate(time); |
225 | 225 |
226 ExpectScrollbarsOpacity(0); | 226 ExpectScrollbarsOpacity(0); |
227 EXPECT_TRUE(scrollbar_controller_->ScrollbarsHidden()); | 227 EXPECT_TRUE(scrollbar_controller_->ScrollbarsHidden()); |
228 } | 228 } |
229 | 229 |
230 // Scroll content. Move the mouse near the scrollbar and confirm it becomes | 230 // Scroll content. Move the mouse near the scrollbar and confirm it becomes |
231 // thick. Ensure it remains visible as long as the mouse is near the scrollbar. | 231 // thick. Ensure it remains visible as long as the mouse is near the scrollbar. |
232 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, MoveNearAndDontFadeOut) { | 232 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, MoveNearAndDontFadeOut) { |
233 base::TimeTicks time; | 233 base::TimeTicks time; |
234 time += base::TimeDelta::FromSeconds(1); | 234 time += base::TimeDelta::FromSeconds(1); |
235 | 235 |
236 scrollbar_controller_->DidScrollBegin(); | 236 scrollbar_controller_->DidScrollBegin(); |
237 scrollbar_controller_->DidScrollUpdate(false); | 237 scrollbar_controller_->WillUpdateScroll(); |
238 scrollbar_controller_->DidScrollEnd(); | 238 scrollbar_controller_->DidScrollEnd(); |
239 | 239 |
240 // An fade out animation should have been enqueued. | 240 // An fade out animation should have been enqueued. |
241 EXPECT_EQ(kFadeOutDelay, client_.delay()); | 241 EXPECT_EQ(kFadeOutDelay, client_.delay()); |
242 EXPECT_FALSE(client_.start_fade().is_null()); | 242 EXPECT_FALSE(client_.start_fade().is_null()); |
243 EXPECT_FALSE(client_.start_fade().IsCancelled()); | 243 EXPECT_FALSE(client_.start_fade().IsCancelled()); |
244 | 244 |
245 // Now move the mouse near the scrollbar. This should cancel the currently | 245 // Now move the mouse near the scrollbar. This should cancel the currently |
246 // queued fading animation and start animating thickness. | 246 // queued fading animation and start animating thickness. |
247 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 1); | 247 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 1); |
(...skipping 20 matching lines...) Expand all Loading... |
268 client_.start_fade().IsCancelled()); | 268 client_.start_fade().IsCancelled()); |
269 } | 269 } |
270 | 270 |
271 // Scroll content. Move the mouse over the scrollbar and confirm it becomes | 271 // Scroll content. Move the mouse over the scrollbar and confirm it becomes |
272 // thick. Ensure it remains visible as long as the mouse is over the scrollbar. | 272 // thick. Ensure it remains visible as long as the mouse is over the scrollbar. |
273 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, MoveOverAndDontFadeOut) { | 273 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, MoveOverAndDontFadeOut) { |
274 base::TimeTicks time; | 274 base::TimeTicks time; |
275 time += base::TimeDelta::FromSeconds(1); | 275 time += base::TimeDelta::FromSeconds(1); |
276 | 276 |
277 scrollbar_controller_->DidScrollBegin(); | 277 scrollbar_controller_->DidScrollBegin(); |
278 scrollbar_controller_->DidScrollUpdate(false); | 278 scrollbar_controller_->WillUpdateScroll(); |
279 scrollbar_controller_->DidScrollEnd(); | 279 scrollbar_controller_->DidScrollEnd(); |
280 | 280 |
281 // An fade out animation should have been enqueued. | 281 // An fade out animation should have been enqueued. |
282 EXPECT_EQ(kFadeOutDelay, client_.delay()); | 282 EXPECT_EQ(kFadeOutDelay, client_.delay()); |
283 EXPECT_FALSE(client_.start_fade().is_null()); | 283 EXPECT_FALSE(client_.start_fade().is_null()); |
284 EXPECT_FALSE(client_.start_fade().IsCancelled()); | 284 EXPECT_FALSE(client_.start_fade().IsCancelled()); |
285 | 285 |
286 // Now move the mouse over the scrollbar. This should cancel the currently | 286 // Now move the mouse over the scrollbar. This should cancel the currently |
287 // queued fading animation and start animating thickness. | 287 // queued fading animation and start animating thickness. |
288 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 0); | 288 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 0); |
(...skipping 21 matching lines...) Expand all Loading... |
310 } | 310 } |
311 | 311 |
312 // Make sure a scrollbar captured before the thickening animation doesn't try | 312 // Make sure a scrollbar captured before the thickening animation doesn't try |
313 // to fade out. | 313 // to fade out. |
314 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, | 314 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, |
315 DontFadeWhileCapturedBeforeThick) { | 315 DontFadeWhileCapturedBeforeThick) { |
316 base::TimeTicks time; | 316 base::TimeTicks time; |
317 time += base::TimeDelta::FromSeconds(1); | 317 time += base::TimeDelta::FromSeconds(1); |
318 | 318 |
319 scrollbar_controller_->DidScrollBegin(); | 319 scrollbar_controller_->DidScrollBegin(); |
320 scrollbar_controller_->DidScrollUpdate(false); | 320 scrollbar_controller_->WillUpdateScroll(); |
321 scrollbar_controller_->DidScrollEnd(); | 321 scrollbar_controller_->DidScrollEnd(); |
322 | 322 |
323 // An fade out animation should have been enqueued. | 323 // An fade out animation should have been enqueued. |
324 EXPECT_EQ(kFadeOutDelay, client_.delay()); | 324 EXPECT_EQ(kFadeOutDelay, client_.delay()); |
325 EXPECT_FALSE(client_.start_fade().is_null()); | 325 EXPECT_FALSE(client_.start_fade().is_null()); |
326 | 326 |
327 // Now move the mouse over the scrollbar and capture it. It should become | 327 // Now move the mouse over the scrollbar and capture it. It should become |
328 // thick without need for an animation. | 328 // thick without need for an animation. |
329 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 0); | 329 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 0); |
330 scrollbar_controller_->DidMouseDown(); | 330 scrollbar_controller_->DidMouseDown(); |
331 ExpectScrollbarsOpacity(1); | 331 ExpectScrollbarsOpacity(1); |
332 EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor()); | 332 EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor()); |
333 EXPECT_FLOAT_EQ(kIdleThicknessScale, | 333 EXPECT_FLOAT_EQ(kIdleThicknessScale, |
334 h_scrollbar_layer_->thumb_thickness_scale_factor()); | 334 h_scrollbar_layer_->thumb_thickness_scale_factor()); |
335 | 335 |
336 // The fade out animation should have been cleared or cancelled. | 336 // The fade out animation should have been cleared or cancelled. |
337 EXPECT_TRUE(client_.start_fade().is_null() || | 337 EXPECT_TRUE(client_.start_fade().is_null() || |
338 client_.start_fade().IsCancelled()); | 338 client_.start_fade().IsCancelled()); |
339 } | 339 } |
340 | 340 |
341 // Make sure a scrollbar captured then move mouse away doesn't try to fade out. | 341 // Make sure a scrollbar captured then move mouse away doesn't try to fade out. |
342 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, | 342 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, |
343 DontFadeWhileCapturedThenAway) { | 343 DontFadeWhileCapturedThenAway) { |
344 base::TimeTicks time; | 344 base::TimeTicks time; |
345 time += base::TimeDelta::FromSeconds(1); | 345 time += base::TimeDelta::FromSeconds(1); |
346 | 346 |
347 scrollbar_controller_->DidScrollBegin(); | 347 scrollbar_controller_->DidScrollBegin(); |
348 scrollbar_controller_->DidScrollUpdate(false); | 348 scrollbar_controller_->WillUpdateScroll(); |
349 scrollbar_controller_->DidScrollEnd(); | 349 scrollbar_controller_->DidScrollEnd(); |
350 | 350 |
351 // An fade out animation should have been enqueued. | 351 // An fade out animation should have been enqueued. |
352 EXPECT_EQ(kFadeOutDelay, client_.delay()); | 352 EXPECT_EQ(kFadeOutDelay, client_.delay()); |
353 EXPECT_FALSE(client_.start_fade().is_null()); | 353 EXPECT_FALSE(client_.start_fade().is_null()); |
354 | 354 |
355 // Now move the mouse over the scrollbar and capture it. It should become | 355 // Now move the mouse over the scrollbar and capture it. It should become |
356 // thick without need for an animation. | 356 // thick without need for an animation. |
357 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 0); | 357 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 0); |
358 scrollbar_controller_->DidMouseDown(); | 358 scrollbar_controller_->DidMouseDown(); |
(...skipping 15 matching lines...) Expand all Loading... |
374 client_.start_fade().IsCancelled()); | 374 client_.start_fade().IsCancelled()); |
375 } | 375 } |
376 | 376 |
377 // Make sure a scrollbar captured after a thickening animation doesn't try to | 377 // Make sure a scrollbar captured after a thickening animation doesn't try to |
378 // fade out. | 378 // fade out. |
379 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, DontFadeWhileCaptured) { | 379 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, DontFadeWhileCaptured) { |
380 base::TimeTicks time; | 380 base::TimeTicks time; |
381 time += base::TimeDelta::FromSeconds(1); | 381 time += base::TimeDelta::FromSeconds(1); |
382 | 382 |
383 scrollbar_controller_->DidScrollBegin(); | 383 scrollbar_controller_->DidScrollBegin(); |
384 scrollbar_controller_->DidScrollUpdate(false); | 384 scrollbar_controller_->WillUpdateScroll(); |
385 scrollbar_controller_->DidScrollEnd(); | 385 scrollbar_controller_->DidScrollEnd(); |
386 | 386 |
387 // An fade out animation should have been enqueued. | 387 // An fade out animation should have been enqueued. |
388 EXPECT_EQ(kFadeOutDelay, client_.delay()); | 388 EXPECT_EQ(kFadeOutDelay, client_.delay()); |
389 EXPECT_FALSE(client_.start_fade().is_null()); | 389 EXPECT_FALSE(client_.start_fade().is_null()); |
390 EXPECT_FALSE(client_.start_fade().IsCancelled()); | 390 EXPECT_FALSE(client_.start_fade().IsCancelled()); |
391 | 391 |
392 // Now move the mouse over the scrollbar and animate it until it's thick. | 392 // Now move the mouse over the scrollbar and animate it until it's thick. |
393 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 0); | 393 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 0); |
394 scrollbar_controller_->Animate(time); | 394 scrollbar_controller_->Animate(time); |
(...skipping 16 matching lines...) Expand all Loading... |
411 client_.start_fade().IsCancelled()); | 411 client_.start_fade().IsCancelled()); |
412 } | 412 } |
413 | 413 |
414 // Make sure releasing a captured scrollbar when the mouse isn't near it, causes | 414 // Make sure releasing a captured scrollbar when the mouse isn't near it, causes |
415 // the scrollbar to fade out. | 415 // the scrollbar to fade out. |
416 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, FadeAfterReleasedFar) { | 416 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, FadeAfterReleasedFar) { |
417 base::TimeTicks time; | 417 base::TimeTicks time; |
418 time += base::TimeDelta::FromSeconds(1); | 418 time += base::TimeDelta::FromSeconds(1); |
419 | 419 |
420 scrollbar_controller_->DidScrollBegin(); | 420 scrollbar_controller_->DidScrollBegin(); |
421 scrollbar_controller_->DidScrollUpdate(false); | 421 scrollbar_controller_->WillUpdateScroll(); |
422 scrollbar_controller_->DidScrollEnd(); | 422 scrollbar_controller_->DidScrollEnd(); |
423 | 423 |
424 // An fade out animation should have been enqueued. | 424 // An fade out animation should have been enqueued. |
425 EXPECT_EQ(kFadeOutDelay, client_.delay()); | 425 EXPECT_EQ(kFadeOutDelay, client_.delay()); |
426 EXPECT_FALSE(client_.start_fade().is_null()); | 426 EXPECT_FALSE(client_.start_fade().is_null()); |
427 EXPECT_FALSE(client_.start_fade().IsCancelled()); | 427 EXPECT_FALSE(client_.start_fade().IsCancelled()); |
428 | 428 |
429 // Now move the mouse over the scrollbar and capture it. | 429 // Now move the mouse over the scrollbar and capture it. |
430 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 0); | 430 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 0); |
431 scrollbar_controller_->DidMouseDown(); | 431 scrollbar_controller_->DidMouseDown(); |
(...skipping 30 matching lines...) Expand all Loading... |
462 EXPECT_FALSE(client_.start_fade().IsCancelled()); | 462 EXPECT_FALSE(client_.start_fade().IsCancelled()); |
463 } | 463 } |
464 | 464 |
465 // Make sure releasing a captured scrollbar when the mouse is near/over it, | 465 // Make sure releasing a captured scrollbar when the mouse is near/over it, |
466 // doesn't cause the scrollbar to fade out. | 466 // doesn't cause the scrollbar to fade out. |
467 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, DontFadeAfterReleasedNear) { | 467 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, DontFadeAfterReleasedNear) { |
468 base::TimeTicks time; | 468 base::TimeTicks time; |
469 time += base::TimeDelta::FromSeconds(1); | 469 time += base::TimeDelta::FromSeconds(1); |
470 | 470 |
471 scrollbar_controller_->DidScrollBegin(); | 471 scrollbar_controller_->DidScrollBegin(); |
472 scrollbar_controller_->DidScrollUpdate(false); | 472 scrollbar_controller_->WillUpdateScroll(); |
473 scrollbar_controller_->DidScrollEnd(); | 473 scrollbar_controller_->DidScrollEnd(); |
474 | 474 |
475 // An fade out animation should have been enqueued. | 475 // An fade out animation should have been enqueued. |
476 EXPECT_EQ(kFadeOutDelay, client_.delay()); | 476 EXPECT_EQ(kFadeOutDelay, client_.delay()); |
477 EXPECT_FALSE(client_.start_fade().is_null()); | 477 EXPECT_FALSE(client_.start_fade().is_null()); |
478 EXPECT_FALSE(client_.start_fade().IsCancelled()); | 478 EXPECT_FALSE(client_.start_fade().IsCancelled()); |
479 | 479 |
480 // Now move the mouse over the scrollbar and capture it. | 480 // Now move the mouse over the scrollbar and capture it. |
481 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 0); | 481 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 0); |
482 scrollbar_controller_->DidMouseDown(); | 482 scrollbar_controller_->DidMouseDown(); |
(...skipping 18 matching lines...) Expand all Loading... |
501 } | 501 } |
502 | 502 |
503 // Make sure moving near a scrollbar while it's fading out causes it to reset | 503 // Make sure moving near a scrollbar while it's fading out causes it to reset |
504 // the opacity and thicken. | 504 // the opacity and thicken. |
505 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, | 505 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, |
506 MoveNearScrollbarWhileFading) { | 506 MoveNearScrollbarWhileFading) { |
507 base::TimeTicks time; | 507 base::TimeTicks time; |
508 time += base::TimeDelta::FromSeconds(1); | 508 time += base::TimeDelta::FromSeconds(1); |
509 | 509 |
510 scrollbar_controller_->DidScrollBegin(); | 510 scrollbar_controller_->DidScrollBegin(); |
511 scrollbar_controller_->DidScrollUpdate(false); | 511 scrollbar_controller_->WillUpdateScroll(); |
512 scrollbar_controller_->DidScrollEnd(); | 512 scrollbar_controller_->DidScrollEnd(); |
513 | 513 |
514 // A fade out animation should have been enqueued. Start it. | 514 // A fade out animation should have been enqueued. Start it. |
515 EXPECT_EQ(kFadeOutDelay, client_.delay()); | 515 EXPECT_EQ(kFadeOutDelay, client_.delay()); |
516 EXPECT_FALSE(client_.start_fade().is_null()); | 516 EXPECT_FALSE(client_.start_fade().is_null()); |
517 client_.start_fade().Run(); | 517 client_.start_fade().Run(); |
518 | 518 |
519 scrollbar_controller_->Animate(time); | 519 scrollbar_controller_->Animate(time); |
520 ExpectScrollbarsOpacity(1); | 520 ExpectScrollbarsOpacity(1); |
521 | 521 |
(...skipping 19 matching lines...) Expand all Loading... |
541 EXPECT_FLOAT_EQ(kIdleThicknessScale, | 541 EXPECT_FLOAT_EQ(kIdleThicknessScale, |
542 h_scrollbar_layer_->thumb_thickness_scale_factor()); | 542 h_scrollbar_layer_->thumb_thickness_scale_factor()); |
543 } | 543 } |
544 | 544 |
545 // Make sure we can't capture scrollbar that's completely faded out. | 545 // Make sure we can't capture scrollbar that's completely faded out. |
546 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, TestCantCaptureWhenFaded) { | 546 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, TestCantCaptureWhenFaded) { |
547 base::TimeTicks time; | 547 base::TimeTicks time; |
548 time += base::TimeDelta::FromSeconds(1); | 548 time += base::TimeDelta::FromSeconds(1); |
549 | 549 |
550 scrollbar_controller_->DidScrollBegin(); | 550 scrollbar_controller_->DidScrollBegin(); |
551 scrollbar_controller_->DidScrollUpdate(false); | 551 scrollbar_controller_->WillUpdateScroll(); |
552 scrollbar_controller_->DidScrollEnd(); | 552 scrollbar_controller_->DidScrollEnd(); |
553 | 553 |
554 EXPECT_EQ(kFadeOutDelay, client_.delay()); | 554 EXPECT_EQ(kFadeOutDelay, client_.delay()); |
555 EXPECT_FALSE(client_.start_fade().is_null()); | 555 EXPECT_FALSE(client_.start_fade().is_null()); |
556 EXPECT_FALSE(client_.start_fade().IsCancelled()); | 556 EXPECT_FALSE(client_.start_fade().IsCancelled()); |
557 client_.start_fade().Run(); | 557 client_.start_fade().Run(); |
558 scrollbar_controller_->Animate(time); | 558 scrollbar_controller_->Animate(time); |
559 ExpectScrollbarsOpacity(1); | 559 ExpectScrollbarsOpacity(1); |
560 | 560 |
561 // Fade the scrollbar out completely. | 561 // Fade the scrollbar out completely. |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
605 time += kThinningDuration; | 605 time += kThinningDuration; |
606 | 606 |
607 // Since the scrollbar isn't visible yet (because we haven't scrolled), we | 607 // Since the scrollbar isn't visible yet (because we haven't scrolled), we |
608 // shouldn't have applied the thickening. | 608 // shouldn't have applied the thickening. |
609 scrollbar_controller_->Animate(time); | 609 scrollbar_controller_->Animate(time); |
610 EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor()); | 610 EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor()); |
611 EXPECT_FLOAT_EQ(kIdleThicknessScale, | 611 EXPECT_FLOAT_EQ(kIdleThicknessScale, |
612 h_scrollbar_layer_->thumb_thickness_scale_factor()); | 612 h_scrollbar_layer_->thumb_thickness_scale_factor()); |
613 | 613 |
614 scrollbar_controller_->DidScrollBegin(); | 614 scrollbar_controller_->DidScrollBegin(); |
615 scrollbar_controller_->DidScrollUpdate(false); | 615 scrollbar_controller_->WillUpdateScroll(); |
616 | 616 |
617 // Now that we've received a scroll, we should be thick without an animation. | 617 // Now that we've received a scroll, we should be thick without an animation. |
618 ExpectScrollbarsOpacity(1); | 618 ExpectScrollbarsOpacity(1); |
619 | 619 |
620 // An animation for the fade should be either null or cancelled, since | 620 // An animation for the fade should be either null or cancelled, since |
621 // mouse is still near the scrollbar. | 621 // mouse is still near the scrollbar. |
622 scrollbar_controller_->DidScrollEnd(); | 622 scrollbar_controller_->DidScrollEnd(); |
623 EXPECT_TRUE(client_.start_fade().is_null() || | 623 EXPECT_TRUE(client_.start_fade().is_null() || |
624 client_.start_fade().IsCancelled()); | 624 client_.start_fade().IsCancelled()); |
625 | 625 |
(...skipping 14 matching lines...) Expand all Loading... |
640 | 640 |
641 // Tests that main thread scroll updates immediatley queue a fade out animation | 641 // Tests that main thread scroll updates immediatley queue a fade out animation |
642 // without requiring a ScrollEnd. | 642 // without requiring a ScrollEnd. |
643 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, | 643 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, |
644 MainThreadScrollQueuesFade) { | 644 MainThreadScrollQueuesFade) { |
645 ASSERT_TRUE(client_.start_fade().is_null()); | 645 ASSERT_TRUE(client_.start_fade().is_null()); |
646 | 646 |
647 // A ScrollUpdate without a ScrollBegin indicates a main thread scroll update | 647 // A ScrollUpdate without a ScrollBegin indicates a main thread scroll update |
648 // so we should schedule a fade out animation without waiting for a ScrollEnd | 648 // so we should schedule a fade out animation without waiting for a ScrollEnd |
649 // (which will never come). | 649 // (which will never come). |
650 scrollbar_controller_->DidScrollUpdate(false); | 650 scrollbar_controller_->WillUpdateScroll(); |
651 EXPECT_FALSE(client_.start_fade().is_null()); | 651 EXPECT_FALSE(client_.start_fade().is_null()); |
652 EXPECT_EQ(kFadeOutDelay, client_.delay()); | 652 EXPECT_EQ(kFadeOutDelay, client_.delay()); |
653 | 653 |
654 client_.start_fade().Reset(); | 654 client_.start_fade().Reset(); |
655 | 655 |
656 // If we got a ScrollBegin, we shouldn't schedule the fade out animation until | 656 // If we got a ScrollBegin, we shouldn't schedule the fade out animation until |
657 // we get a corresponding ScrollEnd. | 657 // we get a corresponding ScrollEnd. |
658 scrollbar_controller_->DidScrollBegin(); | 658 scrollbar_controller_->DidScrollBegin(); |
659 scrollbar_controller_->DidScrollUpdate(false); | 659 scrollbar_controller_->WillUpdateScroll(); |
660 EXPECT_TRUE(client_.start_fade().is_null()); | 660 EXPECT_TRUE(client_.start_fade().is_null()); |
661 scrollbar_controller_->DidScrollEnd(); | 661 scrollbar_controller_->DidScrollEnd(); |
662 EXPECT_FALSE(client_.start_fade().is_null()); | 662 EXPECT_FALSE(client_.start_fade().is_null()); |
663 EXPECT_EQ(kFadeOutDelay, client_.delay()); | 663 EXPECT_EQ(kFadeOutDelay, client_.delay()); |
664 } | 664 } |
665 | 665 |
666 // Make sure that if the scroll update is as a result of a resize, we use the | 666 // Make sure that if the scroll update is as a result of a resize, we use the |
667 // resize delay time instead of the default one. | 667 // resize delay time instead of the default one. |
668 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, ResizeFadeDuration) { | 668 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, ResizeFadeDuration) { |
669 ASSERT_TRUE(client_.delay().is_zero()); | 669 ASSERT_TRUE(client_.delay().is_zero()); |
670 | 670 |
671 scrollbar_controller_->DidScrollUpdate(true); | 671 scrollbar_controller_->DidResize(); |
672 EXPECT_FALSE(client_.start_fade().is_null()); | 672 EXPECT_FALSE(client_.start_fade().is_null()); |
673 EXPECT_EQ(kResizeFadeOutDelay, client_.delay()); | 673 EXPECT_EQ(kResizeFadeOutDelay, client_.delay()); |
674 | 674 |
675 client_.delay() = base::TimeDelta(); | 675 client_.delay() = base::TimeDelta(); |
676 | 676 |
677 // We should use the gesture delay rather than the resize delay if we're in a | 677 // We should use the gesture delay rather than the resize delay if we're in a |
678 // gesture scroll, even if the resize param is set. | 678 // gesture scroll, even if it is resizing. |
679 scrollbar_controller_->DidScrollBegin(); | 679 scrollbar_controller_->DidScrollBegin(); |
680 scrollbar_controller_->DidScrollUpdate(true); | 680 scrollbar_controller_->DidResize(); |
681 scrollbar_controller_->DidScrollEnd(); | 681 scrollbar_controller_->DidScrollEnd(); |
682 | 682 |
683 EXPECT_FALSE(client_.start_fade().is_null()); | 683 EXPECT_FALSE(client_.start_fade().is_null()); |
684 EXPECT_EQ(kFadeOutDelay, client_.delay()); | 684 EXPECT_EQ(kFadeOutDelay, client_.delay()); |
685 } | 685 } |
686 | 686 |
687 // Tests that the fade effect is animated. | 687 // Tests that the fade effect is animated. |
688 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, FadeAnimated) { | 688 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, FadeAnimated) { |
689 base::TimeTicks time; | 689 base::TimeTicks time; |
690 time += base::TimeDelta::FromSeconds(1); | 690 time += base::TimeDelta::FromSeconds(1); |
691 | 691 |
692 // Scroll to make the scrollbars visible. | 692 // Scroll to make the scrollbars visible. |
693 scrollbar_controller_->DidScrollBegin(); | 693 scrollbar_controller_->DidScrollBegin(); |
694 scrollbar_controller_->DidScrollUpdate(false); | 694 scrollbar_controller_->WillUpdateScroll(); |
695 scrollbar_controller_->DidScrollEnd(); | 695 scrollbar_controller_->DidScrollEnd(); |
696 | 696 |
697 // Appearance is instant. | 697 // Appearance is instant. |
698 ExpectScrollbarsOpacity(1); | 698 ExpectScrollbarsOpacity(1); |
699 | 699 |
700 // An fade out animation should have been enqueued. | 700 // An fade out animation should have been enqueued. |
701 EXPECT_EQ(kFadeOutDelay, client_.delay()); | 701 EXPECT_EQ(kFadeOutDelay, client_.delay()); |
702 EXPECT_FALSE(client_.start_fade().is_null()); | 702 EXPECT_FALSE(client_.start_fade().is_null()); |
703 client_.start_fade().Run(); | 703 client_.start_fade().Run(); |
704 | 704 |
(...skipping 11 matching lines...) Expand all Loading... |
716 } | 716 } |
717 | 717 |
718 // Tests that the controller tells the client when the scrollbars hide/show. | 718 // Tests that the controller tells the client when the scrollbars hide/show. |
719 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, NotifyChangedVisibility) { | 719 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, NotifyChangedVisibility) { |
720 base::TimeTicks time; | 720 base::TimeTicks time; |
721 time += base::TimeDelta::FromSeconds(1); | 721 time += base::TimeDelta::FromSeconds(1); |
722 | 722 |
723 EXPECT_CALL(client_, DidChangeScrollbarVisibility()).Times(1); | 723 EXPECT_CALL(client_, DidChangeScrollbarVisibility()).Times(1); |
724 // Scroll to make the scrollbars visible. | 724 // Scroll to make the scrollbars visible. |
725 scrollbar_controller_->DidScrollBegin(); | 725 scrollbar_controller_->DidScrollBegin(); |
726 scrollbar_controller_->DidScrollUpdate(false); | 726 scrollbar_controller_->WillUpdateScroll(); |
727 EXPECT_FALSE(scrollbar_controller_->ScrollbarsHidden()); | 727 EXPECT_FALSE(scrollbar_controller_->ScrollbarsHidden()); |
728 Mock::VerifyAndClearExpectations(&client_); | 728 Mock::VerifyAndClearExpectations(&client_); |
729 | 729 |
730 scrollbar_controller_->DidScrollEnd(); | 730 scrollbar_controller_->DidScrollEnd(); |
731 | 731 |
732 // Play out the fade out animation. We shouldn't notify that the scrollbars | 732 // Play out the fade out animation. We shouldn't notify that the scrollbars |
733 // are hidden until the animation is completly over. We can (but don't have | 733 // are hidden until the animation is completly over. We can (but don't have |
734 // to) notify during the animation that the scrollbars are still visible. | 734 // to) notify during the animation that the scrollbars are still visible. |
735 EXPECT_CALL(client_, DidChangeScrollbarVisibility()).Times(0); | 735 EXPECT_CALL(client_, DidChangeScrollbarVisibility()).Times(0); |
736 ASSERT_FALSE(client_.start_fade().is_null()); | 736 ASSERT_FALSE(client_.start_fade().is_null()); |
(...skipping 14 matching lines...) Expand all Loading... |
751 EXPECT_CALL(client_, DidChangeScrollbarVisibility()).Times(1); | 751 EXPECT_CALL(client_, DidChangeScrollbarVisibility()).Times(1); |
752 time += kFadeOutDuration / 4; | 752 time += kFadeOutDuration / 4; |
753 scrollbar_controller_->Animate(time); | 753 scrollbar_controller_->Animate(time); |
754 EXPECT_TRUE(scrollbar_controller_->ScrollbarsHidden()); | 754 EXPECT_TRUE(scrollbar_controller_->ScrollbarsHidden()); |
755 ExpectScrollbarsOpacity(0); | 755 ExpectScrollbarsOpacity(0); |
756 Mock::VerifyAndClearExpectations(&client_); | 756 Mock::VerifyAndClearExpectations(&client_); |
757 | 757 |
758 // Calling DidScrollUpdate without a begin (i.e. update from commit) should | 758 // Calling DidScrollUpdate without a begin (i.e. update from commit) should |
759 // also notify. | 759 // also notify. |
760 EXPECT_CALL(client_, DidChangeScrollbarVisibility()).Times(1); | 760 EXPECT_CALL(client_, DidChangeScrollbarVisibility()).Times(1); |
761 scrollbar_controller_->DidScrollUpdate(false); | 761 scrollbar_controller_->WillUpdateScroll(); |
762 EXPECT_FALSE(scrollbar_controller_->ScrollbarsHidden()); | 762 EXPECT_FALSE(scrollbar_controller_->ScrollbarsHidden()); |
763 Mock::VerifyAndClearExpectations(&client_); | 763 Mock::VerifyAndClearExpectations(&client_); |
764 } | 764 } |
765 | 765 |
766 // Move the pointer near each scrollbar. Confirm it gets thick and narrow when | 766 // Move the pointer near each scrollbar. Confirm it gets thick and narrow when |
767 // moved away. | 767 // moved away. |
768 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, MouseNearEach) { | 768 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, MouseNearEach) { |
769 base::TimeTicks time; | 769 base::TimeTicks time; |
770 time += base::TimeDelta::FromSeconds(1); | 770 time += base::TimeDelta::FromSeconds(1); |
771 | 771 |
772 // Scroll to make the scrollbars visible. | 772 // Scroll to make the scrollbars visible. |
773 scrollbar_controller_->DidScrollBegin(); | 773 scrollbar_controller_->DidScrollBegin(); |
774 scrollbar_controller_->DidScrollUpdate(false); | 774 scrollbar_controller_->WillUpdateScroll(); |
775 scrollbar_controller_->DidScrollEnd(); | 775 scrollbar_controller_->DidScrollEnd(); |
776 | 776 |
777 // Near vertical scrollbar | 777 // Near vertical scrollbar |
778 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 1); | 778 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 1); |
779 scrollbar_controller_->Animate(time); | 779 scrollbar_controller_->Animate(time); |
780 ExpectScrollbarsOpacity(1); | 780 ExpectScrollbarsOpacity(1); |
781 EXPECT_FLOAT_EQ(kIdleThicknessScale, | 781 EXPECT_FLOAT_EQ(kIdleThicknessScale, |
782 v_scrollbar_layer_->thumb_thickness_scale_factor()); | 782 v_scrollbar_layer_->thumb_thickness_scale_factor()); |
783 EXPECT_FLOAT_EQ(kIdleThicknessScale, | 783 EXPECT_FLOAT_EQ(kIdleThicknessScale, |
784 h_scrollbar_layer_->thumb_thickness_scale_factor()); | 784 h_scrollbar_layer_->thumb_thickness_scale_factor()); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
857 EXPECT_EQ(kFadeOutDelay, client_.delay()); | 857 EXPECT_EQ(kFadeOutDelay, client_.delay()); |
858 } | 858 } |
859 | 859 |
860 // Move mouse near both scrollbars at the same time. | 860 // Move mouse near both scrollbars at the same time. |
861 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, MouseNearBoth) { | 861 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, MouseNearBoth) { |
862 base::TimeTicks time; | 862 base::TimeTicks time; |
863 time += base::TimeDelta::FromSeconds(1); | 863 time += base::TimeDelta::FromSeconds(1); |
864 | 864 |
865 // Scroll to make the scrollbars visible. | 865 // Scroll to make the scrollbars visible. |
866 scrollbar_controller_->DidScrollBegin(); | 866 scrollbar_controller_->DidScrollBegin(); |
867 scrollbar_controller_->DidScrollUpdate(false); | 867 scrollbar_controller_->WillUpdateScroll(); |
868 scrollbar_controller_->DidScrollEnd(); | 868 scrollbar_controller_->DidScrollEnd(); |
869 | 869 |
870 // Near both Scrollbar | 870 // Near both Scrollbar |
871 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 1); | 871 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 1); |
872 scrollbar_controller_->DidMouseMoveNear(HORIZONTAL, 1); | 872 scrollbar_controller_->DidMouseMoveNear(HORIZONTAL, 1); |
873 scrollbar_controller_->Animate(time); | 873 scrollbar_controller_->Animate(time); |
874 ExpectScrollbarsOpacity(1); | 874 ExpectScrollbarsOpacity(1); |
875 EXPECT_FLOAT_EQ(kIdleThicknessScale, | 875 EXPECT_FLOAT_EQ(kIdleThicknessScale, |
876 v_scrollbar_layer_->thumb_thickness_scale_factor()); | 876 v_scrollbar_layer_->thumb_thickness_scale_factor()); |
877 EXPECT_FLOAT_EQ(kIdleThicknessScale, | 877 EXPECT_FLOAT_EQ(kIdleThicknessScale, |
878 h_scrollbar_layer_->thumb_thickness_scale_factor()); | 878 h_scrollbar_layer_->thumb_thickness_scale_factor()); |
879 | 879 |
880 // Should animate to thickened. | 880 // Should animate to thickened. |
881 time += kThinningDuration; | 881 time += kThinningDuration; |
882 scrollbar_controller_->Animate(time); | 882 scrollbar_controller_->Animate(time); |
883 ExpectScrollbarsOpacity(1); | 883 ExpectScrollbarsOpacity(1); |
884 EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor()); | 884 EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor()); |
885 EXPECT_FLOAT_EQ(1, h_scrollbar_layer_->thumb_thickness_scale_factor()); | 885 EXPECT_FLOAT_EQ(1, h_scrollbar_layer_->thumb_thickness_scale_factor()); |
886 } | 886 } |
887 | 887 |
888 // Move mouse from one to the other scrollbar before animation is finished, then | 888 // Move mouse from one to the other scrollbar before animation is finished, then |
889 // away before animation finished. | 889 // away before animation finished. |
890 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, | 890 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, |
891 MouseNearOtherBeforeAnimationFinished) { | 891 MouseNearOtherBeforeAnimationFinished) { |
892 base::TimeTicks time; | 892 base::TimeTicks time; |
893 time += base::TimeDelta::FromSeconds(1); | 893 time += base::TimeDelta::FromSeconds(1); |
894 | 894 |
895 // Scroll to make the scrollbars visible. | 895 // Scroll to make the scrollbars visible. |
896 scrollbar_controller_->DidScrollBegin(); | 896 scrollbar_controller_->DidScrollBegin(); |
897 scrollbar_controller_->DidScrollUpdate(false); | 897 scrollbar_controller_->WillUpdateScroll(); |
898 scrollbar_controller_->DidScrollEnd(); | 898 scrollbar_controller_->DidScrollEnd(); |
899 | 899 |
900 // Near vertical scrollbar. | 900 // Near vertical scrollbar. |
901 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 1); | 901 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 1); |
902 scrollbar_controller_->Animate(time); | 902 scrollbar_controller_->Animate(time); |
903 ExpectScrollbarsOpacity(1); | 903 ExpectScrollbarsOpacity(1); |
904 EXPECT_FLOAT_EQ(kIdleThicknessScale, | 904 EXPECT_FLOAT_EQ(kIdleThicknessScale, |
905 v_scrollbar_layer_->thumb_thickness_scale_factor()); | 905 v_scrollbar_layer_->thumb_thickness_scale_factor()); |
906 EXPECT_FLOAT_EQ(kIdleThicknessScale, | 906 EXPECT_FLOAT_EQ(kIdleThicknessScale, |
907 h_scrollbar_layer_->thumb_thickness_scale_factor()); | 907 h_scrollbar_layer_->thumb_thickness_scale_factor()); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
953 // move. | 953 // move. |
954 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, MouseLeaveFadeOut) { | 954 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, MouseLeaveFadeOut) { |
955 base::TimeTicks time; | 955 base::TimeTicks time; |
956 time += base::TimeDelta::FromSeconds(1); | 956 time += base::TimeDelta::FromSeconds(1); |
957 | 957 |
958 // Move mouse near scrollbar. | 958 // Move mouse near scrollbar. |
959 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 1); | 959 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 1); |
960 | 960 |
961 // Scroll to make the scrollbars visible. | 961 // Scroll to make the scrollbars visible. |
962 scrollbar_controller_->DidScrollBegin(); | 962 scrollbar_controller_->DidScrollBegin(); |
963 scrollbar_controller_->DidScrollUpdate(false); | 963 scrollbar_controller_->WillUpdateScroll(); |
964 scrollbar_controller_->DidScrollEnd(); | 964 scrollbar_controller_->DidScrollEnd(); |
965 | 965 |
966 // Should not have delay fadeout animation. | 966 // Should not have delay fadeout animation. |
967 EXPECT_TRUE(client_.start_fade().is_null() || | 967 EXPECT_TRUE(client_.start_fade().is_null() || |
968 client_.start_fade().IsCancelled()); | 968 client_.start_fade().IsCancelled()); |
969 | 969 |
970 // Mouse leave. | 970 // Mouse leave. |
971 scrollbar_controller_->DidMouseLeave(); | 971 scrollbar_controller_->DidMouseLeave(); |
972 | 972 |
973 // An fade out animation should have been enqueued. | 973 // An fade out animation should have been enqueued. |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1114 protected: | 1114 protected: |
1115 ScrollbarOrientation orientation() const override { return VERTICAL; } | 1115 ScrollbarOrientation orientation() const override { return VERTICAL; } |
1116 }; | 1116 }; |
1117 | 1117 |
1118 TEST_F(ScrollbarAnimationControllerAndroidTest, DelayAnimationOnResize) { | 1118 TEST_F(ScrollbarAnimationControllerAndroidTest, DelayAnimationOnResize) { |
1119 scrollbar_layer_->layer_tree_impl() | 1119 scrollbar_layer_->layer_tree_impl() |
1120 ->property_trees() | 1120 ->property_trees() |
1121 ->effect_tree.OnOpacityAnimated(0.0f, | 1121 ->effect_tree.OnOpacityAnimated(0.0f, |
1122 scrollbar_layer_->effect_tree_index(), | 1122 scrollbar_layer_->effect_tree_index(), |
1123 scrollbar_layer_->layer_tree_impl()); | 1123 scrollbar_layer_->layer_tree_impl()); |
| 1124 // We should use the gesture delay rather than the resize delay if we're in a |
| 1125 // gesture scroll, even if it is resizing. |
1124 scrollbar_controller_->DidScrollBegin(); | 1126 scrollbar_controller_->DidScrollBegin(); |
1125 scrollbar_controller_->DidScrollUpdate(true); | 1127 scrollbar_controller_->DidResize(); |
1126 scrollbar_controller_->DidScrollEnd(); | 1128 scrollbar_controller_->DidScrollEnd(); |
1127 // Normal Animation delay of 2 seconds. | 1129 // Normal Animation delay of 2 seconds. |
1128 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); | 1130 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); |
1129 EXPECT_EQ(delay_, base::TimeDelta::FromSeconds(2)); | 1131 EXPECT_EQ(delay_, base::TimeDelta::FromSeconds(2)); |
1130 | 1132 |
1131 scrollbar_layer_->layer_tree_impl() | 1133 scrollbar_layer_->layer_tree_impl() |
1132 ->property_trees() | 1134 ->property_trees() |
1133 ->effect_tree.OnOpacityAnimated(0.0f, | 1135 ->effect_tree.OnOpacityAnimated(0.0f, |
1134 scrollbar_layer_->effect_tree_index(), | 1136 scrollbar_layer_->effect_tree_index(), |
1135 scrollbar_layer_->layer_tree_impl()); | 1137 scrollbar_layer_->layer_tree_impl()); |
1136 scrollbar_controller_->DidScrollUpdate(true); | 1138 scrollbar_controller_->DidResize(); |
1137 // Delay animation on resize to 5 seconds. | 1139 // Delay animation on resize to 5 seconds. |
1138 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); | 1140 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); |
1139 EXPECT_EQ(delay_, base::TimeDelta::FromSeconds(5)); | 1141 EXPECT_EQ(delay_, base::TimeDelta::FromSeconds(5)); |
1140 } | 1142 } |
1141 | 1143 |
1142 TEST_F(ScrollbarAnimationControllerAndroidTest, HiddenInBegin) { | 1144 TEST_F(ScrollbarAnimationControllerAndroidTest, HiddenInBegin) { |
1143 scrollbar_layer_->layer_tree_impl() | 1145 scrollbar_layer_->layer_tree_impl() |
1144 ->property_trees() | 1146 ->property_trees() |
1145 ->effect_tree.OnOpacityAnimated(0.0f, | 1147 ->effect_tree.OnOpacityAnimated(0.0f, |
1146 scrollbar_layer_->effect_tree_index(), | 1148 scrollbar_layer_->effect_tree_index(), |
(...skipping 30 matching lines...) Expand all Loading... |
1177 EXPECT_EQ(gfx::Size(200, 200), scroll_layer->bounds()); | 1179 EXPECT_EQ(gfx::Size(200, 200), scroll_layer->bounds()); |
1178 | 1180 |
1179 EXPECT_EQ(HORIZONTAL, scrollbar_layer_->orientation()); | 1181 EXPECT_EQ(HORIZONTAL, scrollbar_layer_->orientation()); |
1180 | 1182 |
1181 // Shrink along X axis, horizontal scrollbar should appear. | 1183 // Shrink along X axis, horizontal scrollbar should appear. |
1182 clip_layer_->SetBounds(gfx::Size(100, 200)); | 1184 clip_layer_->SetBounds(gfx::Size(100, 200)); |
1183 EXPECT_EQ(gfx::Size(100, 200), clip_layer_->bounds()); | 1185 EXPECT_EQ(gfx::Size(100, 200), clip_layer_->bounds()); |
1184 | 1186 |
1185 scrollbar_controller_->DidScrollBegin(); | 1187 scrollbar_controller_->DidScrollBegin(); |
1186 | 1188 |
1187 scrollbar_controller_->DidScrollUpdate(false); | 1189 scrollbar_controller_->WillUpdateScroll(); |
1188 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); | 1190 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); |
1189 | 1191 |
1190 scrollbar_controller_->DidScrollEnd(); | 1192 scrollbar_controller_->DidScrollEnd(); |
1191 | 1193 |
1192 // Shrink along Y axis and expand along X, horizontal scrollbar | 1194 // Shrink along Y axis and expand along X, horizontal scrollbar |
1193 // should disappear. | 1195 // should disappear. |
1194 clip_layer_->SetBounds(gfx::Size(200, 100)); | 1196 clip_layer_->SetBounds(gfx::Size(200, 100)); |
1195 EXPECT_EQ(gfx::Size(200, 100), clip_layer_->bounds()); | 1197 EXPECT_EQ(gfx::Size(200, 100), clip_layer_->bounds()); |
1196 | 1198 |
1197 scrollbar_controller_->DidScrollBegin(); | 1199 scrollbar_controller_->DidScrollBegin(); |
1198 | 1200 |
1199 scrollbar_controller_->DidScrollUpdate(false); | 1201 scrollbar_controller_->WillUpdateScroll(); |
1200 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity()); | 1202 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity()); |
1201 | 1203 |
1202 scrollbar_controller_->DidScrollEnd(); | 1204 scrollbar_controller_->DidScrollEnd(); |
1203 } | 1205 } |
1204 | 1206 |
1205 TEST_F(VerticalScrollbarAnimationControllerAndroidTest, HideOnResize) { | 1207 TEST_F(VerticalScrollbarAnimationControllerAndroidTest, HideOnResize) { |
1206 LayerImpl* scroll_layer = host_impl_.active_tree()->LayerById(1); | 1208 LayerImpl* scroll_layer = host_impl_.active_tree()->LayerById(1); |
1207 ASSERT_TRUE(scroll_layer); | 1209 ASSERT_TRUE(scroll_layer); |
1208 EXPECT_EQ(gfx::Size(200, 200), scroll_layer->bounds()); | 1210 EXPECT_EQ(gfx::Size(200, 200), scroll_layer->bounds()); |
1209 | 1211 |
1210 EXPECT_EQ(VERTICAL, scrollbar_layer_->orientation()); | 1212 EXPECT_EQ(VERTICAL, scrollbar_layer_->orientation()); |
1211 | 1213 |
1212 // Shrink along X axis, vertical scrollbar should remain invisible. | 1214 // Shrink along X axis, vertical scrollbar should remain invisible. |
1213 clip_layer_->SetBounds(gfx::Size(100, 200)); | 1215 clip_layer_->SetBounds(gfx::Size(100, 200)); |
1214 EXPECT_EQ(gfx::Size(100, 200), clip_layer_->bounds()); | 1216 EXPECT_EQ(gfx::Size(100, 200), clip_layer_->bounds()); |
1215 | 1217 |
1216 scrollbar_controller_->DidScrollBegin(); | 1218 scrollbar_controller_->DidScrollBegin(); |
1217 | 1219 |
1218 scrollbar_controller_->DidScrollUpdate(false); | 1220 scrollbar_controller_->WillUpdateScroll(); |
1219 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity()); | 1221 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity()); |
1220 | 1222 |
1221 scrollbar_controller_->DidScrollEnd(); | 1223 scrollbar_controller_->DidScrollEnd(); |
1222 | 1224 |
1223 // Shrink along Y axis and expand along X, vertical scrollbar should appear. | 1225 // Shrink along Y axis and expand along X, vertical scrollbar should appear. |
1224 clip_layer_->SetBounds(gfx::Size(200, 100)); | 1226 clip_layer_->SetBounds(gfx::Size(200, 100)); |
1225 EXPECT_EQ(gfx::Size(200, 100), clip_layer_->bounds()); | 1227 EXPECT_EQ(gfx::Size(200, 100), clip_layer_->bounds()); |
1226 | 1228 |
1227 scrollbar_controller_->DidScrollBegin(); | 1229 scrollbar_controller_->DidScrollBegin(); |
1228 | 1230 |
1229 scrollbar_controller_->DidScrollUpdate(false); | 1231 scrollbar_controller_->WillUpdateScroll(); |
1230 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); | 1232 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); |
1231 | 1233 |
1232 scrollbar_controller_->DidScrollEnd(); | 1234 scrollbar_controller_->DidScrollEnd(); |
1233 } | 1235 } |
1234 | 1236 |
1235 TEST_F(ScrollbarAnimationControllerAndroidTest, HideOnUserNonScrollableHorz) { | 1237 TEST_F(ScrollbarAnimationControllerAndroidTest, HideOnUserNonScrollableHorz) { |
1236 EXPECT_EQ(HORIZONTAL, scrollbar_layer_->orientation()); | 1238 EXPECT_EQ(HORIZONTAL, scrollbar_layer_->orientation()); |
1237 | 1239 |
1238 LayerImpl* scroll_layer = host_impl_.active_tree()->LayerById(1); | 1240 LayerImpl* scroll_layer = host_impl_.active_tree()->LayerById(1); |
1239 ASSERT_TRUE(scroll_layer); | 1241 ASSERT_TRUE(scroll_layer); |
1240 scroll_layer->set_user_scrollable_horizontal(false); | 1242 scroll_layer->set_user_scrollable_horizontal(false); |
1241 | 1243 |
1242 scrollbar_controller_->DidScrollBegin(); | 1244 scrollbar_controller_->DidScrollBegin(); |
1243 | 1245 |
1244 scrollbar_controller_->DidScrollUpdate(false); | 1246 scrollbar_controller_->WillUpdateScroll(); |
1245 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity()); | 1247 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity()); |
1246 | 1248 |
1247 scrollbar_controller_->DidScrollEnd(); | 1249 scrollbar_controller_->DidScrollEnd(); |
1248 } | 1250 } |
1249 | 1251 |
1250 TEST_F(ScrollbarAnimationControllerAndroidTest, ShowOnUserNonScrollableVert) { | 1252 TEST_F(ScrollbarAnimationControllerAndroidTest, ShowOnUserNonScrollableVert) { |
1251 EXPECT_EQ(HORIZONTAL, scrollbar_layer_->orientation()); | 1253 EXPECT_EQ(HORIZONTAL, scrollbar_layer_->orientation()); |
1252 | 1254 |
1253 LayerImpl* scroll_layer = host_impl_.active_tree()->LayerById(1); | 1255 LayerImpl* scroll_layer = host_impl_.active_tree()->LayerById(1); |
1254 ASSERT_TRUE(scroll_layer); | 1256 ASSERT_TRUE(scroll_layer); |
1255 scroll_layer->set_user_scrollable_vertical(false); | 1257 scroll_layer->set_user_scrollable_vertical(false); |
1256 | 1258 |
1257 scrollbar_controller_->DidScrollBegin(); | 1259 scrollbar_controller_->DidScrollBegin(); |
1258 | 1260 |
1259 scrollbar_controller_->DidScrollUpdate(false); | 1261 scrollbar_controller_->WillUpdateScroll(); |
1260 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); | 1262 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); |
1261 | 1263 |
1262 scrollbar_controller_->DidScrollEnd(); | 1264 scrollbar_controller_->DidScrollEnd(); |
1263 } | 1265 } |
1264 | 1266 |
1265 TEST_F(VerticalScrollbarAnimationControllerAndroidTest, | 1267 TEST_F(VerticalScrollbarAnimationControllerAndroidTest, |
1266 HideOnUserNonScrollableVert) { | 1268 HideOnUserNonScrollableVert) { |
1267 EXPECT_EQ(VERTICAL, scrollbar_layer_->orientation()); | 1269 EXPECT_EQ(VERTICAL, scrollbar_layer_->orientation()); |
1268 | 1270 |
1269 LayerImpl* scroll_layer = host_impl_.active_tree()->LayerById(1); | 1271 LayerImpl* scroll_layer = host_impl_.active_tree()->LayerById(1); |
1270 ASSERT_TRUE(scroll_layer); | 1272 ASSERT_TRUE(scroll_layer); |
1271 scroll_layer->set_user_scrollable_vertical(false); | 1273 scroll_layer->set_user_scrollable_vertical(false); |
1272 | 1274 |
1273 scrollbar_controller_->DidScrollBegin(); | 1275 scrollbar_controller_->DidScrollBegin(); |
1274 | 1276 |
1275 scrollbar_controller_->DidScrollUpdate(false); | 1277 scrollbar_controller_->WillUpdateScroll(); |
1276 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity()); | 1278 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity()); |
1277 | 1279 |
1278 scrollbar_controller_->DidScrollEnd(); | 1280 scrollbar_controller_->DidScrollEnd(); |
1279 } | 1281 } |
1280 | 1282 |
1281 TEST_F(VerticalScrollbarAnimationControllerAndroidTest, | 1283 TEST_F(VerticalScrollbarAnimationControllerAndroidTest, |
1282 ShowOnUserNonScrollableHorz) { | 1284 ShowOnUserNonScrollableHorz) { |
1283 EXPECT_EQ(VERTICAL, scrollbar_layer_->orientation()); | 1285 EXPECT_EQ(VERTICAL, scrollbar_layer_->orientation()); |
1284 | 1286 |
1285 LayerImpl* scroll_layer = host_impl_.active_tree()->LayerById(1); | 1287 LayerImpl* scroll_layer = host_impl_.active_tree()->LayerById(1); |
1286 ASSERT_TRUE(scroll_layer); | 1288 ASSERT_TRUE(scroll_layer); |
1287 scroll_layer->set_user_scrollable_horizontal(false); | 1289 scroll_layer->set_user_scrollable_horizontal(false); |
1288 | 1290 |
1289 scrollbar_controller_->DidScrollBegin(); | 1291 scrollbar_controller_->DidScrollBegin(); |
1290 | 1292 |
1291 scrollbar_controller_->DidScrollUpdate(false); | 1293 scrollbar_controller_->WillUpdateScroll(); |
1292 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); | 1294 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); |
1293 | 1295 |
1294 scrollbar_controller_->DidScrollEnd(); | 1296 scrollbar_controller_->DidScrollEnd(); |
1295 } | 1297 } |
1296 | 1298 |
1297 TEST_F(ScrollbarAnimationControllerAndroidTest, AwakenByScrollingGesture) { | 1299 TEST_F(ScrollbarAnimationControllerAndroidTest, AwakenByScrollingGesture) { |
1298 base::TimeTicks time; | 1300 base::TimeTicks time; |
1299 time += base::TimeDelta::FromSeconds(1); | 1301 time += base::TimeDelta::FromSeconds(1); |
1300 scrollbar_controller_->DidScrollBegin(); | 1302 scrollbar_controller_->DidScrollBegin(); |
1301 EXPECT_FALSE(did_request_animate_); | 1303 EXPECT_FALSE(did_request_animate_); |
1302 | 1304 |
1303 scrollbar_controller_->DidScrollUpdate(false); | 1305 scrollbar_controller_->WillUpdateScroll(); |
1304 EXPECT_FALSE(did_request_animate_); | 1306 EXPECT_FALSE(did_request_animate_); |
1305 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); | 1307 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); |
1306 | 1308 |
1307 EXPECT_TRUE(start_fade_.Equals(base::Closure())); | 1309 EXPECT_TRUE(start_fade_.Equals(base::Closure())); |
1308 | 1310 |
1309 time += base::TimeDelta::FromSeconds(100); | 1311 time += base::TimeDelta::FromSeconds(100); |
1310 | 1312 |
1311 scrollbar_controller_->Animate(time); | 1313 scrollbar_controller_->Animate(time); |
1312 EXPECT_FALSE(did_request_animate_); | 1314 EXPECT_FALSE(did_request_animate_); |
1313 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); | 1315 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); |
(...skipping 17 matching lines...) Expand all Loading... |
1331 | 1333 |
1332 time += base::TimeDelta::FromSeconds(1); | 1334 time += base::TimeDelta::FromSeconds(1); |
1333 scrollbar_controller_->Animate(time); | 1335 scrollbar_controller_->Animate(time); |
1334 EXPECT_TRUE(did_request_animate_); | 1336 EXPECT_TRUE(did_request_animate_); |
1335 did_request_animate_ = false; | 1337 did_request_animate_ = false; |
1336 EXPECT_FLOAT_EQ(1.0f / 3.0f, scrollbar_layer_->Opacity()); | 1338 EXPECT_FLOAT_EQ(1.0f / 3.0f, scrollbar_layer_->Opacity()); |
1337 | 1339 |
1338 time += base::TimeDelta::FromSeconds(1); | 1340 time += base::TimeDelta::FromSeconds(1); |
1339 | 1341 |
1340 scrollbar_controller_->DidScrollBegin(); | 1342 scrollbar_controller_->DidScrollBegin(); |
1341 scrollbar_controller_->DidScrollUpdate(false); | 1343 scrollbar_controller_->WillUpdateScroll(); |
1342 scrollbar_controller_->DidScrollEnd(); | 1344 scrollbar_controller_->DidScrollEnd(); |
1343 | 1345 |
1344 start_fade_.Run(); | 1346 start_fade_.Run(); |
1345 EXPECT_TRUE(did_request_animate_); | 1347 EXPECT_TRUE(did_request_animate_); |
1346 did_request_animate_ = false; | 1348 did_request_animate_ = false; |
1347 | 1349 |
1348 time += base::TimeDelta::FromSeconds(2); | 1350 time += base::TimeDelta::FromSeconds(2); |
1349 scrollbar_controller_->Animate(time); | 1351 scrollbar_controller_->Animate(time); |
1350 EXPECT_TRUE(did_request_animate_); | 1352 EXPECT_TRUE(did_request_animate_); |
1351 did_request_animate_ = false; | 1353 did_request_animate_ = false; |
(...skipping 13 matching lines...) Expand all Loading... |
1365 | 1367 |
1366 time += base::TimeDelta::FromSeconds(1); | 1368 time += base::TimeDelta::FromSeconds(1); |
1367 scrollbar_controller_->Animate(time); | 1369 scrollbar_controller_->Animate(time); |
1368 EXPECT_FALSE(did_request_animate_); | 1370 EXPECT_FALSE(did_request_animate_); |
1369 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity()); | 1371 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity()); |
1370 } | 1372 } |
1371 | 1373 |
1372 TEST_F(ScrollbarAnimationControllerAndroidTest, AwakenByProgrammaticScroll) { | 1374 TEST_F(ScrollbarAnimationControllerAndroidTest, AwakenByProgrammaticScroll) { |
1373 base::TimeTicks time; | 1375 base::TimeTicks time; |
1374 time += base::TimeDelta::FromSeconds(1); | 1376 time += base::TimeDelta::FromSeconds(1); |
1375 scrollbar_controller_->DidScrollUpdate(false); | 1377 scrollbar_controller_->WillUpdateScroll(); |
1376 EXPECT_FALSE(did_request_animate_); | 1378 EXPECT_FALSE(did_request_animate_); |
1377 | 1379 |
1378 start_fade_.Run(); | 1380 start_fade_.Run(); |
1379 EXPECT_TRUE(did_request_animate_); | 1381 EXPECT_TRUE(did_request_animate_); |
1380 did_request_animate_ = false; | 1382 did_request_animate_ = false; |
1381 scrollbar_controller_->Animate(time); | 1383 scrollbar_controller_->Animate(time); |
1382 EXPECT_TRUE(did_request_animate_); | 1384 EXPECT_TRUE(did_request_animate_); |
1383 did_request_animate_ = false; | 1385 did_request_animate_ = false; |
1384 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); | 1386 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); |
1385 | 1387 |
1386 time += base::TimeDelta::FromSeconds(1); | 1388 time += base::TimeDelta::FromSeconds(1); |
1387 scrollbar_controller_->Animate(time); | 1389 scrollbar_controller_->Animate(time); |
1388 EXPECT_TRUE(did_request_animate_); | 1390 EXPECT_TRUE(did_request_animate_); |
1389 did_request_animate_ = false; | 1391 did_request_animate_ = false; |
1390 EXPECT_FLOAT_EQ(2.0f / 3.0f, scrollbar_layer_->Opacity()); | 1392 EXPECT_FLOAT_EQ(2.0f / 3.0f, scrollbar_layer_->Opacity()); |
1391 scrollbar_controller_->DidScrollUpdate(false); | 1393 scrollbar_controller_->WillUpdateScroll(); |
1392 EXPECT_FALSE(did_request_animate_); | 1394 EXPECT_FALSE(did_request_animate_); |
1393 | 1395 |
1394 start_fade_.Run(); | 1396 start_fade_.Run(); |
1395 EXPECT_TRUE(did_request_animate_); | 1397 EXPECT_TRUE(did_request_animate_); |
1396 did_request_animate_ = false; | 1398 did_request_animate_ = false; |
1397 time += base::TimeDelta::FromSeconds(2); | 1399 time += base::TimeDelta::FromSeconds(2); |
1398 scrollbar_controller_->Animate(time); | 1400 scrollbar_controller_->Animate(time); |
1399 EXPECT_TRUE(did_request_animate_); | 1401 EXPECT_TRUE(did_request_animate_); |
1400 did_request_animate_ = false; | 1402 did_request_animate_ = false; |
1401 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); | 1403 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); |
1402 | 1404 |
1403 time += base::TimeDelta::FromSeconds(1); | 1405 time += base::TimeDelta::FromSeconds(1); |
1404 scrollbar_controller_->Animate(time); | 1406 scrollbar_controller_->Animate(time); |
1405 EXPECT_TRUE(did_request_animate_); | 1407 EXPECT_TRUE(did_request_animate_); |
1406 did_request_animate_ = false; | 1408 did_request_animate_ = false; |
1407 EXPECT_FLOAT_EQ(2.0f / 3.0f, scrollbar_layer_->Opacity()); | 1409 EXPECT_FLOAT_EQ(2.0f / 3.0f, scrollbar_layer_->Opacity()); |
1408 | 1410 |
1409 time += base::TimeDelta::FromSeconds(1); | 1411 time += base::TimeDelta::FromSeconds(1); |
1410 scrollbar_controller_->Animate(time); | 1412 scrollbar_controller_->Animate(time); |
1411 EXPECT_TRUE(did_request_animate_); | 1413 EXPECT_TRUE(did_request_animate_); |
1412 did_request_animate_ = false; | 1414 did_request_animate_ = false; |
1413 EXPECT_FLOAT_EQ(1.0f / 3.0f, scrollbar_layer_->Opacity()); | 1415 EXPECT_FLOAT_EQ(1.0f / 3.0f, scrollbar_layer_->Opacity()); |
1414 | 1416 |
1415 time += base::TimeDelta::FromSeconds(1); | 1417 time += base::TimeDelta::FromSeconds(1); |
1416 scrollbar_controller_->DidScrollUpdate(false); | 1418 scrollbar_controller_->WillUpdateScroll(); |
1417 start_fade_.Run(); | 1419 start_fade_.Run(); |
1418 time += base::TimeDelta::FromSeconds(1); | 1420 time += base::TimeDelta::FromSeconds(1); |
1419 scrollbar_controller_->Animate(time); | 1421 scrollbar_controller_->Animate(time); |
1420 EXPECT_TRUE(did_request_animate_); | 1422 EXPECT_TRUE(did_request_animate_); |
1421 did_request_animate_ = false; | 1423 did_request_animate_ = false; |
1422 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); | 1424 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); |
1423 | 1425 |
1424 time += base::TimeDelta::FromSeconds(1); | 1426 time += base::TimeDelta::FromSeconds(1); |
1425 scrollbar_controller_->Animate(time); | 1427 scrollbar_controller_->Animate(time); |
1426 EXPECT_TRUE(did_request_animate_); | 1428 EXPECT_TRUE(did_request_animate_); |
1427 did_request_animate_ = false; | 1429 did_request_animate_ = false; |
1428 EXPECT_FLOAT_EQ(2.0f / 3.0f, scrollbar_layer_->Opacity()); | 1430 EXPECT_FLOAT_EQ(2.0f / 3.0f, scrollbar_layer_->Opacity()); |
1429 | 1431 |
1430 time += base::TimeDelta::FromSeconds(1); | 1432 time += base::TimeDelta::FromSeconds(1); |
1431 scrollbar_controller_->Animate(time); | 1433 scrollbar_controller_->Animate(time); |
1432 EXPECT_TRUE(did_request_animate_); | 1434 EXPECT_TRUE(did_request_animate_); |
1433 did_request_animate_ = false; | 1435 did_request_animate_ = false; |
1434 EXPECT_FLOAT_EQ(1.0f / 3.0f, scrollbar_layer_->Opacity()); | 1436 EXPECT_FLOAT_EQ(1.0f / 3.0f, scrollbar_layer_->Opacity()); |
1435 | 1437 |
1436 time += base::TimeDelta::FromSeconds(1); | 1438 time += base::TimeDelta::FromSeconds(1); |
1437 scrollbar_controller_->Animate(time); | 1439 scrollbar_controller_->Animate(time); |
1438 EXPECT_FALSE(did_request_animate_); | 1440 EXPECT_FALSE(did_request_animate_); |
1439 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity()); | 1441 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity()); |
1440 } | 1442 } |
1441 | 1443 |
1442 TEST_F(ScrollbarAnimationControllerAndroidTest, | 1444 TEST_F(ScrollbarAnimationControllerAndroidTest, |
1443 AnimationPreservedByNonScrollingGesture) { | 1445 AnimationPreservedByNonScrollingGesture) { |
1444 base::TimeTicks time; | 1446 base::TimeTicks time; |
1445 time += base::TimeDelta::FromSeconds(1); | 1447 time += base::TimeDelta::FromSeconds(1); |
1446 scrollbar_controller_->DidScrollUpdate(false); | 1448 scrollbar_controller_->WillUpdateScroll(); |
1447 start_fade_.Run(); | 1449 start_fade_.Run(); |
1448 EXPECT_TRUE(did_request_animate_); | 1450 EXPECT_TRUE(did_request_animate_); |
1449 did_request_animate_ = false; | 1451 did_request_animate_ = false; |
1450 scrollbar_controller_->Animate(time); | 1452 scrollbar_controller_->Animate(time); |
1451 EXPECT_TRUE(did_request_animate_); | 1453 EXPECT_TRUE(did_request_animate_); |
1452 did_request_animate_ = false; | 1454 did_request_animate_ = false; |
1453 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); | 1455 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); |
1454 | 1456 |
1455 time += base::TimeDelta::FromSeconds(1); | 1457 time += base::TimeDelta::FromSeconds(1); |
1456 scrollbar_controller_->Animate(time); | 1458 scrollbar_controller_->Animate(time); |
(...skipping 18 matching lines...) Expand all Loading... |
1475 time += base::TimeDelta::FromSeconds(1); | 1477 time += base::TimeDelta::FromSeconds(1); |
1476 scrollbar_controller_->Animate(time); | 1478 scrollbar_controller_->Animate(time); |
1477 EXPECT_FALSE(did_request_animate_); | 1479 EXPECT_FALSE(did_request_animate_); |
1478 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity()); | 1480 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity()); |
1479 } | 1481 } |
1480 | 1482 |
1481 TEST_F(ScrollbarAnimationControllerAndroidTest, | 1483 TEST_F(ScrollbarAnimationControllerAndroidTest, |
1482 AnimationOverriddenByScrollingGesture) { | 1484 AnimationOverriddenByScrollingGesture) { |
1483 base::TimeTicks time; | 1485 base::TimeTicks time; |
1484 time += base::TimeDelta::FromSeconds(1); | 1486 time += base::TimeDelta::FromSeconds(1); |
1485 scrollbar_controller_->DidScrollUpdate(false); | 1487 scrollbar_controller_->WillUpdateScroll(); |
1486 EXPECT_FALSE(did_request_animate_); | 1488 EXPECT_FALSE(did_request_animate_); |
1487 start_fade_.Run(); | 1489 start_fade_.Run(); |
1488 EXPECT_TRUE(did_request_animate_); | 1490 EXPECT_TRUE(did_request_animate_); |
1489 did_request_animate_ = false; | 1491 did_request_animate_ = false; |
1490 scrollbar_controller_->Animate(time); | 1492 scrollbar_controller_->Animate(time); |
1491 EXPECT_TRUE(did_request_animate_); | 1493 EXPECT_TRUE(did_request_animate_); |
1492 did_request_animate_ = false; | 1494 did_request_animate_ = false; |
1493 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); | 1495 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); |
1494 | 1496 |
1495 time += base::TimeDelta::FromSeconds(1); | 1497 time += base::TimeDelta::FromSeconds(1); |
1496 scrollbar_controller_->Animate(time); | 1498 scrollbar_controller_->Animate(time); |
1497 EXPECT_TRUE(did_request_animate_); | 1499 EXPECT_TRUE(did_request_animate_); |
1498 did_request_animate_ = false; | 1500 did_request_animate_ = false; |
1499 EXPECT_FLOAT_EQ(2.0f / 3.0f, scrollbar_layer_->Opacity()); | 1501 EXPECT_FLOAT_EQ(2.0f / 3.0f, scrollbar_layer_->Opacity()); |
1500 | 1502 |
1501 scrollbar_controller_->DidScrollBegin(); | 1503 scrollbar_controller_->DidScrollBegin(); |
1502 EXPECT_FLOAT_EQ(2.0f / 3.0f, scrollbar_layer_->Opacity()); | 1504 EXPECT_FLOAT_EQ(2.0f / 3.0f, scrollbar_layer_->Opacity()); |
1503 | 1505 |
1504 time += base::TimeDelta::FromSeconds(1); | 1506 time += base::TimeDelta::FromSeconds(1); |
1505 scrollbar_controller_->Animate(time); | 1507 scrollbar_controller_->Animate(time); |
1506 EXPECT_TRUE(did_request_animate_); | 1508 EXPECT_TRUE(did_request_animate_); |
1507 did_request_animate_ = false; | 1509 did_request_animate_ = false; |
1508 EXPECT_FLOAT_EQ(1.0f / 3.0f, scrollbar_layer_->Opacity()); | 1510 EXPECT_FLOAT_EQ(1.0f / 3.0f, scrollbar_layer_->Opacity()); |
1509 | 1511 |
1510 time += base::TimeDelta::FromSeconds(1); | 1512 time += base::TimeDelta::FromSeconds(1); |
1511 scrollbar_controller_->DidScrollUpdate(false); | 1513 scrollbar_controller_->WillUpdateScroll(); |
1512 EXPECT_FALSE(did_request_animate_); | 1514 EXPECT_FALSE(did_request_animate_); |
1513 EXPECT_FLOAT_EQ(1, scrollbar_layer_->Opacity()); | 1515 EXPECT_FLOAT_EQ(1, scrollbar_layer_->Opacity()); |
1514 | 1516 |
1515 time += base::TimeDelta::FromSeconds(1); | 1517 time += base::TimeDelta::FromSeconds(1); |
1516 scrollbar_controller_->DidScrollEnd(); | 1518 scrollbar_controller_->DidScrollEnd(); |
1517 EXPECT_FALSE(did_request_animate_); | 1519 EXPECT_FALSE(did_request_animate_); |
1518 EXPECT_FLOAT_EQ(1, scrollbar_layer_->Opacity()); | 1520 EXPECT_FLOAT_EQ(1, scrollbar_layer_->Opacity()); |
1519 } | 1521 } |
1520 | 1522 |
1521 } // namespace | 1523 } // namespace |
1522 } // namespace cc | 1524 } // namespace cc |
OLD | NEW |