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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 EXPECT_FLOAT_EQ(kIdleThicknessScale, | 138 EXPECT_FLOAT_EQ(kIdleThicknessScale, |
139 v_scrollbar_layer_->thumb_thickness_scale_factor()); | 139 v_scrollbar_layer_->thumb_thickness_scale_factor()); |
140 } | 140 } |
141 | 141 |
142 // Check that scrollbar appears again when the layer becomes scrollable. | 142 // Check that scrollbar appears again when the layer becomes scrollable. |
143 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, AppearOnResize) { | 143 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, AppearOnResize) { |
144 base::TimeTicks time; | 144 base::TimeTicks time; |
145 time += base::TimeDelta::FromSeconds(1); | 145 time += base::TimeDelta::FromSeconds(1); |
146 | 146 |
147 scrollbar_controller_->DidScrollBegin(); | 147 scrollbar_controller_->DidScrollBegin(); |
148 scrollbar_controller_->DidScrollUpdate(false); | 148 scrollbar_controller_->DidScrollUpdate(); |
149 scrollbar_controller_->DidScrollEnd(); | 149 scrollbar_controller_->DidScrollEnd(); |
150 ExpectScrollbarsOpacity(1); | 150 ExpectScrollbarsOpacity(1); |
151 | 151 |
152 // Make the Layer non-scrollable, scrollbar disappears. | 152 // Make the Layer non-scrollable, scrollbar disappears. |
153 clip_layer_->SetBounds(gfx::Size(200, 200)); | 153 clip_layer_->SetBounds(gfx::Size(200, 200)); |
154 scrollbar_controller_->DidScrollUpdate(false); | 154 scrollbar_controller_->DidScrollUpdate(); |
155 ExpectScrollbarsOpacity(0); | 155 ExpectScrollbarsOpacity(0); |
156 | 156 |
157 // Make the layer scrollable, scrollbar appears again. | 157 // Make the layer scrollable, scrollbar appears again. |
158 clip_layer_->SetBounds(gfx::Size(100, 100)); | 158 clip_layer_->SetBounds(gfx::Size(100, 100)); |
159 scrollbar_controller_->DidScrollUpdate(false); | 159 scrollbar_controller_->DidScrollUpdate(); |
160 ExpectScrollbarsOpacity(1); | 160 ExpectScrollbarsOpacity(1); |
161 } | 161 } |
162 | 162 |
163 // Check that scrollbar disappears when the layer becomes non-scrollable. | 163 // Check that scrollbar disappears when the layer becomes non-scrollable. |
164 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, HideOnResize) { | 164 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, HideOnResize) { |
165 base::TimeTicks time; | 165 base::TimeTicks time; |
166 time += base::TimeDelta::FromSeconds(1); | 166 time += base::TimeDelta::FromSeconds(1); |
167 | 167 |
168 LayerImpl* scroll_layer = host_impl_.active_tree()->LayerById(1); | 168 LayerImpl* scroll_layer = host_impl_.active_tree()->LayerById(1); |
169 ASSERT_TRUE(scroll_layer); | 169 ASSERT_TRUE(scroll_layer); |
170 EXPECT_EQ(gfx::Size(200, 200), scroll_layer->bounds()); | 170 EXPECT_EQ(gfx::Size(200, 200), scroll_layer->bounds()); |
171 | 171 |
172 // Shrink along X axis, horizontal scrollbar should appear. | 172 // Shrink along X axis, horizontal scrollbar should appear. |
173 clip_layer_->SetBounds(gfx::Size(100, 200)); | 173 clip_layer_->SetBounds(gfx::Size(100, 200)); |
174 EXPECT_EQ(gfx::Size(100, 200), clip_layer_->bounds()); | 174 EXPECT_EQ(gfx::Size(100, 200), clip_layer_->bounds()); |
175 | 175 |
176 scrollbar_controller_->DidScrollBegin(); | 176 scrollbar_controller_->DidScrollBegin(); |
177 | 177 |
178 scrollbar_controller_->DidScrollUpdate(false); | 178 scrollbar_controller_->DidScrollUpdate(); |
179 EXPECT_FLOAT_EQ(1, h_scrollbar_layer_->Opacity()); | 179 EXPECT_FLOAT_EQ(1, h_scrollbar_layer_->Opacity()); |
180 | 180 |
181 scrollbar_controller_->DidScrollEnd(); | 181 scrollbar_controller_->DidScrollEnd(); |
182 | 182 |
183 // Shrink along Y axis and expand along X, horizontal scrollbar | 183 // Shrink along Y axis and expand along X, horizontal scrollbar |
184 // should disappear. | 184 // should disappear. |
185 clip_layer_->SetBounds(gfx::Size(200, 100)); | 185 clip_layer_->SetBounds(gfx::Size(200, 100)); |
186 EXPECT_EQ(gfx::Size(200, 100), clip_layer_->bounds()); | 186 EXPECT_EQ(gfx::Size(200, 100), clip_layer_->bounds()); |
187 | 187 |
188 scrollbar_controller_->DidScrollBegin(); | 188 scrollbar_controller_->DidScrollBegin(); |
189 | 189 |
190 scrollbar_controller_->DidScrollUpdate(false); | 190 scrollbar_controller_->DidScrollUpdate(); |
191 EXPECT_FLOAT_EQ(0.0f, h_scrollbar_layer_->Opacity()); | 191 EXPECT_FLOAT_EQ(0.0f, h_scrollbar_layer_->Opacity()); |
192 | 192 |
193 scrollbar_controller_->DidScrollEnd(); | 193 scrollbar_controller_->DidScrollEnd(); |
194 } | 194 } |
195 | 195 |
196 // Scroll content. Confirm the scrollbar appears and fades out. | 196 // Scroll content. Confirm the scrollbar appears and fades out. |
197 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, BasicAppearAndFadeOut) { | 197 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, BasicAppearAndFadeOut) { |
198 base::TimeTicks time; | 198 base::TimeTicks time; |
199 time += base::TimeDelta::FromSeconds(1); | 199 time += base::TimeDelta::FromSeconds(1); |
200 | 200 |
201 // Scrollbar should be invisible. | 201 // Scrollbar should be invisible. |
202 ExpectScrollbarsOpacity(0); | 202 ExpectScrollbarsOpacity(0); |
203 EXPECT_TRUE(scrollbar_controller_->ScrollbarsHidden()); | 203 EXPECT_TRUE(scrollbar_controller_->ScrollbarsHidden()); |
204 | 204 |
205 // Scrollbar should appear only on scroll update. | 205 // Scrollbar should appear only on scroll update. |
206 scrollbar_controller_->DidScrollBegin(); | 206 scrollbar_controller_->DidScrollBegin(); |
207 ExpectScrollbarsOpacity(0); | 207 ExpectScrollbarsOpacity(0); |
208 EXPECT_TRUE(scrollbar_controller_->ScrollbarsHidden()); | 208 EXPECT_TRUE(scrollbar_controller_->ScrollbarsHidden()); |
209 | 209 |
210 scrollbar_controller_->DidScrollUpdate(false); | 210 scrollbar_controller_->DidScrollUpdate(); |
211 ExpectScrollbarsOpacity(1); | 211 ExpectScrollbarsOpacity(1); |
212 EXPECT_FALSE(scrollbar_controller_->ScrollbarsHidden()); | 212 EXPECT_FALSE(scrollbar_controller_->ScrollbarsHidden()); |
213 | 213 |
214 scrollbar_controller_->DidScrollEnd(); | 214 scrollbar_controller_->DidScrollEnd(); |
215 ExpectScrollbarsOpacity(1); | 215 ExpectScrollbarsOpacity(1); |
216 EXPECT_FALSE(scrollbar_controller_->ScrollbarsHidden()); | 216 EXPECT_FALSE(scrollbar_controller_->ScrollbarsHidden()); |
217 | 217 |
218 // An fade out animation should have been enqueued. | 218 // An fade out animation should have been enqueued. |
219 EXPECT_EQ(kFadeOutDelay, client_.delay()); | 219 EXPECT_EQ(kFadeOutDelay, client_.delay()); |
220 EXPECT_FALSE(client_.start_fade().is_null()); | 220 EXPECT_FALSE(client_.start_fade().is_null()); |
221 client_.start_fade().Run(); | 221 client_.start_fade().Run(); |
222 | 222 |
223 // Scrollbar should fade out over kFadeOutDuration. | 223 // Scrollbar should fade out over kFadeOutDuration. |
224 scrollbar_controller_->Animate(time); | 224 scrollbar_controller_->Animate(time); |
225 time += kFadeOutDuration; | 225 time += kFadeOutDuration; |
226 scrollbar_controller_->Animate(time); | 226 scrollbar_controller_->Animate(time); |
227 | 227 |
228 ExpectScrollbarsOpacity(0); | 228 ExpectScrollbarsOpacity(0); |
229 EXPECT_TRUE(scrollbar_controller_->ScrollbarsHidden()); | 229 EXPECT_TRUE(scrollbar_controller_->ScrollbarsHidden()); |
230 } | 230 } |
231 | 231 |
| 232 // Confirm the scrollbar appears by WillUpdateScroll and fade out. |
| 233 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, |
| 234 BasicAppearByWillUpdateScrollThenFadeOut) { |
| 235 base::TimeTicks time; |
| 236 time += base::TimeDelta::FromSeconds(1); |
| 237 |
| 238 // Scrollbar should be invisible. |
| 239 ExpectScrollbarsOpacity(0); |
| 240 EXPECT_TRUE(scrollbar_controller_->ScrollbarsHidden()); |
| 241 |
| 242 // Scrollbar should appear when scroll will update. |
| 243 scrollbar_controller_->WillUpdateScroll(); |
| 244 ExpectScrollbarsOpacity(1); |
| 245 EXPECT_FALSE(scrollbar_controller_->ScrollbarsHidden()); |
| 246 |
| 247 // An fade out animation should have been enqueued. |
| 248 EXPECT_EQ(kFadeOutDelay, client_.delay()); |
| 249 EXPECT_FALSE(client_.start_fade().is_null()); |
| 250 client_.start_fade().Run(); |
| 251 |
| 252 // Scrollbar should fade out over kFadeOutDuration. |
| 253 scrollbar_controller_->Animate(time); |
| 254 time += kFadeOutDuration; |
| 255 scrollbar_controller_->Animate(time); |
| 256 |
| 257 ExpectScrollbarsOpacity(0); |
| 258 EXPECT_TRUE(scrollbar_controller_->ScrollbarsHidden()); |
| 259 } |
| 260 |
232 // Scroll content. Move the mouse near the scrollbar and confirm it becomes | 261 // Scroll content. Move the mouse near the scrollbar and confirm it becomes |
233 // thick. Ensure it remains visible as long as the mouse is near the scrollbar. | 262 // thick. Ensure it remains visible as long as the mouse is near the scrollbar. |
234 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, MoveNearAndDontFadeOut) { | 263 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, MoveNearAndDontFadeOut) { |
235 base::TimeTicks time; | 264 base::TimeTicks time; |
236 time += base::TimeDelta::FromSeconds(1); | 265 time += base::TimeDelta::FromSeconds(1); |
237 | 266 |
238 scrollbar_controller_->DidScrollBegin(); | 267 scrollbar_controller_->DidScrollBegin(); |
239 scrollbar_controller_->DidScrollUpdate(false); | 268 scrollbar_controller_->DidScrollUpdate(); |
240 scrollbar_controller_->DidScrollEnd(); | 269 scrollbar_controller_->DidScrollEnd(); |
241 | 270 |
242 // An fade out animation should have been enqueued. | 271 // An fade out animation should have been enqueued. |
243 EXPECT_EQ(kFadeOutDelay, client_.delay()); | 272 EXPECT_EQ(kFadeOutDelay, client_.delay()); |
244 EXPECT_FALSE(client_.start_fade().is_null()); | 273 EXPECT_FALSE(client_.start_fade().is_null()); |
245 EXPECT_FALSE(client_.start_fade().IsCancelled()); | 274 EXPECT_FALSE(client_.start_fade().IsCancelled()); |
246 | 275 |
247 // Now move the mouse near the scrollbar. This should cancel the currently | 276 // Now move the mouse near the scrollbar. This should cancel the currently |
248 // queued fading animation and start animating thickness. | 277 // queued fading animation and start animating thickness. |
249 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 1); | 278 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 1); |
(...skipping 20 matching lines...) Expand all Loading... |
270 client_.start_fade().IsCancelled()); | 299 client_.start_fade().IsCancelled()); |
271 } | 300 } |
272 | 301 |
273 // Scroll content. Move the mouse over the scrollbar and confirm it becomes | 302 // Scroll content. Move the mouse over the scrollbar and confirm it becomes |
274 // thick. Ensure it remains visible as long as the mouse is over the scrollbar. | 303 // thick. Ensure it remains visible as long as the mouse is over the scrollbar. |
275 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, MoveOverAndDontFadeOut) { | 304 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, MoveOverAndDontFadeOut) { |
276 base::TimeTicks time; | 305 base::TimeTicks time; |
277 time += base::TimeDelta::FromSeconds(1); | 306 time += base::TimeDelta::FromSeconds(1); |
278 | 307 |
279 scrollbar_controller_->DidScrollBegin(); | 308 scrollbar_controller_->DidScrollBegin(); |
280 scrollbar_controller_->DidScrollUpdate(false); | 309 scrollbar_controller_->DidScrollUpdate(); |
281 scrollbar_controller_->DidScrollEnd(); | 310 scrollbar_controller_->DidScrollEnd(); |
282 | 311 |
283 // An fade out animation should have been enqueued. | 312 // An fade out animation should have been enqueued. |
284 EXPECT_EQ(kFadeOutDelay, client_.delay()); | 313 EXPECT_EQ(kFadeOutDelay, client_.delay()); |
285 EXPECT_FALSE(client_.start_fade().is_null()); | 314 EXPECT_FALSE(client_.start_fade().is_null()); |
286 EXPECT_FALSE(client_.start_fade().IsCancelled()); | 315 EXPECT_FALSE(client_.start_fade().IsCancelled()); |
287 | 316 |
288 // Now move the mouse over the scrollbar. This should cancel the currently | 317 // Now move the mouse over the scrollbar. This should cancel the currently |
289 // queued fading animation and start animating thickness. | 318 // queued fading animation and start animating thickness. |
290 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 0); | 319 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 0); |
(...skipping 21 matching lines...) Expand all Loading... |
312 } | 341 } |
313 | 342 |
314 // Make sure a scrollbar captured before the thickening animation doesn't try | 343 // Make sure a scrollbar captured before the thickening animation doesn't try |
315 // to fade out. | 344 // to fade out. |
316 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, | 345 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, |
317 DontFadeWhileCapturedBeforeThick) { | 346 DontFadeWhileCapturedBeforeThick) { |
318 base::TimeTicks time; | 347 base::TimeTicks time; |
319 time += base::TimeDelta::FromSeconds(1); | 348 time += base::TimeDelta::FromSeconds(1); |
320 | 349 |
321 scrollbar_controller_->DidScrollBegin(); | 350 scrollbar_controller_->DidScrollBegin(); |
322 scrollbar_controller_->DidScrollUpdate(false); | 351 scrollbar_controller_->DidScrollUpdate(); |
323 scrollbar_controller_->DidScrollEnd(); | 352 scrollbar_controller_->DidScrollEnd(); |
324 | 353 |
325 // An fade out animation should have been enqueued. | 354 // An fade out animation should have been enqueued. |
326 EXPECT_EQ(kFadeOutDelay, client_.delay()); | 355 EXPECT_EQ(kFadeOutDelay, client_.delay()); |
327 EXPECT_FALSE(client_.start_fade().is_null()); | 356 EXPECT_FALSE(client_.start_fade().is_null()); |
328 | 357 |
329 // Now move the mouse over the scrollbar and capture it. It should become | 358 // Now move the mouse over the scrollbar and capture it. It should become |
330 // thick without need for an animation. | 359 // thick without need for an animation. |
331 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 0); | 360 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 0); |
332 scrollbar_controller_->DidMouseDown(); | 361 scrollbar_controller_->DidMouseDown(); |
333 ExpectScrollbarsOpacity(1); | 362 ExpectScrollbarsOpacity(1); |
334 EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor()); | 363 EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor()); |
335 EXPECT_FLOAT_EQ(kIdleThicknessScale, | 364 EXPECT_FLOAT_EQ(kIdleThicknessScale, |
336 h_scrollbar_layer_->thumb_thickness_scale_factor()); | 365 h_scrollbar_layer_->thumb_thickness_scale_factor()); |
337 | 366 |
338 // The fade out animation should have been cleared or cancelled. | 367 // The fade out animation should have been cleared or cancelled. |
339 EXPECT_TRUE(client_.start_fade().is_null() || | 368 EXPECT_TRUE(client_.start_fade().is_null() || |
340 client_.start_fade().IsCancelled()); | 369 client_.start_fade().IsCancelled()); |
341 } | 370 } |
342 | 371 |
343 // Make sure a scrollbar captured then move mouse away doesn't try to fade out. | 372 // Make sure a scrollbar captured then move mouse away doesn't try to fade out. |
344 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, | 373 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, |
345 DontFadeWhileCapturedThenAway) { | 374 DontFadeWhileCapturedThenAway) { |
346 base::TimeTicks time; | 375 base::TimeTicks time; |
347 time += base::TimeDelta::FromSeconds(1); | 376 time += base::TimeDelta::FromSeconds(1); |
348 | 377 |
349 scrollbar_controller_->DidScrollBegin(); | 378 scrollbar_controller_->DidScrollBegin(); |
350 scrollbar_controller_->DidScrollUpdate(false); | 379 scrollbar_controller_->DidScrollUpdate(); |
351 scrollbar_controller_->DidScrollEnd(); | 380 scrollbar_controller_->DidScrollEnd(); |
352 | 381 |
353 // An fade out animation should have been enqueued. | 382 // An fade out animation should have been enqueued. |
354 EXPECT_EQ(kFadeOutDelay, client_.delay()); | 383 EXPECT_EQ(kFadeOutDelay, client_.delay()); |
355 EXPECT_FALSE(client_.start_fade().is_null()); | 384 EXPECT_FALSE(client_.start_fade().is_null()); |
356 | 385 |
357 // Now move the mouse over the scrollbar and capture it. It should become | 386 // Now move the mouse over the scrollbar and capture it. It should become |
358 // thick without need for an animation. | 387 // thick without need for an animation. |
359 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 0); | 388 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 0); |
360 scrollbar_controller_->DidMouseDown(); | 389 scrollbar_controller_->DidMouseDown(); |
(...skipping 15 matching lines...) Expand all Loading... |
376 client_.start_fade().IsCancelled()); | 405 client_.start_fade().IsCancelled()); |
377 } | 406 } |
378 | 407 |
379 // Make sure a scrollbar captured after a thickening animation doesn't try to | 408 // Make sure a scrollbar captured after a thickening animation doesn't try to |
380 // fade out. | 409 // fade out. |
381 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, DontFadeWhileCaptured) { | 410 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, DontFadeWhileCaptured) { |
382 base::TimeTicks time; | 411 base::TimeTicks time; |
383 time += base::TimeDelta::FromSeconds(1); | 412 time += base::TimeDelta::FromSeconds(1); |
384 | 413 |
385 scrollbar_controller_->DidScrollBegin(); | 414 scrollbar_controller_->DidScrollBegin(); |
386 scrollbar_controller_->DidScrollUpdate(false); | 415 scrollbar_controller_->DidScrollUpdate(); |
387 scrollbar_controller_->DidScrollEnd(); | 416 scrollbar_controller_->DidScrollEnd(); |
388 | 417 |
389 // An fade out animation should have been enqueued. | 418 // An fade out animation should have been enqueued. |
390 EXPECT_EQ(kFadeOutDelay, client_.delay()); | 419 EXPECT_EQ(kFadeOutDelay, client_.delay()); |
391 EXPECT_FALSE(client_.start_fade().is_null()); | 420 EXPECT_FALSE(client_.start_fade().is_null()); |
392 EXPECT_FALSE(client_.start_fade().IsCancelled()); | 421 EXPECT_FALSE(client_.start_fade().IsCancelled()); |
393 | 422 |
394 // Now move the mouse over the scrollbar and animate it until it's thick. | 423 // Now move the mouse over the scrollbar and animate it until it's thick. |
395 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 0); | 424 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 0); |
396 scrollbar_controller_->Animate(time); | 425 scrollbar_controller_->Animate(time); |
(...skipping 16 matching lines...) Expand all Loading... |
413 client_.start_fade().IsCancelled()); | 442 client_.start_fade().IsCancelled()); |
414 } | 443 } |
415 | 444 |
416 // Make sure releasing a captured scrollbar when the mouse isn't near it, causes | 445 // Make sure releasing a captured scrollbar when the mouse isn't near it, causes |
417 // the scrollbar to fade out. | 446 // the scrollbar to fade out. |
418 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, FadeAfterReleasedFar) { | 447 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, FadeAfterReleasedFar) { |
419 base::TimeTicks time; | 448 base::TimeTicks time; |
420 time += base::TimeDelta::FromSeconds(1); | 449 time += base::TimeDelta::FromSeconds(1); |
421 | 450 |
422 scrollbar_controller_->DidScrollBegin(); | 451 scrollbar_controller_->DidScrollBegin(); |
423 scrollbar_controller_->DidScrollUpdate(false); | 452 scrollbar_controller_->DidScrollUpdate(); |
424 scrollbar_controller_->DidScrollEnd(); | 453 scrollbar_controller_->DidScrollEnd(); |
425 | 454 |
426 // An fade out animation should have been enqueued. | 455 // An fade out animation should have been enqueued. |
427 EXPECT_EQ(kFadeOutDelay, client_.delay()); | 456 EXPECT_EQ(kFadeOutDelay, client_.delay()); |
428 EXPECT_FALSE(client_.start_fade().is_null()); | 457 EXPECT_FALSE(client_.start_fade().is_null()); |
429 EXPECT_FALSE(client_.start_fade().IsCancelled()); | 458 EXPECT_FALSE(client_.start_fade().IsCancelled()); |
430 | 459 |
431 // Now move the mouse over the scrollbar and capture it. | 460 // Now move the mouse over the scrollbar and capture it. |
432 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 0); | 461 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 0); |
433 scrollbar_controller_->DidMouseDown(); | 462 scrollbar_controller_->DidMouseDown(); |
(...skipping 30 matching lines...) Expand all Loading... |
464 EXPECT_FALSE(client_.start_fade().IsCancelled()); | 493 EXPECT_FALSE(client_.start_fade().IsCancelled()); |
465 } | 494 } |
466 | 495 |
467 // Make sure releasing a captured scrollbar when the mouse is near/over it, | 496 // Make sure releasing a captured scrollbar when the mouse is near/over it, |
468 // doesn't cause the scrollbar to fade out. | 497 // doesn't cause the scrollbar to fade out. |
469 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, DontFadeAfterReleasedNear) { | 498 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, DontFadeAfterReleasedNear) { |
470 base::TimeTicks time; | 499 base::TimeTicks time; |
471 time += base::TimeDelta::FromSeconds(1); | 500 time += base::TimeDelta::FromSeconds(1); |
472 | 501 |
473 scrollbar_controller_->DidScrollBegin(); | 502 scrollbar_controller_->DidScrollBegin(); |
474 scrollbar_controller_->DidScrollUpdate(false); | 503 scrollbar_controller_->DidScrollUpdate(); |
475 scrollbar_controller_->DidScrollEnd(); | 504 scrollbar_controller_->DidScrollEnd(); |
476 | 505 |
477 // An fade out animation should have been enqueued. | 506 // An fade out animation should have been enqueued. |
478 EXPECT_EQ(kFadeOutDelay, client_.delay()); | 507 EXPECT_EQ(kFadeOutDelay, client_.delay()); |
479 EXPECT_FALSE(client_.start_fade().is_null()); | 508 EXPECT_FALSE(client_.start_fade().is_null()); |
480 EXPECT_FALSE(client_.start_fade().IsCancelled()); | 509 EXPECT_FALSE(client_.start_fade().IsCancelled()); |
481 | 510 |
482 // Now move the mouse over the scrollbar and capture it. | 511 // Now move the mouse over the scrollbar and capture it. |
483 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 0); | 512 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 0); |
484 scrollbar_controller_->DidMouseDown(); | 513 scrollbar_controller_->DidMouseDown(); |
(...skipping 18 matching lines...) Expand all Loading... |
503 } | 532 } |
504 | 533 |
505 // Make sure moving near a scrollbar while it's fading out causes it to reset | 534 // Make sure moving near a scrollbar while it's fading out causes it to reset |
506 // the opacity and thicken. | 535 // the opacity and thicken. |
507 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, | 536 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, |
508 MoveNearScrollbarWhileFading) { | 537 MoveNearScrollbarWhileFading) { |
509 base::TimeTicks time; | 538 base::TimeTicks time; |
510 time += base::TimeDelta::FromSeconds(1); | 539 time += base::TimeDelta::FromSeconds(1); |
511 | 540 |
512 scrollbar_controller_->DidScrollBegin(); | 541 scrollbar_controller_->DidScrollBegin(); |
513 scrollbar_controller_->DidScrollUpdate(false); | 542 scrollbar_controller_->DidScrollUpdate(); |
514 scrollbar_controller_->DidScrollEnd(); | 543 scrollbar_controller_->DidScrollEnd(); |
515 | 544 |
516 // A fade out animation should have been enqueued. Start it. | 545 // A fade out animation should have been enqueued. Start it. |
517 EXPECT_EQ(kFadeOutDelay, client_.delay()); | 546 EXPECT_EQ(kFadeOutDelay, client_.delay()); |
518 EXPECT_FALSE(client_.start_fade().is_null()); | 547 EXPECT_FALSE(client_.start_fade().is_null()); |
519 client_.start_fade().Run(); | 548 client_.start_fade().Run(); |
520 | 549 |
521 scrollbar_controller_->Animate(time); | 550 scrollbar_controller_->Animate(time); |
522 ExpectScrollbarsOpacity(1); | 551 ExpectScrollbarsOpacity(1); |
523 | 552 |
(...skipping 19 matching lines...) Expand all Loading... |
543 EXPECT_FLOAT_EQ(kIdleThicknessScale, | 572 EXPECT_FLOAT_EQ(kIdleThicknessScale, |
544 h_scrollbar_layer_->thumb_thickness_scale_factor()); | 573 h_scrollbar_layer_->thumb_thickness_scale_factor()); |
545 } | 574 } |
546 | 575 |
547 // Make sure we can't capture scrollbar that's completely faded out. | 576 // Make sure we can't capture scrollbar that's completely faded out. |
548 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, TestCantCaptureWhenFaded) { | 577 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, TestCantCaptureWhenFaded) { |
549 base::TimeTicks time; | 578 base::TimeTicks time; |
550 time += base::TimeDelta::FromSeconds(1); | 579 time += base::TimeDelta::FromSeconds(1); |
551 | 580 |
552 scrollbar_controller_->DidScrollBegin(); | 581 scrollbar_controller_->DidScrollBegin(); |
553 scrollbar_controller_->DidScrollUpdate(false); | 582 scrollbar_controller_->DidScrollUpdate(); |
554 scrollbar_controller_->DidScrollEnd(); | 583 scrollbar_controller_->DidScrollEnd(); |
555 | 584 |
556 EXPECT_EQ(kFadeOutDelay, client_.delay()); | 585 EXPECT_EQ(kFadeOutDelay, client_.delay()); |
557 EXPECT_FALSE(client_.start_fade().is_null()); | 586 EXPECT_FALSE(client_.start_fade().is_null()); |
558 EXPECT_FALSE(client_.start_fade().IsCancelled()); | 587 EXPECT_FALSE(client_.start_fade().IsCancelled()); |
559 client_.start_fade().Run(); | 588 client_.start_fade().Run(); |
560 scrollbar_controller_->Animate(time); | 589 scrollbar_controller_->Animate(time); |
561 ExpectScrollbarsOpacity(1); | 590 ExpectScrollbarsOpacity(1); |
562 | 591 |
563 // Fade the scrollbar out completely. | 592 // Fade the scrollbar out completely. |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
607 time += kThinningDuration; | 636 time += kThinningDuration; |
608 | 637 |
609 // Since the scrollbar isn't visible yet (because we haven't scrolled), we | 638 // Since the scrollbar isn't visible yet (because we haven't scrolled), we |
610 // shouldn't have applied the thickening. | 639 // shouldn't have applied the thickening. |
611 scrollbar_controller_->Animate(time); | 640 scrollbar_controller_->Animate(time); |
612 EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor()); | 641 EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor()); |
613 EXPECT_FLOAT_EQ(kIdleThicknessScale, | 642 EXPECT_FLOAT_EQ(kIdleThicknessScale, |
614 h_scrollbar_layer_->thumb_thickness_scale_factor()); | 643 h_scrollbar_layer_->thumb_thickness_scale_factor()); |
615 | 644 |
616 scrollbar_controller_->DidScrollBegin(); | 645 scrollbar_controller_->DidScrollBegin(); |
617 scrollbar_controller_->DidScrollUpdate(false); | 646 scrollbar_controller_->DidScrollUpdate(); |
618 | 647 |
619 // Now that we've received a scroll, we should be thick without an animation. | 648 // Now that we've received a scroll, we should be thick without an animation. |
620 ExpectScrollbarsOpacity(1); | 649 ExpectScrollbarsOpacity(1); |
621 | 650 |
622 // An animation for the fade should be either null or cancelled, since | 651 // An animation for the fade should be either null or cancelled, since |
623 // mouse is still near the scrollbar. | 652 // mouse is still near the scrollbar. |
624 scrollbar_controller_->DidScrollEnd(); | 653 scrollbar_controller_->DidScrollEnd(); |
625 EXPECT_TRUE(client_.start_fade().is_null() || | 654 EXPECT_TRUE(client_.start_fade().is_null() || |
626 client_.start_fade().IsCancelled()); | 655 client_.start_fade().IsCancelled()); |
627 | 656 |
(...skipping 14 matching lines...) Expand all Loading... |
642 | 671 |
643 // Tests that main thread scroll updates immediatley queue a fade out animation | 672 // Tests that main thread scroll updates immediatley queue a fade out animation |
644 // without requiring a ScrollEnd. | 673 // without requiring a ScrollEnd. |
645 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, | 674 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, |
646 MainThreadScrollQueuesFade) { | 675 MainThreadScrollQueuesFade) { |
647 ASSERT_TRUE(client_.start_fade().is_null()); | 676 ASSERT_TRUE(client_.start_fade().is_null()); |
648 | 677 |
649 // A ScrollUpdate without a ScrollBegin indicates a main thread scroll update | 678 // A ScrollUpdate without a ScrollBegin indicates a main thread scroll update |
650 // so we should schedule a fade out animation without waiting for a ScrollEnd | 679 // so we should schedule a fade out animation without waiting for a ScrollEnd |
651 // (which will never come). | 680 // (which will never come). |
652 scrollbar_controller_->DidScrollUpdate(false); | 681 scrollbar_controller_->DidScrollUpdate(); |
653 EXPECT_FALSE(client_.start_fade().is_null()); | 682 EXPECT_FALSE(client_.start_fade().is_null()); |
654 EXPECT_EQ(kFadeOutDelay, client_.delay()); | 683 EXPECT_EQ(kFadeOutDelay, client_.delay()); |
655 | 684 |
656 client_.start_fade().Reset(); | 685 client_.start_fade().Reset(); |
657 | 686 |
658 // If we got a ScrollBegin, we shouldn't schedule the fade out animation until | 687 // If we got a ScrollBegin, we shouldn't schedule the fade out animation until |
659 // we get a corresponding ScrollEnd. | 688 // we get a corresponding ScrollEnd. |
660 scrollbar_controller_->DidScrollBegin(); | 689 scrollbar_controller_->DidScrollBegin(); |
661 scrollbar_controller_->DidScrollUpdate(false); | 690 scrollbar_controller_->DidScrollUpdate(); |
662 EXPECT_TRUE(client_.start_fade().is_null()); | 691 EXPECT_TRUE(client_.start_fade().is_null()); |
663 scrollbar_controller_->DidScrollEnd(); | 692 scrollbar_controller_->DidScrollEnd(); |
664 EXPECT_FALSE(client_.start_fade().is_null()); | 693 EXPECT_FALSE(client_.start_fade().is_null()); |
665 EXPECT_EQ(kFadeOutDelay, client_.delay()); | 694 EXPECT_EQ(kFadeOutDelay, client_.delay()); |
666 } | 695 } |
667 | 696 |
668 // Make sure that if the scroll update is as a result of a resize, we use the | 697 // Make sure that if the scroll update is as a result of a resize, we use the |
669 // resize delay time instead of the default one. | 698 // resize delay time instead of the default one. |
670 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, ResizeFadeDuration) { | 699 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, ResizeFadeDuration) { |
671 ASSERT_TRUE(client_.delay().is_zero()); | 700 ASSERT_TRUE(client_.delay().is_zero()); |
672 | 701 |
673 scrollbar_controller_->DidScrollUpdate(true); | 702 scrollbar_controller_->DidResize(); |
674 EXPECT_FALSE(client_.start_fade().is_null()); | 703 EXPECT_FALSE(client_.start_fade().is_null()); |
675 EXPECT_EQ(kResizeFadeOutDelay, client_.delay()); | 704 EXPECT_EQ(kResizeFadeOutDelay, client_.delay()); |
676 | 705 |
677 client_.delay() = base::TimeDelta(); | 706 client_.delay() = base::TimeDelta(); |
678 | 707 |
679 // We should use the gesture delay rather than the resize delay if we're in a | 708 // We should use the gesture delay rather than the resize delay if we're in a |
680 // gesture scroll, even if the resize param is set. | 709 // gesture scroll, even if it is resizing. |
681 scrollbar_controller_->DidScrollBegin(); | 710 scrollbar_controller_->DidScrollBegin(); |
682 scrollbar_controller_->DidScrollUpdate(true); | 711 scrollbar_controller_->DidResize(); |
683 scrollbar_controller_->DidScrollEnd(); | 712 scrollbar_controller_->DidScrollEnd(); |
684 | 713 |
685 EXPECT_FALSE(client_.start_fade().is_null()); | 714 EXPECT_FALSE(client_.start_fade().is_null()); |
686 EXPECT_EQ(kFadeOutDelay, client_.delay()); | 715 EXPECT_EQ(kFadeOutDelay, client_.delay()); |
687 } | 716 } |
688 | 717 |
689 // Tests that the fade effect is animated. | 718 // Tests that the fade effect is animated. |
690 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, FadeAnimated) { | 719 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, FadeAnimated) { |
691 base::TimeTicks time; | 720 base::TimeTicks time; |
692 time += base::TimeDelta::FromSeconds(1); | 721 time += base::TimeDelta::FromSeconds(1); |
693 | 722 |
694 // Scroll to make the scrollbars visible. | 723 // Scroll to make the scrollbars visible. |
695 scrollbar_controller_->DidScrollBegin(); | 724 scrollbar_controller_->DidScrollBegin(); |
696 scrollbar_controller_->DidScrollUpdate(false); | 725 scrollbar_controller_->DidScrollUpdate(); |
697 scrollbar_controller_->DidScrollEnd(); | 726 scrollbar_controller_->DidScrollEnd(); |
698 | 727 |
699 // Appearance is instant. | 728 // Appearance is instant. |
700 ExpectScrollbarsOpacity(1); | 729 ExpectScrollbarsOpacity(1); |
701 | 730 |
702 // An fade out animation should have been enqueued. | 731 // An fade out animation should have been enqueued. |
703 EXPECT_EQ(kFadeOutDelay, client_.delay()); | 732 EXPECT_EQ(kFadeOutDelay, client_.delay()); |
704 EXPECT_FALSE(client_.start_fade().is_null()); | 733 EXPECT_FALSE(client_.start_fade().is_null()); |
705 client_.start_fade().Run(); | 734 client_.start_fade().Run(); |
706 | 735 |
(...skipping 11 matching lines...) Expand all Loading... |
718 } | 747 } |
719 | 748 |
720 // Tests that the controller tells the client when the scrollbars hide/show. | 749 // Tests that the controller tells the client when the scrollbars hide/show. |
721 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, NotifyChangedVisibility) { | 750 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, NotifyChangedVisibility) { |
722 base::TimeTicks time; | 751 base::TimeTicks time; |
723 time += base::TimeDelta::FromSeconds(1); | 752 time += base::TimeDelta::FromSeconds(1); |
724 | 753 |
725 EXPECT_CALL(client_, DidChangeScrollbarVisibility()).Times(1); | 754 EXPECT_CALL(client_, DidChangeScrollbarVisibility()).Times(1); |
726 // Scroll to make the scrollbars visible. | 755 // Scroll to make the scrollbars visible. |
727 scrollbar_controller_->DidScrollBegin(); | 756 scrollbar_controller_->DidScrollBegin(); |
728 scrollbar_controller_->DidScrollUpdate(false); | 757 scrollbar_controller_->DidScrollUpdate(); |
729 EXPECT_FALSE(scrollbar_controller_->ScrollbarsHidden()); | 758 EXPECT_FALSE(scrollbar_controller_->ScrollbarsHidden()); |
730 Mock::VerifyAndClearExpectations(&client_); | 759 Mock::VerifyAndClearExpectations(&client_); |
731 | 760 |
732 scrollbar_controller_->DidScrollEnd(); | 761 scrollbar_controller_->DidScrollEnd(); |
733 | 762 |
734 // Play out the fade out animation. We shouldn't notify that the scrollbars | 763 // Play out the fade out animation. We shouldn't notify that the scrollbars |
735 // are hidden until the animation is completly over. We can (but don't have | 764 // are hidden until the animation is completly over. We can (but don't have |
736 // to) notify during the animation that the scrollbars are still visible. | 765 // to) notify during the animation that the scrollbars are still visible. |
737 EXPECT_CALL(client_, DidChangeScrollbarVisibility()).Times(0); | 766 EXPECT_CALL(client_, DidChangeScrollbarVisibility()).Times(0); |
738 ASSERT_FALSE(client_.start_fade().is_null()); | 767 ASSERT_FALSE(client_.start_fade().is_null()); |
(...skipping 14 matching lines...) Expand all Loading... |
753 EXPECT_CALL(client_, DidChangeScrollbarVisibility()).Times(1); | 782 EXPECT_CALL(client_, DidChangeScrollbarVisibility()).Times(1); |
754 time += kFadeOutDuration / 4; | 783 time += kFadeOutDuration / 4; |
755 scrollbar_controller_->Animate(time); | 784 scrollbar_controller_->Animate(time); |
756 EXPECT_TRUE(scrollbar_controller_->ScrollbarsHidden()); | 785 EXPECT_TRUE(scrollbar_controller_->ScrollbarsHidden()); |
757 ExpectScrollbarsOpacity(0); | 786 ExpectScrollbarsOpacity(0); |
758 Mock::VerifyAndClearExpectations(&client_); | 787 Mock::VerifyAndClearExpectations(&client_); |
759 | 788 |
760 // Calling DidScrollUpdate without a begin (i.e. update from commit) should | 789 // Calling DidScrollUpdate without a begin (i.e. update from commit) should |
761 // also notify. | 790 // also notify. |
762 EXPECT_CALL(client_, DidChangeScrollbarVisibility()).Times(1); | 791 EXPECT_CALL(client_, DidChangeScrollbarVisibility()).Times(1); |
763 scrollbar_controller_->DidScrollUpdate(false); | 792 scrollbar_controller_->DidScrollUpdate(); |
764 EXPECT_FALSE(scrollbar_controller_->ScrollbarsHidden()); | 793 EXPECT_FALSE(scrollbar_controller_->ScrollbarsHidden()); |
765 Mock::VerifyAndClearExpectations(&client_); | 794 Mock::VerifyAndClearExpectations(&client_); |
766 } | 795 } |
767 | 796 |
768 // Move the pointer near each scrollbar. Confirm it gets thick and narrow when | 797 // Move the pointer near each scrollbar. Confirm it gets thick and narrow when |
769 // moved away. | 798 // moved away. |
770 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, MouseNearEach) { | 799 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, MouseNearEach) { |
771 base::TimeTicks time; | 800 base::TimeTicks time; |
772 time += base::TimeDelta::FromSeconds(1); | 801 time += base::TimeDelta::FromSeconds(1); |
773 | 802 |
774 // Scroll to make the scrollbars visible. | 803 // Scroll to make the scrollbars visible. |
775 scrollbar_controller_->DidScrollBegin(); | 804 scrollbar_controller_->DidScrollBegin(); |
776 scrollbar_controller_->DidScrollUpdate(false); | 805 scrollbar_controller_->DidScrollUpdate(); |
777 scrollbar_controller_->DidScrollEnd(); | 806 scrollbar_controller_->DidScrollEnd(); |
778 | 807 |
779 // Near vertical scrollbar | 808 // Near vertical scrollbar |
780 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 1); | 809 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 1); |
781 scrollbar_controller_->Animate(time); | 810 scrollbar_controller_->Animate(time); |
782 ExpectScrollbarsOpacity(1); | 811 ExpectScrollbarsOpacity(1); |
783 EXPECT_FLOAT_EQ(kIdleThicknessScale, | 812 EXPECT_FLOAT_EQ(kIdleThicknessScale, |
784 v_scrollbar_layer_->thumb_thickness_scale_factor()); | 813 v_scrollbar_layer_->thumb_thickness_scale_factor()); |
785 EXPECT_FLOAT_EQ(kIdleThicknessScale, | 814 EXPECT_FLOAT_EQ(kIdleThicknessScale, |
786 h_scrollbar_layer_->thumb_thickness_scale_factor()); | 815 h_scrollbar_layer_->thumb_thickness_scale_factor()); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
859 EXPECT_EQ(kFadeOutDelay, client_.delay()); | 888 EXPECT_EQ(kFadeOutDelay, client_.delay()); |
860 } | 889 } |
861 | 890 |
862 // Move mouse near both scrollbars at the same time. | 891 // Move mouse near both scrollbars at the same time. |
863 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, MouseNearBoth) { | 892 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, MouseNearBoth) { |
864 base::TimeTicks time; | 893 base::TimeTicks time; |
865 time += base::TimeDelta::FromSeconds(1); | 894 time += base::TimeDelta::FromSeconds(1); |
866 | 895 |
867 // Scroll to make the scrollbars visible. | 896 // Scroll to make the scrollbars visible. |
868 scrollbar_controller_->DidScrollBegin(); | 897 scrollbar_controller_->DidScrollBegin(); |
869 scrollbar_controller_->DidScrollUpdate(false); | 898 scrollbar_controller_->DidScrollUpdate(); |
870 scrollbar_controller_->DidScrollEnd(); | 899 scrollbar_controller_->DidScrollEnd(); |
871 | 900 |
872 // Near both Scrollbar | 901 // Near both Scrollbar |
873 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 1); | 902 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 1); |
874 scrollbar_controller_->DidMouseMoveNear(HORIZONTAL, 1); | 903 scrollbar_controller_->DidMouseMoveNear(HORIZONTAL, 1); |
875 scrollbar_controller_->Animate(time); | 904 scrollbar_controller_->Animate(time); |
876 ExpectScrollbarsOpacity(1); | 905 ExpectScrollbarsOpacity(1); |
877 EXPECT_FLOAT_EQ(kIdleThicknessScale, | 906 EXPECT_FLOAT_EQ(kIdleThicknessScale, |
878 v_scrollbar_layer_->thumb_thickness_scale_factor()); | 907 v_scrollbar_layer_->thumb_thickness_scale_factor()); |
879 EXPECT_FLOAT_EQ(kIdleThicknessScale, | 908 EXPECT_FLOAT_EQ(kIdleThicknessScale, |
880 h_scrollbar_layer_->thumb_thickness_scale_factor()); | 909 h_scrollbar_layer_->thumb_thickness_scale_factor()); |
881 | 910 |
882 // Should animate to thickened. | 911 // Should animate to thickened. |
883 time += kThinningDuration; | 912 time += kThinningDuration; |
884 scrollbar_controller_->Animate(time); | 913 scrollbar_controller_->Animate(time); |
885 ExpectScrollbarsOpacity(1); | 914 ExpectScrollbarsOpacity(1); |
886 EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor()); | 915 EXPECT_FLOAT_EQ(1, v_scrollbar_layer_->thumb_thickness_scale_factor()); |
887 EXPECT_FLOAT_EQ(1, h_scrollbar_layer_->thumb_thickness_scale_factor()); | 916 EXPECT_FLOAT_EQ(1, h_scrollbar_layer_->thumb_thickness_scale_factor()); |
888 } | 917 } |
889 | 918 |
890 // Move mouse from one to the other scrollbar before animation is finished, then | 919 // Move mouse from one to the other scrollbar before animation is finished, then |
891 // away before animation finished. | 920 // away before animation finished. |
892 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, | 921 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, |
893 MouseNearOtherBeforeAnimationFinished) { | 922 MouseNearOtherBeforeAnimationFinished) { |
894 base::TimeTicks time; | 923 base::TimeTicks time; |
895 time += base::TimeDelta::FromSeconds(1); | 924 time += base::TimeDelta::FromSeconds(1); |
896 | 925 |
897 // Scroll to make the scrollbars visible. | 926 // Scroll to make the scrollbars visible. |
898 scrollbar_controller_->DidScrollBegin(); | 927 scrollbar_controller_->DidScrollBegin(); |
899 scrollbar_controller_->DidScrollUpdate(false); | 928 scrollbar_controller_->DidScrollUpdate(); |
900 scrollbar_controller_->DidScrollEnd(); | 929 scrollbar_controller_->DidScrollEnd(); |
901 | 930 |
902 // Near vertical scrollbar. | 931 // Near vertical scrollbar. |
903 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 1); | 932 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 1); |
904 scrollbar_controller_->Animate(time); | 933 scrollbar_controller_->Animate(time); |
905 ExpectScrollbarsOpacity(1); | 934 ExpectScrollbarsOpacity(1); |
906 EXPECT_FLOAT_EQ(kIdleThicknessScale, | 935 EXPECT_FLOAT_EQ(kIdleThicknessScale, |
907 v_scrollbar_layer_->thumb_thickness_scale_factor()); | 936 v_scrollbar_layer_->thumb_thickness_scale_factor()); |
908 EXPECT_FLOAT_EQ(kIdleThicknessScale, | 937 EXPECT_FLOAT_EQ(kIdleThicknessScale, |
909 h_scrollbar_layer_->thumb_thickness_scale_factor()); | 938 h_scrollbar_layer_->thumb_thickness_scale_factor()); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
955 // move. | 984 // move. |
956 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, MouseLeaveFadeOut) { | 985 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, MouseLeaveFadeOut) { |
957 base::TimeTicks time; | 986 base::TimeTicks time; |
958 time += base::TimeDelta::FromSeconds(1); | 987 time += base::TimeDelta::FromSeconds(1); |
959 | 988 |
960 // Move mouse near scrollbar. | 989 // Move mouse near scrollbar. |
961 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 1); | 990 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 1); |
962 | 991 |
963 // Scroll to make the scrollbars visible. | 992 // Scroll to make the scrollbars visible. |
964 scrollbar_controller_->DidScrollBegin(); | 993 scrollbar_controller_->DidScrollBegin(); |
965 scrollbar_controller_->DidScrollUpdate(false); | 994 scrollbar_controller_->DidScrollUpdate(); |
966 scrollbar_controller_->DidScrollEnd(); | 995 scrollbar_controller_->DidScrollEnd(); |
967 | 996 |
968 // Should not have delay fadeout animation. | 997 // Should not have delay fadeout animation. |
969 EXPECT_TRUE(client_.start_fade().is_null() || | 998 EXPECT_TRUE(client_.start_fade().is_null() || |
970 client_.start_fade().IsCancelled()); | 999 client_.start_fade().IsCancelled()); |
971 | 1000 |
972 // Mouse leave. | 1001 // Mouse leave. |
973 scrollbar_controller_->DidMouseLeave(); | 1002 scrollbar_controller_->DidMouseLeave(); |
974 | 1003 |
975 // An fade out animation should have been enqueued. | 1004 // An fade out animation should have been enqueued. |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1141 protected: | 1170 protected: |
1142 ScrollbarOrientation orientation() const override { return VERTICAL; } | 1171 ScrollbarOrientation orientation() const override { return VERTICAL; } |
1143 }; | 1172 }; |
1144 | 1173 |
1145 TEST_F(ScrollbarAnimationControllerAndroidTest, DelayAnimationOnResize) { | 1174 TEST_F(ScrollbarAnimationControllerAndroidTest, DelayAnimationOnResize) { |
1146 scrollbar_layer_->layer_tree_impl() | 1175 scrollbar_layer_->layer_tree_impl() |
1147 ->property_trees() | 1176 ->property_trees() |
1148 ->effect_tree.OnOpacityAnimated(0.0f, | 1177 ->effect_tree.OnOpacityAnimated(0.0f, |
1149 scrollbar_layer_->effect_tree_index(), | 1178 scrollbar_layer_->effect_tree_index(), |
1150 scrollbar_layer_->layer_tree_impl()); | 1179 scrollbar_layer_->layer_tree_impl()); |
| 1180 // We should use the gesture delay rather than the resize delay if we're in a |
| 1181 // gesture scroll, even if it is resizing. |
1151 scrollbar_controller_->DidScrollBegin(); | 1182 scrollbar_controller_->DidScrollBegin(); |
1152 scrollbar_controller_->DidScrollUpdate(true); | 1183 scrollbar_controller_->DidResize(); |
1153 scrollbar_controller_->DidScrollEnd(); | 1184 scrollbar_controller_->DidScrollEnd(); |
1154 // Normal Animation delay of 2 seconds. | 1185 // Normal Animation delay of 2 seconds. |
1155 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); | 1186 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); |
1156 EXPECT_EQ(delay_, base::TimeDelta::FromSeconds(2)); | 1187 EXPECT_EQ(delay_, base::TimeDelta::FromSeconds(2)); |
1157 | 1188 |
1158 scrollbar_layer_->layer_tree_impl() | 1189 scrollbar_layer_->layer_tree_impl() |
1159 ->property_trees() | 1190 ->property_trees() |
1160 ->effect_tree.OnOpacityAnimated(0.0f, | 1191 ->effect_tree.OnOpacityAnimated(0.0f, |
1161 scrollbar_layer_->effect_tree_index(), | 1192 scrollbar_layer_->effect_tree_index(), |
1162 scrollbar_layer_->layer_tree_impl()); | 1193 scrollbar_layer_->layer_tree_impl()); |
1163 scrollbar_controller_->DidScrollUpdate(true); | 1194 scrollbar_controller_->DidResize(); |
1164 // Delay animation on resize to 5 seconds. | 1195 // Delay animation on resize to 5 seconds. |
1165 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); | 1196 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); |
1166 EXPECT_EQ(delay_, base::TimeDelta::FromSeconds(5)); | 1197 EXPECT_EQ(delay_, base::TimeDelta::FromSeconds(5)); |
1167 } | 1198 } |
1168 | 1199 |
1169 TEST_F(ScrollbarAnimationControllerAndroidTest, HiddenInBegin) { | 1200 TEST_F(ScrollbarAnimationControllerAndroidTest, HiddenInBegin) { |
1170 scrollbar_layer_->layer_tree_impl() | 1201 scrollbar_layer_->layer_tree_impl() |
1171 ->property_trees() | 1202 ->property_trees() |
1172 ->effect_tree.OnOpacityAnimated(0.0f, | 1203 ->effect_tree.OnOpacityAnimated(0.0f, |
1173 scrollbar_layer_->effect_tree_index(), | 1204 scrollbar_layer_->effect_tree_index(), |
(...skipping 17 matching lines...) Expand all Loading... |
1191 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity()); | 1222 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity()); |
1192 scrollbar_controller_->DidScrollEnd(); | 1223 scrollbar_controller_->DidScrollEnd(); |
1193 | 1224 |
1194 EXPECT_TRUE(start_fade_.Equals(base::Closure())); | 1225 EXPECT_TRUE(start_fade_.Equals(base::Closure())); |
1195 | 1226 |
1196 time += base::TimeDelta::FromSeconds(100); | 1227 time += base::TimeDelta::FromSeconds(100); |
1197 scrollbar_controller_->Animate(time); | 1228 scrollbar_controller_->Animate(time); |
1198 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity()); | 1229 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity()); |
1199 } | 1230 } |
1200 | 1231 |
| 1232 // Confirm the scrollbar does not appear on WillUpdateScroll on Android. |
| 1233 TEST_F(ScrollbarAnimationControllerAndroidTest, |
| 1234 WillUpdateScrollNotAppearScrollbar) { |
| 1235 base::TimeTicks time; |
| 1236 time += base::TimeDelta::FromSeconds(1); |
| 1237 |
| 1238 // Scrollbar should be invisible. |
| 1239 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity()); |
| 1240 EXPECT_TRUE(scrollbar_controller_->ScrollbarsHidden()); |
| 1241 |
| 1242 // Scrollbar should appear when scroll will update. |
| 1243 scrollbar_controller_->WillUpdateScroll(); |
| 1244 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity()); |
| 1245 EXPECT_TRUE(scrollbar_controller_->ScrollbarsHidden()); |
| 1246 |
| 1247 // No fade out animation should have been enqueued. |
| 1248 EXPECT_TRUE(start_fade_.Equals(base::Closure())); |
| 1249 } |
| 1250 |
1201 TEST_F(ScrollbarAnimationControllerAndroidTest, HideOnResize) { | 1251 TEST_F(ScrollbarAnimationControllerAndroidTest, HideOnResize) { |
1202 LayerImpl* scroll_layer = host_impl_.active_tree()->LayerById(1); | 1252 LayerImpl* scroll_layer = host_impl_.active_tree()->LayerById(1); |
1203 ASSERT_TRUE(scroll_layer); | 1253 ASSERT_TRUE(scroll_layer); |
1204 EXPECT_EQ(gfx::Size(200, 200), scroll_layer->bounds()); | 1254 EXPECT_EQ(gfx::Size(200, 200), scroll_layer->bounds()); |
1205 | 1255 |
1206 EXPECT_EQ(HORIZONTAL, scrollbar_layer_->orientation()); | 1256 EXPECT_EQ(HORIZONTAL, scrollbar_layer_->orientation()); |
1207 | 1257 |
1208 // Shrink along X axis, horizontal scrollbar should appear. | 1258 // Shrink along X axis, horizontal scrollbar should appear. |
1209 clip_layer_->SetBounds(gfx::Size(100, 200)); | 1259 clip_layer_->SetBounds(gfx::Size(100, 200)); |
1210 EXPECT_EQ(gfx::Size(100, 200), clip_layer_->bounds()); | 1260 EXPECT_EQ(gfx::Size(100, 200), clip_layer_->bounds()); |
1211 | 1261 |
1212 scrollbar_controller_->DidScrollBegin(); | 1262 scrollbar_controller_->DidScrollBegin(); |
1213 | 1263 |
1214 scrollbar_controller_->DidScrollUpdate(false); | 1264 scrollbar_controller_->DidScrollUpdate(); |
1215 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); | 1265 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); |
1216 | 1266 |
1217 scrollbar_controller_->DidScrollEnd(); | 1267 scrollbar_controller_->DidScrollEnd(); |
1218 | 1268 |
1219 // Shrink along Y axis and expand along X, horizontal scrollbar | 1269 // Shrink along Y axis and expand along X, horizontal scrollbar |
1220 // should disappear. | 1270 // should disappear. |
1221 clip_layer_->SetBounds(gfx::Size(200, 100)); | 1271 clip_layer_->SetBounds(gfx::Size(200, 100)); |
1222 EXPECT_EQ(gfx::Size(200, 100), clip_layer_->bounds()); | 1272 EXPECT_EQ(gfx::Size(200, 100), clip_layer_->bounds()); |
1223 | 1273 |
1224 scrollbar_controller_->DidScrollBegin(); | 1274 scrollbar_controller_->DidScrollBegin(); |
1225 | 1275 |
1226 scrollbar_controller_->DidScrollUpdate(false); | 1276 scrollbar_controller_->DidScrollUpdate(); |
1227 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity()); | 1277 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity()); |
1228 | 1278 |
1229 scrollbar_controller_->DidScrollEnd(); | 1279 scrollbar_controller_->DidScrollEnd(); |
1230 } | 1280 } |
1231 | 1281 |
1232 TEST_F(VerticalScrollbarAnimationControllerAndroidTest, HideOnResize) { | 1282 TEST_F(VerticalScrollbarAnimationControllerAndroidTest, HideOnResize) { |
1233 LayerImpl* scroll_layer = host_impl_.active_tree()->LayerById(1); | 1283 LayerImpl* scroll_layer = host_impl_.active_tree()->LayerById(1); |
1234 ASSERT_TRUE(scroll_layer); | 1284 ASSERT_TRUE(scroll_layer); |
1235 EXPECT_EQ(gfx::Size(200, 200), scroll_layer->bounds()); | 1285 EXPECT_EQ(gfx::Size(200, 200), scroll_layer->bounds()); |
1236 | 1286 |
1237 EXPECT_EQ(VERTICAL, scrollbar_layer_->orientation()); | 1287 EXPECT_EQ(VERTICAL, scrollbar_layer_->orientation()); |
1238 | 1288 |
1239 // Shrink along X axis, vertical scrollbar should remain invisible. | 1289 // Shrink along X axis, vertical scrollbar should remain invisible. |
1240 clip_layer_->SetBounds(gfx::Size(100, 200)); | 1290 clip_layer_->SetBounds(gfx::Size(100, 200)); |
1241 EXPECT_EQ(gfx::Size(100, 200), clip_layer_->bounds()); | 1291 EXPECT_EQ(gfx::Size(100, 200), clip_layer_->bounds()); |
1242 | 1292 |
1243 scrollbar_controller_->DidScrollBegin(); | 1293 scrollbar_controller_->DidScrollBegin(); |
1244 | 1294 |
1245 scrollbar_controller_->DidScrollUpdate(false); | 1295 scrollbar_controller_->DidScrollUpdate(); |
1246 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity()); | 1296 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity()); |
1247 | 1297 |
1248 scrollbar_controller_->DidScrollEnd(); | 1298 scrollbar_controller_->DidScrollEnd(); |
1249 | 1299 |
1250 // Shrink along Y axis and expand along X, vertical scrollbar should appear. | 1300 // Shrink along Y axis and expand along X, vertical scrollbar should appear. |
1251 clip_layer_->SetBounds(gfx::Size(200, 100)); | 1301 clip_layer_->SetBounds(gfx::Size(200, 100)); |
1252 EXPECT_EQ(gfx::Size(200, 100), clip_layer_->bounds()); | 1302 EXPECT_EQ(gfx::Size(200, 100), clip_layer_->bounds()); |
1253 | 1303 |
1254 scrollbar_controller_->DidScrollBegin(); | 1304 scrollbar_controller_->DidScrollBegin(); |
1255 | 1305 |
1256 scrollbar_controller_->DidScrollUpdate(false); | 1306 scrollbar_controller_->DidScrollUpdate(); |
1257 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); | 1307 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); |
1258 | 1308 |
1259 scrollbar_controller_->DidScrollEnd(); | 1309 scrollbar_controller_->DidScrollEnd(); |
1260 } | 1310 } |
1261 | 1311 |
1262 TEST_F(ScrollbarAnimationControllerAndroidTest, HideOnUserNonScrollableHorz) { | 1312 TEST_F(ScrollbarAnimationControllerAndroidTest, HideOnUserNonScrollableHorz) { |
1263 EXPECT_EQ(HORIZONTAL, scrollbar_layer_->orientation()); | 1313 EXPECT_EQ(HORIZONTAL, scrollbar_layer_->orientation()); |
1264 | 1314 |
1265 LayerImpl* scroll_layer = host_impl_.active_tree()->LayerById(1); | 1315 LayerImpl* scroll_layer = host_impl_.active_tree()->LayerById(1); |
1266 ASSERT_TRUE(scroll_layer); | 1316 ASSERT_TRUE(scroll_layer); |
1267 scroll_layer->set_user_scrollable_horizontal(false); | 1317 scroll_layer->set_user_scrollable_horizontal(false); |
1268 | 1318 |
1269 scrollbar_controller_->DidScrollBegin(); | 1319 scrollbar_controller_->DidScrollBegin(); |
1270 | 1320 |
1271 scrollbar_controller_->DidScrollUpdate(false); | 1321 scrollbar_controller_->DidScrollUpdate(); |
1272 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity()); | 1322 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity()); |
1273 | 1323 |
1274 scrollbar_controller_->DidScrollEnd(); | 1324 scrollbar_controller_->DidScrollEnd(); |
1275 } | 1325 } |
1276 | 1326 |
1277 TEST_F(ScrollbarAnimationControllerAndroidTest, ShowOnUserNonScrollableVert) { | 1327 TEST_F(ScrollbarAnimationControllerAndroidTest, ShowOnUserNonScrollableVert) { |
1278 EXPECT_EQ(HORIZONTAL, scrollbar_layer_->orientation()); | 1328 EXPECT_EQ(HORIZONTAL, scrollbar_layer_->orientation()); |
1279 | 1329 |
1280 LayerImpl* scroll_layer = host_impl_.active_tree()->LayerById(1); | 1330 LayerImpl* scroll_layer = host_impl_.active_tree()->LayerById(1); |
1281 ASSERT_TRUE(scroll_layer); | 1331 ASSERT_TRUE(scroll_layer); |
1282 scroll_layer->set_user_scrollable_vertical(false); | 1332 scroll_layer->set_user_scrollable_vertical(false); |
1283 | 1333 |
1284 scrollbar_controller_->DidScrollBegin(); | 1334 scrollbar_controller_->DidScrollBegin(); |
1285 | 1335 |
1286 scrollbar_controller_->DidScrollUpdate(false); | 1336 scrollbar_controller_->DidScrollUpdate(); |
1287 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); | 1337 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); |
1288 | 1338 |
1289 scrollbar_controller_->DidScrollEnd(); | 1339 scrollbar_controller_->DidScrollEnd(); |
1290 } | 1340 } |
1291 | 1341 |
1292 TEST_F(VerticalScrollbarAnimationControllerAndroidTest, | 1342 TEST_F(VerticalScrollbarAnimationControllerAndroidTest, |
1293 HideOnUserNonScrollableVert) { | 1343 HideOnUserNonScrollableVert) { |
1294 EXPECT_EQ(VERTICAL, scrollbar_layer_->orientation()); | 1344 EXPECT_EQ(VERTICAL, scrollbar_layer_->orientation()); |
1295 | 1345 |
1296 LayerImpl* scroll_layer = host_impl_.active_tree()->LayerById(1); | 1346 LayerImpl* scroll_layer = host_impl_.active_tree()->LayerById(1); |
1297 ASSERT_TRUE(scroll_layer); | 1347 ASSERT_TRUE(scroll_layer); |
1298 scroll_layer->set_user_scrollable_vertical(false); | 1348 scroll_layer->set_user_scrollable_vertical(false); |
1299 | 1349 |
1300 scrollbar_controller_->DidScrollBegin(); | 1350 scrollbar_controller_->DidScrollBegin(); |
1301 | 1351 |
1302 scrollbar_controller_->DidScrollUpdate(false); | 1352 scrollbar_controller_->DidScrollUpdate(); |
1303 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity()); | 1353 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity()); |
1304 | 1354 |
1305 scrollbar_controller_->DidScrollEnd(); | 1355 scrollbar_controller_->DidScrollEnd(); |
1306 } | 1356 } |
1307 | 1357 |
1308 TEST_F(VerticalScrollbarAnimationControllerAndroidTest, | 1358 TEST_F(VerticalScrollbarAnimationControllerAndroidTest, |
1309 ShowOnUserNonScrollableHorz) { | 1359 ShowOnUserNonScrollableHorz) { |
1310 EXPECT_EQ(VERTICAL, scrollbar_layer_->orientation()); | 1360 EXPECT_EQ(VERTICAL, scrollbar_layer_->orientation()); |
1311 | 1361 |
1312 LayerImpl* scroll_layer = host_impl_.active_tree()->LayerById(1); | 1362 LayerImpl* scroll_layer = host_impl_.active_tree()->LayerById(1); |
1313 ASSERT_TRUE(scroll_layer); | 1363 ASSERT_TRUE(scroll_layer); |
1314 scroll_layer->set_user_scrollable_horizontal(false); | 1364 scroll_layer->set_user_scrollable_horizontal(false); |
1315 | 1365 |
1316 scrollbar_controller_->DidScrollBegin(); | 1366 scrollbar_controller_->DidScrollBegin(); |
1317 | 1367 |
1318 scrollbar_controller_->DidScrollUpdate(false); | 1368 scrollbar_controller_->DidScrollUpdate(); |
1319 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); | 1369 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); |
1320 | 1370 |
1321 scrollbar_controller_->DidScrollEnd(); | 1371 scrollbar_controller_->DidScrollEnd(); |
1322 } | 1372 } |
1323 | 1373 |
1324 TEST_F(ScrollbarAnimationControllerAndroidTest, AwakenByScrollingGesture) { | 1374 TEST_F(ScrollbarAnimationControllerAndroidTest, AwakenByScrollingGesture) { |
1325 base::TimeTicks time; | 1375 base::TimeTicks time; |
1326 time += base::TimeDelta::FromSeconds(1); | 1376 time += base::TimeDelta::FromSeconds(1); |
1327 scrollbar_controller_->DidScrollBegin(); | 1377 scrollbar_controller_->DidScrollBegin(); |
1328 EXPECT_FALSE(did_request_animate_); | 1378 EXPECT_FALSE(did_request_animate_); |
1329 | 1379 |
1330 scrollbar_controller_->DidScrollUpdate(false); | 1380 scrollbar_controller_->DidScrollUpdate(); |
1331 EXPECT_FALSE(did_request_animate_); | 1381 EXPECT_FALSE(did_request_animate_); |
1332 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); | 1382 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); |
1333 | 1383 |
1334 EXPECT_TRUE(start_fade_.Equals(base::Closure())); | 1384 EXPECT_TRUE(start_fade_.Equals(base::Closure())); |
1335 | 1385 |
1336 time += base::TimeDelta::FromSeconds(100); | 1386 time += base::TimeDelta::FromSeconds(100); |
1337 | 1387 |
1338 scrollbar_controller_->Animate(time); | 1388 scrollbar_controller_->Animate(time); |
1339 EXPECT_FALSE(did_request_animate_); | 1389 EXPECT_FALSE(did_request_animate_); |
1340 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); | 1390 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); |
(...skipping 17 matching lines...) Expand all Loading... |
1358 | 1408 |
1359 time += base::TimeDelta::FromSeconds(1); | 1409 time += base::TimeDelta::FromSeconds(1); |
1360 scrollbar_controller_->Animate(time); | 1410 scrollbar_controller_->Animate(time); |
1361 EXPECT_TRUE(did_request_animate_); | 1411 EXPECT_TRUE(did_request_animate_); |
1362 did_request_animate_ = false; | 1412 did_request_animate_ = false; |
1363 EXPECT_FLOAT_EQ(1.0f / 3.0f, scrollbar_layer_->Opacity()); | 1413 EXPECT_FLOAT_EQ(1.0f / 3.0f, scrollbar_layer_->Opacity()); |
1364 | 1414 |
1365 time += base::TimeDelta::FromSeconds(1); | 1415 time += base::TimeDelta::FromSeconds(1); |
1366 | 1416 |
1367 scrollbar_controller_->DidScrollBegin(); | 1417 scrollbar_controller_->DidScrollBegin(); |
1368 scrollbar_controller_->DidScrollUpdate(false); | 1418 scrollbar_controller_->DidScrollUpdate(); |
1369 scrollbar_controller_->DidScrollEnd(); | 1419 scrollbar_controller_->DidScrollEnd(); |
1370 | 1420 |
1371 start_fade_.Run(); | 1421 start_fade_.Run(); |
1372 EXPECT_TRUE(did_request_animate_); | 1422 EXPECT_TRUE(did_request_animate_); |
1373 did_request_animate_ = false; | 1423 did_request_animate_ = false; |
1374 | 1424 |
1375 time += base::TimeDelta::FromSeconds(2); | 1425 time += base::TimeDelta::FromSeconds(2); |
1376 scrollbar_controller_->Animate(time); | 1426 scrollbar_controller_->Animate(time); |
1377 EXPECT_TRUE(did_request_animate_); | 1427 EXPECT_TRUE(did_request_animate_); |
1378 did_request_animate_ = false; | 1428 did_request_animate_ = false; |
(...skipping 13 matching lines...) Expand all Loading... |
1392 | 1442 |
1393 time += base::TimeDelta::FromSeconds(1); | 1443 time += base::TimeDelta::FromSeconds(1); |
1394 scrollbar_controller_->Animate(time); | 1444 scrollbar_controller_->Animate(time); |
1395 EXPECT_FALSE(did_request_animate_); | 1445 EXPECT_FALSE(did_request_animate_); |
1396 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity()); | 1446 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity()); |
1397 } | 1447 } |
1398 | 1448 |
1399 TEST_F(ScrollbarAnimationControllerAndroidTest, AwakenByProgrammaticScroll) { | 1449 TEST_F(ScrollbarAnimationControllerAndroidTest, AwakenByProgrammaticScroll) { |
1400 base::TimeTicks time; | 1450 base::TimeTicks time; |
1401 time += base::TimeDelta::FromSeconds(1); | 1451 time += base::TimeDelta::FromSeconds(1); |
1402 scrollbar_controller_->DidScrollUpdate(false); | 1452 scrollbar_controller_->DidScrollUpdate(); |
1403 EXPECT_FALSE(did_request_animate_); | 1453 EXPECT_FALSE(did_request_animate_); |
1404 | 1454 |
1405 start_fade_.Run(); | 1455 start_fade_.Run(); |
1406 EXPECT_TRUE(did_request_animate_); | 1456 EXPECT_TRUE(did_request_animate_); |
1407 did_request_animate_ = false; | 1457 did_request_animate_ = false; |
1408 scrollbar_controller_->Animate(time); | 1458 scrollbar_controller_->Animate(time); |
1409 EXPECT_TRUE(did_request_animate_); | 1459 EXPECT_TRUE(did_request_animate_); |
1410 did_request_animate_ = false; | 1460 did_request_animate_ = false; |
1411 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); | 1461 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); |
1412 | 1462 |
1413 time += base::TimeDelta::FromSeconds(1); | 1463 time += base::TimeDelta::FromSeconds(1); |
1414 scrollbar_controller_->Animate(time); | 1464 scrollbar_controller_->Animate(time); |
1415 EXPECT_TRUE(did_request_animate_); | 1465 EXPECT_TRUE(did_request_animate_); |
1416 did_request_animate_ = false; | 1466 did_request_animate_ = false; |
1417 EXPECT_FLOAT_EQ(2.0f / 3.0f, scrollbar_layer_->Opacity()); | 1467 EXPECT_FLOAT_EQ(2.0f / 3.0f, scrollbar_layer_->Opacity()); |
1418 scrollbar_controller_->DidScrollUpdate(false); | 1468 scrollbar_controller_->DidScrollUpdate(); |
1419 EXPECT_FALSE(did_request_animate_); | 1469 EXPECT_FALSE(did_request_animate_); |
1420 | 1470 |
1421 start_fade_.Run(); | 1471 start_fade_.Run(); |
1422 EXPECT_TRUE(did_request_animate_); | 1472 EXPECT_TRUE(did_request_animate_); |
1423 did_request_animate_ = false; | 1473 did_request_animate_ = false; |
1424 time += base::TimeDelta::FromSeconds(2); | 1474 time += base::TimeDelta::FromSeconds(2); |
1425 scrollbar_controller_->Animate(time); | 1475 scrollbar_controller_->Animate(time); |
1426 EXPECT_TRUE(did_request_animate_); | 1476 EXPECT_TRUE(did_request_animate_); |
1427 did_request_animate_ = false; | 1477 did_request_animate_ = false; |
1428 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); | 1478 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); |
1429 | 1479 |
1430 time += base::TimeDelta::FromSeconds(1); | 1480 time += base::TimeDelta::FromSeconds(1); |
1431 scrollbar_controller_->Animate(time); | 1481 scrollbar_controller_->Animate(time); |
1432 EXPECT_TRUE(did_request_animate_); | 1482 EXPECT_TRUE(did_request_animate_); |
1433 did_request_animate_ = false; | 1483 did_request_animate_ = false; |
1434 EXPECT_FLOAT_EQ(2.0f / 3.0f, scrollbar_layer_->Opacity()); | 1484 EXPECT_FLOAT_EQ(2.0f / 3.0f, scrollbar_layer_->Opacity()); |
1435 | 1485 |
1436 time += base::TimeDelta::FromSeconds(1); | 1486 time += base::TimeDelta::FromSeconds(1); |
1437 scrollbar_controller_->Animate(time); | 1487 scrollbar_controller_->Animate(time); |
1438 EXPECT_TRUE(did_request_animate_); | 1488 EXPECT_TRUE(did_request_animate_); |
1439 did_request_animate_ = false; | 1489 did_request_animate_ = false; |
1440 EXPECT_FLOAT_EQ(1.0f / 3.0f, scrollbar_layer_->Opacity()); | 1490 EXPECT_FLOAT_EQ(1.0f / 3.0f, scrollbar_layer_->Opacity()); |
1441 | 1491 |
1442 time += base::TimeDelta::FromSeconds(1); | 1492 time += base::TimeDelta::FromSeconds(1); |
1443 scrollbar_controller_->DidScrollUpdate(false); | 1493 scrollbar_controller_->DidScrollUpdate(); |
1444 start_fade_.Run(); | 1494 start_fade_.Run(); |
1445 time += base::TimeDelta::FromSeconds(1); | 1495 time += base::TimeDelta::FromSeconds(1); |
1446 scrollbar_controller_->Animate(time); | 1496 scrollbar_controller_->Animate(time); |
1447 EXPECT_TRUE(did_request_animate_); | 1497 EXPECT_TRUE(did_request_animate_); |
1448 did_request_animate_ = false; | 1498 did_request_animate_ = false; |
1449 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); | 1499 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); |
1450 | 1500 |
1451 time += base::TimeDelta::FromSeconds(1); | 1501 time += base::TimeDelta::FromSeconds(1); |
1452 scrollbar_controller_->Animate(time); | 1502 scrollbar_controller_->Animate(time); |
1453 EXPECT_TRUE(did_request_animate_); | 1503 EXPECT_TRUE(did_request_animate_); |
1454 did_request_animate_ = false; | 1504 did_request_animate_ = false; |
1455 EXPECT_FLOAT_EQ(2.0f / 3.0f, scrollbar_layer_->Opacity()); | 1505 EXPECT_FLOAT_EQ(2.0f / 3.0f, scrollbar_layer_->Opacity()); |
1456 | 1506 |
1457 time += base::TimeDelta::FromSeconds(1); | 1507 time += base::TimeDelta::FromSeconds(1); |
1458 scrollbar_controller_->Animate(time); | 1508 scrollbar_controller_->Animate(time); |
1459 EXPECT_TRUE(did_request_animate_); | 1509 EXPECT_TRUE(did_request_animate_); |
1460 did_request_animate_ = false; | 1510 did_request_animate_ = false; |
1461 EXPECT_FLOAT_EQ(1.0f / 3.0f, scrollbar_layer_->Opacity()); | 1511 EXPECT_FLOAT_EQ(1.0f / 3.0f, scrollbar_layer_->Opacity()); |
1462 | 1512 |
1463 time += base::TimeDelta::FromSeconds(1); | 1513 time += base::TimeDelta::FromSeconds(1); |
1464 scrollbar_controller_->Animate(time); | 1514 scrollbar_controller_->Animate(time); |
1465 EXPECT_FALSE(did_request_animate_); | 1515 EXPECT_FALSE(did_request_animate_); |
1466 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity()); | 1516 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity()); |
1467 } | 1517 } |
1468 | 1518 |
1469 TEST_F(ScrollbarAnimationControllerAndroidTest, | 1519 TEST_F(ScrollbarAnimationControllerAndroidTest, |
1470 AnimationPreservedByNonScrollingGesture) { | 1520 AnimationPreservedByNonScrollingGesture) { |
1471 base::TimeTicks time; | 1521 base::TimeTicks time; |
1472 time += base::TimeDelta::FromSeconds(1); | 1522 time += base::TimeDelta::FromSeconds(1); |
1473 scrollbar_controller_->DidScrollUpdate(false); | 1523 scrollbar_controller_->DidScrollUpdate(); |
1474 start_fade_.Run(); | 1524 start_fade_.Run(); |
1475 EXPECT_TRUE(did_request_animate_); | 1525 EXPECT_TRUE(did_request_animate_); |
1476 did_request_animate_ = false; | 1526 did_request_animate_ = false; |
1477 scrollbar_controller_->Animate(time); | 1527 scrollbar_controller_->Animate(time); |
1478 EXPECT_TRUE(did_request_animate_); | 1528 EXPECT_TRUE(did_request_animate_); |
1479 did_request_animate_ = false; | 1529 did_request_animate_ = false; |
1480 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); | 1530 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); |
1481 | 1531 |
1482 time += base::TimeDelta::FromSeconds(1); | 1532 time += base::TimeDelta::FromSeconds(1); |
1483 scrollbar_controller_->Animate(time); | 1533 scrollbar_controller_->Animate(time); |
(...skipping 18 matching lines...) Expand all Loading... |
1502 time += base::TimeDelta::FromSeconds(1); | 1552 time += base::TimeDelta::FromSeconds(1); |
1503 scrollbar_controller_->Animate(time); | 1553 scrollbar_controller_->Animate(time); |
1504 EXPECT_FALSE(did_request_animate_); | 1554 EXPECT_FALSE(did_request_animate_); |
1505 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity()); | 1555 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity()); |
1506 } | 1556 } |
1507 | 1557 |
1508 TEST_F(ScrollbarAnimationControllerAndroidTest, | 1558 TEST_F(ScrollbarAnimationControllerAndroidTest, |
1509 AnimationOverriddenByScrollingGesture) { | 1559 AnimationOverriddenByScrollingGesture) { |
1510 base::TimeTicks time; | 1560 base::TimeTicks time; |
1511 time += base::TimeDelta::FromSeconds(1); | 1561 time += base::TimeDelta::FromSeconds(1); |
1512 scrollbar_controller_->DidScrollUpdate(false); | 1562 scrollbar_controller_->DidScrollUpdate(); |
1513 EXPECT_FALSE(did_request_animate_); | 1563 EXPECT_FALSE(did_request_animate_); |
1514 start_fade_.Run(); | 1564 start_fade_.Run(); |
1515 EXPECT_TRUE(did_request_animate_); | 1565 EXPECT_TRUE(did_request_animate_); |
1516 did_request_animate_ = false; | 1566 did_request_animate_ = false; |
1517 scrollbar_controller_->Animate(time); | 1567 scrollbar_controller_->Animate(time); |
1518 EXPECT_TRUE(did_request_animate_); | 1568 EXPECT_TRUE(did_request_animate_); |
1519 did_request_animate_ = false; | 1569 did_request_animate_ = false; |
1520 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); | 1570 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); |
1521 | 1571 |
1522 time += base::TimeDelta::FromSeconds(1); | 1572 time += base::TimeDelta::FromSeconds(1); |
1523 scrollbar_controller_->Animate(time); | 1573 scrollbar_controller_->Animate(time); |
1524 EXPECT_TRUE(did_request_animate_); | 1574 EXPECT_TRUE(did_request_animate_); |
1525 did_request_animate_ = false; | 1575 did_request_animate_ = false; |
1526 EXPECT_FLOAT_EQ(2.0f / 3.0f, scrollbar_layer_->Opacity()); | 1576 EXPECT_FLOAT_EQ(2.0f / 3.0f, scrollbar_layer_->Opacity()); |
1527 | 1577 |
1528 scrollbar_controller_->DidScrollBegin(); | 1578 scrollbar_controller_->DidScrollBegin(); |
1529 EXPECT_FLOAT_EQ(2.0f / 3.0f, scrollbar_layer_->Opacity()); | 1579 EXPECT_FLOAT_EQ(2.0f / 3.0f, scrollbar_layer_->Opacity()); |
1530 | 1580 |
1531 time += base::TimeDelta::FromSeconds(1); | 1581 time += base::TimeDelta::FromSeconds(1); |
1532 scrollbar_controller_->Animate(time); | 1582 scrollbar_controller_->Animate(time); |
1533 EXPECT_TRUE(did_request_animate_); | 1583 EXPECT_TRUE(did_request_animate_); |
1534 did_request_animate_ = false; | 1584 did_request_animate_ = false; |
1535 EXPECT_FLOAT_EQ(1.0f / 3.0f, scrollbar_layer_->Opacity()); | 1585 EXPECT_FLOAT_EQ(1.0f / 3.0f, scrollbar_layer_->Opacity()); |
1536 | 1586 |
1537 time += base::TimeDelta::FromSeconds(1); | 1587 time += base::TimeDelta::FromSeconds(1); |
1538 scrollbar_controller_->DidScrollUpdate(false); | 1588 scrollbar_controller_->DidScrollUpdate(); |
1539 EXPECT_FALSE(did_request_animate_); | 1589 EXPECT_FALSE(did_request_animate_); |
1540 EXPECT_FLOAT_EQ(1, scrollbar_layer_->Opacity()); | 1590 EXPECT_FLOAT_EQ(1, scrollbar_layer_->Opacity()); |
1541 | 1591 |
1542 time += base::TimeDelta::FromSeconds(1); | 1592 time += base::TimeDelta::FromSeconds(1); |
1543 scrollbar_controller_->DidScrollEnd(); | 1593 scrollbar_controller_->DidScrollEnd(); |
1544 EXPECT_FALSE(did_request_animate_); | 1594 EXPECT_FALSE(did_request_animate_); |
1545 EXPECT_FLOAT_EQ(1, scrollbar_layer_->Opacity()); | 1595 EXPECT_FLOAT_EQ(1, scrollbar_layer_->Opacity()); |
1546 } | 1596 } |
1547 | 1597 |
1548 } // namespace | 1598 } // namespace |
1549 } // namespace cc | 1599 } // namespace cc |
OLD | NEW |