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

Side by Side Diff: tests/Writer32Test.cpp

Issue 2206633004: Move off SK_SUPPORT_LEGACY_DATA_FACTORIES. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Gotta catch 'em all. Created 4 years, 4 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
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 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 260
261 DEF_TEST(Writer32_misc, reporter) { 261 DEF_TEST(Writer32_misc, reporter) {
262 test_reserve(reporter); 262 test_reserve(reporter);
263 test_string_null(reporter); 263 test_string_null(reporter);
264 test_ptr(reporter); 264 test_ptr(reporter);
265 test_rewind(reporter); 265 test_rewind(reporter);
266 } 266 }
267 267
268 DEF_TEST(Writer32_data, reporter) { 268 DEF_TEST(Writer32_data, reporter) {
269 const char* str = "0123456789"; 269 const char* str = "0123456789";
270 SkAutoTUnref<SkData> data0(SkData::NewWithCString(str)); 270 sk_sp<SkData> data0(SkData::MakeWithCString(str));
271 SkAutoTUnref<SkData> data1(SkData::NewEmpty()); 271 sk_sp<SkData> data1(SkData::MakeEmpty());
272 272
273 const size_t sizes[] = { 273 const size_t sizes[] = {
274 SkWriter32::WriteDataSize(nullptr), 274 SkWriter32::WriteDataSize(nullptr),
275 SkWriter32::WriteDataSize(data0), 275 SkWriter32::WriteDataSize(data0.get()),
276 SkWriter32::WriteDataSize(data1), 276 SkWriter32::WriteDataSize(data1.get()),
277 }; 277 };
278 278
279 SkSWriter32<1000> writer; 279 SkSWriter32<1000> writer;
280 size_t sizeWritten = 0; 280 size_t sizeWritten = 0;
281 281
282 writer.writeData(nullptr); 282 writer.writeData(nullptr);
283 sizeWritten += sizes[0]; 283 sizeWritten += sizes[0];
284 REPORTER_ASSERT(reporter, sizeWritten == writer.bytesWritten()); 284 REPORTER_ASSERT(reporter, sizeWritten == writer.bytesWritten());
285 285
286 writer.writeData(data0); 286 writer.writeData(data0.get());
287 sizeWritten += sizes[1]; 287 sizeWritten += sizes[1];
288 REPORTER_ASSERT(reporter, sizeWritten == writer.bytesWritten()); 288 REPORTER_ASSERT(reporter, sizeWritten == writer.bytesWritten());
289 289
290 writer.writeData(data1); 290 writer.writeData(data1.get());
291 sizeWritten += sizes[2]; 291 sizeWritten += sizes[2];
292 REPORTER_ASSERT(reporter, sizeWritten == writer.bytesWritten()); 292 REPORTER_ASSERT(reporter, sizeWritten == writer.bytesWritten());
293 293
294 auto result(writer.snapshotAsData()); 294 auto result(writer.snapshotAsData());
295 295
296 SkReader32 reader(result->data(), result->size()); 296 SkReader32 reader(result->data(), result->size());
297 auto d0(reader.readData()), 297 auto d0(reader.readData()),
298 d1(reader.readData()), 298 d1(reader.readData()),
299 d2(reader.readData()); 299 d2(reader.readData());
300 300
301 REPORTER_ASSERT(reporter, 0 == d0->size()); 301 REPORTER_ASSERT(reporter, 0 == d0->size());
302 REPORTER_ASSERT(reporter, strlen(str)+1 == d1->size()); 302 REPORTER_ASSERT(reporter, strlen(str)+1 == d1->size());
303 REPORTER_ASSERT(reporter, !memcmp(str, d1->data(), strlen(str)+1)); 303 REPORTER_ASSERT(reporter, !memcmp(str, d1->data(), strlen(str)+1));
304 REPORTER_ASSERT(reporter, 0 == d2->size()); 304 REPORTER_ASSERT(reporter, 0 == d2->size());
305 305
306 REPORTER_ASSERT(reporter, reader.offset() == sizeWritten); 306 REPORTER_ASSERT(reporter, reader.offset() == sizeWritten);
307 REPORTER_ASSERT(reporter, reader.eof()); 307 REPORTER_ASSERT(reporter, reader.eof());
308 } 308 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698