2011-07-28 14:26:00 +00:00
|
|
|
|
2010-10-01 23:26:55 +00:00
|
|
|
/*
|
2011-07-28 14:26:00 +00:00
|
|
|
* Copyright 2010 The Android Open Source Project
|
2010-10-01 23:26:55 +00:00
|
|
|
*
|
2011-07-28 14:26:00 +00:00
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
2010-10-01 23:26:55 +00:00
|
|
|
*/
|
|
|
|
|
2011-07-28 14:26:00 +00:00
|
|
|
|
2010-09-24 22:25:30 +00:00
|
|
|
#include "Test.h"
|
2013-01-25 19:27:23 +00:00
|
|
|
#include "SkCanvas.h"
|
2011-06-24 19:12:12 +00:00
|
|
|
#include "SkData.h"
|
2011-07-20 17:39:01 +00:00
|
|
|
#include "SkFlate.h"
|
2010-09-24 22:25:30 +00:00
|
|
|
#include "SkPDFCatalog.h"
|
2013-01-25 19:27:23 +00:00
|
|
|
#include "SkPDFDevice.h"
|
2010-09-24 22:25:30 +00:00
|
|
|
#include "SkPDFStream.h"
|
|
|
|
#include "SkPDFTypes.h"
|
|
|
|
#include "SkScalar.h"
|
|
|
|
#include "SkStream.h"
|
2011-07-20 17:39:01 +00:00
|
|
|
#include "SkTypes.h"
|
2010-09-24 22:25:30 +00:00
|
|
|
|
2011-07-06 23:31:24 +00:00
|
|
|
class SkPDFTestDict : public SkPDFDict {
|
|
|
|
public:
|
2013-02-28 14:01:44 +00:00
|
|
|
void getResources(SkTDArray<SkPDFObject*>* resourceList) {
|
|
|
|
resourceList->setReserve(resourceList->count() + fResources.count());
|
2011-07-06 23:31:24 +00:00
|
|
|
for (int i = 0; i < fResources.count(); i++) {
|
2013-02-28 14:01:44 +00:00
|
|
|
resourceList->push(fResources[i]);
|
2011-07-06 23:31:24 +00:00
|
|
|
fResources[i]->ref();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void addResource(SkPDFObject* object) {
|
|
|
|
fResources.append(1, &object);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
SkTDArray<SkPDFObject*> fResources;
|
|
|
|
};
|
|
|
|
|
2011-06-24 19:12:12 +00:00
|
|
|
static bool stream_equals(const SkDynamicMemoryWStream& stream, size_t offset,
|
|
|
|
const void* buffer, size_t len) {
|
|
|
|
SkAutoDataUnref data(stream.copyToData());
|
2012-07-10 17:30:58 +00:00
|
|
|
if (offset + len > data->size()) {
|
2011-06-24 19:12:12 +00:00
|
|
|
return false;
|
|
|
|
}
|
2012-07-10 17:30:58 +00:00
|
|
|
return memcmp(data->bytes() + offset, buffer, len) == 0;
|
2011-06-24 19:12:12 +00:00
|
|
|
}
|
|
|
|
|
2010-09-24 22:25:30 +00:00
|
|
|
static void CheckObjectOutput(skiatest::Reporter* reporter, SkPDFObject* obj,
|
2011-07-20 17:39:01 +00:00
|
|
|
const char* expectedData, size_t expectedSize,
|
|
|
|
bool indirect, bool compression) {
|
|
|
|
SkPDFDocument::Flags docFlags = (SkPDFDocument::Flags) 0;
|
|
|
|
if (!compression) {
|
2012-07-13 20:06:02 +00:00
|
|
|
docFlags = SkTBitOr(docFlags, SkPDFDocument::kNoCompression_Flags);
|
2011-07-20 17:39:01 +00:00
|
|
|
}
|
|
|
|
SkPDFCatalog catalog(docFlags);
|
2011-07-06 23:31:24 +00:00
|
|
|
size_t directSize = obj->getOutputSize(&catalog, false);
|
2011-07-20 17:39:01 +00:00
|
|
|
REPORTER_ASSERT(reporter, directSize == expectedSize);
|
2010-09-24 22:25:30 +00:00
|
|
|
|
|
|
|
SkDynamicMemoryWStream buffer;
|
2011-07-06 23:31:24 +00:00
|
|
|
obj->emit(&buffer, &catalog, false);
|
2010-09-24 22:25:30 +00:00
|
|
|
REPORTER_ASSERT(reporter, directSize == buffer.getOffset());
|
2011-07-20 17:39:01 +00:00
|
|
|
REPORTER_ASSERT(reporter, stream_equals(buffer, 0, expectedData,
|
2011-06-24 19:12:12 +00:00
|
|
|
directSize));
|
2010-09-24 22:25:30 +00:00
|
|
|
|
|
|
|
if (indirect) {
|
|
|
|
// Indirect output.
|
|
|
|
static char header[] = "1 0 obj\n";
|
|
|
|
static size_t headerLen = strlen(header);
|
|
|
|
static char footer[] = "\nendobj\n";
|
|
|
|
static size_t footerLen = strlen(footer);
|
|
|
|
|
|
|
|
catalog.addObject(obj, false);
|
|
|
|
|
|
|
|
size_t indirectSize = obj->getOutputSize(&catalog, true);
|
|
|
|
REPORTER_ASSERT(reporter,
|
|
|
|
indirectSize == directSize + headerLen + footerLen);
|
|
|
|
|
|
|
|
buffer.reset();
|
2011-07-06 23:31:24 +00:00
|
|
|
obj->emit(&buffer, &catalog, true);
|
2010-09-24 22:25:30 +00:00
|
|
|
REPORTER_ASSERT(reporter, indirectSize == buffer.getOffset());
|
2011-06-24 19:12:12 +00:00
|
|
|
REPORTER_ASSERT(reporter, stream_equals(buffer, 0, header, headerLen));
|
2011-07-20 17:39:01 +00:00
|
|
|
REPORTER_ASSERT(reporter, stream_equals(buffer, headerLen, expectedData,
|
2011-06-24 19:12:12 +00:00
|
|
|
directSize));
|
|
|
|
REPORTER_ASSERT(reporter, stream_equals(buffer, headerLen + directSize,
|
|
|
|
footer, footerLen));
|
2010-09-24 22:25:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-20 17:39:01 +00:00
|
|
|
static void SimpleCheckObjectOutput(skiatest::Reporter* reporter,
|
|
|
|
SkPDFObject* obj,
|
2012-05-14 16:33:36 +00:00
|
|
|
const char* expectedResult) {
|
|
|
|
CheckObjectOutput(reporter, obj, expectedResult,
|
|
|
|
strlen(expectedResult), true, false);
|
2011-07-20 17:39:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void TestPDFStream(skiatest::Reporter* reporter) {
|
|
|
|
char streamBytes[] = "Test\nFoo\tBar";
|
2013-01-04 19:31:24 +00:00
|
|
|
SkAutoTUnref<SkMemoryStream> streamData(new SkMemoryStream(
|
|
|
|
streamBytes, strlen(streamBytes), true));
|
|
|
|
SkAutoTUnref<SkPDFStream> stream(new SkPDFStream(streamData.get()));
|
2011-07-20 17:39:01 +00:00
|
|
|
SimpleCheckObjectOutput(
|
|
|
|
reporter, stream.get(),
|
|
|
|
"<</Length 12\n>> stream\nTest\nFoo\tBar\nendstream");
|
|
|
|
stream->insert("Attribute", new SkPDFInt(42))->unref();
|
|
|
|
SimpleCheckObjectOutput(reporter, stream.get(),
|
|
|
|
"<</Length 12\n/Attribute 42\n>> stream\n"
|
|
|
|
"Test\nFoo\tBar\nendstream");
|
|
|
|
|
|
|
|
if (SkFlate::HaveFlate()) {
|
|
|
|
char streamBytes2[] = "This is a longer string, so that compression "
|
|
|
|
"can do something with it. With shorter strings, "
|
|
|
|
"the short circuit logic cuts in and we end up "
|
|
|
|
"with an uncompressed string.";
|
|
|
|
SkAutoDataUnref streamData2(SkData::NewWithCopy(streamBytes2,
|
|
|
|
strlen(streamBytes2)));
|
2013-01-04 19:31:24 +00:00
|
|
|
SkAutoTUnref<SkPDFStream> stream(new SkPDFStream(streamData2.get()));
|
2011-07-20 17:39:01 +00:00
|
|
|
|
|
|
|
SkDynamicMemoryWStream compressedByteStream;
|
|
|
|
SkFlate::Deflate(streamData2.get(), &compressedByteStream);
|
|
|
|
SkAutoDataUnref compressedData(compressedByteStream.copyToData());
|
|
|
|
|
|
|
|
// Check first without compression.
|
|
|
|
SkDynamicMemoryWStream expectedResult1;
|
|
|
|
expectedResult1.writeText("<</Length 167\n>> stream\n");
|
|
|
|
expectedResult1.writeText(streamBytes2);
|
|
|
|
expectedResult1.writeText("\nendstream");
|
|
|
|
SkAutoDataUnref expectedResultData1(expectedResult1.copyToData());
|
|
|
|
CheckObjectOutput(reporter, stream.get(),
|
2012-07-10 17:30:58 +00:00
|
|
|
(const char*) expectedResultData1->data(),
|
|
|
|
expectedResultData1->size(), true, false);
|
2011-07-20 17:39:01 +00:00
|
|
|
|
|
|
|
// Then again with compression.
|
|
|
|
SkDynamicMemoryWStream expectedResult2;
|
|
|
|
expectedResult2.writeText("<</Filter /FlateDecode\n/Length 116\n"
|
|
|
|
">> stream\n");
|
2012-07-10 17:30:58 +00:00
|
|
|
expectedResult2.write(compressedData->data(), compressedData->size());
|
2011-07-20 17:39:01 +00:00
|
|
|
expectedResult2.writeText("\nendstream");
|
|
|
|
SkAutoDataUnref expectedResultData2(expectedResult2.copyToData());
|
|
|
|
CheckObjectOutput(reporter, stream.get(),
|
2012-07-10 17:30:58 +00:00
|
|
|
(const char*) expectedResultData2->data(),
|
|
|
|
expectedResultData2->size(), true, true);
|
2011-07-20 17:39:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-09-24 22:25:30 +00:00
|
|
|
static void TestCatalog(skiatest::Reporter* reporter) {
|
2011-07-20 17:39:01 +00:00
|
|
|
SkPDFCatalog catalog((SkPDFDocument::Flags)0);
|
2013-01-04 19:31:24 +00:00
|
|
|
SkAutoTUnref<SkPDFInt> int1(new SkPDFInt(1));
|
|
|
|
SkAutoTUnref<SkPDFInt> int2(new SkPDFInt(2));
|
|
|
|
SkAutoTUnref<SkPDFInt> int3(new SkPDFInt(3));
|
|
|
|
int1.get()->ref();
|
|
|
|
SkAutoTUnref<SkPDFInt> int1Again(int1.get());
|
2010-09-24 22:25:30 +00:00
|
|
|
|
|
|
|
catalog.addObject(int1.get(), false);
|
|
|
|
catalog.addObject(int2.get(), false);
|
|
|
|
catalog.addObject(int3.get(), false);
|
|
|
|
|
|
|
|
REPORTER_ASSERT(reporter, catalog.getObjectNumberSize(int1.get()) == 3);
|
|
|
|
REPORTER_ASSERT(reporter, catalog.getObjectNumberSize(int2.get()) == 3);
|
|
|
|
REPORTER_ASSERT(reporter, catalog.getObjectNumberSize(int3.get()) == 3);
|
|
|
|
|
|
|
|
SkDynamicMemoryWStream buffer;
|
|
|
|
catalog.emitObjectNumber(&buffer, int1.get());
|
|
|
|
catalog.emitObjectNumber(&buffer, int2.get());
|
|
|
|
catalog.emitObjectNumber(&buffer, int3.get());
|
|
|
|
catalog.emitObjectNumber(&buffer, int1Again.get());
|
|
|
|
char expectedResult[] = "1 02 03 01 0";
|
2011-06-24 19:12:12 +00:00
|
|
|
REPORTER_ASSERT(reporter, stream_equals(buffer, 0, expectedResult,
|
|
|
|
strlen(expectedResult)));
|
2010-09-24 22:25:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void TestObjectRef(skiatest::Reporter* reporter) {
|
2013-01-04 19:31:24 +00:00
|
|
|
SkAutoTUnref<SkPDFInt> int1(new SkPDFInt(1));
|
|
|
|
SkAutoTUnref<SkPDFInt> int2(new SkPDFInt(2));
|
|
|
|
SkAutoTUnref<SkPDFObjRef> int2ref(new SkPDFObjRef(int2.get()));
|
2010-09-24 22:25:30 +00:00
|
|
|
|
2011-07-20 17:39:01 +00:00
|
|
|
SkPDFCatalog catalog((SkPDFDocument::Flags)0);
|
2010-09-24 22:25:30 +00:00
|
|
|
catalog.addObject(int1.get(), false);
|
|
|
|
catalog.addObject(int2.get(), false);
|
|
|
|
REPORTER_ASSERT(reporter, catalog.getObjectNumberSize(int1.get()) == 3);
|
|
|
|
REPORTER_ASSERT(reporter, catalog.getObjectNumberSize(int2.get()) == 3);
|
|
|
|
|
|
|
|
char expectedResult[] = "2 0 R";
|
|
|
|
SkDynamicMemoryWStream buffer;
|
|
|
|
int2ref->emitObject(&buffer, &catalog, false);
|
|
|
|
REPORTER_ASSERT(reporter, buffer.getOffset() == strlen(expectedResult));
|
2011-06-24 19:12:12 +00:00
|
|
|
REPORTER_ASSERT(reporter, stream_equals(buffer, 0, expectedResult,
|
|
|
|
buffer.getOffset()));
|
2010-09-24 22:25:30 +00:00
|
|
|
}
|
|
|
|
|
2011-07-06 23:31:24 +00:00
|
|
|
static void TestSubstitute(skiatest::Reporter* reporter) {
|
2013-01-04 19:31:24 +00:00
|
|
|
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));
|
2011-07-06 23:31:24 +00:00
|
|
|
|
|
|
|
stub->insert("Value", int33.get());
|
|
|
|
stubResource->insert("InnerValue", int44.get());
|
|
|
|
stub->addResource(stubResource.get());
|
|
|
|
|
2011-07-20 17:39:01 +00:00
|
|
|
SkPDFCatalog catalog((SkPDFDocument::Flags)0);
|
2011-07-06 23:31:24 +00:00
|
|
|
catalog.addObject(proxy.get(), false);
|
|
|
|
catalog.setSubstitute(proxy.get(), stub.get());
|
|
|
|
|
|
|
|
SkDynamicMemoryWStream buffer;
|
|
|
|
proxy->emit(&buffer, &catalog, false);
|
|
|
|
catalog.emitSubstituteResources(&buffer, false);
|
|
|
|
|
2011-07-25 22:22:25 +00:00
|
|
|
char objectResult[] = "2 0 obj\n<</Value 33\n>>\nendobj\n";
|
|
|
|
REPORTER_ASSERT(
|
|
|
|
reporter,
|
|
|
|
catalog.setFileOffset(proxy.get(), 0) == strlen(objectResult));
|
|
|
|
|
2011-07-06 23:31:24 +00:00
|
|
|
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()));
|
|
|
|
}
|
|
|
|
|
2013-01-25 19:27:23 +00:00
|
|
|
// This test used to assert without the fix submitted for
|
|
|
|
// http://code.google.com/p/skia/issues/detail?id=1083.
|
|
|
|
// SKP files might have invalid glyph ids. This test ensures they are ignored,
|
|
|
|
// and there is no assert on input data in Debug mode.
|
2013-02-27 19:17:41 +00:00
|
|
|
static void test_issue1083() {
|
2013-01-25 19:27:23 +00:00
|
|
|
SkISize pageSize = SkISize::Make(100, 100);
|
|
|
|
SkPDFDevice* dev = new SkPDFDevice(pageSize, pageSize, SkMatrix::I());
|
|
|
|
|
|
|
|
SkCanvas c(dev);
|
|
|
|
SkPaint paint;
|
|
|
|
paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
|
|
|
|
|
|
|
|
uint16_t glyphID = 65000;
|
|
|
|
c.drawText(&glyphID, 2, 0, 0, paint);
|
|
|
|
|
|
|
|
SkPDFDocument doc;
|
|
|
|
doc.appendPage(dev);
|
|
|
|
|
|
|
|
SkDynamicMemoryWStream stream;
|
|
|
|
doc.emitPDF(&stream);
|
|
|
|
}
|
|
|
|
|
2010-09-24 22:25:30 +00:00
|
|
|
static void TestPDFPrimitives(skiatest::Reporter* reporter) {
|
2013-01-04 19:31:24 +00:00
|
|
|
SkAutoTUnref<SkPDFInt> int42(new SkPDFInt(42));
|
2011-07-20 17:39:01 +00:00
|
|
|
SimpleCheckObjectOutput(reporter, int42.get(), "42");
|
2010-09-24 22:25:30 +00:00
|
|
|
|
2013-01-04 19:31:24 +00:00
|
|
|
SkAutoTUnref<SkPDFScalar> realHalf(new SkPDFScalar(SK_ScalarHalf));
|
2011-07-20 17:39:01 +00:00
|
|
|
SimpleCheckObjectOutput(reporter, realHalf.get(), "0.5");
|
2010-09-24 22:25:30 +00:00
|
|
|
|
2011-05-18 17:08:05 +00:00
|
|
|
#if defined(SK_SCALAR_IS_FLOAT)
|
2013-01-04 19:31:24 +00:00
|
|
|
SkAutoTUnref<SkPDFScalar> bigScalar(new SkPDFScalar(110999.75f));
|
2011-05-18 17:08:05 +00:00
|
|
|
#if !defined(SK_ALLOW_LARGE_PDF_SCALARS)
|
2011-07-20 17:39:01 +00:00
|
|
|
SimpleCheckObjectOutput(reporter, bigScalar.get(), "111000");
|
2011-03-04 03:15:13 +00:00
|
|
|
#else
|
2011-07-20 17:39:01 +00:00
|
|
|
SimpleCheckObjectOutput(reporter, bigScalar.get(), "110999.75");
|
2011-03-04 03:15:13 +00:00
|
|
|
|
2013-01-04 19:31:24 +00:00
|
|
|
SkAutoTUnref<SkPDFScalar> biggerScalar(new SkPDFScalar(50000000.1));
|
2011-07-20 17:39:01 +00:00
|
|
|
SimpleCheckObjectOutput(reporter, biggerScalar.get(), "50000000");
|
2011-03-04 03:15:13 +00:00
|
|
|
|
2013-01-04 19:31:24 +00:00
|
|
|
SkAutoTUnref<SkPDFScalar> smallestScalar(new SkPDFScalar(1.0/65536));
|
2011-07-20 17:39:01 +00:00
|
|
|
SimpleCheckObjectOutput(reporter, smallestScalar.get(), "0.00001526");
|
2011-05-18 17:08:05 +00:00
|
|
|
#endif
|
2011-03-04 03:15:13 +00:00
|
|
|
#endif
|
|
|
|
|
2013-01-04 19:31:24 +00:00
|
|
|
SkAutoTUnref<SkPDFString> stringSimple(
|
|
|
|
new SkPDFString("test ) string ( foo"));
|
2011-07-20 17:39:01 +00:00
|
|
|
SimpleCheckObjectOutput(reporter, stringSimple.get(),
|
|
|
|
"(test \\) string \\( foo)");
|
2013-01-04 19:31:24 +00:00
|
|
|
SkAutoTUnref<SkPDFString> stringComplex(
|
|
|
|
new SkPDFString("\ttest ) string ( foo"));
|
2011-07-20 17:39:01 +00:00
|
|
|
SimpleCheckObjectOutput(reporter, stringComplex.get(),
|
|
|
|
"<0974657374202920737472696E67202820666F6F>");
|
2010-09-24 22:25:30 +00:00
|
|
|
|
2013-01-04 19:31:24 +00:00
|
|
|
SkAutoTUnref<SkPDFName> name(new SkPDFName("Test name\twith#tab"));
|
2011-07-20 17:39:01 +00:00
|
|
|
const char expectedResult[] = "/Test#20name#09with#23tab";
|
|
|
|
CheckObjectOutput(reporter, name.get(), expectedResult,
|
|
|
|
strlen(expectedResult), false, false);
|
2010-09-24 22:25:30 +00:00
|
|
|
|
2013-01-04 19:31:24 +00:00
|
|
|
SkAutoTUnref<SkPDFName> escapedName(new SkPDFName("A#/%()<>[]{}B"));
|
2012-09-21 17:50:50 +00:00
|
|
|
const char escapedNameExpected[] = "/A#23#2F#25#28#29#3C#3E#5B#5D#7B#7DB";
|
|
|
|
CheckObjectOutput(reporter, escapedName.get(), escapedNameExpected,
|
|
|
|
strlen(escapedNameExpected), false, false);
|
|
|
|
|
2012-03-05 18:44:33 +00:00
|
|
|
// Test that we correctly handle characters with the high-bit set.
|
2012-03-19 21:04:52 +00:00
|
|
|
const unsigned char highBitCString[] = {0xDE, 0xAD, 'b', 'e', 0xEF, 0};
|
2013-01-04 19:31:24 +00:00
|
|
|
SkAutoTUnref<SkPDFName> highBitName(
|
|
|
|
new SkPDFName((const char*)highBitCString));
|
2012-03-05 18:44:33 +00:00
|
|
|
const char highBitExpectedResult[] = "/#DE#ADbe#EF";
|
|
|
|
CheckObjectOutput(reporter, highBitName.get(), highBitExpectedResult,
|
|
|
|
strlen(highBitExpectedResult), false, false);
|
|
|
|
|
2013-01-04 19:31:24 +00:00
|
|
|
SkAutoTUnref<SkPDFArray> array(new SkPDFArray);
|
2011-07-20 17:39:01 +00:00
|
|
|
SimpleCheckObjectOutput(reporter, array.get(), "[]");
|
2010-09-24 22:25:30 +00:00
|
|
|
array->append(int42.get());
|
2011-07-20 17:39:01 +00:00
|
|
|
SimpleCheckObjectOutput(reporter, array.get(), "[42]");
|
2010-09-24 22:25:30 +00:00
|
|
|
array->append(realHalf.get());
|
2011-07-20 17:39:01 +00:00
|
|
|
SimpleCheckObjectOutput(reporter, array.get(), "[42 0.5]");
|
2013-01-04 19:31:24 +00:00
|
|
|
SkAutoTUnref<SkPDFInt> int0(new SkPDFInt(0));
|
2010-09-24 22:25:30 +00:00
|
|
|
array->append(int0.get());
|
2011-07-20 17:39:01 +00:00
|
|
|
SimpleCheckObjectOutput(reporter, array.get(), "[42 0.5 0]");
|
2013-01-04 19:31:24 +00:00
|
|
|
SkAutoTUnref<SkPDFInt> int1(new SkPDFInt(1));
|
2010-09-24 22:25:30 +00:00
|
|
|
array->setAt(0, int1.get());
|
2011-07-20 17:39:01 +00:00
|
|
|
SimpleCheckObjectOutput(reporter, array.get(), "[1 0.5 0]");
|
2010-09-24 22:25:30 +00:00
|
|
|
|
2013-01-04 19:31:24 +00:00
|
|
|
SkAutoTUnref<SkPDFDict> dict(new SkPDFDict);
|
2011-07-20 17:39:01 +00:00
|
|
|
SimpleCheckObjectOutput(reporter, dict.get(), "<<>>");
|
2013-01-04 19:31:24 +00:00
|
|
|
SkAutoTUnref<SkPDFName> n1(new SkPDFName("n1"));
|
2010-09-24 22:25:30 +00:00
|
|
|
dict->insert(n1.get(), int42.get());
|
2011-07-20 17:39:01 +00:00
|
|
|
SimpleCheckObjectOutput(reporter, dict.get(), "<</n1 42\n>>");
|
2013-01-04 19:31:24 +00:00
|
|
|
SkAutoTUnref<SkPDFName> n2(new SkPDFName("n2"));
|
|
|
|
SkAutoTUnref<SkPDFName> n3(new SkPDFName("n3"));
|
2010-09-24 22:25:30 +00:00
|
|
|
dict->insert(n2.get(), realHalf.get());
|
|
|
|
dict->insert(n3.get(), array.get());
|
2011-07-20 17:39:01 +00:00
|
|
|
SimpleCheckObjectOutput(reporter, dict.get(),
|
|
|
|
"<</n1 42\n/n2 0.5\n/n3 [1 0.5 0]\n>>");
|
2010-09-24 22:25:30 +00:00
|
|
|
|
2011-07-20 17:39:01 +00:00
|
|
|
TestPDFStream(reporter);
|
2010-09-24 22:25:30 +00:00
|
|
|
|
|
|
|
TestCatalog(reporter);
|
|
|
|
|
|
|
|
TestObjectRef(reporter);
|
2011-07-06 23:31:24 +00:00
|
|
|
|
|
|
|
TestSubstitute(reporter);
|
2013-01-25 19:27:23 +00:00
|
|
|
|
2013-02-27 19:17:41 +00:00
|
|
|
test_issue1083();
|
2010-09-24 22:25:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#include "TestClassDef.h"
|
|
|
|
DEFINE_TESTCLASS("PDFPrimitives", PDFPrimitivesTestClass, TestPDFPrimitives)
|