| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "SkBitmap.h" | 8 #include "SkBitmap.h" |
| 9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
| 10 #include "SkDocument.h" | 10 #include "SkDocument.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 return bitmap; | 36 return bitmap; |
| 37 } | 37 } |
| 38 | 38 |
| 39 SkBitmap make_invalid_bitmap(SkColorType colorType) { | 39 SkBitmap make_invalid_bitmap(SkColorType colorType) { |
| 40 return make_invalid_bitmap( | 40 return make_invalid_bitmap( |
| 41 SkImageInfo::Make(100, 100, colorType, kPremul_SkAlphaType)); | 41 SkImageInfo::Make(100, 100, colorType, kPremul_SkAlphaType)); |
| 42 } | 42 } |
| 43 | 43 |
| 44 } // namespace | 44 } // namespace |
| 45 | 45 |
| 46 DEF_TEST(PDFInvalidBitmap, reporter) { | 46 DEF_TEST(SkPDF_InvalidBitmap, reporter) { |
| 47 SkDynamicMemoryWStream stream; | 47 SkDynamicMemoryWStream stream; |
| 48 sk_sp<SkDocument> document(SkDocument::MakePDF(&stream)); | 48 sk_sp<SkDocument> document(SkDocument::MakePDF(&stream)); |
| 49 if (!document) { |
| 50 return; |
| 51 } |
| 49 SkCanvas* canvas = document->beginPage(100, 100); | 52 SkCanvas* canvas = document->beginPage(100, 100); |
| 50 | 53 |
| 51 canvas->drawBitmap(SkBitmap(), 0, 0); | 54 canvas->drawBitmap(SkBitmap(), 0, 0); |
| 52 canvas->drawBitmap(make_invalid_bitmap(SkImageInfo()), 0, 0); | 55 canvas->drawBitmap(make_invalid_bitmap(SkImageInfo()), 0, 0); |
| 53 canvas->drawBitmap(make_invalid_bitmap(kN32_SkColorType), 0, 0); | 56 canvas->drawBitmap(make_invalid_bitmap(kN32_SkColorType), 0, 0); |
| 54 canvas->drawBitmap(make_invalid_bitmap(kIndex_8_SkColorType), 0, 0); | 57 canvas->drawBitmap(make_invalid_bitmap(kIndex_8_SkColorType), 0, 0); |
| 55 canvas->drawBitmap(make_invalid_bitmap(kARGB_4444_SkColorType), 0, 0); | 58 canvas->drawBitmap(make_invalid_bitmap(kARGB_4444_SkColorType), 0, 0); |
| 56 canvas->drawBitmap(make_invalid_bitmap(kRGB_565_SkColorType), 0, 0); | 59 canvas->drawBitmap(make_invalid_bitmap(kRGB_565_SkColorType), 0, 0); |
| 57 canvas->drawBitmap(make_invalid_bitmap(kAlpha_8_SkColorType), 0, 0); | 60 canvas->drawBitmap(make_invalid_bitmap(kAlpha_8_SkColorType), 0, 0); |
| 58 | 61 |
| 59 // This test passes if it does not crash. | 62 // This test passes if it does not crash. |
| 60 } | 63 } |
| OLD | NEW |