aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorGravatar halcanary <halcanary@google.com>2015-08-11 10:30:12 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-08-11 10:30:12 -0700
commit8ee06f21a27bbffaf613a312c6f24bbbb21c650a (patch)
tree781cfcac8ec506a9fcb9cbddf943f5ff37eba355 /tests
parent4cf9e7e14797f87f08b2078fa1afaf731cbf8f52 (diff)
SkPDF: allow PDF module to be disabled in DM and SampleApp
To disable PDF: GYP_DEFINES='skia_pdf=0' bin/sync-and-gyp ninja -C out/Debug dm SampleApp When disabled, SkDocument::CreatePDF() always returns NULL. Review URL: https://codereview.chromium.org/1279123007
Diffstat (limited to 'tests')
-rw-r--r--tests/AnnotationTest.cpp3
-rw-r--r--tests/CanvasTest.cpp5
-rw-r--r--tests/DeflateWStream.cpp3
-rw-r--r--tests/DocumentTest.cpp8
-rw-r--r--tests/FlateTest.cpp3
-rw-r--r--tests/PDFInvalidBitmapTest.cpp3
-rw-r--r--tests/PDFJpegEmbedTest.cpp3
-rw-r--r--tests/PDFPrimitivesTest.cpp3
-rw-r--r--tests/ToUnicodeTest.cpp3
-rw-r--r--tests/skpdf_opaquesrcmodetosrcover.cpp3
10 files changed, 37 insertions, 0 deletions
diff --git a/tests/AnnotationTest.cpp b/tests/AnnotationTest.cpp
index 7a1ca97a55..a40a5f427b 100644
--- a/tests/AnnotationTest.cpp
+++ b/tests/AnnotationTest.cpp
@@ -12,6 +12,8 @@
#include "SkStream.h"
#include "Test.h"
+#if SK_SUPPORT_PDF
+
/** Returns true if data (may contain null characters) contains needle (null
* terminated). */
static bool ContainsString(const char* data, size_t dataSize, const char* needle) {
@@ -74,3 +76,4 @@ DEF_TEST(Annotation_NamedDestination, reporter) {
REPORTER_ASSERT(reporter,
ContainsString(rawOutput, out->size(), "/example "));
}
+#endif // SK_SUPPORT_PDF
diff --git a/tests/CanvasTest.cpp b/tests/CanvasTest.cpp
index 970a37074f..78253ac900 100644
--- a/tests/CanvasTest.cpp
+++ b/tests/CanvasTest.cpp
@@ -568,6 +568,8 @@ static void TestPdfDevice(skiatest::Reporter* reporter,
CanvasTestStep* testStep) {
SkDynamicMemoryWStream outStream;
SkAutoTUnref<SkDocument> doc(SkDocument::CreatePDF(&outStream));
+#if SK_SUPPORT_PDF
+ REPORTER_ASSERT(reporter, doc);
SkCanvas* canvas = doc->beginPage(SkIntToScalar(d.fWidth),
SkIntToScalar(d.fHeight));
REPORTER_ASSERT(reporter, canvas);
@@ -575,6 +577,9 @@ static void TestPdfDevice(skiatest::Reporter* reporter,
testStep->draw(canvas, d, reporter);
REPORTER_ASSERT(reporter, doc->close());
+#else
+ REPORTER_ASSERT(reporter, !doc);
+#endif // SK_SUPPORT_PDF
}
// The following class groups static functions that need to access
diff --git a/tests/DeflateWStream.cpp b/tests/DeflateWStream.cpp
index b22574671b..930ecb4144 100644
--- a/tests/DeflateWStream.cpp
+++ b/tests/DeflateWStream.cpp
@@ -9,6 +9,8 @@
#include "SkRandom.h"
#include "Test.h"
+#if SK_SUPPORT_PDF
+
DEF_TEST(SkDeflateWStream, r) {
SkRandom random(123456);
for (int i = 0; i < 50; ++i) {
@@ -70,3 +72,4 @@ DEF_TEST(SkDeflateWStream, r) {
}
}
}
+#endif // SK_SUPPORT_PDF
diff --git a/tests/DocumentTest.cpp b/tests/DocumentTest.cpp
index 8bfb502700..5bd6ba6a03 100644
--- a/tests/DocumentTest.cpp
+++ b/tests/DocumentTest.cpp
@@ -1,9 +1,16 @@
+/*
+ * Copyright 2013 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
#include "Test.h"
#include "SkCanvas.h"
#include "SkDocument.h"
#include "SkOSFile.h"
#include "SkStream.h"
+#if SK_SUPPORT_PDF
static void test_empty(skiatest::Reporter* reporter) {
SkDynamicMemoryWStream stream;
@@ -103,3 +110,4 @@ DEF_TEST(document_tests, reporter) {
test_file(reporter);
test_close(reporter);
}
+#endif // SK_SUPPORT_PDF
diff --git a/tests/FlateTest.cpp b/tests/FlateTest.cpp
index 40efe1a5d8..8387f527d1 100644
--- a/tests/FlateTest.cpp
+++ b/tests/FlateTest.cpp
@@ -10,6 +10,8 @@
#include "SkStream.h"
#include "Test.h"
+#if SK_SUPPORT_PDF
+
// A memory stream that reports zero size with the standard call, like
// an unseekable file stream would.
class SkZeroSizeMemStream : public SkMemoryStream {
@@ -112,3 +114,4 @@ DEF_TEST(Flate, reporter) {
TestFlate(reporter, &fileStream, 512);
TestFlate(reporter, &fileStream, 10240);
}
+#endif // SK_SUPPORT_PDF
diff --git a/tests/PDFInvalidBitmapTest.cpp b/tests/PDFInvalidBitmapTest.cpp
index 8a9b1fa132..6a547066d5 100644
--- a/tests/PDFInvalidBitmapTest.cpp
+++ b/tests/PDFInvalidBitmapTest.cpp
@@ -15,6 +15,8 @@
#include "Test.h"
+#if SK_SUPPORT_PDF
+
namespace {
// SkPixelRef which fails to lock, as a lazy pixel ref might if its pixels
@@ -58,3 +60,4 @@ DEF_TEST(PDFInvalidBitmap, reporter) {
// This test passes if it does not crash.
}
+#endif // SK_SUPPORT_PDF
diff --git a/tests/PDFJpegEmbedTest.cpp b/tests/PDFJpegEmbedTest.cpp
index cfe6776bf5..021161bf9f 100644
--- a/tests/PDFJpegEmbedTest.cpp
+++ b/tests/PDFJpegEmbedTest.cpp
@@ -14,6 +14,8 @@
#include "Resources.h"
#include "Test.h"
+#if SK_SUPPORT_PDF
+
// Returned bitmap is lazy. Only lazy bitmaps hold onto the original data.
static SkBitmap bitmap_from_data(SkData* data) {
SkASSERT(data);
@@ -125,3 +127,4 @@ DEF_TEST(JpegIdentification, r) {
}
}
}
+#endif // SK_SUPPORT_PDF
diff --git a/tests/PDFPrimitivesTest.cpp b/tests/PDFPrimitivesTest.cpp
index 013d58657b..22d8d16328 100644
--- a/tests/PDFPrimitivesTest.cpp
+++ b/tests/PDFPrimitivesTest.cpp
@@ -22,6 +22,8 @@
#include "SkTypes.h"
#include "Test.h"
+#if SK_SUPPORT_PDF
+
#define DUMMY_TEXT "DCT compessed stream."
namespace {
@@ -413,3 +415,4 @@ DEF_TEST(PDFImageFilter, reporter) {
// Filter was used in rendering; should be visited.
REPORTER_ASSERT(reporter, filter->visited());
}
+#endif // SK_SUPPORT_PDF
diff --git a/tests/ToUnicodeTest.cpp b/tests/ToUnicodeTest.cpp
index 33fcc80ef7..4dcb2df0b2 100644
--- a/tests/ToUnicodeTest.cpp
+++ b/tests/ToUnicodeTest.cpp
@@ -11,6 +11,8 @@
#include "SkStream.h"
#include "Test.h"
+#if SK_SUPPORT_PDF
+
static bool stream_equals(const SkDynamicMemoryWStream& stream, size_t offset,
const char* buffer, size_t len) {
SkAutoDataUnref data(stream.copyToData());
@@ -178,3 +180,4 @@ endbfrange\n";
REPORTER_ASSERT(reporter, stream_equals(buffer2, 0, expectedResult2,
buffer2.getOffset()));
}
+#endif // SK_SUPPORT_PDF
diff --git a/tests/skpdf_opaquesrcmodetosrcover.cpp b/tests/skpdf_opaquesrcmodetosrcover.cpp
index f742f3ddd6..8c7fc75162 100644
--- a/tests/skpdf_opaquesrcmodetosrcover.cpp
+++ b/tests/skpdf_opaquesrcmodetosrcover.cpp
@@ -9,6 +9,8 @@
#include "SkStream.h"
#include "Test.h"
+#if SK_SUPPORT_PDF
+
static void run_test(SkWStream* out, SkXfermode::Mode mode, U8CPU alpha) {
SkAutoTUnref<SkDocument> pdfDoc(SkDocument::CreatePDF(out));
SkCanvas* c = pdfDoc->beginPage(612.0f, 792.0f);
@@ -44,3 +46,4 @@ DEF_TEST(SkPDF_OpaqueSrcModeToSrcOver, r) {
REPORTER_ASSERT(r, srcMode.getOffset() > srcOverMode.getOffset());
// The two PDFs should not be equal because they have a non-opaque alpha.
}
+#endif // SK_SUPPORT_PDF