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

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

Issue 2533053002: Handle view resize for ripple (Closed)
Patch Set: Created 4 years 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/point.h" 9 #include "ui/gfx/geometry/point.h"
10 #include "ui/gfx/geometry/rect.h"
9 #include "ui/gfx/geometry/size.h" 11 #include "ui/gfx/geometry/size.h"
10 #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"
11 13
12 namespace views { 14 namespace views {
13 namespace test { 15 namespace test {
14 16
15 TEST(FloodFillInkDropRippleTest, TransformedCenterPointForIrregularClipBounds) { 17 TEST(FloodFillInkDropRippleTest, TransformedCenterPointForIrregularClipBounds) {
16 const gfx::Rect clip_bounds(8, 9, 32, 32); 18 const gfx::Size host_size(48, 50);
19 const gfx::Insets clip_insets(9, 8);
17 const gfx::Point requested_center_point(25, 24); 20 const gfx::Point requested_center_point(25, 24);
18 21
19 // |expected_center_point| is in the |clip_bounds| coordinate space. 22 // |expected_center_point| is in the coordinate space defined by
23 // |clip_insets|.
bruthig 2016/11/28 22:13:46 nit: It doesn't really make sense for |clip_insets
mohsen 2016/11/29 00:07:12 Updated comments.
20 const gfx::Point expected_center_point( 24 const gfx::Point expected_center_point(
21 requested_center_point.x() - clip_bounds.x(), 25 requested_center_point.x() - clip_insets.left(),
22 requested_center_point.y() - clip_bounds.y()); 26 requested_center_point.y() - clip_insets.top());
23 27
24 FloodFillInkDropRipple ripple(clip_bounds, requested_center_point, 28 FloodFillInkDropRipple ripple(host_size, clip_insets, requested_center_point,
25 SK_ColorWHITE, 0.175f); 29 SK_ColorWHITE, 0.175f);
26 FloodFillInkDropRippleTestApi test_api(&ripple); 30 FloodFillInkDropRippleTestApi test_api(&ripple);
27 31
28 gfx::Point actual_center = test_api.GetDrawnCenterPoint(); 32 gfx::Point actual_center = test_api.GetDrawnCenterPoint();
29 test_api.TransformPoint(10, &actual_center); 33 test_api.TransformPoint(10, &actual_center);
30 34
31 EXPECT_EQ(expected_center_point, actual_center); 35 EXPECT_EQ(expected_center_point, actual_center);
32 } 36 }
33 37
34 TEST(FloodFillInkDropRippleTest, MaxDistanceToCorners) { 38 TEST(FloodFillInkDropRippleTest, MaxDistanceToCorners) {
35 const float kAbsError = 0.01f; 39 const float kAbsError = 0.01f;
40 const gfx::Size host_size(70, 130);
36 // Rect with the following corners in clockwise order starting at the origin: 41 // Rect with the following corners in clockwise order starting at the origin:
37 // (10, 30), (60, 30), (10, 100), (60, 100) 42 // (10, 30), (60, 30), (10, 100), (60, 100)
38 const gfx::Rect clip_bounds(10, 30, 50, 70); 43 const gfx::Insets clip_insets(30, 10);
39 44
40 FloodFillInkDropRipple ripple(clip_bounds, gfx::Point(), SK_ColorWHITE, 45 FloodFillInkDropRipple ripple(host_size, clip_insets, gfx::Point(),
41 0.175f); 46 SK_ColorWHITE, 0.175f);
42 FloodFillInkDropRippleTestApi test_api(&ripple); 47 FloodFillInkDropRippleTestApi test_api(&ripple);
43 48
44 // Interior points 49 // Interior points
45 EXPECT_NEAR(78.10f, test_api.MaxDistanceToCorners(gfx::Point(10, 40)), 50 EXPECT_NEAR(78.10f, test_api.MaxDistanceToCorners(gfx::Point(10, 40)),
46 kAbsError); 51 kAbsError);
47 EXPECT_NEAR(71.06f, test_api.MaxDistanceToCorners(gfx::Point(55, 45)), 52 EXPECT_NEAR(71.06f, test_api.MaxDistanceToCorners(gfx::Point(55, 45)),
48 kAbsError); 53 kAbsError);
49 EXPECT_NEAR(64.03f, test_api.MaxDistanceToCorners(gfx::Point(50, 80)), 54 EXPECT_NEAR(64.03f, test_api.MaxDistanceToCorners(gfx::Point(50, 80)),
50 kAbsError); 55 kAbsError);
51 EXPECT_NEAR(68.01f, test_api.MaxDistanceToCorners(gfx::Point(20, 85)), 56 EXPECT_NEAR(68.01f, test_api.MaxDistanceToCorners(gfx::Point(20, 85)),
52 kAbsError); 57 kAbsError);
53 58
54 // Exterior points 59 // Exterior points
55 EXPECT_NEAR(110.79f, test_api.MaxDistanceToCorners(gfx::Point(3, 5)), 60 EXPECT_NEAR(110.79f, test_api.MaxDistanceToCorners(gfx::Point(3, 5)),
56 kAbsError); 61 kAbsError);
57 EXPECT_NEAR(108.17f, test_api.MaxDistanceToCorners(gfx::Point(70, 10)), 62 EXPECT_NEAR(108.17f, test_api.MaxDistanceToCorners(gfx::Point(70, 10)),
58 kAbsError); 63 kAbsError);
59 EXPECT_NEAR(103.08f, test_api.MaxDistanceToCorners(gfx::Point(75, 110)), 64 EXPECT_NEAR(103.08f, test_api.MaxDistanceToCorners(gfx::Point(75, 110)),
60 kAbsError); 65 kAbsError);
61 EXPECT_NEAR(101.24f, test_api.MaxDistanceToCorners(gfx::Point(5, 115)), 66 EXPECT_NEAR(101.24f, test_api.MaxDistanceToCorners(gfx::Point(5, 115)),
62 kAbsError); 67 kAbsError);
63 } 68 }
64 69
65 } // namespace test 70 } // namespace test
66 } // namespace views 71 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698