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

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

Issue 1406403007: Eliminate HICON leaks caused by creating icons from bitmap image. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 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
« no previous file with comments | « ui/gfx/path_win.cc ('k') | ui/gfx/platform_font_win.cc » ('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 2014 The Chromium Authors. All rights reserved. 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 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/gfx/path_win.h" 5 #include "ui/gfx/path_win.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/win/scoped_gdi_object.h" 10 #include "base/win/scoped_gdi_object.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 { 11, 47, 39, 48 }, 72 { 11, 47, 39, 48 },
73 { 12, 48, 38, 49 }, 73 { 12, 48, 38, 49 },
74 { 16, 49, 34, 50 }, 74 { 16, 49, 34, 50 },
75 }; 75 };
76 76
77 Path path; 77 Path path;
78 SkRRect rrect; 78 SkRRect rrect;
79 rrect.setRectXY(SkRect::MakeWH(50, 50), 20, 20); 79 rrect.setRectXY(SkRect::MakeWH(50, 50), 20, 20);
80 path.addRRect(rrect); 80 path.addRRect(rrect);
81 base::win::ScopedRegion region(CreateHRGNFromSkPath(path)); 81 base::win::ScopedRegion region(CreateHRGNFromSkPath(path));
82 const std::vector<SkIRect>& region_rects = GetRectsFromHRGN(region); 82 const std::vector<SkIRect>& region_rects = GetRectsFromHRGN(region.get());
83 EXPECT_EQ(arraysize(rects), region_rects.size()); 83 EXPECT_EQ(arraysize(rects), region_rects.size());
84 for (size_t i = 0; i < arraysize(rects) && i < region_rects.size(); ++i) 84 for (size_t i = 0; i < arraysize(rects) && i < region_rects.size(); ++i)
85 EXPECT_EQ(rects[i], region_rects[i]); 85 EXPECT_EQ(rects[i], region_rects[i]);
86 } 86 }
87 87
88 // Check that a path enclosing two non-adjacent areas is correctly translated 88 // Check that a path enclosing two non-adjacent areas is correctly translated
89 // to a non-contiguous region. 89 // to a non-contiguous region.
90 TEST(CreateHRGNFromSkPathTest, NonContiguousPath) { 90 TEST(CreateHRGNFromSkPathTest, NonContiguousPath) {
91 const SkIRect rects[] = { 91 const SkIRect rects[] = {
92 { 0, 0, 50, 50}, 92 { 0, 0, 50, 50},
93 { 100, 100, 150, 150}, 93 { 100, 100, 150, 150},
94 }; 94 };
95 95
96 Path path; 96 Path path;
97 for (const SkIRect& rect : rects) { 97 for (const SkIRect& rect : rects) {
98 path.addRect(SkRect::Make(rect)); 98 path.addRect(SkRect::Make(rect));
99 } 99 }
100 base::win::ScopedRegion region(CreateHRGNFromSkPath(path)); 100 base::win::ScopedRegion region(CreateHRGNFromSkPath(path));
101 const std::vector<SkIRect>& region_rects = GetRectsFromHRGN(region); 101 const std::vector<SkIRect>& region_rects = GetRectsFromHRGN(region.get());
102 ASSERT_EQ(arraysize(rects), region_rects.size()); 102 ASSERT_EQ(arraysize(rects), region_rects.size());
103 for (size_t i = 0; i < arraysize(rects); ++i) 103 for (size_t i = 0; i < arraysize(rects); ++i)
104 EXPECT_EQ(rects[i], region_rects[i]); 104 EXPECT_EQ(rects[i], region_rects[i]);
105 } 105 }
106 106
107 // Check that empty region is returned for empty path. 107 // Check that empty region is returned for empty path.
108 TEST(CreateHRGNFromSkPathTest, EmptyPath) { 108 TEST(CreateHRGNFromSkPathTest, EmptyPath) {
109 Path path; 109 Path path;
110 base::win::ScopedRegion empty_region(::CreateRectRgn(0, 0, 0, 0)); 110 base::win::ScopedRegion empty_region(::CreateRectRgn(0, 0, 0, 0));
111 base::win::ScopedRegion region(CreateHRGNFromSkPath(path)); 111 base::win::ScopedRegion region(CreateHRGNFromSkPath(path));
112 EXPECT_TRUE(::EqualRgn(empty_region, region)); 112 EXPECT_TRUE(::EqualRgn(empty_region.get(), region.get()));
113 } 113 }
114 114
115 } // namespace gfx 115 } // namespace gfx
116 116
OLDNEW
« no previous file with comments | « ui/gfx/path_win.cc ('k') | ui/gfx/platform_font_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698