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

Unified Diff: ui/views/animation/flood_fill_ink_drop_ripple_unittest.cc

Issue 2615613003: Fix double ripple on activated flood fill ripple (Closed)
Patch Set: Added tests Created 3 years, 11 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
Index: ui/views/animation/flood_fill_ink_drop_ripple_unittest.cc
diff --git a/ui/views/animation/flood_fill_ink_drop_ripple_unittest.cc b/ui/views/animation/flood_fill_ink_drop_ripple_unittest.cc
index 8f3ed99ce31259f95a79f26832db6052c169a461..5d9cef2260e36e8ead542aac1790714a2621f29c 100644
--- a/ui/views/animation/flood_fill_ink_drop_ripple_unittest.cc
+++ b/ui/views/animation/flood_fill_ink_drop_ripple_unittest.cc
@@ -10,6 +10,7 @@
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/size.h"
#include "ui/views/animation/test/flood_fill_ink_drop_ripple_test_api.h"
+#include "ui/views/animation/test/test_ink_drop_ripple_observer.h"
namespace views {
namespace test {
@@ -67,5 +68,46 @@ TEST(FloodFillInkDropRippleTest, MaxDistanceToCorners) {
kAbsError);
}
+// Verifies that both going directly from HIDDEN to ACTIVATED state and going
+// through PENDING to ACTIVAED state lead to the same final opacity and
+// transform values.
+TEST(FloodFillInkDropRippleTest, ActivatedFinalState) {
+ const float kAbsError = 0.01f;
+
+ const gfx::Size host_size(100, 50);
+ const gfx::Point center_point(host_size.width() / 2, host_size.height() / 2);
+ const SkColor color = SK_ColorWHITE;
+ const float visible_opacity = 0.7f;
+
+ TestInkDropRippleObserver observer;
+ FloodFillInkDropRipple ripple(host_size, center_point, color,
+ visible_opacity);
+ ripple.set_observer(&observer);
bruthig 2017/01/10 17:08:03 nit: Can you add a TODO in InkDropRipple to handle
mohsen 2017/01/10 22:28:16 It's a very small change to add null check to InkD
+ FloodFillInkDropRippleTestApi test_api(&ripple);
+
+ // Go to ACTIVATED state directly.
+ ripple.AnimateToState(InkDropState::ACTIVATED);
+ test_api.CompleteAnimations();
+ float activated_opacity = test_api.GetCurrentOpacity();
bruthig 2017/01/10 17:08:03 nit: Might be a good idea to mark these as const.
mohsen 2017/01/10 22:28:16 Done.
+ gfx::Transform activated_transform = test_api.GetPaintedLayerTransform();
+
+ // Reset state.
+ ripple.AnimateToState(InkDropState::HIDDEN);
+ test_api.CompleteAnimations();
+
+ // Go to ACTIVATED state through PENDING state.
+ ripple.AnimateToState(InkDropState::ACTION_PENDING);
+ ripple.AnimateToState(InkDropState::ACTIVATED);
+ test_api.CompleteAnimations();
+ float pending_activated_opacity = test_api.GetCurrentOpacity();
+ gfx::Transform pending_activated_transform =
+ test_api.GetPaintedLayerTransform();
+
+ // Compare opacity and transform values.
+ EXPECT_NEAR(activated_opacity, pending_activated_opacity, kAbsError);
+ EXPECT_TRUE(
+ activated_transform.ApproximatelyEqual(pending_activated_transform));
+}
+
} // namespace test
} // namespace views

Powered by Google App Engine
This is Rietveld 408576698