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

Unified Diff: tests/PathTest.cpp

Issue 22681006: SkPath: fix rFooTo() methods following close() (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: clean up import Created 7 years, 4 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 | « src/core/SkPath.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/PathTest.cpp
diff --git a/tests/PathTest.cpp b/tests/PathTest.cpp
index e698c7cda5fe4c777e1cbb75a064e398d64c8783..4637e9218b8533762850e76cbffc4edd9d178f48 100644
--- a/tests/PathTest.cpp
+++ b/tests/PathTest.cpp
@@ -32,6 +32,56 @@ static SkSurface* new_surface(int w, int h) {
return SkSurface::NewRaster(info);
}
+static void test_path_close_issue1474(skiatest::Reporter* reporter) {
+ // This test checks that r{Line,Quad,Conic,Cubic}To following a close()
+ // are relative to the point we close to, not relative to the point we close from.
+ SkPath path;
+ SkPoint last;
+
+ // Test rLineTo().
+ path.rLineTo(0, 100);
+ path.rLineTo(100, 0);
+ path.close(); // Returns us back to 0,0.
+ path.rLineTo(50, 50); // This should go to 50,50.
+
+ path.getLastPt(&last);
+ REPORTER_ASSERT(reporter, 50 == last.fX);
+ REPORTER_ASSERT(reporter, 50 == last.fY);
+
+ // Test rQuadTo().
+ path.rewind();
+ path.rLineTo(0, 100);
+ path.rLineTo(100, 0);
+ path.close();
+ path.rQuadTo(50, 50, 75, 75);
+
+ path.getLastPt(&last);
+ REPORTER_ASSERT(reporter, 75 == last.fX);
+ REPORTER_ASSERT(reporter, 75 == last.fY);
+
+ // Test rConicTo().
+ path.rewind();
+ path.rLineTo(0, 100);
+ path.rLineTo(100, 0);
+ path.close();
+ path.rConicTo(50, 50, 85, 85, 2);
+
+ path.getLastPt(&last);
+ REPORTER_ASSERT(reporter, 85 == last.fX);
+ REPORTER_ASSERT(reporter, 85 == last.fY);
+
+ // Test rCubicTo().
+ path.rewind();
+ path.rLineTo(0, 100);
+ path.rLineTo(100, 0);
+ path.close();
+ path.rCubicTo(50, 50, 85, 85, 95, 95);
+
+ path.getLastPt(&last);
+ REPORTER_ASSERT(reporter, 95 == last.fX);
+ REPORTER_ASSERT(reporter, 95 == last.fY);
+}
+
static void test_android_specific_behavior(skiatest::Reporter* reporter) {
#ifdef SK_BUILD_FOR_ANDROID
// Copy constructor should preserve generation ID, but assignment shouldn't.
@@ -2469,6 +2519,7 @@ static void TestPath(skiatest::Reporter* reporter) {
test_bad_cubic_crbug229478();
test_bad_cubic_crbug234190();
test_android_specific_behavior(reporter);
+ test_path_close_issue1474(reporter);
}
#include "TestClassDef.h"
« no previous file with comments | « src/core/SkPath.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698