Chromium Code Reviews| 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)); |
| + } |
| +} |