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

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: rebase and fix tests Created 4 years, 4 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') | ui/views/animation/test/ink_drop_impl_test_api.h » ('j') | 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 EXPECT_EQ(0, ink_drop_host_.num_ink_drop_layers());
258
259 ink_drop_.AnimateToState(InkDropState::ACTIVATED);
260 EXPECT_EQ(1, ink_drop_host_.num_ink_drop_layers());
261 test_api_.CompleteAnimations();
262
263 ink_drop_.AnimateToState(InkDropState::DEACTIVATED);
264 EXPECT_EQ(1, ink_drop_host_.num_ink_drop_layers());
265 EXPECT_TRUE(test_api_.HasActiveAnimations());
266 EXPECT_FALSE(test_api_.IsHighlightFadingInOrVisible());
267 }
268
269 TEST_F(InkDropImplTest, AnimationSkippedWhenFocusedAndDeactivated) {
270 ink_drop_host_.set_should_show_highlight(true);
271
272 EXPECT_EQ(0, ink_drop_host_.num_ink_drop_layers());
273
274 ink_drop_.SetFocused(true);
275 EXPECT_EQ(1, ink_drop_host_.num_ink_drop_layers());
276
277 ink_drop_.AnimateToState(InkDropState::ACTIVATED);
278 EXPECT_EQ(1, ink_drop_host_.num_ink_drop_layers());
279 test_api_.CompleteAnimations();
280
281 ink_drop_.AnimateToState(InkDropState::DEACTIVATED);
282 EXPECT_EQ(1, ink_drop_host_.num_ink_drop_layers());
283 EXPECT_FALSE(test_api_.HasActiveAnimations());
284 EXPECT_TRUE(test_api_.IsHighlightFadingInOrVisible());
285 EXPECT_EQ(InkDropState::HIDDEN, test_api_.ripple()->target_ink_drop_state());
bruthig 2016/07/25 22:13:20 nit: Why not use InkDrop::GetTargetInkDropState()?
Evan Stade 2016/07/25 22:20:05 no reason, done
286 }
287
288 TEST_F(InkDropImplTest, FocusHighlightComesBackImmediatelyAfterAction) {
289 ink_drop_host_.set_should_show_highlight(true);
290
291 EXPECT_EQ(0, ink_drop_host_.num_ink_drop_layers());
292
293 ink_drop_.SetFocused(true);
294 EXPECT_EQ(1, ink_drop_host_.num_ink_drop_layers());
295
296 ink_drop_.AnimateToState(InkDropState::ACTION_PENDING);
297 EXPECT_EQ(1, ink_drop_host_.num_ink_drop_layers());
298
299 ink_drop_.AnimateToState(InkDropState::ACTION_TRIGGERED);
300 EXPECT_EQ(1, ink_drop_host_.num_ink_drop_layers());
301
302 test_api_.CompleteAnimations();
303
304 // No delay (unlike in the hover case).
305 EXPECT_FALSE(task_runner_->HasPendingTask());
306
307 // Highlight should be back.
308 EXPECT_TRUE(test_api_.IsHighlightFadingInOrVisible());
309 }
310
256 } // namespace views 311 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/animation/ink_drop_impl.cc ('k') | ui/views/animation/test/ink_drop_impl_test_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698