OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef UI_VIEWS_ANIMATION_INK_DROP_ANIMATION_CONTROLLER_FACTORY_UNITTEST_H_ | 5 #ifndef UI_VIEWS_ANIMATION_INK_DROP_ANIMATION_CONTROLLER_FACTORY_UNITTEST_H_ |
6 #define UI_VIEWS_ANIMATION_INK_DROP_ANIMATION_CONTROLLER_FACTORY_UNITTEST_H_ | 6 #define UI_VIEWS_ANIMATION_INK_DROP_ANIMATION_CONTROLLER_FACTORY_UNITTEST_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
11 #include "ui/base/test/material_design_controller_test_api.h" | 11 #include "ui/base/test/material_design_controller_test_api.h" |
12 #include "ui/views/animation/ink_drop_animation_controller.h" | 12 #include "ui/views/animation/ink_drop_animation_controller.h" |
13 #include "ui/views/animation/ink_drop_animation_controller_factory.h" | 13 #include "ui/views/animation/ink_drop_animation_controller_factory.h" |
14 #include "ui/views/animation/ink_drop_host.h" | 14 #include "ui/views/animation/ink_drop_host.h" |
15 #include "ui/views/animation/ink_drop_state.h" | 15 #include "ui/views/animation/ink_drop_state.h" |
16 #include "ui/views/animation/test/test_ink_drop_host.h" | 16 #include "ui/views/animation/test/test_ink_drop_host.h" |
17 | 17 |
18 namespace views { | 18 namespace views { |
19 | 19 |
20 // Macro that will execute |test_code| against all derivatives of the | 20 // Macro that will execute |test_code| against all derivatives of the |
21 // InkDropAnimationController returned by the InkDropAnimationControllerFactory. | 21 // InkDropAnimationController returned by the InkDropAnimationControllerFactory. |
| 22 // TODO(bruthig): Refactor these tests to use TEST_P and |
| 23 // INSTANTIATE_TEST_CASE_P. |
22 #define TEST_ALL_INK_DROPS(test_name, test_code) \ | 24 #define TEST_ALL_INK_DROPS(test_name, test_code) \ |
23 TEST_F(InkDropAnimationControllerFactoryTest, test_name) \ | 25 TEST_F(InkDropAnimationControllerFactoryTest, test_name) \ |
24 test_code TEST_F(MDInkDropAnimationControllerFactoryTest, test_name) test_code | 26 test_code TEST_F(MDInkDropAnimationControllerFactoryTest, test_name) test_code |
25 | 27 |
26 // Test fixture to test the non material design InkDropAnimationController. | 28 // Test fixture to test the non material design InkDropAnimationController. |
27 class InkDropAnimationControllerFactoryTest : public testing::Test { | 29 class InkDropAnimationControllerFactoryTest : public testing::Test { |
28 public: | 30 public: |
29 InkDropAnimationControllerFactoryTest() {} | 31 InkDropAnimationControllerFactoryTest() {} |
30 ~InkDropAnimationControllerFactoryTest() override {} | 32 ~InkDropAnimationControllerFactoryTest() override {} |
31 | 33 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 private: | 74 private: |
73 DISALLOW_COPY_AND_ASSIGN(MDInkDropAnimationControllerFactoryTest); | 75 DISALLOW_COPY_AND_ASSIGN(MDInkDropAnimationControllerFactoryTest); |
74 }; | 76 }; |
75 | 77 |
76 void MDInkDropAnimationControllerFactoryTest::SetUp() { | 78 void MDInkDropAnimationControllerFactoryTest::SetUp() { |
77 ui::test::MaterialDesignControllerTestAPI::SetMode( | 79 ui::test::MaterialDesignControllerTestAPI::SetMode( |
78 ui::MaterialDesignController::MATERIAL_NORMAL); | 80 ui::MaterialDesignController::MATERIAL_NORMAL); |
79 InkDropAnimationControllerFactoryTest::SetUp(); | 81 InkDropAnimationControllerFactoryTest::SetUp(); |
80 } | 82 } |
81 | 83 |
| 84 TEST_ALL_INK_DROPS( |
| 85 VerifyAllInkDropLayersRemovedAfterDestruction, |
| 86 { |
| 87 ink_drop_animation_controller_->AnimateToState( |
| 88 InkDropState::ACTION_PENDING); |
| 89 ink_drop_animation_controller_.reset(); |
| 90 EXPECT_EQ(0, test_ink_drop_host_.num_ink_drop_layers()); |
| 91 }) |
| 92 |
82 TEST_ALL_INK_DROPS(StateIsHiddenInitially, | 93 TEST_ALL_INK_DROPS(StateIsHiddenInitially, |
83 { | 94 { |
84 EXPECT_EQ( | 95 EXPECT_EQ( |
85 InkDropState::HIDDEN, | 96 InkDropState::HIDDEN, |
86 ink_drop_animation_controller_->GetInkDropState()); | 97 ink_drop_animation_controller_->GetInkDropState()); |
87 }) | 98 }) |
88 | 99 |
89 TEST_ALL_INK_DROPS(TypicalQuickAction, | 100 TEST_ALL_INK_DROPS(TypicalQuickAction, |
90 { | 101 { |
91 ink_drop_animation_controller_->AnimateToState( | 102 ink_drop_animation_controller_->AnimateToState( |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 InkDropState::SLOW_ACTION_PENDING); | 165 InkDropState::SLOW_ACTION_PENDING); |
155 ink_drop_animation_controller_->AnimateToState(InkDropState::ACTIVATED); | 166 ink_drop_animation_controller_->AnimateToState(InkDropState::ACTIVATED); |
156 ink_drop_animation_controller_->AnimateToState(InkDropState::DEACTIVATED); | 167 ink_drop_animation_controller_->AnimateToState(InkDropState::DEACTIVATED); |
157 EXPECT_EQ(InkDropState::HIDDEN, | 168 EXPECT_EQ(InkDropState::HIDDEN, |
158 ink_drop_animation_controller_->GetInkDropState()); | 169 ink_drop_animation_controller_->GetInkDropState()); |
159 }) | 170 }) |
160 | 171 |
161 } // namespace views | 172 } // namespace views |
162 | 173 |
163 #endif // UI_VIEWS_ANIMATION_INK_DROP_ANIMATION_CONTROLLER_FACTORY_UNITTEST_H_ | 174 #endif // UI_VIEWS_ANIMATION_INK_DROP_ANIMATION_CONTROLLER_FACTORY_UNITTEST_H_ |
OLD | NEW |