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

Side by Side Diff: tests/ColorSpaceTest.cpp

Issue 1838583002: Don't crash when resource path isn't specified (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 8 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 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"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 REPORTER_ASSERT(r, almost_equal(0.0970764f, xyz.fMat[5])); 50 REPORTER_ASSERT(r, almost_equal(0.0970764f, xyz.fMat[5]));
51 REPORTER_ASSERT(r, almost_equal(0.143066f, xyz.fMat[6])); 51 REPORTER_ASSERT(r, almost_equal(0.143066f, xyz.fMat[6]));
52 REPORTER_ASSERT(r, almost_equal(0.0606079f, xyz.fMat[7])); 52 REPORTER_ASSERT(r, almost_equal(0.0606079f, xyz.fMat[7]));
53 REPORTER_ASSERT(r, almost_equal(0.714096f, xyz.fMat[8])); 53 REPORTER_ASSERT(r, almost_equal(0.714096f, xyz.fMat[8]));
54 #endif 54 #endif
55 } 55 }
56 56
57 DEF_TEST(ColorSpaceParseJpegICCProfile, r) { 57 DEF_TEST(ColorSpaceParseJpegICCProfile, r) {
58 SkAutoTDelete<SkStream> stream(resource("icc-v2-gbr.jpg")); 58 SkAutoTDelete<SkStream> stream(resource("icc-v2-gbr.jpg"));
59 REPORTER_ASSERT(r, nullptr != stream); 59 REPORTER_ASSERT(r, nullptr != stream);
60 if (!stream) {
61 return;
62 }
60 63
61 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream.release())); 64 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream.release()));
62 REPORTER_ASSERT(r, nullptr != codec); 65 REPORTER_ASSERT(r, nullptr != codec);
66 if (!codec) {
67 return;
68 }
63 69
64 SkColorSpace* colorSpace = codec->getColorSpace(); 70 SkColorSpace* colorSpace = codec->getColorSpace();
65 REPORTER_ASSERT(r, nullptr != colorSpace); 71 REPORTER_ASSERT(r, nullptr != colorSpace);
66 72
67 // It's important to use almost equal here. This profile sets gamma as 73 // It's important to use almost equal here. This profile sets gamma as
68 // 563 / 256, which actually comes out to about 2.19922. 74 // 563 / 256, which actually comes out to about 2.19922.
69 SkFloat3 gammas = colorSpace->gamma(); 75 SkFloat3 gammas = colorSpace->gamma();
70 REPORTER_ASSERT(r, almost_equal(2.2f, gammas.fVec[0])); 76 REPORTER_ASSERT(r, almost_equal(2.2f, gammas.fVec[0]));
71 REPORTER_ASSERT(r, almost_equal(2.2f, gammas.fVec[1])); 77 REPORTER_ASSERT(r, almost_equal(2.2f, gammas.fVec[1]));
72 REPORTER_ASSERT(r, almost_equal(2.2f, gammas.fVec[2])); 78 REPORTER_ASSERT(r, almost_equal(2.2f, gammas.fVec[2]));
73 79
74 // These nine values were extracted from the color profile. Until we know a ny 80 // These nine values were extracted from the color profile. Until we know a ny
75 // better, we'll assume these are the right values and test that we continue 81 // better, we'll assume these are the right values and test that we continue
76 // to extract them properly. 82 // to extract them properly.
77 SkFloat3x3 xyz = colorSpace->xyz(); 83 SkFloat3x3 xyz = colorSpace->xyz();
78 REPORTER_ASSERT(r, almost_equal(0.385117f, xyz.fMat[0])); 84 REPORTER_ASSERT(r, almost_equal(0.385117f, xyz.fMat[0]));
79 REPORTER_ASSERT(r, almost_equal(0.716904f, xyz.fMat[1])); 85 REPORTER_ASSERT(r, almost_equal(0.716904f, xyz.fMat[1]));
80 REPORTER_ASSERT(r, almost_equal(0.0970612f, xyz.fMat[2])); 86 REPORTER_ASSERT(r, almost_equal(0.0970612f, xyz.fMat[2]));
81 REPORTER_ASSERT(r, almost_equal(0.143051f, xyz.fMat[3])); 87 REPORTER_ASSERT(r, almost_equal(0.143051f, xyz.fMat[3]));
82 REPORTER_ASSERT(r, almost_equal(0.0606079f, xyz.fMat[4])); 88 REPORTER_ASSERT(r, almost_equal(0.0606079f, xyz.fMat[4]));
83 REPORTER_ASSERT(r, almost_equal(0.713913f, xyz.fMat[5])); 89 REPORTER_ASSERT(r, almost_equal(0.713913f, xyz.fMat[5]));
84 REPORTER_ASSERT(r, almost_equal(0.436035f, xyz.fMat[6])); 90 REPORTER_ASSERT(r, almost_equal(0.436035f, xyz.fMat[6]));
85 REPORTER_ASSERT(r, almost_equal(0.222488f, xyz.fMat[7])); 91 REPORTER_ASSERT(r, almost_equal(0.222488f, xyz.fMat[7]));
86 REPORTER_ASSERT(r, almost_equal(0.013916f, xyz.fMat[8])); 92 REPORTER_ASSERT(r, almost_equal(0.013916f, xyz.fMat[8]));
87 } 93 }
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