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

Side by Side Diff: tests/FlattenableCustomFactory.cpp

Issue 1920423002: Prototype code that turns any/every flattenable into JSON (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix copyright dates in new files Created 4 years, 7 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/FlattenDrawableTest.cpp ('k') | tests/ImageIsOpaqueTest.cpp » ('j') | 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 2016 Google Inc. 2 * Copyright 2016 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 "SkFlattenable.h" 8 #include "SkFlattenable.h"
9 #include "SkReadBuffer.h" 9 #include "SkReadBuffer.h"
10 #include "SkWriteBuffer.h" 10 #include "SkWriteBuffer.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 static sk_sp<SkFlattenable> custom_create_proc(SkReadBuffer& buffer) { 45 static sk_sp<SkFlattenable> custom_create_proc(SkReadBuffer& buffer) {
46 uint32_t a = buffer.readUInt(); 46 uint32_t a = buffer.readUInt();
47 uint32_t b = buffer.readUInt(); 47 uint32_t b = buffer.readUInt();
48 uint32_t c = buffer.readUInt(); 48 uint32_t c = buffer.readUInt();
49 uint32_t d = buffer.readUInt(); 49 uint32_t d = buffer.readUInt();
50 return sk_sp<SkFlattenable>(new IntFlattenable(a + 1, b + 1, c + 1, d + 1)); 50 return sk_sp<SkFlattenable>(new IntFlattenable(a + 1, b + 1, c + 1, d + 1));
51 } 51 }
52 52
53 DEF_TEST(UnflattenWithCustomFactory, r) { 53 DEF_TEST(UnflattenWithCustomFactory, r) {
54 // Create and flatten the test flattenable 54 // Create and flatten the test flattenable
55 SkWriteBuffer writeBuffer; 55 SkBinaryWriteBuffer writeBuffer;
56 SkAutoTUnref<SkFlattenable> flattenable1(new IntFlattenable(1, 2, 3, 4)); 56 SkAutoTUnref<SkFlattenable> flattenable1(new IntFlattenable(1, 2, 3, 4));
57 writeBuffer.writeFlattenable(flattenable1); 57 writeBuffer.writeFlattenable(flattenable1);
58 SkAutoTUnref<SkFlattenable> flattenable2(new IntFlattenable(2, 3, 4, 5)); 58 SkAutoTUnref<SkFlattenable> flattenable2(new IntFlattenable(2, 3, 4, 5));
59 writeBuffer.writeFlattenable(flattenable2); 59 writeBuffer.writeFlattenable(flattenable2);
60 SkAutoTUnref<SkFlattenable> flattenable3(new IntFlattenable(3, 4, 5, 6)); 60 SkAutoTUnref<SkFlattenable> flattenable3(new IntFlattenable(3, 4, 5, 6));
61 writeBuffer.writeFlattenable(flattenable3); 61 writeBuffer.writeFlattenable(flattenable3);
62 62
63 // Copy the contents of the write buffer into a read buffer 63 // Copy the contents of the write buffer into a read buffer
64 sk_sp<SkData> data = SkData::MakeUninitialized(writeBuffer.bytesWritten()); 64 sk_sp<SkData> data = SkData::MakeUninitialized(writeBuffer.bytesWritten());
65 writeBuffer.writeToMemory(data->writable_data()); 65 writeBuffer.writeToMemory(data->writable_data());
(...skipping 20 matching lines...) Expand all
86 REPORTER_ASSERT(r, 6 == out2->d()); 86 REPORTER_ASSERT(r, 6 == out2->d());
87 87
88 SkAutoTUnref<IntFlattenable> out3((IntFlattenable*) readBuffer.readFlattenab le( 88 SkAutoTUnref<IntFlattenable> out3((IntFlattenable*) readBuffer.readFlattenab le(
89 SkFlattenable::kSkUnused_Type)); 89 SkFlattenable::kSkUnused_Type));
90 REPORTER_ASSERT(r, out3); 90 REPORTER_ASSERT(r, out3);
91 REPORTER_ASSERT(r, 4 == out3->a()); 91 REPORTER_ASSERT(r, 4 == out3->a());
92 REPORTER_ASSERT(r, 5 == out3->b()); 92 REPORTER_ASSERT(r, 5 == out3->b());
93 REPORTER_ASSERT(r, 6 == out3->c()); 93 REPORTER_ASSERT(r, 6 == out3->c());
94 REPORTER_ASSERT(r, 7 == out3->d()); 94 REPORTER_ASSERT(r, 7 == out3->d());
95 } 95 }
OLDNEW
« no previous file with comments | « tests/FlattenDrawableTest.cpp ('k') | tests/ImageIsOpaqueTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698