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

Side by Side Diff: tests/FlattenDrawableTest.cpp

Issue 1917183002: Remove redundant test (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 8 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 | « no previous file | 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 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 "SkCanvas.h" 8 #include "SkCanvas.h"
9 #include "SkDrawable.h" 9 #include "SkDrawable.h"
10 #include "SkOnce.h" 10 #include "SkOnce.h"
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 239
240 // Note that we can still recognize the generic drawable as an IntDrawable 240 // Note that we can still recognize the generic drawable as an IntDrawable
241 SkDrawable* generic = rootOut->drawable(); 241 SkDrawable* generic = rootOut->drawable();
242 REPORTER_ASSERT(r, !strcmp("IntDrawable", generic->getTypeName())); 242 REPORTER_ASSERT(r, !strcmp("IntDrawable", generic->getTypeName()));
243 IntDrawable* integer = (IntDrawable*) generic; 243 IntDrawable* integer = (IntDrawable*) generic;
244 REPORTER_ASSERT(r, 1 == integer->a()); 244 REPORTER_ASSERT(r, 1 == integer->a());
245 REPORTER_ASSERT(r, 2 == integer->b()); 245 REPORTER_ASSERT(r, 2 == integer->b());
246 REPORTER_ASSERT(r, 3 == integer->c()); 246 REPORTER_ASSERT(r, 3 == integer->c());
247 REPORTER_ASSERT(r, 4 == integer->d()); 247 REPORTER_ASSERT(r, 4 == integer->d());
248 } 248 }
249
250 static sk_sp<SkFlattenable> custom_create_proc(SkReadBuffer& buffer) {
251 sk_sp<SkFlattenable> drawable = IntDrawable::CreateProc(buffer);
252 IntDrawable* intDrawable = (IntDrawable*) drawable.get();
253 return sk_sp<IntDrawable>(new IntDrawable(intDrawable->a() + 1, intDrawable- >b() + 1,
254 intDrawable->c() + 1, intDrawable- >d() + 1));
255 }
256
257 DEF_TEST(FlattenCustomDrawable, r) {
258 // Create and serialize the test drawable
259 SkAutoTUnref<SkDrawable> drawable(new IntDrawable(1, 2, 3, 4));
260 SkWriteBuffer writeBuffer;
261 writeBuffer.writeFlattenable(drawable);
262
263 // Copy the contents of the write buffer into a read buffer
264 sk_sp<SkData> data = SkData::MakeUninitialized(writeBuffer.bytesWritten());
265 writeBuffer.writeToMemory(data->writable_data());
266 SkReadBuffer readBuffer(data->data(), data->size());
267
268 // Register a custom factory with the read buffer
269 readBuffer.setCustomFactory(SkString("IntDrawable"), &custom_create_proc);
270
271 // Deserialize and verify the drawable
272 SkAutoTUnref<IntDrawable> out((IntDrawable*)
273 readBuffer.readFlattenable(SkFlattenable::kSkDrawable_Type));
274 REPORTER_ASSERT(r, out);
275 REPORTER_ASSERT(r, 2 == out->a());
276 REPORTER_ASSERT(r, 3 == out->b());
277 REPORTER_ASSERT(r, 4 == out->c());
278 REPORTER_ASSERT(r, 5 == out->d());
279 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698