Chromium Code Reviews| Index: tests/PictureTest.cpp |
| diff --git a/tests/PictureTest.cpp b/tests/PictureTest.cpp |
| index 6adfd5a9be1d19b1161cb24e05eb26045ad486ee..49ed7f3f0e5998cbe5e0b1e12a00d39ea0f36d4f 100644 |
| --- a/tests/PictureTest.cpp |
| +++ b/tests/PictureTest.cpp |
| @@ -8,6 +8,7 @@ |
| #include "SkCanvas.h" |
| #include "SkColorPriv.h" |
| #include "SkData.h" |
| +#include "SkError.h" |
| #include "SkPaint.h" |
| #include "SkPicture.h" |
| #include "SkRandom.h" |
| @@ -371,6 +372,10 @@ static SkData* serialized_picture_from_bitmap(const SkBitmap& bitmap) { |
| return wStream.copyToData(); |
| } |
| +static void error_callback(SkError, void*) { |
| + // Do nothing. |
| +} |
| + |
| static void test_bitmap_with_encoded_data(skiatest::Reporter* reporter) { |
| // Create a bitmap that will be encoded. |
| SkBitmap original; |
| @@ -395,6 +400,16 @@ static void test_bitmap_with_encoded_data(skiatest::Reporter* reporter) { |
| SkAutoDataUnref picture1(serialized_picture_from_bitmap(original)); |
| SkAutoDataUnref picture2(serialized_picture_from_bitmap(bm)); |
| REPORTER_ASSERT(reporter, picture1->equals(picture2)); |
| + // Now test that a parse error was generated when trying to create a new SkPicture without |
| + // providing a function to decode the bitmap. |
| + SkSetErrorCallback(error_callback, NULL); |
|
humper
2013/04/25 17:07:08
Is the idea here to silence the built-in default c
|
| + SkMemoryStream pictureStream(picture1); |
| + bool success; |
| + SkClearLastError(); |
| + SkPicture pictureFromStream(&pictureStream, &success, NULL); |
| + REPORTER_ASSERT(reporter, success); |
| + REPORTER_ASSERT(reporter, SkGetLastError() == kParseError_SkError); |
| + SkClearLastError(); |
| } |
| static void test_clone_empty(skiatest::Reporter* reporter) { |