| Index: ui/views/animation/ink_drop_animation_controller_factory_unittest.cc
|
| diff --git a/ui/views/animation/ink_drop_animation_controller_factory_unittest.cc b/ui/views/animation/ink_drop_animation_controller_factory_unittest.cc
|
| index 8f15a8286f68ad0e88d3deac7a4245d06beb0e18..b374ba1605634d2b8546a3e6fe837aa737592a11 100644
|
| --- a/ui/views/animation/ink_drop_animation_controller_factory_unittest.cc
|
| +++ b/ui/views/animation/ink_drop_animation_controller_factory_unittest.cc
|
| @@ -7,12 +7,16 @@
|
|
|
| #include "base/macros.h"
|
| #include "base/memory/scoped_ptr.h"
|
| +#include "base/timer/mock_timer.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
| #include "ui/base/test/material_design_controller_test_api.h"
|
| +#include "ui/compositor/scoped_animation_duration_scale_mode.h"
|
| #include "ui/views/animation/ink_drop_animation_controller.h"
|
| #include "ui/views/animation/ink_drop_animation_controller_factory.h"
|
| +#include "ui/views/animation/ink_drop_animation_controller_impl.h"
|
| #include "ui/views/animation/ink_drop_host.h"
|
| #include "ui/views/animation/ink_drop_state.h"
|
| +#include "ui/views/animation/test/test_ink_drop_consumer.h"
|
| #include "ui/views/animation/test/test_ink_drop_host.h"
|
|
|
| namespace views {
|
| @@ -34,9 +38,20 @@ class InkDropAnimationControllerFactoryTest : public testing::Test {
|
| void TearDown() override;
|
|
|
| protected:
|
| + // Template function called during SetUp() that sets the
|
| + // MaterialDesignController::Mode.
|
| + virtual void SetMaterialMode();
|
| +
|
| + // Template method called by SetUp() that can be used to configure the
|
| + // |ink_drop_animation_controller_| instance.
|
| + virtual void SetupInkDropAnimationController();
|
| +
|
| // A dummy InkDropHost required to create an InkDropAnimationController.
|
| TestInkDropHost test_ink_drop_host_;
|
|
|
| + // A dummy InkDropConsumer required to create an InkDropAnimationController.
|
| + test::TestInkDropConsumer test_ink_drop_consumer_;
|
| +
|
| // The InkDropAnimationController returned by the
|
| // InkDropAnimationControllerFactory test target.
|
| scoped_ptr<InkDropAnimationController> ink_drop_animation_controller_;
|
| @@ -51,15 +66,26 @@ void InkDropAnimationControllerFactoryTest::SetUp() {
|
| // a non-initialized state.
|
| ui::test::MaterialDesignControllerTestAPI::UninitializeMode();
|
|
|
| + SetMaterialMode();
|
| +
|
| ink_drop_animation_controller_ =
|
| InkDropAnimationControllerFactory::CreateInkDropAnimationController(
|
| - &test_ink_drop_host_);
|
| + &test_ink_drop_host_, &test_ink_drop_consumer_);
|
| +
|
| + SetupInkDropAnimationController();
|
| }
|
|
|
| void InkDropAnimationControllerFactoryTest::TearDown() {
|
| ui::test::MaterialDesignControllerTestAPI::UninitializeMode();
|
| }
|
|
|
| +void InkDropAnimationControllerFactoryTest::SetMaterialMode() {
|
| + ui::test::MaterialDesignControllerTestAPI::SetMode(
|
| + ui::MaterialDesignController::NON_MATERIAL);
|
| +}
|
| +
|
| +void InkDropAnimationControllerFactoryTest::SetupInkDropAnimationController() {}
|
| +
|
| // Test fixture to test the material design InkDropAnimationController.
|
| class MDInkDropAnimationControllerFactoryTest
|
| : public InkDropAnimationControllerFactoryTest {
|
| @@ -69,23 +95,62 @@ class MDInkDropAnimationControllerFactoryTest
|
| // InkDropAnimationControllerFactoryTest:
|
| void SetUp() override;
|
|
|
| + protected:
|
| + // InkDropAnimationControllerFactoryTest:
|
| + void SetMaterialMode() override;
|
| + void SetupInkDropAnimationController() override;
|
| +
|
| private:
|
| + scoped_ptr<ui::ScopedAnimationDurationScaleMode> zero_duration_mode_;
|
| +
|
| DISALLOW_COPY_AND_ASSIGN(MDInkDropAnimationControllerFactoryTest);
|
| };
|
|
|
| void MDInkDropAnimationControllerFactoryTest::SetUp() {
|
| + zero_duration_mode_.reset(new ui::ScopedAnimationDurationScaleMode(
|
| + ui::ScopedAnimationDurationScaleMode::ZERO_DURATION));
|
| + InkDropAnimationControllerFactoryTest::SetUp();
|
| +}
|
| +
|
| +void MDInkDropAnimationControllerFactoryTest::SetMaterialMode() {
|
| ui::test::MaterialDesignControllerTestAPI::SetMode(
|
| ui::MaterialDesignController::MATERIAL_NORMAL);
|
| - InkDropAnimationControllerFactoryTest::SetUp();
|
| }
|
|
|
| -TEST_ALL_INK_DROPS(StateIsHiddenInitially,
|
| +void MDInkDropAnimationControllerFactoryTest::
|
| + SetupInkDropAnimationController() {
|
| + InkDropAnimationControllerImpl* controller =
|
| + reinterpret_cast<InkDropAnimationControllerImpl*>(
|
| + ink_drop_animation_controller_.get());
|
| + controller->SetTimerForTest(new base::MockTimer(false, false));
|
| +}
|
| +
|
| +TEST_ALL_INK_DROPS(InitialState,
|
| {
|
| + EXPECT_FALSE(ink_drop_animation_controller_->IsHovered());
|
| EXPECT_EQ(
|
| InkDropState::HIDDEN,
|
| ink_drop_animation_controller_->GetInkDropState());
|
| })
|
|
|
| +TEST_ALL_INK_DROPS(SetHovered,
|
| + {
|
| + ink_drop_animation_controller_->SetHovered(true);
|
| + EXPECT_TRUE(ink_drop_animation_controller_->IsHovered());
|
| +
|
| + ink_drop_animation_controller_->SetHovered(false);
|
| + EXPECT_FALSE(ink_drop_animation_controller_->IsHovered());
|
| + })
|
| +
|
| +TEST_ALL_INK_DROPS(HoveredStateAfterAnimateToState,
|
| + {
|
| + ink_drop_animation_controller_->SetHovered(true);
|
| + ink_drop_animation_controller_->AnimateToState(
|
| + InkDropState::QUICK_ACTION);
|
| +
|
| + EXPECT_FALSE(ink_drop_animation_controller_->IsHovered());
|
| + })
|
| +
|
| TEST_ALL_INK_DROPS(TypicalQuickAction,
|
| {
|
| ink_drop_animation_controller_->AnimateToState(
|
|
|