Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(236)

Side by Side Diff: ui/views/animation/ink_drop_animation_controller_factory_unittest.cc

Issue 1298513003: Implemented prototype for new ink drop specs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments from patch set 10. Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef UI_VIEWS_ANIMATION_INK_DROP_ANIMATION_CONTROLLER_FACTORY_UNITTEST_H_
6 #define UI_VIEWS_ANIMATION_INK_DROP_ANIMATION_CONTROLLER_FACTORY_UNITTEST_H_
7
8 #include "base/macros.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "testing/gtest/include/gtest/gtest.h"
11 #include "ui/base/test/material_design_controller_test_api.h"
12 #include "ui/views/animation/ink_drop_animation_controller.h"
13 #include "ui/views/animation/ink_drop_animation_controller_factory.h"
14 #include "ui/views/animation/ink_drop_host.h"
15 #include "ui/views/animation/ink_drop_state.h"
16 #include "ui/views/animation/test/test_ink_drop_host.h"
17
18 namespace views {
19
20 // Macro that will execute |test_code| against all derivatives of the
21 // InkDropAnimationController returned by the InkDropAnimationControllerFactory.
22 #define TEST_ALL_INK_DROPS(test_name, test_code) \
23 TEST_F(InkDropAnimationControllerFactoryTest, test_name) \
24 test_code TEST_F(MDInkDropAnimationControllerFactoryTest, test_name) test_code
25
26 // Test fixture to test the non material design InkDropAnimationController.
27 class InkDropAnimationControllerFactoryTest : public testing::Test {
28 public:
29 InkDropAnimationControllerFactoryTest() {}
30 ~InkDropAnimationControllerFactoryTest() override {}
31
32 // testing::Test:
33 void SetUp() override;
34 void TearDown() override;
35
36 protected:
37 // A dummy InkDropHost required to create an InkDropAnimationController.
38 TestInkDropHost test_ink_drop_host_;
39
40 // The InkDropAnimationController returned by the
41 // InkDropAnimationControllerFactory test target.
42 scoped_ptr<InkDropAnimationController> ink_drop_animation_controller_;
43
44 private:
45 DISALLOW_COPY_AND_ASSIGN(InkDropAnimationControllerFactoryTest);
46 };
47
48 void InkDropAnimationControllerFactoryTest::SetUp() {
49 // Any call by a previous test to MaterialDesignController::GetMode() will
50 // initialize and cache the mode. This ensures that these tests will run from
51 // a non-initialized state.
52 ui::test::MaterialDesignControllerTestAPI::UninitializeMode();
53
54 ink_drop_animation_controller_ =
55 InkDropAnimationControllerFactory::CreateInkDropAnimationController(
56 &test_ink_drop_host_);
57 }
58
59 void InkDropAnimationControllerFactoryTest::TearDown() {
60 ui::test::MaterialDesignControllerTestAPI::UninitializeMode();
61 }
62
63 // Test fixture to test the material design InkDropAnimationController.
64 class MDInkDropAnimationControllerFactoryTest
65 : public InkDropAnimationControllerFactoryTest {
66 public:
67 MDInkDropAnimationControllerFactoryTest() {}
68
69 // InkDropAnimationControllerFactoryTest:
70 void SetUp() override;
71
72 private:
73 DISALLOW_COPY_AND_ASSIGN(MDInkDropAnimationControllerFactoryTest);
74 };
75
76 void MDInkDropAnimationControllerFactoryTest::SetUp() {
77 ui::test::MaterialDesignControllerTestAPI::SetMode(
78 ui::MaterialDesignController::MATERIAL_NORMAL);
79 InkDropAnimationControllerFactoryTest::SetUp();
80 }
81
82 TEST_ALL_INK_DROPS(StateIsHiddenInitially,
83 {
84 EXPECT_EQ(
85 InkDropState::HIDDEN,
86 ink_drop_animation_controller_->GetInkDropState());
87 })
88
89 TEST_ALL_INK_DROPS(TypicalQuickAction,
90 {
91 ink_drop_animation_controller_->AnimateToState(
92 InkDropState::ACTION_PENDING);
93 ink_drop_animation_controller_->AnimateToState(
94 InkDropState::QUICK_ACTION);
95 EXPECT_EQ(
96 InkDropState::HIDDEN,
97 ink_drop_animation_controller_->GetInkDropState());
98 })
99
100 TEST_ALL_INK_DROPS(CancelQuickAction,
101 {
102 ink_drop_animation_controller_->AnimateToState(
103 InkDropState::ACTION_PENDING);
104 ink_drop_animation_controller_->AnimateToState(
105 InkDropState::HIDDEN);
106 EXPECT_EQ(
107 InkDropState::HIDDEN,
108 ink_drop_animation_controller_->GetInkDropState());
109 })
110
111 TEST_ALL_INK_DROPS(TypicalSlowAction,
112 {
113 ink_drop_animation_controller_->AnimateToState(
114 InkDropState::ACTION_PENDING);
115 ink_drop_animation_controller_->AnimateToState(
116 InkDropState::SLOW_ACTION_PENDING);
117 ink_drop_animation_controller_->AnimateToState(
118 InkDropState::SLOW_ACTION);
119 EXPECT_EQ(
120 InkDropState::HIDDEN,
121 ink_drop_animation_controller_->GetInkDropState());
122 })
123
124 TEST_ALL_INK_DROPS(CancelSlowAction,
125 {
126 ink_drop_animation_controller_->AnimateToState(
127 InkDropState::ACTION_PENDING);
128 ink_drop_animation_controller_->AnimateToState(
129 InkDropState::SLOW_ACTION_PENDING);
130 ink_drop_animation_controller_->AnimateToState(
131 InkDropState::HIDDEN);
132 EXPECT_EQ(
133 InkDropState::HIDDEN,
134 ink_drop_animation_controller_->GetInkDropState());
135 })
136
137 TEST_ALL_INK_DROPS(
138 TypicalQuickActivated,
139 {
140 ink_drop_animation_controller_->AnimateToState(
141 InkDropState::ACTION_PENDING);
142 ink_drop_animation_controller_->AnimateToState(InkDropState::ACTIVATED);
143 ink_drop_animation_controller_->AnimateToState(InkDropState::DEACTIVATED);
144 EXPECT_EQ(InkDropState::HIDDEN,
145 ink_drop_animation_controller_->GetInkDropState());
146 })
147
148 TEST_ALL_INK_DROPS(
149 TypicalSlowActivated,
150 {
151 ink_drop_animation_controller_->AnimateToState(
152 InkDropState::ACTION_PENDING);
153 ink_drop_animation_controller_->AnimateToState(
154 InkDropState::SLOW_ACTION_PENDING);
155 ink_drop_animation_controller_->AnimateToState(InkDropState::ACTIVATED);
156 ink_drop_animation_controller_->AnimateToState(InkDropState::DEACTIVATED);
157 EXPECT_EQ(InkDropState::HIDDEN,
158 ink_drop_animation_controller_->GetInkDropState());
159 })
160
161 } // namespace views
162
163 #endif // UI_VIEWS_ANIMATION_INK_DROP_ANIMATION_CONTROLLER_FACTORY_UNITTEST_H_
OLDNEW
« no previous file with comments | « ui/views/animation/ink_drop_animation_controller_factory.cc ('k') | ui/views/animation/ink_drop_animation_controller_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698