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