| 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 1743c59355dfc156692ef6956c0b0269026ad88c..915c60a4133285f75ff34b37633aa7ee18eea2b9 100644
|
| --- a/ui/views/animation/ink_drop_animation_controller_factory_unittest.cc
|
| +++ b/ui/views/animation/ink_drop_animation_controller_factory_unittest.cc
|
| @@ -4,21 +4,48 @@
|
|
|
| #include "base/macros.h"
|
| #include "base/memory/scoped_ptr.h"
|
| +#include "base/test/test_simple_task_runner.h"
|
| +#include "base/timer/timer.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
| #include "ui/base/resource/material_design/material_design_controller.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_host.h"
|
|
|
| namespace views {
|
| +typedef void SetupInkDropAnimationControllerFunc(InkDropAnimationController*);
|
| +
|
| +// Dummy no-op setup function that can be used with the
|
| +// InkDropAnimationControllerFactoryTest fixture.
|
| +void DummySetupInkDropAnimationController(InkDropAnimationController*) {}
|
|
|
| class InkDropAnimationControllerFactoryTest
|
| - : public testing::TestWithParam<ui::MaterialDesignController::Mode> {
|
| + : public testing::TestWithParam<
|
| + testing::tuple<ui::MaterialDesignController::Mode,
|
| + SetupInkDropAnimationControllerFunc*>> {
|
| public:
|
| + // InkDropAnimationController setup function to be used to configure all
|
| + // Material based controllers. Can be used when instantiating
|
| + // InkDropAnimationControllerFactoryTest fixtures.
|
| + //
|
| + // Note: This is implemented as a static member function because
|
| + // InkDropAnimationControllerImpl::hover_after_animation_timer_for_test() is
|
| + // private and is only accessible due to a friend declaration.
|
| + static void MDSetupInkDropAnimationController(
|
| + InkDropAnimationController* controller) {
|
| + InkDropAnimationControllerImpl* controller_impl =
|
| + reinterpret_cast<InkDropAnimationControllerImpl*>(controller);
|
| + scoped_refptr<base::TestSimpleTaskRunner> task_runner =
|
| + new base::TestSimpleTaskRunner();
|
| + controller_impl->hover_after_animation_timer_for_test()->SetTaskRunner(
|
| + task_runner);
|
| + }
|
| +
|
| InkDropAnimationControllerFactoryTest();
|
| ~InkDropAnimationControllerFactoryTest();
|
|
|
| @@ -42,7 +69,8 @@ InkDropAnimationControllerFactoryTest::InkDropAnimationControllerFactoryTest()
|
| // initialize and cache the mode. This ensures that these tests will run from
|
| // a non-initialized state.
|
| ui::test::MaterialDesignControllerTestAPI::UninitializeMode();
|
| - ui::test::MaterialDesignControllerTestAPI::SetMode(GetParam());
|
| + ui::test::MaterialDesignControllerTestAPI::SetMode(
|
| + testing::get<0>(GetParam()));
|
| ink_drop_animation_controller_.reset(
|
| InkDropAnimationControllerFactory::CreateInkDropAnimationController(
|
| &test_ink_drop_host_)
|
| @@ -52,6 +80,10 @@ InkDropAnimationControllerFactoryTest::InkDropAnimationControllerFactoryTest()
|
|
|
| zero_duration_mode_.reset(new ui::ScopedAnimationDurationScaleMode(
|
| ui::ScopedAnimationDurationScaleMode::ZERO_DURATION));
|
| +
|
| + SetupInkDropAnimationControllerFunc* setup_controller_func =
|
| + testing::get<1>(GetParam());
|
| + (*setup_controller_func)(ink_drop_animation_controller_.get());
|
| }
|
|
|
| InkDropAnimationControllerFactoryTest::
|
| @@ -64,8 +96,12 @@ InkDropAnimationControllerFactoryTest::
|
| INSTANTIATE_TEST_CASE_P(
|
| ,
|
| InkDropAnimationControllerFactoryTest,
|
| - testing::Values(ui::MaterialDesignController::NON_MATERIAL,
|
| - ui::MaterialDesignController::MATERIAL_NORMAL));
|
| + testing::Values(
|
| + testing::make_tuple(ui::MaterialDesignController::NON_MATERIAL,
|
| + &DummySetupInkDropAnimationController),
|
| + testing::make_tuple(ui::MaterialDesignController::MATERIAL_NORMAL,
|
| + &InkDropAnimationControllerFactoryTest::
|
| + MDSetupInkDropAnimationController)));
|
|
|
| TEST_P(InkDropAnimationControllerFactoryTest,
|
| VerifyAllInkDropLayersRemovedAfterDestruction) {
|
| @@ -79,6 +115,13 @@ TEST_P(InkDropAnimationControllerFactoryTest, StateIsHiddenInitially) {
|
| ink_drop_animation_controller_->GetInkDropState());
|
| }
|
|
|
| +TEST_P(InkDropAnimationControllerFactoryTest, HoveredStateAfterAnimateToState) {
|
| + ink_drop_animation_controller_->SetHovered(true);
|
| + ink_drop_animation_controller_->AnimateToState(InkDropState::QUICK_ACTION);
|
| +
|
| + EXPECT_FALSE(ink_drop_animation_controller_->IsHovered());
|
| +}
|
| +
|
| TEST_P(InkDropAnimationControllerFactoryTest, TypicalQuickAction) {
|
| ink_drop_animation_controller_->AnimateToState(InkDropState::ACTION_PENDING);
|
| ink_drop_animation_controller_->AnimateToState(InkDropState::QUICK_ACTION);
|
|
|