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

Unified Diff: tests/PathTest.cpp

Issue 351833003: add path dump test (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: generate a single line feed (or none if empty) Created 6 years, 6 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 e265d317cadd87d0cad7a047576036cc2c036042..3941ad6e183946ff42f86a40434c87c8b5467f02 100644
--- a/tests/PathTest.cpp
+++ b/tests/PathTest.cpp
@@ -15,6 +15,7 @@
#include "SkRandom.h"
#include "SkReader32.h"
#include "SkSize.h"
+#include "SkStream.h"
#include "SkSurface.h"
#include "SkTypes.h"
#include "SkWriter32.h"
@@ -3364,6 +3365,44 @@ static void test_operatorEqual(skiatest::Reporter* reporter) {
REPORTER_ASSERT(reporter, a == b);
}
+static void compare_dump(skiatest::Reporter* reporter, const SkPath& path, bool force,
+ const char* str) {
+ SkDynamicMemoryWStream wStream;
+ path.dump(&wStream, force);
+ SkAutoDataUnref data(wStream.copyToData());
+ REPORTER_ASSERT(reporter, data->size() == strlen(str));
+ REPORTER_ASSERT(reporter, !memcmp(data->data(), str, strlen(str)));
+}
+
+static void test_dump(skiatest::Reporter* reporter) {
+ SkPath p;
+ compare_dump(reporter, p, false, "");
+ compare_dump(reporter, p, true, "");
+ p.moveTo(1, 2);
+ p.lineTo(3, 4);
+ compare_dump(reporter, p, false, "path.moveTo(1, 2);\n"
+ "path.lineTo(3, 4);\n");
+ compare_dump(reporter, p, true, "path.moveTo(1, 2);\n"
+ "path.lineTo(3, 4);\n"
+ "path.lineTo(1, 2);\n"
+ "path.close();\n");
+ p.reset();
+ p.moveTo(1, 2);
+ p.quadTo(3, 4, 5, 6);
+ compare_dump(reporter, p, false, "path.moveTo(1, 2);\n"
+ "path.quadTo(3, 4, 5, 6);\n");
+ p.reset();
+ p.moveTo(1, 2);
+ p.conicTo(3, 4, 5, 6, 0.5f);
+ compare_dump(reporter, p, false, "path.moveTo(1, 2);\n"
+ "path.conicTo(3, 4, 5, 6, 0.5f);\n");
+ p.reset();
+ p.moveTo(1, 2);
+ p.cubicTo(3, 4, 5, 6, 7, 8);
+ compare_dump(reporter, p, false, "path.moveTo(1, 2);\n"
+ "path.cubicTo(3, 4, 5, 6, 7, 8);\n");
+}
+
class PathTest_Private {
public:
static void TestPathTo(skiatest::Reporter* reporter) {
@@ -3513,4 +3552,5 @@ DEF_TEST(Paths, reporter) {
test_contains(reporter);
PathTest_Private::TestPathTo(reporter);
PathRefTest_Private::TestPathRef(reporter);
+ test_dump(reporter);
}
« 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