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

Side by Side Diff: testing/test_support.h

Issue 1564583004: Merge to XFA: Return unique_ptrs from test_support functions (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Created 4 years, 11 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 unified diff | Download patch
« no previous file with comments | « testing/embedder_test.cpp ('k') | testing/test_support.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <string> 10 #include <string>
10 11
11 #include "public/fpdfview.h" 12 #include "public/fpdfview.h"
12 13
13 #ifdef PDF_ENABLE_V8 14 #ifdef PDF_ENABLE_V8
14 #include "v8/include/v8.h" 15 #include "v8/include/v8.h"
15 #endif // PDF_ENABLE_V8 16 #endif // PDF_ENABLE_V8
16 17
17 // Reads the entire contents of a file into a newly malloc'd buffer. 18 namespace pdfium {
18 char* GetFileContents(const char* filename, size_t* retlen); 19
20 // Used with std::unique_ptr to free() objects that can't be deleted.
21 struct FreeDeleter {
22 inline void operator()(void* ptr) const { free(ptr); }
23 };
24
25 } // namespace pdfium
26
27 // Reads the entire contents of a file into a newly alloc'd buffer.
28 std::unique_ptr<char, pdfium::FreeDeleter> GetFileContents(const char* filename,
29 size_t* retlen);
19 30
20 // Converts a FPDF_WIDESTRING to a std::wstring. 31 // Converts a FPDF_WIDESTRING to a std::wstring.
21 // Deals with differences between UTF16LE and wchar_t. 32 // Deals with differences between UTF16LE and wchar_t.
22 std::wstring GetPlatformWString(const FPDF_WIDESTRING wstr); 33 std::wstring GetPlatformWString(const FPDF_WIDESTRING wstr);
23 34
24 // Returns a newly mallocated FPDF_WIDESTRING (caller must free()). 35 // Returns a newly allocated FPDF_WIDESTRING.
25 // Deals with differences between UTF16LE and wchar_t. 36 // Deals with differences between UTF16LE and wchar_t.
26 FPDF_WIDESTRING GetFPDFWideString(const std::wstring& wstr); 37 std::unique_ptr<unsigned short, pdfium::FreeDeleter> GetFPDFWideString(
38 const std::wstring& wstr);
27 39
28 #ifdef PDF_ENABLE_V8 40 #ifdef PDF_ENABLE_V8
29 #ifdef V8_USE_EXTERNAL_STARTUP_DATA 41 #ifdef V8_USE_EXTERNAL_STARTUP_DATA
30 bool InitializeV8ForPDFium(const std::string& exe_path, 42 bool InitializeV8ForPDFium(const std::string& exe_path,
31 const std::string& bin_dir, 43 const std::string& bin_dir,
32 v8::StartupData* natives_blob, 44 v8::StartupData* natives_blob,
33 v8::StartupData* snapshot_blob, 45 v8::StartupData* snapshot_blob,
34 v8::Platform** platform); 46 v8::Platform** platform);
35 #else // V8_USE_EXTERNAL_STARTUP_DATA 47 #else // V8_USE_EXTERNAL_STARTUP_DATA
36 bool InitializeV8ForPDFium(v8::Platform** platform); 48 bool InitializeV8ForPDFium(v8::Platform** platform);
37 #endif // V8_USE_EXTERNAL_STARTUP_DATA 49 #endif // V8_USE_EXTERNAL_STARTUP_DATA
38 #endif // PDF_ENABLE_V8 50 #endif // PDF_ENABLE_V8
39 51
40 class TestLoader { 52 class TestLoader {
41 public: 53 public:
42 TestLoader(const char* pBuf, size_t len); 54 TestLoader(const char* pBuf, size_t len);
43 static int GetBlock(void* param, 55 static int GetBlock(void* param,
44 unsigned long pos, 56 unsigned long pos,
45 unsigned char* pBuf, 57 unsigned char* pBuf,
46 unsigned long size); 58 unsigned long size);
47 59
48 private: 60 private:
49 const char* const m_pBuf; 61 const char* const m_pBuf;
50 const size_t m_Len; 62 const size_t m_Len;
51 }; 63 };
52 64
53 #endif // TESTING_EMBEDDER_TEST_SUPPORT_H_ 65 #endif // TESTING_EMBEDDER_TEST_SUPPORT_H_
OLDNEW
« no previous file with comments | « testing/embedder_test.cpp ('k') | testing/test_support.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698