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

Side by Side Diff: tests/PDFJpegEmbedTest.cpp

Issue 2333713002: change SkStreams to work with sk_sp<SkData> instead of SkData* (Closed)
Patch Set: fix xpsdevice Created 4 years, 3 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
« no previous file with comments | « tests/PDFGlyphsToUnicodeTest.cpp ('k') | tests/PDFMetadataAttributeTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "SkCanvas.h" 8 #include "SkCanvas.h"
9 #include "SkData.h" 9 #include "SkData.h"
10 #include "SkDocument.h" 10 #include "SkDocument.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 canvas->clear(SK_ColorLTGRAY); 71 canvas->clear(SK_ColorLTGRAY);
72 72
73 SkBitmap bm1(bitmap_from_data(mandrillData.get())); 73 SkBitmap bm1(bitmap_from_data(mandrillData.get()));
74 canvas->drawBitmap(bm1, 65.0, 0.0, nullptr); 74 canvas->drawBitmap(bm1, 65.0, 0.0, nullptr);
75 SkBitmap bm2(bitmap_from_data(cmykData.get())); 75 SkBitmap bm2(bitmap_from_data(cmykData.get()));
76 canvas->drawBitmap(bm2, 0.0, 512.0, nullptr); 76 canvas->drawBitmap(bm2, 0.0, 512.0, nullptr);
77 77
78 canvas->flush(); 78 canvas->flush();
79 document->endPage(); 79 document->endPage();
80 document->close(); 80 document->close();
81 sk_sp<SkData> pdfData(pdf.copyToData()); 81 sk_sp<SkData> pdfData(pdf.detachAsData());
82 SkASSERT(pdfData); 82 SkASSERT(pdfData);
83 pdf.reset();
84 83
85 REPORTER_ASSERT(r, is_subset_of(mandrillData.get(), pdfData.get())); 84 REPORTER_ASSERT(r, is_subset_of(mandrillData.get(), pdfData.get()));
86 85
87 // This JPEG uses a nonstandard colorspace - it can not be 86 // This JPEG uses a nonstandard colorspace - it can not be
88 // embedded into the PDF directly. 87 // embedded into the PDF directly.
89 REPORTER_ASSERT(r, !is_subset_of(cmykData.get(), pdfData.get())); 88 REPORTER_ASSERT(r, !is_subset_of(cmykData.get(), pdfData.get()));
90 //////////////////////////////////////////////////////////////////////////// 89 ////////////////////////////////////////////////////////////////////////////
91 pdf.reset(); 90 pdf.reset();
92 document = SkDocument::MakePDF(&pdf); 91 document = SkDocument::MakePDF(&pdf);
93 canvas = document->beginPage(642, 1028); 92 canvas = document->beginPage(642, 1028);
94 93
95 canvas->clear(SK_ColorLTGRAY); 94 canvas->clear(SK_ColorLTGRAY);
96 95
97 sk_sp<SkImage> im1(SkImage::MakeFromEncoded(mandrillData)); 96 sk_sp<SkImage> im1(SkImage::MakeFromEncoded(mandrillData));
98 canvas->drawImage(im1.get(), 65.0, 0.0, nullptr); 97 canvas->drawImage(im1.get(), 65.0, 0.0, nullptr);
99 sk_sp<SkImage> im2(SkImage::MakeFromEncoded(cmykData)); 98 sk_sp<SkImage> im2(SkImage::MakeFromEncoded(cmykData));
100 canvas->drawImage(im2.get(), 0.0, 512.0, nullptr); 99 canvas->drawImage(im2.get(), 0.0, 512.0, nullptr);
101 100
102 canvas->flush(); 101 canvas->flush();
103 document->endPage(); 102 document->endPage();
104 document->close(); 103 document->close();
105 pdfData.reset(pdf.copyToData()); 104 pdfData = pdf.detachAsData();
106 SkASSERT(pdfData); 105 SkASSERT(pdfData);
107 pdf.reset();
108 106
109 REPORTER_ASSERT(r, is_subset_of(mandrillData.get(), pdfData.get())); 107 REPORTER_ASSERT(r, is_subset_of(mandrillData.get(), pdfData.get()));
110 108
111 // This JPEG uses a nonstandard colorspace - it can not be 109 // This JPEG uses a nonstandard colorspace - it can not be
112 // embedded into the PDF directly. 110 // embedded into the PDF directly.
113 REPORTER_ASSERT(r, !is_subset_of(cmykData.get(), pdfData.get())); 111 REPORTER_ASSERT(r, !is_subset_of(cmykData.get(), pdfData.get()));
114 } 112 }
115 113
116 DEF_TEST(SkPDF_JpegIdentification, r) { 114 DEF_TEST(SkPDF_JpegIdentification, r) {
117 static struct { 115 static struct {
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 "\377\330\377\340\0\20JFIF\0\1\1\0\0\1\0\1\0\0\377\333\0C\0\10\6\6\7 " 232 "\377\330\377\340\0\20JFIF\0\1\1\0\0\1\0\1\0\0\377\333\0C\0\10\6\6\7 "
235 "\6\5\10\7\7\7\t\t\10\n\14\24\r\14\13\13\14\31\22\23\17\24\35\32\37" 233 "\6\5\10\7\7\7\t\t\10\n\14\24\r\14\13\13\14\31\22\23\17\24\35\32\37"
236 "\36\35\32\34\34 $.' \",#\34\34(7),01444\37'9=82<.342\377\333\0C\1\t " 234 "\36\35\32\34\34 $.' \",#\34\34(7),01444\37'9=82<.342\377\333\0C\1\t "
237 "\t\t\14\13\14\30\r\r\0302!\34!222222222222222222222222222222222222" 235 "\t\t\14\13\14\30\r\r\0302!\34!222222222222222222222222222222222222"
238 "22222222222222\377\300\0\21\10\2\0\2\0\2\1\"\0\2\21\1\3\21\001"; 236 "22222222222222\377\300\0\21\10\2\0\2\0\2\1\"\0\2\21\1\3\21\001";
239 size_t jpegLength = 177; 237 size_t jpegLength = 177;
240 auto data = SkData::MakeWithoutCopy(jpeg, jpegLength); 238 auto data = SkData::MakeWithoutCopy(jpeg, jpegLength);
241 REPORTER_ASSERT(r, !SkIsJFIF(data.get(), &info)); 239 REPORTER_ASSERT(r, !SkIsJFIF(data.get(), &info));
242 } 240 }
243 } 241 }
OLDNEW
« no previous file with comments | « tests/PDFGlyphsToUnicodeTest.cpp ('k') | tests/PDFMetadataAttributeTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698