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