diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/BadIcoTest.cpp | 6 | ||||
-rw-r--r-- | tests/CodecTest.cpp | 45 | ||||
-rw-r--r-- | tests/ColorSpaceTest.cpp | 7 | ||||
-rw-r--r-- | tests/ExifTest.cpp | 9 | ||||
-rw-r--r-- | tests/SerializationTest.cpp | 5 | ||||
-rw-r--r-- | tests/YUVTest.cpp | 8 |
6 files changed, 26 insertions, 54 deletions
diff --git a/tests/BadIcoTest.cpp b/tests/BadIcoTest.cpp index 5c01490f9b..4affa85b7b 100644 --- a/tests/BadIcoTest.cpp +++ b/tests/BadIcoTest.cpp @@ -26,11 +26,9 @@ DEF_TEST(BadImage, reporter) { const char* badImagesFolder = "invalid_images"; - SkString resourcePath = GetResourcePath(badImagesFolder); - for (size_t i = 0; i < SK_ARRAY_COUNT(badImages); ++i) { - SkString fullPath = SkOSPath::Join(resourcePath.c_str(), badImages[i]); - SkAutoTDelete<SkStream> stream(SkStream::NewFromFile(fullPath.c_str())); + SkString resourcePath = SkOSPath::Join(badImagesFolder, badImages[i]); + SkAutoTDelete<SkStream> stream(GetResourceAsStream(resourcePath.c_str())); SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream.release())); // These images are corrupt. It's not important whether we succeed/fail in codec diff --git a/tests/CodecTest.cpp b/tests/CodecTest.cpp index 044c2fd6b4..341433b379 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); diff --git a/tests/ColorSpaceTest.cpp b/tests/ColorSpaceTest.cpp index 4a64460370..7e247d304d 100644 --- a/tests/ColorSpaceTest.cpp +++ b/tests/ColorSpaceTest.cpp @@ -40,15 +40,10 @@ static void test_space(skiatest::Reporter* r, SkColorSpace* space, } } -static SkStreamAsset* resource(const char path[]) { - SkString fullPath = GetResourcePath(path); - return SkStream::NewFromFile(fullPath.c_str()); -} - static void test_path(skiatest::Reporter* r, const char* path, const float red[], const float green[], const float blue[], const SkGammaNamed expectedGamma) { - SkAutoTDelete<SkStream> stream(resource(path)); + SkAutoTDelete<SkStream> stream(GetResourceAsStream(path)); REPORTER_ASSERT(r, nullptr != stream); if (!stream) { return; diff --git a/tests/ExifTest.cpp b/tests/ExifTest.cpp index 7fcd8b861d..4aac487064 100644 --- a/tests/ExifTest.cpp +++ b/tests/ExifTest.cpp @@ -9,13 +9,8 @@ #include "SkCodec.h" #include "Test.h" -static SkStreamAsset* resource(const char path[]) { - SkString fullPath = GetResourcePath(path); - return SkStream::NewFromFile(fullPath.c_str()); -} - DEF_TEST(ExifOrientation, r) { - SkAutoTDelete<SkStream> stream(resource("exif-orientation-2-ur.jpg")); + SkAutoTDelete<SkStream> stream(GetResourceAsStream("exif-orientation-2-ur.jpg")); REPORTER_ASSERT(r, nullptr != stream); if (!stream) { return; @@ -26,7 +21,7 @@ DEF_TEST(ExifOrientation, r) { SkCodec::Origin origin = codec->getOrigin(); REPORTER_ASSERT(r, SkCodec::kTopRight_Origin == origin); - stream.reset(resource("mandrill_512_q075.jpg")); + stream.reset(GetResourceAsStream("mandrill_512_q075.jpg")); codec.reset(SkCodec::NewFromStream(stream.release())); REPORTER_ASSERT(r, nullptr != codec); origin = codec->getOrigin(); diff --git a/tests/SerializationTest.cpp b/tests/SerializationTest.cpp index ff9b342074..bc2770ebda 100644 --- a/tests/SerializationTest.cpp +++ b/tests/SerializationTest.cpp @@ -13,6 +13,7 @@ #include "SkImage.h" #include "SkImageSource.h" #include "SkLightingShader.h" +#include "SkMakeUnique.h" #include "SkMallocPixelRef.h" #include "SkNormalSource.h" #include "SkOSFile.h" @@ -370,13 +371,13 @@ static void TestPictureTypefaceSerialization(skiatest::Reporter* reporter) { { // Load typeface as stream to create with axis settings. - SkAutoTDelete<SkStreamAsset> distortable(GetResourceAsStream("/fonts/Distortable.ttf")); + std::unique_ptr<SkStreamAsset> distortable(GetResourceAsStream("/fonts/Distortable.ttf")); if (!distortable) { INFOF(reporter, "Could not run fontstream test because Distortable.ttf not found."); } else { SkFixed axis = SK_FixedSqrt2; sk_sp<SkTypeface> typeface(SkTypeface::MakeFromFontData( - new SkFontData(distortable.release(), 0, &axis, 1))); + skstd::make_unique<SkFontData>(std::move(distortable), 0, &axis, 1))); if (!typeface) { INFOF(reporter, "Could not run fontstream test because Distortable.ttf not created."); } else { diff --git a/tests/YUVTest.cpp b/tests/YUVTest.cpp index f7b3306b98..d3b9167843 100644 --- a/tests/YUVTest.cpp +++ b/tests/YUVTest.cpp @@ -12,17 +12,11 @@ #include "SkYUVSizeInfo.h" #include "Test.h" -static SkStreamAsset* resource(const char path[]) { - SkString fullPath = GetResourcePath(path); - return SkStream::NewFromFile(fullPath.c_str()); -} - static void codec_yuv(skiatest::Reporter* reporter, const char path[], SkISize expectedSizes[3]) { - SkAutoTDelete<SkStream> stream(resource(path)); + SkAutoTDelete<SkStream> stream(GetResourceAsStream(path)); if (!stream) { - INFOF(reporter, "Missing resource '%s'\n", path); return; } SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream.release())); |