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

Unified 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: IWYU 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/animation/ink_drop_impl.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/animation/ink_drop_impl_unittest.cc
diff --git a/ui/views/animation/ink_drop_impl_unittest.cc b/ui/views/animation/ink_drop_impl_unittest.cc
index b6fc8cebb0cfc2ecc281a84b1cc61e70a114f192..14c549a9f37e11d5fb68d5f54cfd3afe03b3fc38 100644
--- a/ui/views/animation/ink_drop_impl_unittest.cc
+++ b/ui/views/animation/ink_drop_impl_unittest.cc
@@ -8,7 +8,6 @@
#include "base/test/test_simple_task_runner.h"
#include "base/threading/thread_task_runner_handle.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include "ui/views/animation/ink_drop_ripple.h"
#include "ui/views/animation/test/ink_drop_impl_test_api.h"
#include "ui/views/animation/test/test_ink_drop_host.h"
@@ -253,4 +252,59 @@ TEST_F(InkDropImplTest, LayersArentRemovedWhenPreemptingFadeOut) {
EXPECT_EQ(1, ink_drop_host_.num_ink_drop_layers());
}
+TEST_F(InkDropImplTest, AnimationWhenDeactivated) {
+ EXPECT_EQ(0, ink_drop_host_.num_ink_drop_layers());
+
+ ink_drop_.AnimateToState(InkDropState::ACTIVATED);
+ EXPECT_EQ(1, ink_drop_host_.num_ink_drop_layers());
+ test_api_.CompleteAnimations();
+
+ ink_drop_.AnimateToState(InkDropState::DEACTIVATED);
+ EXPECT_EQ(1, ink_drop_host_.num_ink_drop_layers());
+ EXPECT_TRUE(test_api_.HasActiveAnimations());
+ EXPECT_FALSE(test_api_.IsHighlightFadingInOrVisible());
+}
+
+TEST_F(InkDropImplTest, AnimationSkippedWhenFocusedAndDeactivated) {
+ ink_drop_host_.set_should_show_highlight(true);
+
+ EXPECT_EQ(0, ink_drop_host_.num_ink_drop_layers());
+
+ ink_drop_.SetFocused(true);
+ EXPECT_EQ(1, ink_drop_host_.num_ink_drop_layers());
+
+ ink_drop_.AnimateToState(InkDropState::ACTIVATED);
+ EXPECT_EQ(1, ink_drop_host_.num_ink_drop_layers());
+ test_api_.CompleteAnimations();
+
+ ink_drop_.AnimateToState(InkDropState::DEACTIVATED);
+ EXPECT_EQ(1, ink_drop_host_.num_ink_drop_layers());
+ EXPECT_FALSE(test_api_.HasActiveAnimations());
+ EXPECT_TRUE(test_api_.IsHighlightFadingInOrVisible());
+ EXPECT_EQ(InkDropState::HIDDEN, ink_drop_.GetTargetInkDropState());
+}
+
+TEST_F(InkDropImplTest, FocusHighlightComesBackImmediatelyAfterAction) {
+ ink_drop_host_.set_should_show_highlight(true);
+
+ EXPECT_EQ(0, ink_drop_host_.num_ink_drop_layers());
+
+ ink_drop_.SetFocused(true);
+ EXPECT_EQ(1, ink_drop_host_.num_ink_drop_layers());
+
+ ink_drop_.AnimateToState(InkDropState::ACTION_PENDING);
+ EXPECT_EQ(1, ink_drop_host_.num_ink_drop_layers());
+
+ ink_drop_.AnimateToState(InkDropState::ACTION_TRIGGERED);
+ EXPECT_EQ(1, ink_drop_host_.num_ink_drop_layers());
+
+ test_api_.CompleteAnimations();
+
+ // No delay (unlike in the hover case).
+ EXPECT_FALSE(task_runner_->HasPendingTask());
+
+ // Highlight should be back.
+ EXPECT_TRUE(test_api_.IsHighlightFadingInOrVisible());
+}
+
} // namespace views
« 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