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

Side by Side Diff: tests/InvalidIndexedPngTest.cpp

Issue 1002583002: Fix Windows build. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 9 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 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 // The PNG decoder is not available on all platforms.
9 #if !defined(SK_BUILD_FOR_MAC) && \
10 !defined(SK_BUILD_FOR_WIN) && \
11 !defined(SK_BUILD_FOR_IOS)
12
13 #include "SkBitmap.h" 8 #include "SkBitmap.h"
14 #include "SkForceLinking.h" 9 #include "SkForceLinking.h"
15 #include "SkImageDecoder.h" 10 #include "SkImageDecoder.h"
16 #include "Test.h" 11 #include "Test.h"
17 12
18 // A valid 1x1 indexed PNG. 13 // A valid 1x1 indexed PNG.
19 unsigned char gPngData[] = { 14 unsigned char gPngData[] = {
20 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 15 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d,
21 0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 16 0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01,
22 0x08, 0x03, 0x00, 0x00, 0x00, 0x28, 0xcb, 0x34, 0xbb, 0x00, 0x00, 0x00, 17 0x08, 0x03, 0x00, 0x00, 0x00, 0x28, 0xcb, 0x34, 0xbb, 0x00, 0x00, 0x00,
23 0x09, 0x70, 0x48, 0x59, 0x73, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 18 0x09, 0x70, 0x48, 0x59, 0x73, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00,
24 0x1c, 0x00, 0x0f, 0x01, 0xb9, 0x8f, 0x00, 0x00, 0x00, 0x06, 0x50, 0x4c, 19 0x1c, 0x00, 0x0f, 0x01, 0xb9, 0x8f, 0x00, 0x00, 0x00, 0x06, 0x50, 0x4c,
25 0x54, 0x45, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0xd2, 0x87, 0xef, 0x71, 20 0x54, 0x45, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0xd2, 0x87, 0xef, 0x71,
26 0x00, 0x00, 0x00, 0x13, 0x49, 0x44, 0x41, 0x54, 0x78, 0xda, 0xed, 0xfd, 21 0x00, 0x00, 0x00, 0x13, 0x49, 0x44, 0x41, 0x54, 0x78, 0xda, 0xed, 0xfd,
27 0x81, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0xf8, 0xaf, 0x16, 0x46, 0x00, 22 0x81, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0xf8, 0xaf, 0x16, 0x46, 0x00,
28 0x02, 0x00, 0x01, 0x32, 0x60, 0xf7, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x49, 23 0x02, 0x00, 0x01, 0x32, 0x60, 0xf7, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x49,
29 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82 24 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
30 }; 25 };
31 26
32 // Attempt to decode an invalid PNG that has a palette. Mostly we're looking to 27 // Attempt to decode an invalid PNG that has a palette. Mostly we're looking to
33 // make sure we don't leak memory since libpng uses setjmp for error handling so 28 // make sure we don't leak memory since libpng uses setjmp for error handling so
34 // it's very easy to accidentally skip destructors when a failure happens. 29 // it's very easy to accidentally skip destructors when a failure happens.
30 // As a result, we do not have any REPORTER_ASSERT statements
35 DEF_TEST(InvalidIndexedPng, reporter) { 31 DEF_TEST(InvalidIndexedPng, reporter) {
36 SkBitmap image; 32 SkBitmap image;
37 SkForceLinking(false); 33 SkForceLinking(false);
38 // Make our PNG invalid by changing a byte. 34 // Make our PNG invalid by changing a byte.
39 gPngData[sizeof(gPngData) - 1] = 1; 35 gPngData[sizeof(gPngData) - 1] = 1;
40 bool success = SkImageDecoder::DecodeMemory( 36
41 gPngData, sizeof(gPngData), &image, SkColorType::kUnknown_SkColorType, 37 SkImageDecoder::DecodeMemory(gPngData, sizeof(gPngData), &image);
42 SkImageDecoder::kDecodePixels_Mode);
43 REPORTER_ASSERT(reporter, !success);
44 } 38 }
45
46 #endif // !(SK_BUILD_FOR_MAC||SK_BUILD_FOR_WIN||SK_BUILD_FOR_IOS)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698