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