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

Unified Diff: tests/CodecTest.cpp

Issue 2339273002: SkFontData to use smart pointers. (Closed)
Patch Set: Add trivial bodies to the trivial implementations. Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/BadIcoTest.cpp ('k') | tests/ColorSpaceTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/CodecTest.cpp
diff --git a/tests/CodecTest.cpp b/tests/CodecTest.cpp
index 044c2fd6b45ff733b5c7c2c55eec5fd265570ee9..341433b379674b1db376765d80392bb650947dea 100644
--- a/tests/CodecTest.cpp
+++ b/tests/CodecTest.cpp
@@ -22,11 +22,6 @@
#include "png.h"
-static SkStreamAsset* resource(const char path[]) {
- SkString fullPath = GetResourcePath(path);
- return SkStream::NewFromFile(fullPath.c_str());
-}
-
static void md5(const SkBitmap& bm, SkMD5::Digest* digest) {
SkAutoLockPixels autoLockPixels(bm);
SkASSERT(bm.getPixels());
@@ -199,9 +194,8 @@ static void check(skiatest::Reporter* r,
bool supportsSubsetDecoding,
bool supportsIncomplete = true) {
- SkAutoTDelete<SkStream> stream(resource(path));
+ SkAutoTDelete<SkStream> stream(GetResourceAsStream(path));
if (!stream) {
- SkDebugf("Missing resource '%s'\n", path);
return;
}
@@ -329,9 +323,8 @@ static void check(skiatest::Reporter* r,
// SkAndroidCodec tests
if (supportsScanlineDecoding || supportsSubsetDecoding) {
- SkAutoTDelete<SkStream> stream(resource(path));
+ SkAutoTDelete<SkStream> stream(GetResourceAsStream(path));
if (!stream) {
- SkDebugf("Missing resource '%s'\n", path);
return;
}
@@ -356,7 +349,7 @@ static void check(skiatest::Reporter* r,
if (!isIncomplete) {
// Test SkCodecImageGenerator
- SkAutoTDelete<SkStream> stream(resource(path));
+ SkAutoTDelete<SkStream> stream(GetResourceAsStream(path));
sk_sp<SkData> fullData(SkData::MakeFromStream(stream, stream->getLength()));
SkAutoTDelete<SkImageGenerator> gen(
SkCodecImageGenerator::NewFromEncodedCodec(fullData.get()));
@@ -449,9 +442,10 @@ DEF_TEST(Codec, r) {
// Test interlaced PNG in stripes, similar to DM's kStripe_Mode
DEF_TEST(Codec_stripes, r) {
const char * path = "plane_interlaced.png";
- SkAutoTDelete<SkStream> stream(resource(path));
+ SkAutoTDelete<SkStream> stream(GetResourceAsStream(path));
+ REPORTER_ASSERT(r, stream);
if (!stream) {
- SkDebugf("Missing resource '%s'\n", path);
+ return;
}
SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream.release()));
@@ -582,9 +576,8 @@ DEF_TEST(Codec_null, r) {
static void test_dimensions(skiatest::Reporter* r, const char path[]) {
// Create the codec from the resource file
- SkAutoTDelete<SkStream> stream(resource(path));
+ SkAutoTDelete<SkStream> stream(GetResourceAsStream(path));
if (!stream) {
- SkDebugf("Missing resource '%s'\n", path);
return;
}
SkAutoTDelete<SkAndroidCodec> codec(SkAndroidCodec::NewFromStream(stream.release()));
@@ -647,9 +640,8 @@ DEF_TEST(Codec_Dimensions, r) {
}
static void test_invalid(skiatest::Reporter* r, const char path[]) {
- SkAutoTDelete<SkStream> stream(resource(path));
+ SkAutoTDelete<SkStream> stream(GetResourceAsStream(path));
if (!stream) {
- SkDebugf("Missing resource '%s'\n", path);
return;
}
SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream.release()));
@@ -673,9 +665,8 @@ DEF_TEST(Codec_Empty, r) {
}
static void test_invalid_parameters(skiatest::Reporter* r, const char path[]) {
- SkAutoTDelete<SkStream> stream(resource(path));
+ SkAutoTDelete<SkStream> stream(GetResourceAsStream(path));
if (!stream) {
- SkDebugf("Missing resource '%s'\n", path);
return;
}
SkAutoTDelete<SkCodec> decoder(SkCodec::NewFromStream(stream.release()));
@@ -965,9 +956,8 @@ DEF_TEST(Codec_webp_peek, r) {
// Test that SkCodec now supports an image with these bits set.
DEF_TEST(Codec_wbmp, r) {
const char* path = "mandrill.wbmp";
- SkAutoTDelete<SkStream> stream(resource(path));
+ SkAutoTDelete<SkStream> stream(GetResourceAsStream(path));
if (!stream) {
- SkDebugf("Missing resource '%s'\n", path);
return;
}
@@ -1016,9 +1006,8 @@ DEF_TEST(Codec_wbmp_max_size, r) {
DEF_TEST(Codec_jpeg_rewind, r) {
const char* path = "mandrill_512_q075.jpg";
- SkAutoTDelete<SkStream> stream(resource(path));
+ SkAutoTDelete<SkStream> stream(GetResourceAsStream(path));
if (!stream) {
- SkDebugf("Missing resource '%s'\n", path);
return;
}
SkAutoTDelete<SkAndroidCodec> codec(SkAndroidCodec::NewFromStream(stream.release()));
@@ -1044,7 +1033,7 @@ DEF_TEST(Codec_jpeg_rewind, r) {
}
static void check_color_xform(skiatest::Reporter* r, const char* path) {
- SkAutoTDelete<SkAndroidCodec> codec(SkAndroidCodec::NewFromStream(resource(path)));
+ SkAutoTDelete<SkAndroidCodec> codec(SkAndroidCodec::NewFromStream(GetResourceAsStream(path)));
SkAndroidCodec::AndroidOptions opts;
opts.fSampleSize = 3;
@@ -1130,7 +1119,7 @@ static void check_round_trip(skiatest::Reporter* r, SkCodec* origCodec, const Sk
DEF_TEST(Codec_PngRoundTrip, r) {
const char* path = "mandrill_512_q075.jpg";
- SkAutoTDelete<SkStream> stream(resource(path));
+ SkAutoTDelete<SkStream> stream(GetResourceAsStream(path));
SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream.release()));
SkColorType colorTypesOpaque[] = {
@@ -1142,12 +1131,12 @@ DEF_TEST(Codec_PngRoundTrip, r) {
}
path = "grayscale.jpg";
- stream.reset(resource(path));
+ stream.reset(GetResourceAsStream(path));
codec.reset(SkCodec::NewFromStream(stream.release()));
check_round_trip(r, codec.get(), codec->getInfo());
path = "yellow_rose.png";
- stream.reset(resource(path));
+ stream.reset(GetResourceAsStream(path));
codec.reset(SkCodec::NewFromStream(stream.release()));
SkColorType colorTypesWithAlpha[] = {
@@ -1167,7 +1156,7 @@ DEF_TEST(Codec_PngRoundTrip, r) {
}
path = "index8.png";
- stream.reset(resource(path));
+ stream.reset(GetResourceAsStream(path));
codec.reset(SkCodec::NewFromStream(stream.release()));
for (SkAlphaType alphaType : alphaTypes) {
@@ -1179,7 +1168,7 @@ DEF_TEST(Codec_PngRoundTrip, r) {
static void test_conversion_possible(skiatest::Reporter* r, const char* path,
bool testScanlineDecoder) {
- SkAutoTDelete<SkStream> stream(resource(path));
+ SkAutoTDelete<SkStream> stream(GetResourceAsStream(path));
SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream.release()));
SkImageInfo infoF16 = codec->getInfo().makeColorType(kRGBA_F16_SkColorType);
« no previous file with comments | « tests/BadIcoTest.cpp ('k') | tests/ColorSpaceTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698