Index: Source/platform/image-decoders/jpeg/JPEGImageDecoderTest.cpp |
diff --git a/Source/platform/image-decoders/jpeg/JPEGImageDecoderTest.cpp b/Source/platform/image-decoders/jpeg/JPEGImageDecoderTest.cpp |
index 0fabc53c64dfa3772da4b4cdcf19a0d607b48b11..2b743ea157f46b5b8eeeb6feb562fe512e9bc949 100644 |
--- a/Source/platform/image-decoders/jpeg/JPEGImageDecoderTest.cpp |
+++ b/Source/platform/image-decoders/jpeg/JPEGImageDecoderTest.cpp |
@@ -79,6 +79,35 @@ void downsample(size_t maxDecodedBytes, unsigned* outputWidth, unsigned* outputH |
EXPECT_EQ(IntSize(*outputWidth, *outputHeight), decoder->decodedSize()); |
} |
+void readYUV(size_t maxDecodedBytes, unsigned* outputYWidth, unsigned* outputYHeight, unsigned* outputUVWidth, unsigned* outputUVHeight, const char* imageFilePath) |
+{ |
+ RefPtr<SharedBuffer> data = readFile(imageFilePath); |
+ ASSERT_TRUE(data.get()); |
+ |
+ OwnPtr<JPEGImageDecoder> decoder = createDecoder(maxDecodedBytes); |
+ decoder->setData(data.get(), true); |
+ |
+ OwnPtr<ImagePlanes> imagePlanes = adoptPtr(new ImagePlanes()); |
+ decoder->setImagePlanes(imagePlanes); |
+ bool sizeIsAvailable = decoder->isSizeAvailable(); |
+ ASSERT_TRUE(sizeIsAvailable); |
+ |
+ IntSize size = decoder->decodedSize(); |
+ IntSize ySize = decoder->decodedYUVSize(0); |
+ IntSize uSize = decoder->decodedYUVSize(1); |
+ IntSize vSize = decoder->decodedYUVSize(2); |
+ |
+ ASSERT_TRUE(size.width() == ySize.width()); |
+ ASSERT_TRUE(size.height() == ySize.height()); |
+ ASSERT_TRUE(uSize.width() == vSize.width()); |
+ ASSERT_TRUE(uSize.height() == vSize.height()); |
+ |
+ *outputYWidth = ySize.width(); |
+ *outputYHeight = ySize.height(); |
+ *outputUVWidth = uSize.width(); |
+ *outputUVHeight = uSize.height(); |
+} |
+ |
// Tests failure on a too big image. |
TEST(JPEGImageDecoderTest, tooBig) |
{ |
@@ -183,3 +212,14 @@ TEST(JPEGImageDecoderTest, upsample) |
EXPECT_EQ(256u, outputWidth); |
EXPECT_EQ(256u, outputHeight); |
} |
+ |
+TEST(JPEGImageDecoderTest, yuv) |
+{ |
+ const char* jpegFile = "/LayoutTests/fast/images/resources/lenna.jpg"; // 256x256, YUV 4:2:0 |
+ unsigned outputYWidth, outputYHeight, outputUVWidth, outputUVHeight; |
+ readYUV(1000 * 1000, &outputYWidth, &outputYHeight, &outputUVWidth, &outputUVHeight, jpegFile); |
Stephen White
2014/07/25 18:25:10
Let's pull that out into a constant at the top-of-
|
+ EXPECT_EQ(256u, outputYWidth); |
+ EXPECT_EQ(256u, outputYHeight); |
+ EXPECT_EQ(128u, outputUVWidth); |
+ EXPECT_EQ(128u, outputUVHeight); |
+} |