| 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_thinning.h" | 5 #include "cc/input/scrollbar_animation_controller_thinning.h" |
| 6 | 6 |
| 7 #include "cc/layers/solid_color_scrollbar_layer_impl.h" | 7 #include "cc/layers/solid_color_scrollbar_layer_impl.h" |
| 8 #include "cc/test/fake_impl_task_runner_provider.h" | 8 #include "cc/test/fake_impl_task_runner_provider.h" |
| 9 #include "cc/test/fake_layer_tree_host_impl.h" | 9 #include "cc/test/fake_layer_tree_host_impl.h" |
| 10 #include "cc/test/geometry_test_utils.h" | 10 #include "cc/test/geometry_test_utils.h" |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 // call Animate once to start the animation(initial the last_awaken_time_), | 421 // call Animate once to start the animation(initial the last_awaken_time_), |
| 422 // now you can jump x seconds. | 422 // now you can jump x seconds. |
| 423 scrollbar_controller_->Animate(time); | 423 scrollbar_controller_->Animate(time); |
| 424 time += base::TimeDelta::FromSeconds(kDuration); | 424 time += base::TimeDelta::FromSeconds(kDuration); |
| 425 scrollbar_controller_->Animate(time); | 425 scrollbar_controller_->Animate(time); |
| 426 | 426 |
| 427 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); | 427 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); |
| 428 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor()); | 428 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor()); |
| 429 | 429 |
| 430 // Capture | 430 // Capture |
| 431 scrollbar_controller_->DidCaptureScrollbarBegin(); | 431 scrollbar_controller_->DidMouseDown(); |
| 432 time += base::TimeDelta::FromSeconds(1); | 432 time += base::TimeDelta::FromSeconds(1); |
| 433 scrollbar_controller_->Animate(time); | 433 scrollbar_controller_->Animate(time); |
| 434 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); | 434 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); |
| 435 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor()); | 435 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor()); |
| 436 | 436 |
| 437 // test for 10 seconds, stay thick and dark | 437 // test for 10 seconds, stay thick and dark |
| 438 for (int i = 0; i < 10; ++i) { | 438 for (int i = 0; i < 10; ++i) { |
| 439 // move away from bar. | 439 // move away from bar. |
| 440 scrollbar_controller_->DidMouseMoveNear(26 + i); | 440 scrollbar_controller_->DidMouseMoveNear(26 + i); |
| 441 time += base::TimeDelta::FromSeconds(1); | 441 time += base::TimeDelta::FromSeconds(1); |
| 442 scrollbar_controller_->Animate(time); | 442 scrollbar_controller_->Animate(time); |
| 443 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); | 443 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); |
| 444 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor()); | 444 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor()); |
| 445 } | 445 } |
| 446 | 446 |
| 447 // release | 447 // release |
| 448 scrollbar_controller_->DidCaptureScrollbarEnd(); | 448 scrollbar_controller_->DidMouseUp(); |
| 449 | 449 |
| 450 // get thickness and light | 450 // get thickness and light |
| 451 time += base::TimeDelta::FromSeconds(1); | 451 time += base::TimeDelta::FromSeconds(1); |
| 452 scrollbar_controller_->Animate(time); | 452 scrollbar_controller_->Animate(time); |
| 453 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); | 453 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); |
| 454 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor()); | 454 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor()); |
| 455 | 455 |
| 456 time += base::TimeDelta::FromSeconds(1); | 456 time += base::TimeDelta::FromSeconds(1); |
| 457 scrollbar_controller_->Animate(time); | 457 scrollbar_controller_->Animate(time); |
| 458 EXPECT_FLOAT_EQ(0.9f, scrollbar_layer_->Opacity()); | 458 EXPECT_FLOAT_EQ(0.9f, scrollbar_layer_->Opacity()); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 479 // Move in | 479 // Move in |
| 480 scrollbar_controller_->DidMouseMoveNear(0); | 480 scrollbar_controller_->DidMouseMoveNear(0); |
| 481 | 481 |
| 482 scrollbar_controller_->Animate(time); | 482 scrollbar_controller_->Animate(time); |
| 483 time += base::TimeDelta::FromSeconds(kDuration); | 483 time += base::TimeDelta::FromSeconds(kDuration); |
| 484 scrollbar_controller_->Animate(time); | 484 scrollbar_controller_->Animate(time); |
| 485 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); | 485 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); |
| 486 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor()); | 486 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor()); |
| 487 | 487 |
| 488 // Capture | 488 // Capture |
| 489 scrollbar_controller_->DidCaptureScrollbarBegin(); | 489 scrollbar_controller_->DidMouseDown(); |
| 490 time += base::TimeDelta::FromSeconds(1); | 490 time += base::TimeDelta::FromSeconds(1); |
| 491 scrollbar_controller_->Animate(time); | 491 scrollbar_controller_->Animate(time); |
| 492 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); | 492 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); |
| 493 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor()); | 493 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor()); |
| 494 | 494 |
| 495 // test for 10 seconds, stay thick and dark | 495 // test for 10 seconds, stay thick and dark |
| 496 for (int i = 0; i < 10; ++i) { | 496 for (int i = 0; i < 10; ++i) { |
| 497 // move away from bar. | 497 // move away from bar. |
| 498 scrollbar_controller_->DidMouseMoveNear(26 + i); | 498 scrollbar_controller_->DidMouseMoveNear(26 + i); |
| 499 time += base::TimeDelta::FromSeconds(1); | 499 time += base::TimeDelta::FromSeconds(1); |
| 500 scrollbar_controller_->Animate(time); | 500 scrollbar_controller_->Animate(time); |
| 501 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); | 501 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); |
| 502 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor()); | 502 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor()); |
| 503 } | 503 } |
| 504 | 504 |
| 505 // move to the bar. | 505 // move to the bar. |
| 506 scrollbar_controller_->DidMouseMoveNear(0); | 506 scrollbar_controller_->DidMouseMoveNear(0); |
| 507 | 507 |
| 508 // release | 508 // release |
| 509 scrollbar_controller_->DidCaptureScrollbarEnd(); | 509 scrollbar_controller_->DidMouseUp(); |
| 510 | 510 |
| 511 // stay thick and dark | 511 // stay thick and dark |
| 512 // test for 10 seconds, stay thick and dark | 512 // test for 10 seconds, stay thick and dark |
| 513 for (int i = 0; i < 10; ++i) { | 513 for (int i = 0; i < 10; ++i) { |
| 514 time += base::TimeDelta::FromSeconds(1); | 514 time += base::TimeDelta::FromSeconds(1); |
| 515 scrollbar_controller_->Animate(time); | 515 scrollbar_controller_->Animate(time); |
| 516 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); | 516 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); |
| 517 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor()); | 517 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor()); |
| 518 } | 518 } |
| 519 } | 519 } |
| 520 | 520 |
| 521 // Move mouse on scrollbar and capture then move out of window. Confirm that | 521 // Move mouse on scrollbar and capture then move out of window. Confirm that |
| 522 // the bar stays thick and dark. | 522 // the bar stays thick and dark. |
| 523 TEST_F(ScrollbarAnimationControllerThinningTest, | 523 TEST_F(ScrollbarAnimationControllerThinningTest, |
| 524 MouseCapturedAndExitWindowFromScrollbar) { | 524 MouseCapturedAndExitWindowFromScrollbar) { |
| 525 base::TimeTicks time; | 525 base::TimeTicks time; |
| 526 time += base::TimeDelta::FromSeconds(1); | 526 time += base::TimeDelta::FromSeconds(1); |
| 527 | 527 |
| 528 // Move in | 528 // Move in |
| 529 scrollbar_controller_->DidMouseMoveNear(0); | 529 scrollbar_controller_->DidMouseMoveNear(0); |
| 530 | 530 |
| 531 scrollbar_controller_->Animate(time); | 531 scrollbar_controller_->Animate(time); |
| 532 time += base::TimeDelta::FromSeconds(kDuration); | 532 time += base::TimeDelta::FromSeconds(kDuration); |
| 533 scrollbar_controller_->Animate(time); | 533 scrollbar_controller_->Animate(time); |
| 534 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); | 534 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); |
| 535 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor()); | 535 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor()); |
| 536 | 536 |
| 537 // Capture | 537 // Capture |
| 538 scrollbar_controller_->DidCaptureScrollbarBegin(); | 538 scrollbar_controller_->DidMouseDown(); |
| 539 time += base::TimeDelta::FromSeconds(1); | 539 time += base::TimeDelta::FromSeconds(1); |
| 540 scrollbar_controller_->Animate(time); | 540 scrollbar_controller_->Animate(time); |
| 541 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); | 541 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); |
| 542 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor()); | 542 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor()); |
| 543 | 543 |
| 544 // move out of window | 544 // move out of window |
| 545 scrollbar_controller_->DidMouseMoveOffScrollbar(); | 545 scrollbar_controller_->DidMouseMoveOffScrollbar(); |
| 546 | 546 |
| 547 // test for 10 seconds, stay thick and dark | 547 // test for 10 seconds, stay thick and dark |
| 548 for (int i = 0; i < 10; ++i) { | 548 for (int i = 0; i < 10; ++i) { |
| 549 time += base::TimeDelta::FromSeconds(1); | 549 time += base::TimeDelta::FromSeconds(1); |
| 550 scrollbar_controller_->Animate(time); | 550 scrollbar_controller_->Animate(time); |
| 551 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); | 551 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); |
| 552 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor()); | 552 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor()); |
| 553 } | 553 } |
| 554 } | 554 } |
| 555 | 555 |
| 556 } // namespace | 556 } // namespace |
| 557 } // namespace cc | 557 } // namespace cc |
| OLD | NEW |