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

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

Issue 2615613003: Fix double ripple on activated flood fill ripple (Closed)
Patch Set: Addressed nits 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/flood_fill_ink_drop_ripple.h" 5 #include "ui/views/animation/flood_fill_ink_drop_ripple.h"
6 6
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 #include "ui/gfx/geometry/insets.h" 8 #include "ui/gfx/geometry/insets.h"
9 #include "ui/gfx/geometry/point.h" 9 #include "ui/gfx/geometry/point.h"
10 #include "ui/gfx/geometry/rect.h" 10 #include "ui/gfx/geometry/rect.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 EXPECT_NEAR(110.79f, test_api.MaxDistanceToCorners(gfx::Point(3, 5)), 60 EXPECT_NEAR(110.79f, test_api.MaxDistanceToCorners(gfx::Point(3, 5)),
61 kAbsError); 61 kAbsError);
62 EXPECT_NEAR(108.17f, test_api.MaxDistanceToCorners(gfx::Point(70, 10)), 62 EXPECT_NEAR(108.17f, test_api.MaxDistanceToCorners(gfx::Point(70, 10)),
63 kAbsError); 63 kAbsError);
64 EXPECT_NEAR(103.08f, test_api.MaxDistanceToCorners(gfx::Point(75, 110)), 64 EXPECT_NEAR(103.08f, test_api.MaxDistanceToCorners(gfx::Point(75, 110)),
65 kAbsError); 65 kAbsError);
66 EXPECT_NEAR(101.24f, test_api.MaxDistanceToCorners(gfx::Point(5, 115)), 66 EXPECT_NEAR(101.24f, test_api.MaxDistanceToCorners(gfx::Point(5, 115)),
67 kAbsError); 67 kAbsError);
68 } 68 }
69 69
70 // Verifies that both going directly from HIDDEN to ACTIVATED state and going
71 // through PENDING to ACTIVAED state lead to the same final opacity and
72 // transform values.
73 TEST(FloodFillInkDropRippleTest, ActivatedFinalState) {
74 const float kAbsError = 0.01f;
75
76 const gfx::Size host_size(100, 50);
77 const gfx::Point center_point(host_size.width() / 2, host_size.height() / 2);
78 const SkColor color = SK_ColorWHITE;
79 const float visible_opacity = 0.7f;
80
81 FloodFillInkDropRipple ripple(host_size, center_point, color,
82 visible_opacity);
83 FloodFillInkDropRippleTestApi test_api(&ripple);
84
85 // Go to ACTIVATED state directly.
86 ripple.AnimateToState(InkDropState::ACTIVATED);
87 test_api.CompleteAnimations();
88 const float activated_opacity = test_api.GetCurrentOpacity();
89 const gfx::Transform activated_transform =
90 test_api.GetPaintedLayerTransform();
91
92 // Reset state.
93 ripple.AnimateToState(InkDropState::HIDDEN);
94 test_api.CompleteAnimations();
95
96 // Go to ACTIVATED state through PENDING state.
97 ripple.AnimateToState(InkDropState::ACTION_PENDING);
98 ripple.AnimateToState(InkDropState::ACTIVATED);
99 test_api.CompleteAnimations();
100 const float pending_activated_opacity = test_api.GetCurrentOpacity();
101 const gfx::Transform pending_activated_transform =
102 test_api.GetPaintedLayerTransform();
103
104 // Compare opacity and transform values.
105 EXPECT_NEAR(activated_opacity, pending_activated_opacity, kAbsError);
106 EXPECT_TRUE(
107 activated_transform.ApproximatelyEqual(pending_activated_transform));
108 }
109
70 } // namespace test 110 } // namespace test
71 } // namespace views 111 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/animation/flood_fill_ink_drop_ripple.cc ('k') | ui/views/animation/ink_drop_highlight_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698