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

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

Issue 2125223004: Restore focus-state ink drop highlight on buttons after ripple animation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add some tests Created 4 years, 5 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
« no previous file with comments | « ui/views/animation/ink_drop_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_impl.h" 5 #include "ui/views/animation/ink_drop_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/threading/thread_task_runner_handle.h" 9 #include "base/threading/thread_task_runner_handle.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 246
247 test_api_.CompleteAnimations(); 247 test_api_.CompleteAnimations();
248 248
249 ink_drop_.SetHovered(false); 249 ink_drop_.SetHovered(false);
250 EXPECT_EQ(1, ink_drop_host_.num_ink_drop_layers()); 250 EXPECT_EQ(1, ink_drop_host_.num_ink_drop_layers());
251 251
252 ink_drop_.SetHovered(true); 252 ink_drop_.SetHovered(true);
253 EXPECT_EQ(1, ink_drop_host_.num_ink_drop_layers()); 253 EXPECT_EQ(1, ink_drop_host_.num_ink_drop_layers());
254 } 254 }
255 255
256 TEST_F(InkDropImplTest, AnimationWhenDeactivated) {
257 ink_drop_host_.set_should_show_highlight(true);
258
259 EXPECT_EQ(0, ink_drop_host_.num_ink_drop_layers());
260
261 ink_drop_.AnimateToState(InkDropState::ACTIVATED);
262 EXPECT_EQ(1, ink_drop_host_.num_ink_drop_layers());
263 test_api_.CompleteAnimations();
264
265 ink_drop_.AnimateToState(InkDropState::DEACTIVATED);
266 EXPECT_EQ(1, ink_drop_host_.num_ink_drop_layers());
267 EXPECT_TRUE(test_api_.HasActiveAnimations());
bruthig 2016/07/13 21:11:38 nit: test_api_.HasActiveAnimations() could return
Evan Stade 2016/07/25 22:00:42 Done, sorta
268 }
269
270 TEST_F(InkDropImplTest, AnimationSkippedWhenFocusedAndDeactivated) {
271 ink_drop_host_.set_should_show_highlight(true);
272
273 EXPECT_EQ(0, ink_drop_host_.num_ink_drop_layers());
274
275 ink_drop_.SetFocused(true);
276 EXPECT_EQ(1, ink_drop_host_.num_ink_drop_layers());
277
278 ink_drop_.AnimateToState(InkDropState::ACTIVATED);
279 EXPECT_EQ(1, ink_drop_host_.num_ink_drop_layers());
280 test_api_.CompleteAnimations();
281
282 ink_drop_.AnimateToState(InkDropState::DEACTIVATED);
283 EXPECT_EQ(1, ink_drop_host_.num_ink_drop_layers());
284 EXPECT_FALSE(test_api_.HasActiveAnimations());
bruthig 2016/07/13 21:11:38 nit: Might want to confirm the highlight is visibl
Evan Stade 2016/07/25 22:00:42 Done.
285 }
286
287 TEST_F(InkDropImplTest, FocusHighlightComesBackImmediatelyAfterAction) {
288 ink_drop_host_.set_should_show_highlight(true);
289
290 EXPECT_EQ(0, ink_drop_host_.num_ink_drop_layers());
291
292 ink_drop_.SetHovered(true);
bruthig 2016/07/13 21:11:38 I believe this should be SetFocused() and not hove
Evan Stade 2016/07/25 22:00:42 -_-
293 EXPECT_EQ(1, ink_drop_host_.num_ink_drop_layers());
294
295 ink_drop_.AnimateToState(InkDropState::ACTION_PENDING);
296 EXPECT_EQ(1, ink_drop_host_.num_ink_drop_layers());
297
298 ink_drop_.AnimateToState(InkDropState::ACTION_TRIGGERED);
299 EXPECT_EQ(1, ink_drop_host_.num_ink_drop_layers());
300
301 test_api_.CompleteAnimations();
302
303 // No delay (unlike in the hover case).
304 EXPECT_FALSE(task_runner_->HasPendingTask());
305
306 // Highlight should be back.
307 EXPECT_TRUE(test_api_.IsHighlightFadingInOrVisible());
308 }
309
256 } // namespace views 310 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/animation/ink_drop_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698