OLD | NEW |
1 // Copyright 2015 PDFium Authors. All rights reserved. | 1 // Copyright 2015 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef TESTING_EMBEDDER_TEST_SUPPORT_H_ | 5 #ifndef TESTING_EMBEDDER_TEST_SUPPORT_H_ |
6 #define TESTING_EMBEDDER_TEST_SUPPORT_H_ | 6 #define TESTING_EMBEDDER_TEST_SUPPORT_H_ |
7 | 7 |
8 #include <stdlib.h> | 8 #include <stdlib.h> |
9 #include <memory> | 9 #include <memory> |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "public/fpdfview.h" | 12 #include "public/fpdfview.h" |
| 13 #include "public/fpdf_save.h" |
13 | 14 |
14 #ifdef PDF_ENABLE_V8 | 15 #ifdef PDF_ENABLE_V8 |
15 #include "v8/include/v8.h" | 16 #include "v8/include/v8.h" |
16 #endif // PDF_ENABLE_V8 | 17 #endif // PDF_ENABLE_V8 |
17 | 18 |
18 namespace pdfium { | 19 namespace pdfium { |
19 | 20 |
20 // Used with std::unique_ptr to free() objects that can't be deleted. | 21 // Used with std::unique_ptr to free() objects that can't be deleted. |
21 struct FreeDeleter { | 22 struct FreeDeleter { |
22 inline void operator()(void* ptr) const { free(ptr); } | 23 inline void operator()(void* ptr) const { free(ptr); } |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 static int GetBlock(void* param, | 56 static int GetBlock(void* param, |
56 unsigned long pos, | 57 unsigned long pos, |
57 unsigned char* pBuf, | 58 unsigned char* pBuf, |
58 unsigned long size); | 59 unsigned long size); |
59 | 60 |
60 private: | 61 private: |
61 const char* const m_pBuf; | 62 const char* const m_pBuf; |
62 const size_t m_Len; | 63 const size_t m_Len; |
63 }; | 64 }; |
64 | 65 |
| 66 class TestSaver : public FPDF_FILEWRITE { |
| 67 public: |
| 68 TestSaver(); |
| 69 |
| 70 void ClearString(); |
| 71 const std::string& GetString() const { return m_String; } |
| 72 |
| 73 private: |
| 74 static int WriteBlockCallback(FPDF_FILEWRITE* pFileWrite, |
| 75 const void* data, |
| 76 unsigned long size); |
| 77 |
| 78 std::string m_String; |
| 79 }; |
| 80 |
65 #endif // TESTING_EMBEDDER_TEST_SUPPORT_H_ | 81 #endif // TESTING_EMBEDDER_TEST_SUPPORT_H_ |
OLD | NEW |