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

Unified Diff: tests/PDFPrimitivesTest.cpp

Issue 870333002: Simplify reference management in SkPDF (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: tests Created 5 years, 11 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 side-by-side diff with in-line comments
Download patch
« src/pdf/SkPDFTypes.h ('K') | « src/pdf/SkPDFTypes.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/PDFPrimitivesTest.cpp
diff --git a/tests/PDFPrimitivesTest.cpp b/tests/PDFPrimitivesTest.cpp
index f15f06090d7b10787e32f9f6498290224abcf127..edcd36d1c24946e175ba141631709f4ed849d55c 100644
--- a/tests/PDFPrimitivesTest.cpp
+++ b/tests/PDFPrimitivesTest.cpp
@@ -237,38 +237,16 @@ static void TestObjectRef(skiatest::Reporter* reporter) {
static void TestSubstitute(skiatest::Reporter* reporter) {
SkAutoTUnref<SkPDFTestDict> proxy(new SkPDFTestDict());
SkAutoTUnref<SkPDFTestDict> stub(new SkPDFTestDict());
- SkAutoTUnref<SkPDFInt> int33(new SkPDFInt(33));
- SkAutoTUnref<SkPDFDict> stubResource(new SkPDFDict());
- SkAutoTUnref<SkPDFInt> int44(new SkPDFInt(44));
- stub->insert("Value", int33.get());
- stubResource->insert("InnerValue", int44.get());
- stub->addResource(stubResource.get());
+ proxy->insert("Value", new SkPDFInt(33))->unref();
mtklein 2015/01/26 23:38:59 If we're getting serious about PDF memory allocati
hal.canary 2015/02/09 23:35:01 Acknowledged. Let's do that *after* making these
+ stub->insert("Value", new SkPDFInt(44))->unref();
SkPDFCatalog catalog((SkPDFDocument::Flags)0);
catalog.addObject(proxy.get(), false);
catalog.setSubstitute(proxy.get(), stub.get());
- SkDynamicMemoryWStream buffer;
- emit_object(proxy, &buffer, &catalog, false);
- SkTSet<SkPDFObject*>* substituteResources =
- catalog.getSubstituteList(false);
- for (int i = 0; i < substituteResources->count(); ++i) {
- emit_object((*substituteResources)[i], &buffer, &catalog, true);
- }
-
- char objectResult[] = "2 0 obj\n<</Value 33\n>>\nendobj\n";
- catalog.setFileOffset(proxy.get(), 0);
-
- size_t outputSize = get_output_size(
- catalog.getSubstituteObject(proxy.get()), &catalog, true);
- REPORTER_ASSERT(reporter, outputSize == strlen(objectResult));
-
- char expectedResult[] =
- "<</Value 33\n>>1 0 obj\n<</InnerValue 44\n>>\nendobj\n";
- REPORTER_ASSERT(reporter, buffer.getOffset() == strlen(expectedResult));
- REPORTER_ASSERT(reporter, stream_equals(buffer, 0, expectedResult,
- buffer.getOffset()));
+ REPORTER_ASSERT(reporter, stub.get() == catalog.getSubstituteObject(proxy));
+ REPORTER_ASSERT(reporter, proxy.get() != catalog.getSubstituteObject(stub));
}
// Create a bitmap that would be very eficiently compressed in a ZIP.
« src/pdf/SkPDFTypes.h ('K') | « src/pdf/SkPDFTypes.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698