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

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

Issue 2250783002: Allow InkDropRipple to co-exist with highlight (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 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
« no previous file with comments | « ui/views/animation/ink_drop_impl.cc ('k') | ui/views/animation/ink_drop_ripple.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 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 TEST_F(InkDropImplTest, FocusHighlightComesBackImmediatelyAfterAction) { 287 TEST_F(InkDropImplTest, FocusHighlightComesBackImmediatelyAfterAction) {
288 ink_drop_host_.set_should_show_highlight(true); 288 ink_drop_host_.set_should_show_highlight(true);
289 289
290 EXPECT_EQ(0, ink_drop_host_.num_ink_drop_layers()); 290 EXPECT_EQ(0, ink_drop_host_.num_ink_drop_layers());
291 291
292 ink_drop_.SetFocused(true); 292 ink_drop_.SetFocused(true);
293 EXPECT_EQ(1, ink_drop_host_.num_ink_drop_layers()); 293 EXPECT_EQ(1, ink_drop_host_.num_ink_drop_layers());
294 294
295 ink_drop_.AnimateToState(InkDropState::ACTION_PENDING); 295 ink_drop_.AnimateToState(InkDropState::ACTION_PENDING);
296 EXPECT_EQ(1, ink_drop_host_.num_ink_drop_layers()); 296 EXPECT_EQ(1, ink_drop_host_.num_ink_drop_layers());
297 EXPECT_FALSE(test_api_.IsHighlightFadingInOrVisible());
297 298
298 ink_drop_.AnimateToState(InkDropState::ACTION_TRIGGERED); 299 ink_drop_.AnimateToState(InkDropState::ACTION_TRIGGERED);
299 EXPECT_EQ(1, ink_drop_host_.num_ink_drop_layers()); 300 EXPECT_EQ(1, ink_drop_host_.num_ink_drop_layers());
300 301
301 test_api_.CompleteAnimations(); 302 test_api_.CompleteAnimations();
302 303
303 // No delay (unlike in the hover case). 304 // No delay (unlike in the hover case).
304 EXPECT_FALSE(task_runner_->HasPendingTask()); 305 EXPECT_FALSE(task_runner_->HasPendingTask());
305 306
306 // Highlight should be back. 307 // Highlight should be back.
307 EXPECT_TRUE(test_api_.IsHighlightFadingInOrVisible()); 308 EXPECT_TRUE(test_api_.IsHighlightFadingInOrVisible());
308 } 309 }
309 310
311 TEST_F(InkDropImplTest, HighlightCanCoexistWithRipple) {
312 ink_drop_host_.set_should_show_highlight(true);
313 ink_drop_host_.set_ripple_overrides_highlight(false);
314
315 EXPECT_EQ(0, ink_drop_host_.num_ink_drop_layers());
316
317 ink_drop_.SetHovered(true);
318 EXPECT_EQ(1, ink_drop_host_.num_ink_drop_layers());
319
320 ink_drop_.AnimateToState(InkDropState::ACTION_PENDING);
321 EXPECT_EQ(1, ink_drop_host_.num_ink_drop_layers());
322 EXPECT_TRUE(test_api_.IsHighlightFadingInOrVisible());
323
324 ink_drop_.AnimateToState(InkDropState::ACTION_TRIGGERED);
325 EXPECT_EQ(1, ink_drop_host_.num_ink_drop_layers());
326 EXPECT_TRUE(test_api_.IsHighlightFadingInOrVisible());
327
328 test_api_.CompleteAnimations();
329
330 // Nothing to fade in because the highlight has always been visible.
331 EXPECT_FALSE(task_runner_->HasPendingTask());
332 EXPECT_TRUE(test_api_.IsHighlightFadingInOrVisible());
333
334 // Now try with the ripple showing before the highlight comes in.
335 ink_drop_.AnimateToState(InkDropState::HIDDEN);
336 ink_drop_.SetHovered(false);
337 test_api_.CompleteAnimations();
338 EXPECT_EQ(0, ink_drop_host_.num_ink_drop_layers());
339
340 ink_drop_.AnimateToState(InkDropState::ACTION_PENDING);
341 EXPECT_EQ(1, ink_drop_host_.num_ink_drop_layers());
bruthig 2016/09/09 16:05:47 Shouldn't this be 0?
Evan Stade 2016/09/09 18:55:48 why? we're animating the ripple in
bruthig 2016/09/09 19:30:05 I guess I was thinking of the IsVisible() clause b
342 ink_drop_.SetHovered(true);
343 EXPECT_EQ(1, ink_drop_host_.num_ink_drop_layers());
344 EXPECT_TRUE(test_api_.IsHighlightFadingInOrVisible());
345 }
346
347 TEST_F(InkDropImplTest, HighlightCanCoexistWithSnapToActivatedRipple) {
348 ink_drop_host_.set_should_show_highlight(true);
349 ink_drop_host_.set_ripple_overrides_highlight(false);
350
351 EXPECT_EQ(0, ink_drop_host_.num_ink_drop_layers());
352
353 ink_drop_.SetHovered(true);
354 EXPECT_EQ(1, ink_drop_host_.num_ink_drop_layers());
355
356 ink_drop_.SnapToActivated();
357 EXPECT_EQ(1, ink_drop_host_.num_ink_drop_layers());
358 EXPECT_TRUE(test_api_.IsHighlightFadingInOrVisible());
359
360 // Now try with the ripple showing before the highlight comes in.
361 ink_drop_.AnimateToState(InkDropState::HIDDEN);
362 ink_drop_.SetHovered(false);
363 test_api_.CompleteAnimations();
364 EXPECT_EQ(0, ink_drop_host_.num_ink_drop_layers());
365
366 ink_drop_.SnapToActivated();
367 EXPECT_EQ(1, ink_drop_host_.num_ink_drop_layers());
bruthig 2016/09/09 16:05:47 Shouldn't this be 0?
Evan Stade 2016/09/09 18:55:48 after snapping to activated?
bruthig 2016/09/09 19:30:05 Nevermind, I thought it was similar to above.
368 ink_drop_.SetHovered(true);
369 EXPECT_EQ(1, ink_drop_host_.num_ink_drop_layers());
370 EXPECT_TRUE(test_api_.IsHighlightFadingInOrVisible());
371 }
372
373 TEST_F(InkDropImplTest, HighlightCanExistWithoutRipple) {
374 ink_drop_host_.set_should_show_highlight(true);
375 ink_drop_host_.set_should_show_ripple(false);
376
377 EXPECT_EQ(0, ink_drop_host_.num_ink_drop_layers());
378
379 ink_drop_.SetHovered(true);
380 EXPECT_EQ(1, ink_drop_host_.num_ink_drop_layers());
381
382 ink_drop_.AnimateToState(InkDropState::ACTION_PENDING);
383 EXPECT_EQ(InkDropState::HIDDEN, ink_drop_.GetTargetInkDropState());
384 EXPECT_EQ(1, ink_drop_host_.num_ink_drop_layers());
385 EXPECT_TRUE(test_api_.IsHighlightFadingInOrVisible());
386
387 ink_drop_.AnimateToState(InkDropState::ACTION_TRIGGERED);
388 EXPECT_EQ(InkDropState::HIDDEN, ink_drop_.GetTargetInkDropState());
389 EXPECT_EQ(1, ink_drop_host_.num_ink_drop_layers());
390 EXPECT_TRUE(test_api_.IsHighlightFadingInOrVisible());
391
392 // Nothing to fade in because the highlight has always been visible.
393 EXPECT_FALSE(task_runner_->HasPendingTask());
394 EXPECT_TRUE(test_api_.IsHighlightFadingInOrVisible());
395 }
310 } // namespace views 396 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/animation/ink_drop_impl.cc ('k') | ui/views/animation/ink_drop_ripple.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698