| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
| 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 #include "Test.h" | 7 #include "Test.h" |
| 8 | 8 |
| 9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
| 10 #include "SkDocument.h" | 10 #include "SkDocument.h" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 | 75 |
| 76 SkAutoTUnref<SkDocument> doc(SkDocument::CreatePDF(path.c_str())); | 76 SkAutoTUnref<SkDocument> doc(SkDocument::CreatePDF(path.c_str())); |
| 77 | 77 |
| 78 SkCanvas* canvas = doc->beginPage(100, 100); | 78 SkCanvas* canvas = doc->beginPage(100, 100); |
| 79 | 79 |
| 80 canvas->drawColor(SK_ColorRED); | 80 canvas->drawColor(SK_ColorRED); |
| 81 doc->endPage(); | 81 doc->endPage(); |
| 82 doc->close(); | 82 doc->close(); |
| 83 | 83 |
| 84 FILE* file = fopen(path.c_str(), "r"); | 84 FILE* file = fopen(path.c_str(), "r"); |
| 85 REPORTER_ASSERT(reporter, file != NULL); | 85 REPORTER_ASSERT(reporter, file != nullptr); |
| 86 char header[100]; | 86 char header[100]; |
| 87 REPORTER_ASSERT(reporter, fread(header, 4, 1, file) != 0); | 87 REPORTER_ASSERT(reporter, fread(header, 4, 1, file) != 0); |
| 88 REPORTER_ASSERT(reporter, strncmp(header, "%PDF", 4) == 0); | 88 REPORTER_ASSERT(reporter, strncmp(header, "%PDF", 4) == 0); |
| 89 fclose(file); | 89 fclose(file); |
| 90 } | 90 } |
| 91 | 91 |
| 92 static void test_close(skiatest::Reporter* reporter) { | 92 static void test_close(skiatest::Reporter* reporter) { |
| 93 SkDynamicMemoryWStream stream; | 93 SkDynamicMemoryWStream stream; |
| 94 SkAutoTUnref<SkDocument> doc(SkDocument::CreatePDF(&stream)); | 94 SkAutoTUnref<SkDocument> doc(SkDocument::CreatePDF(&stream)); |
| 95 | 95 |
| 96 SkCanvas* canvas = doc->beginPage(100, 100); | 96 SkCanvas* canvas = doc->beginPage(100, 100); |
| 97 canvas->drawColor(SK_ColorRED); | 97 canvas->drawColor(SK_ColorRED); |
| 98 doc->endPage(); | 98 doc->endPage(); |
| 99 | 99 |
| 100 doc->close(); | 100 doc->close(); |
| 101 | 101 |
| 102 REPORTER_ASSERT(reporter, stream.bytesWritten() != 0); | 102 REPORTER_ASSERT(reporter, stream.bytesWritten() != 0); |
| 103 } | 103 } |
| 104 | 104 |
| 105 DEF_TEST(document_tests, reporter) { | 105 DEF_TEST(document_tests, reporter) { |
| 106 REQUIRE_PDF_DOCUMENT(document_tests, reporter); | 106 REQUIRE_PDF_DOCUMENT(document_tests, reporter); |
| 107 test_empty(reporter); | 107 test_empty(reporter); |
| 108 test_abort(reporter); | 108 test_abort(reporter); |
| 109 test_abortWithFile(reporter); | 109 test_abortWithFile(reporter); |
| 110 test_file(reporter); | 110 test_file(reporter); |
| 111 test_close(reporter); | 111 test_close(reporter); |
| 112 } | 112 } |
| OLD | NEW |