Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(130)

Side by Side Diff: tests/PDFJpegEmbedTest.cpp

Issue 2206633004: Move off SK_SUPPORT_LEGACY_DATA_FACTORIES. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Gotta catch 'em all. Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkDocument.h" 8 #include "SkDocument.h"
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkImageGenerator.h" 10 #include "SkImageGenerator.h"
(...skipping 20 matching lines...) Expand all
31 size_t size_diff = larger->size() - size; 31 size_t size_diff = larger->size() - size;
32 for (size_t i = 0; i <= size_diff; ++i) { 32 for (size_t i = 0; i <= size_diff; ++i) {
33 if (0 == memcmp(larger->bytes() + i, smaller->bytes(), size)) { 33 if (0 == memcmp(larger->bytes() + i, smaller->bytes(), size)) {
34 return true; 34 return true;
35 } 35 }
36 } 36 }
37 return false; 37 return false;
38 } 38 }
39 39
40 40
41 static SkData* load_resource( 41 static sk_sp<SkData> load_resource(
42 skiatest::Reporter* r, const char* test, const char* filename) { 42 skiatest::Reporter* r, const char* test, const char* filename) {
43 SkString path(GetResourcePath(filename)); 43 SkString path(GetResourcePath(filename));
44 SkData* data = SkData::NewFromFileName(path.c_str()); 44 sk_sp<SkData> data(SkData::MakeFromFileName(path.c_str()));
45 if (!data) { 45 if (!data) {
46 INFOF(r, "\n%s: Resource '%s' can not be found.\n", 46 INFOF(r, "\n%s: Resource '%s' can not be found.\n",
47 test, filename); 47 test, filename);
48 } 48 }
49 return data; // May return nullptr. 49 return data; // May return nullptr.
50 } 50 }
51 51
52 /** 52 /**
53 * Test that for Jpeg files that use the JFIF colorspace, they are 53 * Test that for Jpeg files that use the JFIF colorspace, they are
54 * directly embedded into the PDF (without re-encoding) when that 54 * directly embedded into the PDF (without re-encoding) when that
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 static struct { 117 static struct {
118 const char* path; 118 const char* path;
119 bool isJfif; 119 bool isJfif;
120 SkJFIFInfo::Type type; 120 SkJFIFInfo::Type type;
121 } kTests[] = {{"CMYK.jpg", false, SkJFIFInfo::kGrayscale}, 121 } kTests[] = {{"CMYK.jpg", false, SkJFIFInfo::kGrayscale},
122 {"color_wheel.jpg", true, SkJFIFInfo::kYCbCr}, 122 {"color_wheel.jpg", true, SkJFIFInfo::kYCbCr},
123 {"grayscale.jpg", true, SkJFIFInfo::kGrayscale}, 123 {"grayscale.jpg", true, SkJFIFInfo::kGrayscale},
124 {"mandrill_512_q075.jpg", true, SkJFIFInfo::kYCbCr}, 124 {"mandrill_512_q075.jpg", true, SkJFIFInfo::kYCbCr},
125 {"randPixels.jpg", true, SkJFIFInfo::kYCbCr}}; 125 {"randPixels.jpg", true, SkJFIFInfo::kYCbCr}};
126 for (size_t i = 0; i < SK_ARRAY_COUNT(kTests); ++i) { 126 for (size_t i = 0; i < SK_ARRAY_COUNT(kTests); ++i) {
127 SkAutoTUnref<SkData> data( 127 sk_sp<SkData> data(load_resource(r, "JpegIdentification", kTests[i].path ));
128 load_resource(r, "JpegIdentification", kTests[i].path));
129 if (!data) { 128 if (!data) {
130 continue; 129 continue;
131 } 130 }
132 SkJFIFInfo info; 131 SkJFIFInfo info;
133 bool isJfif = SkIsJFIF(data, &info); 132 bool isJfif = SkIsJFIF(data.get(), &info);
134 if (isJfif != kTests[i].isJfif) { 133 if (isJfif != kTests[i].isJfif) {
135 ERRORF(r, "%s failed isJfif test", kTests[i].path); 134 ERRORF(r, "%s failed isJfif test", kTests[i].path);
136 continue; 135 continue;
137 } 136 }
138 if (!isJfif) { 137 if (!isJfif) {
139 continue; // not applicable 138 continue; // not applicable
140 } 139 }
141 if (kTests[i].type != info.fType) { 140 if (kTests[i].type != info.fType) {
142 ERRORF(r, "%s failed jfif type test", kTests[i].path); 141 ERRORF(r, "%s failed jfif type test", kTests[i].path);
143 continue; 142 continue;
144 } 143 }
145 INFOF(r, "\nJpegIdentification: %s [%d x %d]\n", kTests[i].path, 144 INFOF(r, "\nJpegIdentification: %s [%d x %d]\n", kTests[i].path,
146 info.fSize.width(), info.fSize.height()); 145 info.fSize.width(), info.fSize.height());
147 } 146 }
148 } 147 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698