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

Unified Diff: tests/Writer32Test.cpp

Issue 1744103002: move annotations to canvas virtual (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/SerializationTest.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/Writer32Test.cpp
diff --git a/tests/Writer32Test.cpp b/tests/Writer32Test.cpp
index 39ae79cff624f3370ff2ecf9ec7081be383828b4..e03a9163aa446050fabb979a456f54a56a89c78f 100644
--- a/tests/Writer32Test.cpp
+++ b/tests/Writer32Test.cpp
@@ -278,3 +278,44 @@ DEF_TEST(Writer32_misc, reporter) {
test_rewind(reporter);
}
+DEF_TEST(Writer32_data, reporter) {
+ const char* str = "0123456789";
+ SkAutoTUnref<SkData> data0(SkData::NewWithCString(str));
+ SkAutoTUnref<SkData> data1(SkData::NewEmpty());
+
+ const size_t sizes[] = {
+ SkWriter32::WriteDataSize(nullptr),
+ SkWriter32::WriteDataSize(data0),
+ SkWriter32::WriteDataSize(data1),
+ };
+
+ SkSWriter32<1000> writer;
+ size_t sizeWritten = 0;
+
+ writer.writeData(nullptr);
+ sizeWritten += sizes[0];
+ REPORTER_ASSERT(reporter, sizeWritten == writer.bytesWritten());
+
+ writer.writeData(data0);
+ sizeWritten += sizes[1];
+ REPORTER_ASSERT(reporter, sizeWritten == writer.bytesWritten());
+
+ writer.writeData(data1);
+ sizeWritten += sizes[2];
+ REPORTER_ASSERT(reporter, sizeWritten == writer.bytesWritten());
+
+ SkAutoTUnref<SkData> result(writer.snapshotAsData());
+
+ SkReader32 reader(result->data(), result->size());
+ SkAutoTUnref<SkData> d0(reader.readData()),
+ d1(reader.readData()),
+ d2(reader.readData());
+
+ REPORTER_ASSERT(reporter, 0 == d0->size());
+ REPORTER_ASSERT(reporter, strlen(str)+1 == d1->size());
+ REPORTER_ASSERT(reporter, !memcmp(str, d1->data(), strlen(str)+1));
+ REPORTER_ASSERT(reporter, 0 == d2->size());
+
+ REPORTER_ASSERT(reporter, reader.offset() == sizeWritten);
+ REPORTER_ASSERT(reporter, reader.eof());
+}
« no previous file with comments | « tests/SerializationTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698