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

Unified Diff: tests/DocumentTest.cpp

Issue 1278403006: SkPDF: clean up overuse of SK_SUPPORT_PDF (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-08-11 (Tuesday) 16:25:36 EDT Created 5 years, 4 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
« no previous file with comments | « tests/DeflateWStream.cpp ('k') | tests/FlateTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/DocumentTest.cpp
diff --git a/tests/DocumentTest.cpp b/tests/DocumentTest.cpp
deleted file mode 100644
index 5bd6ba6a0367200cc9782bf6fdd565e4c5174485..0000000000000000000000000000000000000000
--- a/tests/DocumentTest.cpp
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * 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;
-
- SkAutoTUnref<SkDocument> doc(SkDocument::CreatePDF(&stream));
-
- doc->close();
-
- REPORTER_ASSERT(reporter, stream.bytesWritten() == 0);
-}
-
-static void test_abort(skiatest::Reporter* reporter) {
- SkDynamicMemoryWStream stream;
- SkAutoTUnref<SkDocument> doc(SkDocument::CreatePDF(&stream));
-
- SkCanvas* canvas = doc->beginPage(100, 100);
- canvas->drawColor(SK_ColorRED);
- doc->endPage();
-
- doc->abort();
-
- REPORTER_ASSERT(reporter, stream.bytesWritten() == 0);
-}
-
-static void test_abortWithFile(skiatest::Reporter* reporter) {
- SkString tmpDir = skiatest::GetTmpDir();
-
- if (tmpDir.isEmpty()) {
- return; // TODO(edisonn): unfortunatelly this pattern is used in other
- // tests, but if GetTmpDir() starts returning and empty dir
- // allways, then all these tests will be disabled.
- }
-
- SkString path = SkOSPath::Join(tmpDir.c_str(), "aborted.pdf");
-
- // Make sure doc's destructor is called to flush.
- {
- SkAutoTUnref<SkDocument> doc(SkDocument::CreatePDF(path.c_str()));
-
- SkCanvas* canvas = doc->beginPage(100, 100);
- canvas->drawColor(SK_ColorRED);
- doc->endPage();
-
- doc->abort();
- }
-
- FILE* file = fopen(path.c_str(), "r");
- // The created file should be empty.
- char buffer[100];
- REPORTER_ASSERT(reporter, fread(buffer, 1, 1, file) == 0);
- fclose(file);
-}
-
-static void test_file(skiatest::Reporter* reporter) {
- SkString tmpDir = skiatest::GetTmpDir();
- if (tmpDir.isEmpty()) {
- return; // TODO(edisonn): unfortunatelly this pattern is used in other
- // tests, but if GetTmpDir() starts returning and empty dir
- // allways, then all these tests will be disabled.
- }
-
- SkString path = SkOSPath::Join(tmpDir.c_str(), "file.pdf");
-
- SkAutoTUnref<SkDocument> doc(SkDocument::CreatePDF(path.c_str()));
-
- SkCanvas* canvas = doc->beginPage(100, 100);
-
- canvas->drawColor(SK_ColorRED);
- doc->endPage();
- doc->close();
-
- FILE* file = fopen(path.c_str(), "r");
- REPORTER_ASSERT(reporter, file != NULL);
- char header[100];
- REPORTER_ASSERT(reporter, fread(header, 4, 1, file) != 0);
- REPORTER_ASSERT(reporter, strncmp(header, "%PDF", 4) == 0);
- fclose(file);
-}
-
-static void test_close(skiatest::Reporter* reporter) {
- SkDynamicMemoryWStream stream;
- SkAutoTUnref<SkDocument> doc(SkDocument::CreatePDF(&stream));
-
- SkCanvas* canvas = doc->beginPage(100, 100);
- canvas->drawColor(SK_ColorRED);
- doc->endPage();
-
- doc->close();
-
- REPORTER_ASSERT(reporter, stream.bytesWritten() != 0);
-}
-
-DEF_TEST(document_tests, reporter) {
- test_empty(reporter);
- test_abort(reporter);
- test_abortWithFile(reporter);
- test_file(reporter);
- test_close(reporter);
-}
-#endif // SK_SUPPORT_PDF
« no previous file with comments | « tests/DeflateWStream.cpp ('k') | tests/FlateTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698