diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/MatrixTest.cpp | 12 | ||||
-rw-r--r-- | tests/PathTest.cpp | 21 |
2 files changed, 25 insertions, 8 deletions
diff --git a/tests/MatrixTest.cpp b/tests/MatrixTest.cpp index 979f6ce76e..60f4831762 100644 --- a/tests/MatrixTest.cpp +++ b/tests/MatrixTest.cpp @@ -84,19 +84,19 @@ static bool is_identity(const SkMatrix& m) { static void test_flatten(skiatest::Reporter* reporter, const SkMatrix& m) { // add 100 in case we have a bug, I don't want to kill my stack in the test char buffer[SkMatrix::kMaxFlattenSize + 100]; - uint32_t size1 = m.flatten(NULL); - uint32_t size2 = m.flatten(buffer); + uint32_t size1 = m.writeToMemory(NULL); + uint32_t size2 = m.writeToMemory(buffer); REPORTER_ASSERT(reporter, size1 == size2); REPORTER_ASSERT(reporter, size1 <= SkMatrix::kMaxFlattenSize); SkMatrix m2; - uint32_t size3 = m2.unflatten(buffer); - REPORTER_ASSERT(reporter, size1 == size2); + uint32_t size3 = m2.readFromMemory(buffer); + REPORTER_ASSERT(reporter, size1 == size3); REPORTER_ASSERT(reporter, are_equal(reporter, m, m2)); char buffer2[SkMatrix::kMaxFlattenSize + 100]; - size3 = m2.flatten(buffer2); - REPORTER_ASSERT(reporter, size1 == size2); + size3 = m2.writeToMemory(buffer2); + REPORTER_ASSERT(reporter, size1 == size3); REPORTER_ASSERT(reporter, memcmp(buffer, buffer2, size1) == 0); } diff --git a/tests/PathTest.cpp b/tests/PathTest.cpp index 21f78bf2ce..ff12e8eb53 100644 --- a/tests/PathTest.cpp +++ b/tests/PathTest.cpp @@ -700,7 +700,7 @@ static void test_flattening(skiatest::Reporter* reporter) { p.cubicTo(pts[4], pts[5], pts[6]); SkWriter32 writer(100); - p.flatten(writer); + writer.writePath(p); size_t size = writer.size(); SkAutoMalloc storage(size); writer.flatten(storage.get()); @@ -708,8 +708,25 @@ static void test_flattening(skiatest::Reporter* reporter) { SkPath p1; REPORTER_ASSERT(reporter, p1 != p); - p1.unflatten(reader); + reader.readPath(&p1); REPORTER_ASSERT(reporter, p1 == p); + + // create a buffer that should be much larger than the path so we don't + // kill our stack if writer goes too far. + char buffer[1024]; + uint32_t size1 = p.writeToMemory(NULL); + uint32_t size2 = p.writeToMemory(buffer); + REPORTER_ASSERT(reporter, size1 == size2); + + SkPath p2; + uint32_t size3 = p2.readFromMemory(buffer); + REPORTER_ASSERT(reporter, size1 == size3); + REPORTER_ASSERT(reporter, p == p2); + + char buffer2[1024]; + size3 = p2.writeToMemory(buffer2); + REPORTER_ASSERT(reporter, size1 == size3); + REPORTER_ASSERT(reporter, memcmp(buffer, buffer2, size1) == 0); } static void test_transform(skiatest::Reporter* reporter) { |