OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "SkDocument.h" | 7 #include "SkDocument.h" |
8 #include "SkStream.h" | 8 #include "SkStream.h" |
9 #include "SkData.h" | 9 #include "SkData.h" |
10 #include "Test.h" | 10 #include "Test.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 doc->setMetadata(&info[0], infoCount, &now, &now); | 27 doc->setMetadata(&info[0], infoCount, &now, &now); |
28 doc->beginPage(612.0f, 792.0f); | 28 doc->beginPage(612.0f, 792.0f); |
29 doc->close(); | 29 doc->close(); |
30 SkAutoTUnref<SkData> data(pdf.copyToData()); | 30 SkAutoTUnref<SkData> data(pdf.copyToData()); |
31 static const char* expectations[] = { | 31 static const char* expectations[] = { |
32 "/Title (A1)", | 32 "/Title (A1)", |
33 "/Author (A2)", | 33 "/Author (A2)", |
34 "/Subject (A3)", | 34 "/Subject (A3)", |
35 "/Keywords (A4)", | 35 "/Keywords (A4)", |
36 "/Creator (A5)", | 36 "/Creator (A5)", |
37 "/Producer (Skia/PDF)", | 37 "/Producer (Skia/PDF ", |
38 "/CreationDate (D:", | 38 "/CreationDate (D:", |
39 "/ModDate (D:" | 39 "/ModDate (D:" |
40 }; | 40 }; |
41 for (const char* expectation : expectations) { | 41 for (const char* expectation : expectations) { |
42 bool found = false; | 42 bool found = false; |
43 size_t N = 1 + data->size() - strlen(expectation); | 43 size_t N = 1 + data->size() - strlen(expectation); |
44 for (size_t i = 0; i < N; ++i) { | 44 for (size_t i = 0; i < N; ++i) { |
45 if (0 == memcmp(data->bytes() + i, | 45 if (0 == memcmp(data->bytes() + i, |
46 expectation, strlen(expectation))) { | 46 expectation, strlen(expectation))) { |
47 found = true; | 47 found = true; |
48 break; | 48 break; |
49 } | 49 } |
50 } | 50 } |
51 if (!found) { | 51 if (!found) { |
52 ERRORF(r, "expectation missing: '%s'.", expectation); | 52 ERRORF(r, "expectation missing: '%s'.", expectation); |
53 } | 53 } |
54 } | 54 } |
55 } | 55 } |
OLD | NEW |