| Index: ui/views/animation/ink_drop_animation_controller_impl_unittest.cc
|
| diff --git a/ui/views/animation/ink_drop_animation_controller_impl_unittest.cc b/ui/views/animation/ink_drop_animation_controller_impl_unittest.cc
|
| index 96e2d3ed199d76b815fd53305cab02fb240f2488..f32787a4158163367f49ca5bfa83d3d6ea5a219d 100644
|
| --- a/ui/views/animation/ink_drop_animation_controller_impl_unittest.cc
|
| +++ b/ui/views/animation/ink_drop_animation_controller_impl_unittest.cc
|
| @@ -8,7 +8,8 @@
|
| #include "base/test/test_simple_task_runner.h"
|
| #include "base/thread_task_runner_handle.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
| -#include "ui/compositor/scoped_animation_duration_scale_mode.h"
|
| +#include "ui/views/animation/ink_drop_animation.h"
|
| +#include "ui/views/animation/test/ink_drop_animation_controller_impl_test_api.h"
|
| #include "ui/views/animation/test/test_ink_drop_host.h"
|
|
|
| namespace views {
|
| @@ -23,17 +24,12 @@ class InkDropAnimationControllerImplTest : public testing::Test {
|
| protected:
|
| TestInkDropHost ink_drop_host_;
|
|
|
| - bool is_hover_fading_in_or_visible() {
|
| - return ink_drop_animation_controller_.IsHoverFadingInOrVisible();
|
| - }
|
| -
|
| - const InkDropHover* hover() const {
|
| - return ink_drop_animation_controller_.hover_.get();
|
| - }
|
| -
|
| // The test target.
|
| InkDropAnimationControllerImpl ink_drop_animation_controller_;
|
|
|
| + // Allows privileged access to the the |ink_drop_hover_|.
|
| + test::InkDropAnimationControllerImplTestApi test_api_;
|
| +
|
| // Used to control the tasks scheduled by the InkDropAnimationControllerImpl's
|
| // Timer.
|
| scoped_refptr<base::TestSimpleTaskRunner> task_runner_;
|
| @@ -42,19 +38,16 @@ class InkDropAnimationControllerImplTest : public testing::Test {
|
| scoped_ptr<base::ThreadTaskRunnerHandle> thread_task_runner_handle_;
|
|
|
| private:
|
| - // Ensures all animations complete immediately.
|
| - scoped_ptr<ui::ScopedAnimationDurationScaleMode> zero_duration_mode_;
|
| -
|
| DISALLOW_COPY_AND_ASSIGN(InkDropAnimationControllerImplTest);
|
| };
|
|
|
| InkDropAnimationControllerImplTest::InkDropAnimationControllerImplTest()
|
| : ink_drop_animation_controller_(&ink_drop_host_),
|
| + test_api_(&ink_drop_animation_controller_),
|
| task_runner_(new base::TestSimpleTaskRunner),
|
| thread_task_runner_handle_(
|
| new base::ThreadTaskRunnerHandle(task_runner_)) {
|
| - zero_duration_mode_.reset(new ui::ScopedAnimationDurationScaleMode(
|
| - ui::ScopedAnimationDurationScaleMode::ZERO_DURATION));
|
| + ink_drop_host_.set_disable_timers_for_test(true);
|
| }
|
|
|
| InkDropAnimationControllerImplTest::~InkDropAnimationControllerImplTest() {}
|
| @@ -63,10 +56,12 @@ TEST_F(InkDropAnimationControllerImplTest, SetHoveredIsFadingInOrVisible) {
|
| ink_drop_host_.set_should_show_hover(true);
|
|
|
| ink_drop_animation_controller_.SetHovered(true);
|
| - EXPECT_TRUE(is_hover_fading_in_or_visible());
|
| + EXPECT_TRUE(test_api_.IsHoverFadingInOrVisible());
|
| +
|
| + test_api_.CompleteAnimations();
|
|
|
| ink_drop_animation_controller_.SetHovered(false);
|
| - EXPECT_FALSE(is_hover_fading_in_or_visible());
|
| + EXPECT_FALSE(test_api_.IsHoverFadingInOrVisible());
|
| }
|
|
|
| TEST_F(InkDropAnimationControllerImplTest,
|
| @@ -74,9 +69,10 @@ TEST_F(InkDropAnimationControllerImplTest,
|
| ink_drop_host_.set_should_show_hover(true);
|
| ink_drop_animation_controller_.SetHovered(false);
|
| ink_drop_animation_controller_.AnimateToState(InkDropState::ACTION_TRIGGERED);
|
| + test_api_.CompleteAnimations();
|
|
|
| EXPECT_FALSE(task_runner_->HasPendingTask());
|
| - EXPECT_FALSE(is_hover_fading_in_or_visible());
|
| + EXPECT_FALSE(test_api_.IsHoverFadingInOrVisible());
|
| }
|
|
|
| TEST_F(InkDropAnimationControllerImplTest,
|
| @@ -84,12 +80,13 @@ TEST_F(InkDropAnimationControllerImplTest,
|
| ink_drop_host_.set_should_show_hover(true);
|
| ink_drop_animation_controller_.SetHovered(true);
|
| ink_drop_animation_controller_.AnimateToState(InkDropState::ACTION_TRIGGERED);
|
| + test_api_.CompleteAnimations();
|
|
|
| EXPECT_TRUE(task_runner_->HasPendingTask());
|
|
|
| task_runner_->RunPendingTasks();
|
|
|
| - EXPECT_TRUE(is_hover_fading_in_or_visible());
|
| + EXPECT_TRUE(test_api_.IsHoverFadingInOrVisible());
|
| }
|
|
|
| TEST_F(InkDropAnimationControllerImplTest,
|
| @@ -97,12 +94,13 @@ TEST_F(InkDropAnimationControllerImplTest,
|
| ink_drop_host_.set_should_show_hover(false);
|
| ink_drop_animation_controller_.SetHovered(true);
|
| ink_drop_animation_controller_.AnimateToState(InkDropState::ACTION_TRIGGERED);
|
| + test_api_.CompleteAnimations();
|
|
|
| EXPECT_TRUE(task_runner_->HasPendingTask());
|
|
|
| task_runner_->RunPendingTasks();
|
|
|
| - EXPECT_FALSE(is_hover_fading_in_or_visible());
|
| + EXPECT_FALSE(test_api_.IsHoverFadingInOrVisible());
|
| }
|
|
|
| TEST_F(InkDropAnimationControllerImplTest,
|
| @@ -110,10 +108,11 @@ TEST_F(InkDropAnimationControllerImplTest,
|
| ink_drop_host_.set_should_show_hover(true);
|
|
|
| ink_drop_animation_controller_.SetHovered(true);
|
| - EXPECT_TRUE(is_hover_fading_in_or_visible());
|
| + test_api_.CompleteAnimations();
|
| + EXPECT_TRUE(test_api_.IsHoverFadingInOrVisible());
|
|
|
| ink_drop_animation_controller_.AnimateToState(InkDropState::ACTION_TRIGGERED);
|
| - EXPECT_FALSE(is_hover_fading_in_or_visible());
|
| + EXPECT_FALSE(test_api_.IsHoverFadingInOrVisible());
|
| }
|
|
|
| // Verifies that there is not a crash when setting hovered state and the host
|
| @@ -122,20 +121,21 @@ TEST_F(InkDropAnimationControllerImplTest,
|
| SetHoveredFalseWorksWhenNoInkDropHoverExists) {
|
| ink_drop_host_.set_should_show_hover(false);
|
| ink_drop_animation_controller_.SetHovered(true);
|
| - EXPECT_FALSE(hover());
|
| + EXPECT_FALSE(test_api_.hover());
|
| ink_drop_animation_controller_.SetHovered(false);
|
| - EXPECT_FALSE(hover());
|
| + EXPECT_FALSE(test_api_.hover());
|
| }
|
|
|
| TEST_F(InkDropAnimationControllerImplTest, HoverFadesOutOnSnapToActivated) {
|
| ink_drop_host_.set_should_show_hover(true);
|
| ink_drop_animation_controller_.SetHovered(true);
|
| + test_api_.CompleteAnimations();
|
|
|
| - EXPECT_TRUE(is_hover_fading_in_or_visible());
|
| + EXPECT_TRUE(test_api_.IsHoverFadingInOrVisible());
|
|
|
| ink_drop_animation_controller_.SnapToActivated();
|
|
|
| - EXPECT_FALSE(is_hover_fading_in_or_visible());
|
| + EXPECT_FALSE(test_api_.IsHoverFadingInOrVisible());
|
| }
|
|
|
| } // namespace views
|
|
|