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

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

Issue 2042073002: Centered flood fill style ink drop ripples on mouse/touch points. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Renamed LocatedEvent::AsLocatedIfLocatedEvent() as FromIfValid(). Created 4 years, 6 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
« no previous file with comments | « ui/views/animation/flood_fill_ink_drop_ripple.cc ('k') | ui/views/animation/ink_drop.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/point.h" 8 #include "ui/gfx/geometry/point.h"
9 #include "ui/gfx/geometry/size.h" 9 #include "ui/gfx/geometry/size.h"
10 #include "ui/views/animation/test/flood_fill_ink_drop_ripple_test_api.h" 10 #include "ui/views/animation/test/flood_fill_ink_drop_ripple_test_api.h"
(...skipping 13 matching lines...) Expand all
24 FloodFillInkDropRipple ripple(clip_bounds, requested_center_point, 24 FloodFillInkDropRipple ripple(clip_bounds, requested_center_point,
25 SK_ColorWHITE); 25 SK_ColorWHITE);
26 FloodFillInkDropRippleTestApi test_api(&ripple); 26 FloodFillInkDropRippleTestApi test_api(&ripple);
27 27
28 gfx::Point actual_center = test_api.GetDrawnCenterPoint(); 28 gfx::Point actual_center = test_api.GetDrawnCenterPoint();
29 test_api.TransformPoint(10, &actual_center); 29 test_api.TransformPoint(10, &actual_center);
30 30
31 EXPECT_EQ(expected_center_point, actual_center); 31 EXPECT_EQ(expected_center_point, actual_center);
32 } 32 }
33 33
34 TEST(FloodFillInkDropRippleTest, MaxDistanceToCorners) {
35 const float kAbsError = 0.01f;
36 // Rect with the following corners in clockwise order starting at the origin:
37 // (10, 30), (60, 30), (10, 100), (60, 100)
38 const gfx::Rect clip_bounds(10, 30, 50, 70);
39
40 FloodFillInkDropRipple ripple(clip_bounds, gfx::Point(), SK_ColorWHITE);
41 FloodFillInkDropRippleTestApi test_api(&ripple);
42
43 // Interior points
44 EXPECT_NEAR(78.10f, test_api.MaxDistanceToCorners(gfx::Point(10, 40)),
45 kAbsError);
46 EXPECT_NEAR(71.06f, test_api.MaxDistanceToCorners(gfx::Point(55, 45)),
47 kAbsError);
48 EXPECT_NEAR(64.03f, test_api.MaxDistanceToCorners(gfx::Point(50, 80)),
49 kAbsError);
50 EXPECT_NEAR(68.01f, test_api.MaxDistanceToCorners(gfx::Point(20, 85)),
51 kAbsError);
52
53 // Exterior points
54 EXPECT_NEAR(110.79f, test_api.MaxDistanceToCorners(gfx::Point(3, 5)),
55 kAbsError);
56 EXPECT_NEAR(108.17f, test_api.MaxDistanceToCorners(gfx::Point(70, 10)),
57 kAbsError);
58 EXPECT_NEAR(103.08f, test_api.MaxDistanceToCorners(gfx::Point(75, 110)),
59 kAbsError);
60 EXPECT_NEAR(101.24f, test_api.MaxDistanceToCorners(gfx::Point(5, 115)),
61 kAbsError);
62 }
63
34 } // namespace test 64 } // namespace test
35 } // namespace views 65 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/animation/flood_fill_ink_drop_ripple.cc ('k') | ui/views/animation/ink_drop.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698