| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 #include "Test.h" | 7 #include "Test.h" |
| 8 #include "SkCanvas.h" | 8 #include "SkCanvas.h" |
| 9 #include "SkColorPriv.h" | 9 #include "SkColorPriv.h" |
| 10 #include "SkData.h" | 10 #include "SkData.h" |
| (...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 SkAutoDataUnref picture1(serialized_picture_from_bitmap(original)); | 413 SkAutoDataUnref picture1(serialized_picture_from_bitmap(original)); |
| 414 SkAutoDataUnref picture2(serialized_picture_from_bitmap(bm)); | 414 SkAutoDataUnref picture2(serialized_picture_from_bitmap(bm)); |
| 415 REPORTER_ASSERT(reporter, picture1->equals(picture2)); | 415 REPORTER_ASSERT(reporter, picture1->equals(picture2)); |
| 416 // Now test that a parse error was generated when trying to create a new SkP
icture without | 416 // Now test that a parse error was generated when trying to create a new SkP
icture without |
| 417 // providing a function to decode the bitmap. | 417 // providing a function to decode the bitmap. |
| 418 ErrorContext context; | 418 ErrorContext context; |
| 419 context.fErrors = 0; | 419 context.fErrors = 0; |
| 420 context.fReporter = reporter; | 420 context.fReporter = reporter; |
| 421 SkSetErrorCallback(assert_one_parse_error_cb, &context); | 421 SkSetErrorCallback(assert_one_parse_error_cb, &context); |
| 422 SkMemoryStream pictureStream(picture1); | 422 SkMemoryStream pictureStream(picture1); |
| 423 bool success; | |
| 424 SkClearLastError(); | 423 SkClearLastError(); |
| 425 SkPicture pictureFromStream(&pictureStream, &success, NULL); | 424 SkAutoUnref pictureFromStream(SkPicture::CreateFromStream(&pictureStream, NU
LL)); |
| 426 REPORTER_ASSERT(reporter, success); | 425 REPORTER_ASSERT(reporter, pictureFromStream.get() != NULL); |
| 427 SkClearLastError(); | 426 SkClearLastError(); |
| 428 SkSetErrorCallback(NULL, NULL); | 427 SkSetErrorCallback(NULL, NULL); |
| 429 } | 428 } |
| 430 | 429 |
| 431 static void test_clone_empty(skiatest::Reporter* reporter) { | 430 static void test_clone_empty(skiatest::Reporter* reporter) { |
| 432 // This is a regression test for crbug.com/172062 | 431 // This is a regression test for crbug.com/172062 |
| 433 // Before the fix, we used to crash accessing a null pointer when we | 432 // Before the fix, we used to crash accessing a null pointer when we |
| 434 // had a picture with no paints. This test passes by not crashing. | 433 // had a picture with no paints. This test passes by not crashing. |
| 435 { | 434 { |
| 436 SkPicture picture; | 435 SkPicture picture; |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 #endif | 557 #endif |
| 559 test_peephole(); | 558 test_peephole(); |
| 560 test_gatherpixelrefs(reporter); | 559 test_gatherpixelrefs(reporter); |
| 561 test_bitmap_with_encoded_data(reporter); | 560 test_bitmap_with_encoded_data(reporter); |
| 562 test_clone_empty(reporter); | 561 test_clone_empty(reporter); |
| 563 test_clip_bound_opt(reporter); | 562 test_clip_bound_opt(reporter); |
| 564 } | 563 } |
| 565 | 564 |
| 566 #include "TestClassDef.h" | 565 #include "TestClassDef.h" |
| 567 DEFINE_TESTCLASS("Pictures", PictureTestClass, TestPicture) | 566 DEFINE_TESTCLASS("Pictures", PictureTestClass, TestPicture) |
| OLD | NEW |