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

Side by Side Diff: tests/ColorSpaceTest.cpp

Issue 1840573004: Don't crash when resource path is omitted (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 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 | tests/ExifTest.cpp » ('j') | 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 2016 Google Inc. 2 * Copyright 2016 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 "Resources.h" 8 #include "Resources.h"
9 #include "SkCodec.h" 9 #include "SkCodec.h"
10 #include "SkColorSpace.h" 10 #include "SkColorSpace.h"
11 #include "Test.h" 11 #include "Test.h"
12 12
13 #include "png.h" 13 #include "png.h"
14 14
15 static SkStreamAsset* resource(const char path[]) { 15 static SkStreamAsset* resource(const char path[]) {
16 SkString fullPath = GetResourcePath(path); 16 SkString fullPath = GetResourcePath(path);
17 return SkStream::NewFromFile(fullPath.c_str()); 17 return SkStream::NewFromFile(fullPath.c_str());
18 } 18 }
19 19
20 static bool almost_equal(float a, float b) { 20 static bool almost_equal(float a, float b) {
21 return SkTAbs(a - b) < 0.001f; 21 return SkTAbs(a - b) < 0.001f;
22 } 22 }
23 23
24 DEF_TEST(ColorSpaceParsePngICCProfile, r) { 24 DEF_TEST(ColorSpaceParsePngICCProfile, r) {
25 SkAutoTDelete<SkStream> stream(resource("color_wheel_with_profile.png")); 25 SkAutoTDelete<SkStream> stream(resource("color_wheel_with_profile.png"));
26 REPORTER_ASSERT(r, nullptr != stream); 26 REPORTER_ASSERT(r, nullptr != stream);
27 if (!stream) {
28 return;
29 }
27 30
28 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream.release())); 31 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream.release()));
29 REPORTER_ASSERT(r, nullptr != codec); 32 REPORTER_ASSERT(r, nullptr != codec);
30 33
31 #if (PNG_LIBPNG_VER_MAJOR > 1) || (PNG_LIBPNG_VER_MAJOR == 1 && PNG_LIBPNG_VER_M INOR >= 6) 34 #if (PNG_LIBPNG_VER_MAJOR > 1) || (PNG_LIBPNG_VER_MAJOR == 1 && PNG_LIBPNG_VER_M INOR >= 6)
32 SkColorSpace* colorSpace = codec->getColorSpace(); 35 SkColorSpace* colorSpace = codec->getColorSpace();
33 REPORTER_ASSERT(r, nullptr != colorSpace); 36 REPORTER_ASSERT(r, nullptr != colorSpace);
34 37
35 // No need to use almost equal here. The color profile that we have extract ed 38 // No need to use almost equal here. The color profile that we have extract ed
36 // actually has a table of gammas. And our current implementation guesses 2 .2f. 39 // actually has a table of gammas. And our current implementation guesses 2 .2f.
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 REPORTER_ASSERT(r, almost_equal(0.385117f, xyz.fMat[0])); 87 REPORTER_ASSERT(r, almost_equal(0.385117f, xyz.fMat[0]));
85 REPORTER_ASSERT(r, almost_equal(0.716904f, xyz.fMat[1])); 88 REPORTER_ASSERT(r, almost_equal(0.716904f, xyz.fMat[1]));
86 REPORTER_ASSERT(r, almost_equal(0.0970612f, xyz.fMat[2])); 89 REPORTER_ASSERT(r, almost_equal(0.0970612f, xyz.fMat[2]));
87 REPORTER_ASSERT(r, almost_equal(0.143051f, xyz.fMat[3])); 90 REPORTER_ASSERT(r, almost_equal(0.143051f, xyz.fMat[3]));
88 REPORTER_ASSERT(r, almost_equal(0.0606079f, xyz.fMat[4])); 91 REPORTER_ASSERT(r, almost_equal(0.0606079f, xyz.fMat[4]));
89 REPORTER_ASSERT(r, almost_equal(0.713913f, xyz.fMat[5])); 92 REPORTER_ASSERT(r, almost_equal(0.713913f, xyz.fMat[5]));
90 REPORTER_ASSERT(r, almost_equal(0.436035f, xyz.fMat[6])); 93 REPORTER_ASSERT(r, almost_equal(0.436035f, xyz.fMat[6]));
91 REPORTER_ASSERT(r, almost_equal(0.222488f, xyz.fMat[7])); 94 REPORTER_ASSERT(r, almost_equal(0.222488f, xyz.fMat[7]));
92 REPORTER_ASSERT(r, almost_equal(0.013916f, xyz.fMat[8])); 95 REPORTER_ASSERT(r, almost_equal(0.013916f, xyz.fMat[8]));
93 } 96 }
OLDNEW
« no previous file with comments | « no previous file | tests/ExifTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698