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

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

Issue 1897073002: Add MD Ink Drop Layers to InkDropHost only when a ripple/hover is active. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed InkDropHoverTests to use proper expectation comparisons. Created 4 years, 7 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
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 #include "ui/views/animation/ink_drop_animation_controller_impl.h" 5 #include "ui/views/animation/ink_drop_animation_controller_impl.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/test/test_simple_task_runner.h" 8 #include "base/test/test_simple_task_runner.h"
9 #include "base/thread_task_runner_handle.h" 9 #include "base/thread_task_runner_handle.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 ink_drop_animation_controller_.SetHovered(true); 131 ink_drop_animation_controller_.SetHovered(true);
132 test_api_.CompleteAnimations(); 132 test_api_.CompleteAnimations();
133 133
134 EXPECT_TRUE(test_api_.IsHoverFadingInOrVisible()); 134 EXPECT_TRUE(test_api_.IsHoverFadingInOrVisible());
135 135
136 ink_drop_animation_controller_.SnapToActivated(); 136 ink_drop_animation_controller_.SnapToActivated();
137 137
138 EXPECT_FALSE(test_api_.IsHoverFadingInOrVisible()); 138 EXPECT_FALSE(test_api_.IsHoverFadingInOrVisible());
139 } 139 }
140 140
141 TEST_F(InkDropAnimationControllerImplTest, LayersRemovedFromHostAfterHover) {
142 ink_drop_host_.set_should_show_hover(true);
143
144 EXPECT_EQ(0, ink_drop_host_.num_ink_drop_layers());
145
146 ink_drop_animation_controller_.SetHovered(true);
147 EXPECT_EQ(1, ink_drop_host_.num_ink_drop_layers());
148
149 test_api_.CompleteAnimations();
150
151 ink_drop_animation_controller_.SetHovered(false);
152 EXPECT_EQ(1, ink_drop_host_.num_ink_drop_layers());
153
154 test_api_.CompleteAnimations();
155 EXPECT_EQ(0, ink_drop_host_.num_ink_drop_layers());
156 }
157
158 TEST_F(InkDropAnimationControllerImplTest, LayersRemovedFromHostAfterInkDrop) {
159 ink_drop_host_.set_should_show_hover(true);
160
161 EXPECT_EQ(0, ink_drop_host_.num_ink_drop_layers());
162
163 ink_drop_animation_controller_.AnimateToState(InkDropState::ACTION_PENDING);
164 EXPECT_EQ(1, ink_drop_host_.num_ink_drop_layers());
165
166 ink_drop_animation_controller_.AnimateToState(InkDropState::HIDDEN);
167 EXPECT_EQ(1, ink_drop_host_.num_ink_drop_layers());
168
169 test_api_.CompleteAnimations();
170 EXPECT_EQ(0, ink_drop_host_.num_ink_drop_layers());
171 }
172
173 TEST_F(InkDropAnimationControllerImplTest,
174 LayersAddedToHostWhenHoverOrInkDropVisible) {
175 ink_drop_host_.set_should_show_hover(true);
176
177 EXPECT_EQ(0, ink_drop_host_.num_ink_drop_layers());
178
179 ink_drop_animation_controller_.SetHovered(true);
180 EXPECT_EQ(1, ink_drop_host_.num_ink_drop_layers());
181
182 ink_drop_animation_controller_.AnimateToState(InkDropState::ACTION_PENDING);
183 EXPECT_EQ(1, ink_drop_host_.num_ink_drop_layers());
184
185 ink_drop_animation_controller_.AnimateToState(InkDropState::HIDDEN);
186 EXPECT_EQ(1, ink_drop_host_.num_ink_drop_layers());
187
188 test_api_.CompleteAnimations();
189 EXPECT_EQ(0, ink_drop_host_.num_ink_drop_layers());
190
191 EXPECT_TRUE(task_runner_->HasPendingTask());
192 task_runner_->RunPendingTasks();
193
194 // Hover should be fading back in.
195 EXPECT_TRUE(test_api_.HasActiveAnimations());
196 EXPECT_EQ(1, ink_drop_host_.num_ink_drop_layers());
197 }
198
199 TEST_F(InkDropAnimationControllerImplTest,
200 LayersNotAddedToHostWhenHoverTimeFires) {
201 ink_drop_host_.set_should_show_hover(true);
202
203 EXPECT_EQ(0, ink_drop_host_.num_ink_drop_layers());
204
205 ink_drop_animation_controller_.SetHovered(true);
206 EXPECT_EQ(1, ink_drop_host_.num_ink_drop_layers());
207
208 ink_drop_animation_controller_.AnimateToState(InkDropState::ACTION_PENDING);
209 EXPECT_EQ(1, ink_drop_host_.num_ink_drop_layers());
210
211 ink_drop_animation_controller_.AnimateToState(InkDropState::HIDDEN);
212 test_api_.CompleteAnimations();
213 EXPECT_EQ(0, ink_drop_host_.num_ink_drop_layers());
214
215 ink_drop_host_.set_should_show_hover(false);
216
217 EXPECT_TRUE(task_runner_->HasPendingTask());
218 task_runner_->RunPendingTasks();
219
220 EXPECT_EQ(0, ink_drop_host_.num_ink_drop_layers());
221 }
222
223 TEST_F(InkDropAnimationControllerImplTest,
224 LayersArentRemovedWhenPreemptingFadeOut) {
225 ink_drop_host_.set_should_show_hover(true);
226
227 EXPECT_EQ(0, ink_drop_host_.num_ink_drop_layers());
228
229 ink_drop_animation_controller_.SetHovered(true);
230 EXPECT_EQ(1, ink_drop_host_.num_ink_drop_layers());
231
232 test_api_.CompleteAnimations();
233
234 ink_drop_animation_controller_.SetHovered(false);
235 EXPECT_EQ(1, ink_drop_host_.num_ink_drop_layers());
236
237 ink_drop_animation_controller_.SetHovered(true);
238 EXPECT_EQ(1, ink_drop_host_.num_ink_drop_layers());
239 }
240
141 } // namespace views 241 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/animation/ink_drop_animation_controller_impl.cc ('k') | ui/views/animation/ink_drop_animation_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698