diff options
author | halcanary <halcanary@google.com> | 2015-05-07 11:46:59 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-05-07 11:46:59 -0700 |
commit | 96287f7af7ff6aaa48b8d28ec6b7b79836da2d7c (patch) | |
tree | c8dd447d551c2fc5d6843c8c26739eb6306f07cd /tests/PDFJpegEmbedTest.cpp | |
parent | e64eb570a5b9480bc24d0656ccabcff1ab13a229 (diff) |
SkPDF: detect YUV-JPEG without relying on ImageGenerator
JPEG/JFIF References:
* http://www.w3.org/Graphics/JPEG/itu-t81.pdf
* http://www.w3.org/Graphics/JPEG/jfif3.pdf
BUG=476721
BUG=446940
Review URL: https://codereview.chromium.org/1133443003
Diffstat (limited to 'tests/PDFJpegEmbedTest.cpp')
-rw-r--r-- | tests/PDFJpegEmbedTest.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/PDFJpegEmbedTest.cpp b/tests/PDFJpegEmbedTest.cpp index 133d84a3ff..cfe6776bf5 100644 --- a/tests/PDFJpegEmbedTest.cpp +++ b/tests/PDFJpegEmbedTest.cpp @@ -87,3 +87,41 @@ DEF_TEST(PDFJpegEmbedTest, r) { // embedded into the PDF directly. REPORTER_ASSERT(r, !is_subset_of(cmykData, pdfData)); } + +#include "SkJpegInfo.h" + +DEF_TEST(JpegIdentification, r) { + static struct { + const char* path; + bool isJfif; + SkJFIFInfo::Type type; + } kTests[] = {{"CMYK.jpg", false, SkJFIFInfo::kGrayscale}, + {"color_wheel.jpg", true, SkJFIFInfo::kYCbCr}, + {"grayscale.jpg", true, SkJFIFInfo::kGrayscale}, + {"mandrill_512_q075.jpg", true, SkJFIFInfo::kYCbCr}, + {"randPixels.jpg", true, SkJFIFInfo::kYCbCr}}; + for (size_t i = 0; i < SK_ARRAY_COUNT(kTests); ++i) { + SkAutoTUnref<SkData> data( + load_resource(r, "JpegIdentification", kTests[i].path)); + if (!data) { + continue; + } + SkJFIFInfo info; + bool isJfif = SkIsJFIF(data, &info); + if (isJfif != kTests[i].isJfif) { + ERRORF(r, "%s failed isJfif test", kTests[i].path); + continue; + } + if (!isJfif) { + continue; // not applicable + } + if (kTests[i].type != info.fType) { + ERRORF(r, "%s failed jfif type test", kTests[i].path); + continue; + } + if (r->verbose()) { + SkDebugf("\nJpegIdentification: %s [%d x %d]\n", kTests[i].path, + info.fWidth, info.fHeight); + } + } +} |