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

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: 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 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"
11 #include "ui/gfx/geometry/size.h" 11 #include "ui/gfx/geometry/size.h"
12 #include "ui/views/animation/test/flood_fill_ink_drop_ripple_test_api.h" 12 #include "ui/views/animation/test/flood_fill_ink_drop_ripple_test_api.h"
13 #include "ui/views/animation/test/test_ink_drop_ripple_observer.h"
13 14
14 namespace views { 15 namespace views {
15 namespace test { 16 namespace test {
16 17
17 TEST(FloodFillInkDropRippleTest, TransformedCenterPointForIrregularClipBounds) { 18 TEST(FloodFillInkDropRippleTest, TransformedCenterPointForIrregularClipBounds) {
18 const gfx::Size host_size(48, 50); 19 const gfx::Size host_size(48, 50);
19 const gfx::Insets clip_insets(9, 8); 20 const gfx::Insets clip_insets(9, 8);
20 const gfx::Point requested_center_point(25, 24); 21 const gfx::Point requested_center_point(25, 24);
21 22
22 // |expected_center_point| is in the coordinate space of ripple's clip bounds 23 // |expected_center_point| is in the coordinate space of ripple's clip bounds
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 EXPECT_NEAR(110.79f, test_api.MaxDistanceToCorners(gfx::Point(3, 5)), 61 EXPECT_NEAR(110.79f, test_api.MaxDistanceToCorners(gfx::Point(3, 5)),
61 kAbsError); 62 kAbsError);
62 EXPECT_NEAR(108.17f, test_api.MaxDistanceToCorners(gfx::Point(70, 10)), 63 EXPECT_NEAR(108.17f, test_api.MaxDistanceToCorners(gfx::Point(70, 10)),
63 kAbsError); 64 kAbsError);
64 EXPECT_NEAR(103.08f, test_api.MaxDistanceToCorners(gfx::Point(75, 110)), 65 EXPECT_NEAR(103.08f, test_api.MaxDistanceToCorners(gfx::Point(75, 110)),
65 kAbsError); 66 kAbsError);
66 EXPECT_NEAR(101.24f, test_api.MaxDistanceToCorners(gfx::Point(5, 115)), 67 EXPECT_NEAR(101.24f, test_api.MaxDistanceToCorners(gfx::Point(5, 115)),
67 kAbsError); 68 kAbsError);
68 } 69 }
69 70
71 // Verifies that both going directly from HIDDEN to ACTIVATED state and going
72 // through PENDING to ACTIVAED state lead to the same final opacity and
73 // transform values.
74 TEST(FloodFillInkDropRippleTest, ActivatedFinalState) {
75 const float kAbsError = 0.01f;
76
77 const gfx::Size host_size(100, 50);
78 const gfx::Point center_point(host_size.width() / 2, host_size.height() / 2);
79 const SkColor color = SK_ColorWHITE;
80 const float visible_opacity = 0.7f;
81
82 TestInkDropRippleObserver observer;
83 FloodFillInkDropRipple ripple(host_size, center_point, color,
84 visible_opacity);
85 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
86 FloodFillInkDropRippleTestApi test_api(&ripple);
87
88 // Go to ACTIVATED state directly.
89 ripple.AnimateToState(InkDropState::ACTIVATED);
90 test_api.CompleteAnimations();
91 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.
92 gfx::Transform activated_transform = test_api.GetPaintedLayerTransform();
93
94 // Reset state.
95 ripple.AnimateToState(InkDropState::HIDDEN);
96 test_api.CompleteAnimations();
97
98 // Go to ACTIVATED state through PENDING state.
99 ripple.AnimateToState(InkDropState::ACTION_PENDING);
100 ripple.AnimateToState(InkDropState::ACTIVATED);
101 test_api.CompleteAnimations();
102 float pending_activated_opacity = test_api.GetCurrentOpacity();
103 gfx::Transform pending_activated_transform =
104 test_api.GetPaintedLayerTransform();
105
106 // Compare opacity and transform values.
107 EXPECT_NEAR(activated_opacity, pending_activated_opacity, kAbsError);
108 EXPECT_TRUE(
109 activated_transform.ApproximatelyEqual(pending_activated_transform));
110 }
111
70 } // namespace test 112 } // namespace test
71 } // namespace views 113 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698