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

Side by Side Diff: tests/SkBlend_optsTest.cpp

Issue 1987143002: Make SkBlend_optsTests fail rather than crash when resources are missing (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 7 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 <string> 8 #include <string>
9 #include <tuple> 9 #include <tuple>
10 #include <vector> 10 #include <vector>
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 Spec spec, 55 Spec spec,
56 std::string resourceName, 56 std::string resourceName,
57 skiatest::Reporter* reporter) 57 skiatest::Reporter* reporter)
58 { 58 {
59 Blender blender; 59 Blender blender;
60 std::string name; 60 std::string name;
61 std::tie(blender, name) = spec; 61 std::tie(blender, name) = spec;
62 62
63 std::string fileName = resourceName + ".png"; 63 std::string fileName = resourceName + ".png";
64 sk_sp<SkImage> image = GetResourceAsImage(fileName.c_str()); 64 sk_sp<SkImage> image = GetResourceAsImage(fileName.c_str());
65 SkASSERT(image != nullptr);
66 if (image == nullptr) { 65 if (image == nullptr) {
67 SkFAIL("image is NULL"); 66 ERRORF(reporter, "image is NULL");
67 return;
68 } 68 }
69 SkBitmap bm; 69 SkBitmap bm;
70 if (!as_IB(image)->getROPixels(&bm)) { 70 if (!as_IB(image)->getROPixels(&bm)) {
71 SkFAIL("Could not read resource"); 71 ERRORF(reporter, "Could not read resource");
72 return;
72 } 73 }
73 74
74 SkPixmap pixmap; 75 SkPixmap pixmap;
75 bm.peekPixels(&pixmap); 76 bm.peekPixels(&pixmap);
76 SkASSERTF(pixmap.colorType() == kN32_SkColorType, "colorType: %d", pixmap.co lorType()); 77 SkASSERTF(pixmap.colorType() == kN32_SkColorType, "colorType: %d", pixmap.co lorType());
77 SkASSERT(pixmap.alphaType() != kUnpremul_SkAlphaType); 78 SkASSERT(pixmap.alphaType() != kUnpremul_SkAlphaType);
78 const uint32_t* src = pixmap.addr32(); 79 const uint32_t* src = pixmap.addr32();
79 const int width = pixmap.rowBytesAsPixels(); 80 const int width = pixmap.rowBytesAsPixels();
80 SkASSERT(width > 0); 81 SkASSERT(width > 0);
81 SkASSERT(width < 4000); 82 SkASSERT(width < 4000);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 DEF_TEST(SkBlend_optsSqrtCheck, reporter) { 126 DEF_TEST(SkBlend_optsSqrtCheck, reporter) {
126 for (int c = 0; c < 256; c++) { 127 for (int c = 0; c < 256; c++) {
127 Sk4f i{(float)c}; 128 Sk4f i{(float)c};
128 Sk4f ii = i * i; 129 Sk4f ii = i * i;
129 Sk4f s = ii.sqrt() + 0.5f; 130 Sk4f s = ii.sqrt() + 0.5f;
130 Sk4f sf = s.floor(); 131 Sk4f sf = s.floor();
131 REPORTER_ASSERT_MESSAGE( 132 REPORTER_ASSERT_MESSAGE(
132 reporter, i[0] == sf[0], SkStringPrintf("i: %f, s: %f", i[0], sf[0]) ); 133 reporter, i[0] == sf[0], SkStringPrintf("i: %f, s: %f", i[0], sf[0]) );
133 } 134 }
134 } 135 }
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