add test that setLastPt() invalidates path bounds
Spoiler alert... it doesn't.
Bug: oss-fuzz:10488
Change-Id: Ifafd92f40aed55ff14a5198ea7d79a20751e40aa
Reviewed-on: https://skia-review.googlesource.com/156661
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
diff --git a/tests/PathTest.cpp b/tests/PathTest.cpp
index cbb2b48..de7f2c4 100644
--- a/tests/PathTest.cpp
+++ b/tests/PathTest.cpp
@@ -5180,3 +5180,19 @@
SkDebugf("max_free %zu\n", max_free);
}
}
+
+DEF_TEST(Path_setLastPt, r) {
+ // There was a time where SkPath::setLastPoint() didn't invalidate cached path bounds.
+ SkPath p;
+ p.moveTo(0,0);
+ p.moveTo(20,01);
+ p.moveTo(20,10);
+ p.moveTo(20,61);
+ REPORTER_ASSERT(r, p.getBounds() == SkRect::MakeLTRB(0,0, 20,61));
+
+ p.setLastPt(30,01);
+ REPORTER_ASSERT(r, p.getBounds() == SkRect::MakeLTRB(0,0, 30,10)); // was {0,0, 20,61}
+
+ REPORTER_ASSERT(r, p.isValid());
+ REPORTER_ASSERT(r, p.pathRefIsValid());
+}