| 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 eb32904b8a5fea360b1301245143d030205c6962..1743c59355dfc156692ef6956c0b0269026ad88c 100644
|
| --- a/ui/views/animation/ink_drop_animation_controller_factory_unittest.cc
|
| +++ b/ui/views/animation/ink_drop_animation_controller_factory_unittest.cc
|
| @@ -2,13 +2,12 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#ifndef UI_VIEWS_ANIMATION_INK_DROP_ANIMATION_CONTROLLER_FACTORY_UNITTEST_H_
|
| -#define UI_VIEWS_ANIMATION_INK_DROP_ANIMATION_CONTROLLER_FACTORY_UNITTEST_H_
|
| -
|
| #include "base/macros.h"
|
| #include "base/memory/scoped_ptr.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_host.h"
|
| @@ -17,23 +16,11 @@
|
|
|
| namespace views {
|
|
|
| -// Macro that will execute |test_code| against all derivatives of the
|
| -// InkDropAnimationController returned by the InkDropAnimationControllerFactory.
|
| -// TODO(bruthig): Refactor these tests to use TEST_P and
|
| -// INSTANTIATE_TEST_CASE_P.
|
| -#define TEST_ALL_INK_DROPS(test_name, test_code) \
|
| - TEST_F(InkDropAnimationControllerFactoryTest, test_name) \
|
| - test_code TEST_F(MDInkDropAnimationControllerFactoryTest, test_name) test_code
|
| -
|
| -// Test fixture to test the non material design InkDropAnimationController.
|
| -class InkDropAnimationControllerFactoryTest : public testing::Test {
|
| +class InkDropAnimationControllerFactoryTest
|
| + : public testing::TestWithParam<ui::MaterialDesignController::Mode> {
|
| public:
|
| - InkDropAnimationControllerFactoryTest() {}
|
| - ~InkDropAnimationControllerFactoryTest() override {}
|
| -
|
| - // testing::Test:
|
| - void SetUp() override;
|
| - void TearDown() override;
|
| + InkDropAnimationControllerFactoryTest();
|
| + ~InkDropAnimationControllerFactoryTest();
|
|
|
| protected:
|
| // A dummy InkDropHost required to create an InkDropAnimationController.
|
| @@ -44,130 +31,102 @@ class InkDropAnimationControllerFactoryTest : public testing::Test {
|
| scoped_ptr<InkDropAnimationController> ink_drop_animation_controller_;
|
|
|
| private:
|
| + scoped_ptr<ui::ScopedAnimationDurationScaleMode> zero_duration_mode_;
|
| +
|
| DISALLOW_COPY_AND_ASSIGN(InkDropAnimationControllerFactoryTest);
|
| };
|
|
|
| -void InkDropAnimationControllerFactoryTest::SetUp() {
|
| +InkDropAnimationControllerFactoryTest::InkDropAnimationControllerFactoryTest()
|
| + : ink_drop_animation_controller_(nullptr) {
|
| // Any call by a previous test to MaterialDesignController::GetMode() will
|
| // initialize and cache the mode. This ensures that these tests will run from
|
| // a non-initialized state.
|
| ui::test::MaterialDesignControllerTestAPI::UninitializeMode();
|
| -
|
| - ink_drop_animation_controller_ =
|
| + ui::test::MaterialDesignControllerTestAPI::SetMode(GetParam());
|
| + ink_drop_animation_controller_.reset(
|
| InkDropAnimationControllerFactory::CreateInkDropAnimationController(
|
| - &test_ink_drop_host_);
|
| + &test_ink_drop_host_)
|
| + .release());
|
| + ink_drop_animation_controller_->SetInkDropSize(gfx::Size(10, 10), 4,
|
| + gfx::Size(8, 8), 2);
|
| +
|
| + zero_duration_mode_.reset(new ui::ScopedAnimationDurationScaleMode(
|
| + ui::ScopedAnimationDurationScaleMode::ZERO_DURATION));
|
| }
|
|
|
| -void InkDropAnimationControllerFactoryTest::TearDown() {
|
| +InkDropAnimationControllerFactoryTest::
|
| + ~InkDropAnimationControllerFactoryTest() {
|
| ui::test::MaterialDesignControllerTestAPI::UninitializeMode();
|
| }
|
|
|
| -// Test fixture to test the material design InkDropAnimationController.
|
| -class MDInkDropAnimationControllerFactoryTest
|
| - : public InkDropAnimationControllerFactoryTest {
|
| - public:
|
| - MDInkDropAnimationControllerFactoryTest() {}
|
| +// Note: First argument is optional and intentionally left blank.
|
| +// (it's a prefix for the generated test cases)
|
| +INSTANTIATE_TEST_CASE_P(
|
| + ,
|
| + InkDropAnimationControllerFactoryTest,
|
| + testing::Values(ui::MaterialDesignController::NON_MATERIAL,
|
| + ui::MaterialDesignController::MATERIAL_NORMAL));
|
| +
|
| +TEST_P(InkDropAnimationControllerFactoryTest,
|
| + VerifyAllInkDropLayersRemovedAfterDestruction) {
|
| + ink_drop_animation_controller_->AnimateToState(InkDropState::ACTION_PENDING);
|
| + ink_drop_animation_controller_.reset();
|
| + EXPECT_EQ(0, test_ink_drop_host_.num_ink_drop_layers());
|
| +}
|
|
|
| - // InkDropAnimationControllerFactoryTest:
|
| - void SetUp() override;
|
| +TEST_P(InkDropAnimationControllerFactoryTest, StateIsHiddenInitially) {
|
| + EXPECT_EQ(InkDropState::HIDDEN,
|
| + ink_drop_animation_controller_->GetInkDropState());
|
| +}
|
|
|
| - private:
|
| - DISALLOW_COPY_AND_ASSIGN(MDInkDropAnimationControllerFactoryTest);
|
| -};
|
| +TEST_P(InkDropAnimationControllerFactoryTest, TypicalQuickAction) {
|
| + ink_drop_animation_controller_->AnimateToState(InkDropState::ACTION_PENDING);
|
| + ink_drop_animation_controller_->AnimateToState(InkDropState::QUICK_ACTION);
|
| + EXPECT_EQ(InkDropState::HIDDEN,
|
| + ink_drop_animation_controller_->GetInkDropState());
|
| +}
|
|
|
| -void MDInkDropAnimationControllerFactoryTest::SetUp() {
|
| - ui::test::MaterialDesignControllerTestAPI::SetMode(
|
| - ui::MaterialDesignController::MATERIAL_NORMAL);
|
| - InkDropAnimationControllerFactoryTest::SetUp();
|
| +TEST_P(InkDropAnimationControllerFactoryTest, CancelQuickAction) {
|
| + ink_drop_animation_controller_->AnimateToState(InkDropState::ACTION_PENDING);
|
| + ink_drop_animation_controller_->AnimateToState(InkDropState::HIDDEN);
|
| + EXPECT_EQ(InkDropState::HIDDEN,
|
| + ink_drop_animation_controller_->GetInkDropState());
|
| }
|
|
|
| -TEST_ALL_INK_DROPS(VerifyAllInkDropLayersRemovedAfterDestruction,
|
| - {
|
| - ink_drop_animation_controller_->AnimateToState(
|
| - InkDropState::ACTION_PENDING);
|
| - ink_drop_animation_controller_.reset();
|
| - EXPECT_EQ(0, test_ink_drop_host_.num_ink_drop_layers());
|
| - })
|
| -
|
| -TEST_ALL_INK_DROPS(StateIsHiddenInitially,
|
| - {
|
| - EXPECT_EQ(
|
| - InkDropState::HIDDEN,
|
| - ink_drop_animation_controller_->GetInkDropState());
|
| - })
|
| -
|
| -TEST_ALL_INK_DROPS(TypicalQuickAction,
|
| - {
|
| - ink_drop_animation_controller_->AnimateToState(
|
| - InkDropState::ACTION_PENDING);
|
| - ink_drop_animation_controller_->AnimateToState(
|
| - InkDropState::QUICK_ACTION);
|
| - EXPECT_EQ(
|
| - InkDropState::HIDDEN,
|
| - ink_drop_animation_controller_->GetInkDropState());
|
| - })
|
| -
|
| -TEST_ALL_INK_DROPS(CancelQuickAction,
|
| - {
|
| - ink_drop_animation_controller_->AnimateToState(
|
| - InkDropState::ACTION_PENDING);
|
| - ink_drop_animation_controller_->AnimateToState(
|
| - InkDropState::HIDDEN);
|
| - EXPECT_EQ(
|
| - InkDropState::HIDDEN,
|
| - ink_drop_animation_controller_->GetInkDropState());
|
| - })
|
| -
|
| -TEST_ALL_INK_DROPS(TypicalSlowAction,
|
| - {
|
| - ink_drop_animation_controller_->AnimateToState(
|
| - InkDropState::ACTION_PENDING);
|
| - ink_drop_animation_controller_->AnimateToState(
|
| - InkDropState::SLOW_ACTION_PENDING);
|
| - ink_drop_animation_controller_->AnimateToState(
|
| - InkDropState::SLOW_ACTION);
|
| - EXPECT_EQ(
|
| - InkDropState::HIDDEN,
|
| - ink_drop_animation_controller_->GetInkDropState());
|
| - })
|
| -
|
| -TEST_ALL_INK_DROPS(CancelSlowAction,
|
| - {
|
| - ink_drop_animation_controller_->AnimateToState(
|
| - InkDropState::ACTION_PENDING);
|
| - ink_drop_animation_controller_->AnimateToState(
|
| - InkDropState::SLOW_ACTION_PENDING);
|
| - ink_drop_animation_controller_->AnimateToState(
|
| - InkDropState::HIDDEN);
|
| - EXPECT_EQ(
|
| - InkDropState::HIDDEN,
|
| - ink_drop_animation_controller_->GetInkDropState());
|
| - })
|
| -
|
| -TEST_ALL_INK_DROPS(
|
| - TypicalQuickActivated,
|
| - {
|
| - ink_drop_animation_controller_->AnimateToState(
|
| - InkDropState::ACTION_PENDING);
|
| - ink_drop_animation_controller_->AnimateToState(InkDropState::ACTIVATED);
|
| - ink_drop_animation_controller_->AnimateToState(InkDropState::DEACTIVATED);
|
| - EXPECT_EQ(InkDropState::HIDDEN,
|
| - ink_drop_animation_controller_->GetInkDropState());
|
| - })
|
| -
|
| -TEST_ALL_INK_DROPS(
|
| - TypicalSlowActivated,
|
| - {
|
| - ink_drop_animation_controller_->AnimateToState(
|
| - InkDropState::ACTION_PENDING);
|
| - ink_drop_animation_controller_->AnimateToState(
|
| - InkDropState::SLOW_ACTION_PENDING);
|
| - ink_drop_animation_controller_->AnimateToState(InkDropState::ACTIVATED);
|
| - ink_drop_animation_controller_->AnimateToState(InkDropState::DEACTIVATED);
|
| - EXPECT_EQ(InkDropState::HIDDEN,
|
| - ink_drop_animation_controller_->GetInkDropState());
|
| - })
|
| +TEST_P(InkDropAnimationControllerFactoryTest, TypicalSlowAction) {
|
| + ink_drop_animation_controller_->AnimateToState(InkDropState::ACTION_PENDING);
|
| + ink_drop_animation_controller_->AnimateToState(
|
| + InkDropState::SLOW_ACTION_PENDING);
|
| + ink_drop_animation_controller_->AnimateToState(InkDropState::SLOW_ACTION);
|
| + EXPECT_EQ(InkDropState::HIDDEN,
|
| + ink_drop_animation_controller_->GetInkDropState());
|
| +}
|
|
|
| -} // namespace views
|
| +TEST_P(InkDropAnimationControllerFactoryTest, CancelSlowAction) {
|
| + ink_drop_animation_controller_->AnimateToState(InkDropState::ACTION_PENDING);
|
| + ink_drop_animation_controller_->AnimateToState(
|
| + InkDropState::SLOW_ACTION_PENDING);
|
| + ink_drop_animation_controller_->AnimateToState(InkDropState::HIDDEN);
|
| + EXPECT_EQ(InkDropState::HIDDEN,
|
| + ink_drop_animation_controller_->GetInkDropState());
|
| +}
|
|
|
| -#endif // UI_VIEWS_ANIMATION_INK_DROP_ANIMATION_CONTROLLER_FACTORY_UNITTEST_H_
|
| +TEST_P(InkDropAnimationControllerFactoryTest, TypicalQuickActivated) {
|
| + ink_drop_animation_controller_->AnimateToState(InkDropState::ACTION_PENDING);
|
| + ink_drop_animation_controller_->AnimateToState(InkDropState::ACTIVATED);
|
| + ink_drop_animation_controller_->AnimateToState(InkDropState::DEACTIVATED);
|
| + EXPECT_EQ(InkDropState::HIDDEN,
|
| + ink_drop_animation_controller_->GetInkDropState());
|
| +}
|
| +
|
| +TEST_P(InkDropAnimationControllerFactoryTest, TypicalSlowActivated) {
|
| + ink_drop_animation_controller_->AnimateToState(InkDropState::ACTION_PENDING);
|
| + ink_drop_animation_controller_->AnimateToState(
|
| + InkDropState::SLOW_ACTION_PENDING);
|
| + ink_drop_animation_controller_->AnimateToState(InkDropState::ACTIVATED);
|
| + ink_drop_animation_controller_->AnimateToState(InkDropState::DEACTIVATED);
|
| + EXPECT_EQ(InkDropState::HIDDEN,
|
| + ink_drop_animation_controller_->GetInkDropState());
|
| +}
|
| +
|
| +} // namespace views
|
|
|