diff options
author | Mike Reed <reed@google.com> | 2017-12-09 01:27:41 +0000 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-12-09 01:27:50 +0000 |
commit | 0933bc9b679457ef9333988fe3a1faae6a0b4126 (patch) | |
tree | 0e55ae3a74ec688c3dca189dfe909b026b77985f /tests/CodecTest.cpp | |
parent | 1a24cd9f6f7d617d9cfb86bf06bdc06b903ac197 (diff) |
Revert "Revert "resources: remove most uses of GetResourcePath()""
This reverts commit cca230055921d2df8708ed6f9abcc2d43468dc7f.
Reason for revert: think I guessed wrong about g32 -- unreverting
Original change's description:
> Revert "resources: remove most uses of GetResourcePath()"
>
> This reverts commit 5093a539def3ae09df324018f2343827009b2e05.
>
> Reason for revert: google3 seems broken
>
> Original change's description:
> > resources: remove most uses of GetResourcePath()
> >
> > Going forward, we will standardize on GetResourceAsData(), which will
> > make it easier to run tests in environments without access to the
> > filesystem.
> >
> > Also: GetResourceAsData() complains when a resource is missing.
> > This is usually an error.
> >
> > Change-Id: Iaf70b71b0ca5ed8cd1a5538a60ef185ae8736188
> > Reviewed-on: https://skia-review.googlesource.com/82642
> > Reviewed-by: Hal Canary <halcanary@google.com>
> > Commit-Queue: Hal Canary <halcanary@google.com>
>
> TBR=halcanary@google.com,scroggo@google.com
>
> Change-Id: Ic5a7c0167c995a672e6b06dc92abe00564432214
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://skia-review.googlesource.com/83001
> Reviewed-by: Mike Reed <reed@google.com>
> Commit-Queue: Mike Reed <reed@google.com>
TBR=halcanary@google.com,scroggo@google.com,reed@google.com
Change-Id: I5a46e4de61186a8a5eb9cacd3275e24e311d5a07
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/82942
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
Diffstat (limited to 'tests/CodecTest.cpp')
-rw-r--r-- | tests/CodecTest.cpp | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/tests/CodecTest.cpp b/tests/CodecTest.cpp index ab21e4a2c1..787e8549fc 100644 --- a/tests/CodecTest.cpp +++ b/tests/CodecTest.cpp @@ -846,9 +846,8 @@ private: // Test that the RawCodec works also for not asset stream. This will test the code path using // SkRawBufferedStream instead of SkRawAssetStream. DEF_TEST(Codec_raw_notseekable, r) { - const char* path = "images/dng_with_preview.dng"; - SkString fullPath(GetResourcePath(path)); - sk_sp<SkData> data(SkData::MakeFromFileName(fullPath.c_str())); + constexpr char path[] = "images/dng_with_preview.dng"; + sk_sp<SkData> data(GetResourceAsData(path)); if (!data) { SkDebugf("Missing resource '%s'\n", path); return; @@ -865,9 +864,8 @@ DEF_TEST(Codec_raw_notseekable, r) { // Test that even if webp_parse_header fails to peek enough, it will fall back to read() // + rewind() and succeed. DEF_TEST(Codec_webp_peek, r) { - const char* path = "images/baby_tux.webp"; - SkString fullPath(GetResourcePath(path)); - auto data = SkData::MakeFromFileName(fullPath.c_str()); + constexpr char path[] = "images/baby_tux.webp"; + auto data = GetResourceAsData(path); if (!data) { SkDebugf("Missing resource '%s'\n", path); return; @@ -1003,8 +1001,7 @@ static void check_color_xform(skiatest::Reporter* r, const char* path) { const int dstWidth = subsetWidth / opts.fSampleSize; const int dstHeight = subsetHeight / opts.fSampleSize; - sk_sp<SkData> data = SkData::MakeFromFileName( - GetResourcePath("icc_profiles/HP_ZR30w.icc").c_str()); + sk_sp<SkData> data = GetResourceAsData("icc_profiles/HP_ZR30w.icc"); sk_sp<SkColorSpace> colorSpace = SkColorSpace::MakeICC(data->data(), data->size()); SkImageInfo dstInfo = codec->getInfo().makeWH(dstWidth, dstHeight) .makeColorType(kN32_SkColorType) @@ -1386,12 +1383,14 @@ DEF_TEST(Codec_InvalidImages, r) { } static void test_invalid_header(skiatest::Reporter* r, const char* path) { - SkString resourcePath = GetResourcePath(path); - auto stream = SkFILEStream::Make(resourcePath.c_str()); + auto data = GetResourceAsData(path); + if (!data) { + return; + } + std::unique_ptr<SkStreamAsset> stream(new SkMemoryStream(std::move(data))); if (!stream) { return; } - std::unique_ptr<SkCodec> codec(SkCodec::MakeFromStream(std::move(stream))); REPORTER_ASSERT(r, !codec); } |