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

Unified 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, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/gfx/path_win.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/path_win_unittest.cc
diff --git a/ui/gfx/path_win_unittest.cc b/ui/gfx/path_win_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..1b2ca0a948be00467922b87df83066e33cda4237
--- /dev/null
+++ b/ui/gfx/path_win_unittest.cc
@@ -0,0 +1,73 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/win/scoped_gdi_object.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "third_party/skia/include/core/SkRRect.h"
+#include "ui/gfx/path.h"
+#include "ui/gfx/path_win.h"
+
+// Test that rectangle with round corners stil has _round_ corners after
+// converting from SkPath to the HRGN.
+// Old implementation of the CreateHRGNFromSkPath operates with polygons and
+// can't make round corners.
+TEST(CreateHRGNFromSkPathTest, RoundCornerTest) {
+ struct TestPoint {
+ int x;
+ int y;
+ bool in_region;
+ };
+ const TestPoint points[] = {
+ { 0, 20, true },
+ { 0, 19, true },
+ { 0, 18, true },
+ { 0, 17, true },
+ { 0, 16, false },
+ { 1, 16, true },
+ { 1, 15, true },
+ { 1, 14, true },
+ { 1, 13, true },
+ { 1, 12, true },
+ { 1, 11, false },
+ { 2, 11, true },
+ { 2, 10, false },
+ { 3, 10, true },
+ { 3, 9, true },
+ { 3, 8, false },
+ { 4, 8, true },
+ { 4, 7, false },
+ { 5, 7, true },
+ { 5, 6, true },
+ { 5, 5, false },
+ { 6, 5, true },
+ { 6, 4, false},
+ { 7, 4, false },
+ { 8, 4, true },
+ { 8, 3, false },
+ { 9, 3, true },
+ { 9, 2, false },
+ { 10, 2, false },
+ { 11, 2, true },
+ { 11, 1, false },
+ { 12, 1, true },
+ { 12, 0, false },
+ { 13, 0, false },
+ { 14, 0, false },
+ { 15, 0, false },
+ { 16, 0, false },
+ { 17, 0, true },
+ { 18, 0, true },
+ { 19, 0, true },
+ { 20, 0, true },
+ };
Alexei Svitkine (slow) 2014/10/22 15:14:46 Nit: De-indent this.
+
+ gfx::Path path;
+ SkRRect rrect;
+ rrect.setRectXY(SkRect::MakeWH(50, 50), 20, 20);
+ path.addRRect(rrect);
+ base::win::ScopedRegion region(gfx::CreateHRGNFromSkPath(path));
+ for (const TestPoint& point : points) {
+ EXPECT_EQ(point.in_region, !!::PtInRegion(region, point.x, point.y));
+ }
+}
« 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