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

Side by Side 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, 9 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 unified diff | Download patch
« no previous file with comments | « tests/SerializationTest.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkRandom.h" 8 #include "SkRandom.h"
9 #include "SkReader32.h" 9 #include "SkReader32.h"
10 #include "SkWriter32.h" 10 #include "SkWriter32.h"
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 testOverwriteT(reporter, &writer); 271 testOverwriteT(reporter, &writer);
272 } 272 }
273 273
274 DEF_TEST(Writer32_misc, reporter) { 274 DEF_TEST(Writer32_misc, reporter) {
275 test_reserve(reporter); 275 test_reserve(reporter);
276 test_string_null(reporter); 276 test_string_null(reporter);
277 test_ptr(reporter); 277 test_ptr(reporter);
278 test_rewind(reporter); 278 test_rewind(reporter);
279 } 279 }
280 280
281 DEF_TEST(Writer32_data, reporter) {
282 const char* str = "0123456789";
283 SkAutoTUnref<SkData> data0(SkData::NewWithCString(str));
284 SkAutoTUnref<SkData> data1(SkData::NewEmpty());
285
286 const size_t sizes[] = {
287 SkWriter32::WriteDataSize(nullptr),
288 SkWriter32::WriteDataSize(data0),
289 SkWriter32::WriteDataSize(data1),
290 };
291
292 SkSWriter32<1000> writer;
293 size_t sizeWritten = 0;
294
295 writer.writeData(nullptr);
296 sizeWritten += sizes[0];
297 REPORTER_ASSERT(reporter, sizeWritten == writer.bytesWritten());
298
299 writer.writeData(data0);
300 sizeWritten += sizes[1];
301 REPORTER_ASSERT(reporter, sizeWritten == writer.bytesWritten());
302
303 writer.writeData(data1);
304 sizeWritten += sizes[2];
305 REPORTER_ASSERT(reporter, sizeWritten == writer.bytesWritten());
306
307 SkAutoTUnref<SkData> result(writer.snapshotAsData());
308
309 SkReader32 reader(result->data(), result->size());
310 SkAutoTUnref<SkData> d0(reader.readData()),
311 d1(reader.readData()),
312 d2(reader.readData());
313
314 REPORTER_ASSERT(reporter, 0 == d0->size());
315 REPORTER_ASSERT(reporter, strlen(str)+1 == d1->size());
316 REPORTER_ASSERT(reporter, !memcmp(str, d1->data(), strlen(str)+1));
317 REPORTER_ASSERT(reporter, 0 == d2->size());
318
319 REPORTER_ASSERT(reporter, reader.offset() == sizeWritten);
320 REPORTER_ASSERT(reporter, reader.eof());
321 }
OLDNEW
« 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