blob: 240de514c981f2881d9ee356813fe2d4f760e87d [file] [log] [blame]
scroggob61e2062014-11-10 13:12:25 -08001/*
2 * Copyright 2014 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#include "Resources.h"
9#include "Test.h"
10#include "SkBitmap.h"
11#include "SkImageDecoder.h"
12#include "SkOSFile.h"
13
scroggo139491f2015-07-10 09:32:09 -070014DEF_TEST(BadImage, reporter) {
15 const char* const badImages [] = {
scroggob61e2062014-11-10 13:12:25 -080016 "sigabort_favicon.ico",
17 "sigsegv_favicon.ico",
18 "sigsegv_favicon_2.ico",
msarett6e8f9032015-03-13 08:07:01 -070019 "ico_leak01.ico",
20 "ico_fuzz0.ico",
scroggo139491f2015-07-10 09:32:09 -070021 "ico_fuzz1.ico",
22 "skbug3442.webp",
23 "skbug3429.webp",
scroggob61e2062014-11-10 13:12:25 -080024 };
25
scroggo139491f2015-07-10 09:32:09 -070026 const char* badImagesFolder = "invalid_images";
scroggob61e2062014-11-10 13:12:25 -080027
scroggo139491f2015-07-10 09:32:09 -070028 SkString resourcePath = GetResourcePath(badImagesFolder);
scroggob61e2062014-11-10 13:12:25 -080029
30 SkBitmap bm;
scroggo139491f2015-07-10 09:32:09 -070031 for (size_t i = 0; i < SK_ARRAY_COUNT(badImages); ++i) {
32 SkString fullPath = SkOSPath::Join(resourcePath.c_str(), badImages[i]);
scroggob61e2062014-11-10 13:12:25 -080033 bool success = SkImageDecoder::DecodeFile(fullPath.c_str(), &bm);
34 // These files are invalid, and should not decode. More importantly,
35 // though, we reached here without crashing.
36 REPORTER_ASSERT(reporter, !success);
37 }
38}