Chromium Code Reviews| Index: tests/CodexTest.cpp |
| diff --git a/tests/CodexTest.cpp b/tests/CodexTest.cpp |
| index b6b5d8276d536d48bc9d5f8ea3a47334ffc73d62..4d9df81160cbccf2be55e2193fa17e0a1e04900a 100644 |
| --- a/tests/CodexTest.cpp |
| +++ b/tests/CodexTest.cpp |
| @@ -454,6 +454,7 @@ DEF_TEST(Codec, r) { |
| // RAW |
| #if defined(SK_CODEC_DECODES_RAW) |
| check(r, "sample_1mp.dng", SkISize::Make(600, 338), false, false, false); |
| + check(r, "dng_with_preview.dng", SkISize::Make(600, 338), true, false, false); |
| #endif |
| } |
| @@ -651,6 +652,7 @@ DEF_TEST(Codec_Dimensions, r) { |
| // RAW |
| #if defined(SK_CODEC_DECODES_RAW) |
| test_dimensions(r, "sample_1mp.dng"); |
| + test_dimensions(r, "dng_with_preview.dng"); |
| #endif |
| } |
| @@ -894,6 +896,54 @@ private: |
| const size_t fLimit; |
| }; |
| +// Stream that is not seekable (!hasPotions() or !hasLength()) |
|
scroggo
2016/02/04 15:46:24
hasPosition()*
yujieqin
2016/02/05 08:53:21
Done.
|
| +class NotSeekableMemStream : public SkStream { |
| +public: |
| + NotSeekableMemStream(SkData* data) : fStream(data) {} |
| + |
| + bool hasPosition() const override { |
| + return false; |
| + } |
| + |
| + bool hasLength() const override { |
| + return false; |
| + } |
| + |
| + size_t peek(void* buf, size_t bytes) const override { |
| + return fStream.peek(buf, bytes); |
| + } |
| + size_t read(void* buf, size_t bytes) override { |
| + return fStream.read(buf, bytes); |
| + } |
| + bool rewind() override { |
| + return fStream.rewind(); |
| + } |
| + bool isAtEnd() const override { |
| + return false; |
|
scroggo
2016/02/04 15:46:24
Should this return fStream.isAtEnd()? (I'm guessin
yujieqin
2016/02/05 08:53:21
Done.
|
| + } |
| +private: |
| + SkMemoryStream fStream; |
| +}; |
| + |
| +// Test that the RawCodec works also for not seekable stream. This will test the code path using |
| +// SkRawBufferedStream instead of SkRawSeekableStream. |
| +#if defined(SK_CODEC_DECODES_RAW) |
| +DEF_TEST(Codec_raw_notseekable, r) { |
| + const char* path = "dng_with_preview.dng"; |
| + SkString fullPath(GetResourcePath(path)); |
| + SkAutoTUnref<SkData> data(SkData::NewFromFileName(fullPath.c_str())); |
| + if (!data) { |
| + SkDebugf("Missing resource '%s'\n", path); |
| + return; |
| + } |
| + |
| + SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(new NotSeekableMemStream(data))); |
| + REPORTER_ASSERT(r, codec); |
| + |
| + test_info(r, codec, codec->getInfo(), SkCodec::kSuccess, nullptr); |
| +} |
| +#endif |
| + |
| // 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) { |