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

Unified Diff: tests/SerializationTest.cpp

Issue 604873004: Fix SkTableColorFilter deserialization validation. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Increase buffer size in test Created 6 years, 3 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 | « src/effects/SkTableColorFilter.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/SerializationTest.cpp
diff --git a/tests/SerializationTest.cpp b/tests/SerializationTest.cpp
index af146006e7f1975ac20bb24a971dd36e61561650..dd9b938d52e26df4d9761144db484c35a90c4b08 100644
--- a/tests/SerializationTest.cpp
+++ b/tests/SerializationTest.cpp
@@ -11,6 +11,7 @@
#include "SkMallocPixelRef.h"
#include "SkOSFile.h"
#include "SkPictureRecorder.h"
+#include "SkTableColorFilter.h"
#include "SkTemplates.h"
#include "SkTypeface.h"
#include "SkWriteBuffer.h"
@@ -177,7 +178,7 @@ static T* TestFlattenableSerialization(T* testObj, bool shouldSucceed,
size_t bytesWritten = writer.bytesWritten();
REPORTER_ASSERT(reporter, SkAlign4(bytesWritten) == bytesWritten);
- unsigned char dataWritten[1024];
+ unsigned char dataWritten[4096];
SkASSERT(bytesWritten <= sizeof(dataWritten));
writer.writeToMemory(dataWritten);
@@ -274,6 +275,16 @@ static void TestXfermodeSerialization(skiatest::Reporter* reporter) {
}
}
+static void TestColorFilterSerialization(skiatest::Reporter* reporter) {
+ uint8_t table[256];
+ for (int i = 0; i < 256; ++i) {
+ table[i] = (i * 41) % 256;
+ }
+ SkAutoTUnref<SkColorFilter> colorFilter(SkTableColorFilter::Create(table));
+ SkAutoTUnref<SkColorFilter> copy(
+ TestFlattenableSerialization<SkColorFilter>(colorFilter.get(), true, reporter));
+}
+
static SkBitmap draw_picture(SkPicture& picture) {
SkBitmap bitmap;
bitmap.allocN32Pixels(SkScalarCeilToInt(picture.cullRect().width()),
@@ -424,6 +435,11 @@ DEF_TEST(Serialization, reporter) {
TestXfermodeSerialization(reporter);
}
+ // Test color filter serialization
+ {
+ TestColorFilterSerialization(reporter);
+ }
+
// Test string serialization
{
SkString string("string");
« no previous file with comments | « src/effects/SkTableColorFilter.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698