Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 } | |
| OLD | NEW |