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

Unified Diff: tests/SerializationTest.cpp

Issue 68973005: Expand pixelref to return SkImageInfo and rowbytes (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years 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
« tests/DrawBitmapRectTest.cpp ('K') | « tests/PixelRefTest.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 e7bb437030264626668d8595f5c1430a739c24af..e50cf41353ee0b401cfc716ca019e5b9c48afcff 100644
--- a/tests/SerializationTest.cpp
+++ b/tests/SerializationTest.cpp
@@ -148,6 +148,7 @@ static T* TestFlattenableSerialization(T* testObj, bool shouldSucceed,
REPORTER_ASSERT(reporter, SkAlign4(bytesWritten) == bytesWritten);
unsigned char dataWritten[1024];
+ SkASSERT(bytesWritten <= sizeof(dataWritten));
writer.writeToMemory(dataWritten);
// Make sure this fails when it should (test with smaller size, but still multiple of 4)
@@ -307,10 +308,21 @@ static void Tests(skiatest::Reporter* reporter) {
TestBitmapSerialization(validBitmap, invalidBitmap, true, reporter);
// Create a bitmap with a pixel ref too small
+ SkImageInfo info;
+ info.fWidth = 256;
+ info.fHeight = 256;
+ info.fColorType = kPMColor_SkColorType;
+ info.fAlphaType = kPremul_SkAlphaType;
+
SkBitmap invalidBitmap2;
- invalidBitmap2.setConfig(SkBitmap::kARGB_8888_Config, 256, 256);
- invalidBitmap2.setPixelRef(SkNEW_ARGS(SkMallocPixelRef,
- (NULL, 256, NULL)))->unref();
+ invalidBitmap2.setConfig(info);
+
+ // Hack to force invalid
+ info.fWidth = 32;
scroggo 2013/12/06 14:50:33 Is the hack that the SkMallocPixelRef's SkImageInf
reed1 2013/12/06 15:48:46 The hack is that the bitmap is LARGER than the pix
+ info.fHeight = 1;
+
+ invalidBitmap2.setPixelRef(SkMallocPixelRef::NewAllocate(
+ info, invalidBitmap2.rowBytes(), NULL))->unref();
// The deserialization should detect the pixel ref being too small and fail
TestBitmapSerialization(validBitmap, invalidBitmap2, false, reporter);
« tests/DrawBitmapRectTest.cpp ('K') | « tests/PixelRefTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698