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

Side by Side Diff: ui/gfx/path_win_unittest.cc

Issue 673623002: Fix regions generation on windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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/gfx/path_win.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "base/win/scoped_gdi_object.h"
6 #include "testing/gtest/include/gtest/gtest.h"
7 #include "third_party/skia/include/core/SkRRect.h"
8 #include "ui/gfx/path.h"
9 #include "ui/gfx/path_win.h"
10
11 // Test that rectangle with round corners stil has _round_ corners after
12 // converting from SkPath to the HRGN.
13 // Old implementation of the CreateHRGNFromSkPath operates with polygons and
14 // can't make round corners.
15 TEST(CreateHRGNFromSkPathTest, RoundCornerTest) {
16 struct TestPoint {
17 int x;
18 int y;
19 bool in_region;
20 };
21 const TestPoint points[] = {
22 { 0, 20, true },
23 { 0, 19, true },
24 { 0, 18, true },
25 { 0, 17, true },
26 { 0, 16, false },
27 { 1, 16, true },
28 { 1, 15, true },
29 { 1, 14, true },
30 { 1, 13, true },
31 { 1, 12, true },
32 { 1, 11, false },
33 { 2, 11, true },
34 { 2, 10, false },
35 { 3, 10, true },
36 { 3, 9, true },
37 { 3, 8, false },
38 { 4, 8, true },
39 { 4, 7, false },
40 { 5, 7, true },
41 { 5, 6, true },
42 { 5, 5, false },
43 { 6, 5, true },
44 { 6, 4, false},
45 { 7, 4, false },
46 { 8, 4, true },
47 { 8, 3, false },
48 { 9, 3, true },
49 { 9, 2, false },
50 { 10, 2, false },
51 { 11, 2, true },
52 { 11, 1, false },
53 { 12, 1, true },
54 { 12, 0, false },
55 { 13, 0, false },
56 { 14, 0, false },
57 { 15, 0, false },
58 { 16, 0, false },
59 { 17, 0, true },
60 { 18, 0, true },
61 { 19, 0, true },
62 { 20, 0, true },
63 };
Alexei Svitkine (slow) 2014/10/22 15:14:46 Nit: De-indent this.
64
65 gfx::Path path;
66 SkRRect rrect;
67 rrect.setRectXY(SkRect::MakeWH(50, 50), 20, 20);
68 path.addRRect(rrect);
69 base::win::ScopedRegion region(gfx::CreateHRGNFromSkPath(path));
70 for (const TestPoint& point : points) {
71 EXPECT_EQ(point.in_region, !!::PtInRegion(region, point.x, point.y));
72 }
73 }
OLDNEW
« no previous file with comments | « ui/gfx/path_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698