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

Side by Side Diff: tests/PDFPrimitivesTest.cpp

Issue 968683002: PDF: Switch some unit tests to higher level API. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 9 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/CanvasTest.cpp ('k') | no next file » | 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 2010 The Android Open Source Project 2 * Copyright 2010 The Android Open Source Project
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 "SkBitmap.h" 8 #include "SkBitmap.h"
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkData.h" 10 #include "SkData.h"
11 #include "SkDocument.h"
11 #include "SkFlate.h" 12 #include "SkFlate.h"
12 #include "SkImageEncoder.h" 13 #include "SkImageEncoder.h"
13 #include "SkMatrix.h" 14 #include "SkMatrix.h"
14 #include "SkPDFCanon.h" 15 #include "SkPDFCanon.h"
15 #include "SkPDFCatalog.h" 16 #include "SkPDFCatalog.h"
16 #include "SkPDFDevice.h" 17 #include "SkPDFDevice.h"
17 #include "SkPDFStream.h" 18 #include "SkPDFStream.h"
18 #include "SkPDFTypes.h" 19 #include "SkPDFTypes.h"
19 #include "SkReadBuffer.h" 20 #include "SkReadBuffer.h"
20 #include "SkScalar.h" 21 #include "SkScalar.h"
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 209
209 REPORTER_ASSERT(reporter, stub.get() == catalog.getSubstituteObject(proxy)); 210 REPORTER_ASSERT(reporter, stub.get() == catalog.getSubstituteObject(proxy));
210 REPORTER_ASSERT(reporter, proxy.get() != catalog.getSubstituteObject(stub)); 211 REPORTER_ASSERT(reporter, proxy.get() != catalog.getSubstituteObject(stub));
211 } 212 }
212 213
213 // This test used to assert without the fix submitted for 214 // This test used to assert without the fix submitted for
214 // http://code.google.com/p/skia/issues/detail?id=1083. 215 // http://code.google.com/p/skia/issues/detail?id=1083.
215 // SKP files might have invalid glyph ids. This test ensures they are ignored, 216 // SKP files might have invalid glyph ids. This test ensures they are ignored,
216 // and there is no assert on input data in Debug mode. 217 // and there is no assert on input data in Debug mode.
217 static void test_issue1083() { 218 static void test_issue1083() {
218 SkISize pageSize = SkISize::Make(100, 100); 219 SkDynamicMemoryWStream outStream;
219 SkPDFCanon canon; 220 SkAutoTUnref<SkDocument> doc(SkDocument::CreatePDF(&outStream));
220 SkAutoTUnref<SkPDFDevice> dev(SkPDFDevice::Create(pageSize, 72.0f, &canon)); 221 SkCanvas* canvas = doc->beginPage(100.0f, 100.0f);
221 SkCanvas c(dev);
222 SkPaint paint; 222 SkPaint paint;
223 paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding); 223 paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
224 224
225 uint16_t glyphID = 65000; 225 uint16_t glyphID = 65000;
226 c.drawText(&glyphID, 2, 0, 0, paint); 226 canvas->drawText(&glyphID, 2, 0, 0, paint);
227 227
228 SkPDFDocument doc; 228 doc->close();
229 doc.appendPage(dev);
230
231 SkDynamicMemoryWStream stream;
232 doc.emitPDF(&stream);
233 } 229 }
234 230
235 DEF_TEST(PDFPrimitives, reporter) { 231 DEF_TEST(PDFPrimitives, reporter) {
236 SkAutoTUnref<SkPDFInt> int42(new SkPDFInt(42)); 232 SkAutoTUnref<SkPDFInt> int42(new SkPDFInt(42));
237 SimpleCheckObjectOutput(reporter, int42.get(), "42"); 233 SimpleCheckObjectOutput(reporter, int42.get(), "42");
238 234
239 SkAutoTUnref<SkPDFScalar> realHalf(new SkPDFScalar(SK_ScalarHalf)); 235 SkAutoTUnref<SkPDFScalar> realHalf(new SkPDFScalar(SK_ScalarHalf));
240 SimpleCheckObjectOutput(reporter, realHalf.get(), "0.5"); 236 SimpleCheckObjectOutput(reporter, realHalf.get(), "0.5");
241 237
242 SkAutoTUnref<SkPDFScalar> bigScalar(new SkPDFScalar(110999.75f)); 238 SkAutoTUnref<SkPDFScalar> bigScalar(new SkPDFScalar(110999.75f));
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 str->appendf("DummyImageFilter: ("); 343 str->appendf("DummyImageFilter: (");
348 str->append(")"); 344 str->append(")");
349 } 345 }
350 #endif 346 #endif
351 347
352 }; 348 };
353 349
354 // Check that PDF rendering of image filters successfully falls back to 350 // Check that PDF rendering of image filters successfully falls back to
355 // CPU rasterization. 351 // CPU rasterization.
356 DEF_TEST(PDFImageFilter, reporter) { 352 DEF_TEST(PDFImageFilter, reporter) {
357 SkISize pageSize = SkISize::Make(100, 100); 353 SkDynamicMemoryWStream stream;
358 SkPDFCanon canon; 354 SkAutoTUnref<SkDocument> doc(SkDocument::CreatePDF(&stream));
359 SkAutoTUnref<SkPDFDevice> pdfDevice( 355 SkCanvas* canvas = doc->beginPage(100.0f, 100.0f);
360 SkPDFDevice::Create(pageSize, 72.0f, &canon)); 356
361 SkCanvas canvas(pdfDevice.get());
362 SkAutoTUnref<DummyImageFilter> filter(new DummyImageFilter()); 357 SkAutoTUnref<DummyImageFilter> filter(new DummyImageFilter());
363 358
364 // Filter just created; should be unvisited. 359 // Filter just created; should be unvisited.
365 REPORTER_ASSERT(reporter, !filter->visited()); 360 REPORTER_ASSERT(reporter, !filter->visited());
366 SkPaint paint; 361 SkPaint paint;
367 paint.setImageFilter(filter.get()); 362 paint.setImageFilter(filter.get());
368 canvas.drawRect(SkRect::MakeWH(100, 100), paint); 363 canvas->drawRect(SkRect::MakeWH(100, 100), paint);
364 doc->close();
369 365
370 // Filter was used in rendering; should be visited. 366 // Filter was used in rendering; should be visited.
371 REPORTER_ASSERT(reporter, filter->visited()); 367 REPORTER_ASSERT(reporter, filter->visited());
372 } 368 }
OLDNEW
« no previous file with comments | « tests/CanvasTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698