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

Side by Side Diff: tests/PathTest.cpp

Issue 138703008: fix minor error between kStroke_PathAsRect and kFill_PathAsRect in SkPath::asRect (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 10 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 unified diff | Download patch
« src/core/SkPath.cpp ('K') | « src/core/SkPath.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkCanvas.h" 8 #include "SkCanvas.h"
9 #include "SkPaint.h" 9 #include "SkPaint.h"
10 #include "SkParse.h" 10 #include "SkParse.h"
(...skipping 1425 matching lines...) Expand 10 before | Expand all | Expand 10 after
1436 static void test_isRect_open_close(skiatest::Reporter* reporter) { 1436 static void test_isRect_open_close(skiatest::Reporter* reporter) {
1437 SkPath path; 1437 SkPath path;
1438 bool isClosed; 1438 bool isClosed;
1439 1439
1440 path.moveTo(0, 0); path.lineTo(1, 0); path.lineTo(1, 1); path.lineTo(0, 1); 1440 path.moveTo(0, 0); path.lineTo(1, 0); path.lineTo(1, 1); path.lineTo(0, 1);
1441 path.close(); 1441 path.close();
1442 1442
1443 REPORTER_ASSERT(reporter, path.isRect(NULL, NULL)); 1443 REPORTER_ASSERT(reporter, path.isRect(NULL, NULL));
1444 REPORTER_ASSERT(reporter, path.isRect(&isClosed, NULL)); 1444 REPORTER_ASSERT(reporter, path.isRect(&isClosed, NULL));
1445 REPORTER_ASSERT(reporter, isClosed); 1445 REPORTER_ASSERT(reporter, isClosed);
1446 REPORTER_ASSERT(reporter, SkPath::kFill_PathAsRect == path.asRect(NULL)); 1446 REPORTER_ASSERT(reporter, SkPath::kStroke_PathAsRect == path.asRect(NULL));
1447 } 1447 }
1448 1448
1449 // Simple isRect test is inline TestPath, below. 1449 // Simple isRect test is inline TestPath, below.
1450 // test_isRect provides more extensive testing. 1450 // test_isRect provides more extensive testing.
1451 static void test_isRect(skiatest::Reporter* reporter) { 1451 static void test_isRect(skiatest::Reporter* reporter) {
1452 test_isRect_open_close(reporter); 1452 test_isRect_open_close(reporter);
1453 1453
1454 // passing tests (all moveTo / lineTo... 1454 // passing tests (all moveTo / lineTo...
1455 SkPoint r1[] = {{0, 0}, {1, 0}, {1, 1}, {0, 1}}; 1455 SkPoint r1[] = {{0, 0}, {1, 0}, {1, 1}, {0, 1}};
1456 SkPoint r2[] = {{1, 0}, {1, 1}, {0, 1}, {0, 0}}; 1456 SkPoint r2[] = {{1, 0}, {1, 1}, {0, 1}, {0, 0}};
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
1555 REPORTER_ASSERT(reporter, path.isRect(&computed)); 1555 REPORTER_ASSERT(reporter, path.isRect(&computed));
1556 REPORTER_ASSERT(reporter, expected == computed); 1556 REPORTER_ASSERT(reporter, expected == computed);
1557 1557
1558 bool isClosed; 1558 bool isClosed;
1559 SkPath::Direction direction, cheapDirection; 1559 SkPath::Direction direction, cheapDirection;
1560 REPORTER_ASSERT(reporter, path.cheapComputeDirection(&cheapDirection )); 1560 REPORTER_ASSERT(reporter, path.cheapComputeDirection(&cheapDirection ));
1561 REPORTER_ASSERT(reporter, path.isRect(&isClosed, &direction)); 1561 REPORTER_ASSERT(reporter, path.isRect(&isClosed, &direction));
1562 REPORTER_ASSERT(reporter, isClosed == tests[testIndex].fClose); 1562 REPORTER_ASSERT(reporter, isClosed == tests[testIndex].fClose);
1563 REPORTER_ASSERT(reporter, direction == cheapDirection); 1563 REPORTER_ASSERT(reporter, direction == cheapDirection);
1564 direction = (SkPath::Direction) -1; 1564 direction = (SkPath::Direction) -1;
1565 if (tests[testIndex].fClose) { 1565 if (!tests[testIndex].fClose) {
1566 REPORTER_ASSERT(reporter, SkPath::kFill_PathAsRect == path.asRec t()); 1566 REPORTER_ASSERT(reporter, SkPath::kFill_PathAsRect == path.asRec t());
1567 REPORTER_ASSERT(reporter, SkPath::kFill_PathAsRect == path.asRec t(&direction)); 1567 REPORTER_ASSERT(reporter, SkPath::kFill_PathAsRect == path.asRec t(&direction));
1568 } else { 1568 } else {
1569 REPORTER_ASSERT(reporter, SkPath::kStroke_PathAsRect == path.asR ect()); 1569 REPORTER_ASSERT(reporter, SkPath::kStroke_PathAsRect == path.asR ect());
1570 REPORTER_ASSERT(reporter, SkPath::kStroke_PathAsRect == path.asR ect(&direction)); 1570 REPORTER_ASSERT(reporter, SkPath::kStroke_PathAsRect == path.asR ect(&direction));
1571 } 1571 }
1572 REPORTER_ASSERT(reporter, direction == cheapDirection); 1572 REPORTER_ASSERT(reporter, direction == cheapDirection);
1573 } else { 1573 } else {
1574 SkRect computed; 1574 SkRect computed;
1575 computed.set(123, 456, 789, 1011); 1575 computed.set(123, 456, 789, 1011);
(...skipping 1800 matching lines...) Expand 10 before | Expand all | Expand 10 after
3376 test_rrect(reporter); 3376 test_rrect(reporter);
3377 test_arc(reporter); 3377 test_arc(reporter);
3378 test_arcTo(reporter); 3378 test_arcTo(reporter);
3379 test_addPath(reporter); 3379 test_addPath(reporter);
3380 test_conicTo_special_case(reporter); 3380 test_conicTo_special_case(reporter);
3381 test_get_point(reporter); 3381 test_get_point(reporter);
3382 test_contains(reporter); 3382 test_contains(reporter);
3383 PathTest_Private::TestPathTo(reporter); 3383 PathTest_Private::TestPathTo(reporter);
3384 PathRefTest_Private::TestPathRef(reporter); 3384 PathRefTest_Private::TestPathRef(reporter);
3385 } 3385 }
OLDNEW
« src/core/SkPath.cpp ('K') | « src/core/SkPath.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698