caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2012 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
caryclark@google.com | 8d0a524 | 2013-07-16 16:11:16 +0000 | [diff] [blame] | 7 | #include "PathOpsTestCommon.h" |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 8 | #include "SkPathOpsQuad.h" |
| 9 | #include "Test.h" |
| 10 | |
| 11 | static const SkDQuad tests[] = { |
| 12 | {{{1, 1}, {2, 1}, {0, 2}}}, |
| 13 | {{{0, 0}, {1, 1}, {3, 1}}}, |
| 14 | {{{2, 0}, {1, 1}, {2, 2}}}, |
| 15 | {{{4, 0}, {0, 1}, {4, 2}}}, |
| 16 | {{{0, 0}, {0, 1}, {1, 1}}}, |
| 17 | }; |
| 18 | |
| 19 | static const SkDPoint inPoint[]= { |
| 20 | {1, 1.2}, |
| 21 | {1, 0.8}, |
| 22 | {1.8, 1}, |
| 23 | {1.5, 1}, |
| 24 | {0.5, 0.5}, |
| 25 | }; |
| 26 | |
| 27 | static const SkDPoint outPoint[]= { |
| 28 | {1, 1.6}, |
| 29 | {1, 1.5}, |
| 30 | {2.2, 1}, |
| 31 | {1.5, 1.5}, |
| 32 | {1.1, 0.5}, |
| 33 | }; |
| 34 | |
caryclark@google.com | ad65a3e | 2013-04-15 19:13:59 +0000 | [diff] [blame] | 35 | static const size_t tests_count = SK_ARRAY_COUNT(tests); |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 36 | |
caryclark@google.com | ad65a3e | 2013-04-15 19:13:59 +0000 | [diff] [blame] | 37 | static void PathOpsDQuadTest(skiatest::Reporter* reporter) { |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 38 | for (size_t index = 0; index < tests_count; ++index) { |
| 39 | const SkDQuad& quad = tests[index]; |
caryclark@google.com | 8d0a524 | 2013-07-16 16:11:16 +0000 | [diff] [blame] | 40 | SkASSERT(ValidQuad(quad)); |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 41 | bool result = quad.pointInHull(inPoint[index]); |
| 42 | if (!result) { |
| 43 | SkDebugf("%s [%d] expected in hull\n", __FUNCTION__, index); |
| 44 | REPORTER_ASSERT(reporter, 0); |
| 45 | } |
| 46 | result = quad.pointInHull(outPoint[index]); |
| 47 | if (result) { |
| 48 | SkDebugf("%s [%d] expected outside hull\n", __FUNCTION__, index); |
| 49 | REPORTER_ASSERT(reporter, 0); |
| 50 | } |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | #include "TestClassDef.h" |
caryclark@google.com | ad65a3e | 2013-04-15 19:13:59 +0000 | [diff] [blame] | 55 | DEFINE_TESTCLASS_SHORT(PathOpsDQuadTest) |