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 #include "testing/embedder_test.h" | 5 #include "testing/embedder_test.h" |
6 | 6 |
7 #include <limits.h> | 7 #include <limits.h> |
8 | 8 |
9 #include <list> | 9 #include <list> |
10 #include <string> | 10 #include <string> |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 | 92 |
93 FPDFAvail_Destroy(avail_); | 93 FPDFAvail_Destroy(avail_); |
94 FPDF_DestroyLibrary(); | 94 FPDF_DestroyLibrary(); |
95 | 95 |
96 #ifdef PDF_ENABLE_V8 | 96 #ifdef PDF_ENABLE_V8 |
97 v8::V8::ShutdownPlatform(); | 97 v8::V8::ShutdownPlatform(); |
98 delete platform_; | 98 delete platform_; |
99 #endif // PDF_ENABLE_V8 | 99 #endif // PDF_ENABLE_V8 |
100 | 100 |
101 delete loader_; | 101 delete loader_; |
102 free(file_contents_); | |
103 } | 102 } |
104 | 103 |
105 bool EmbedderTest::CreateEmptyDocument() { | 104 bool EmbedderTest::CreateEmptyDocument() { |
106 document_ = FPDF_CreateNewDocument(); | 105 document_ = FPDF_CreateNewDocument(); |
107 if (!document_) | 106 if (!document_) |
108 return false; | 107 return false; |
109 | 108 |
110 SetupFormFillEnvironment(); | 109 SetupFormFillEnvironment(); |
111 return true; | 110 return true; |
112 } | 111 } |
113 | 112 |
114 bool EmbedderTest::OpenDocument(const std::string& filename, | 113 bool EmbedderTest::OpenDocument(const std::string& filename, |
115 bool must_linearize) { | 114 bool must_linearize) { |
116 std::string file_path; | 115 std::string file_path; |
117 if (!PathService::GetTestFilePath(filename, &file_path)) | 116 if (!PathService::GetTestFilePath(filename, &file_path)) |
118 return false; | 117 return false; |
119 file_contents_ = GetFileContents(file_path.c_str(), &file_length_); | 118 file_contents_ = GetFileContents(file_path.c_str(), &file_length_); |
120 if (!file_contents_) | 119 if (!file_contents_) |
121 return false; | 120 return false; |
122 | 121 |
123 loader_ = new TestLoader(file_contents_, file_length_); | 122 loader_ = new TestLoader(file_contents_.get(), file_length_); |
124 file_access_.m_FileLen = static_cast<unsigned long>(file_length_); | 123 file_access_.m_FileLen = static_cast<unsigned long>(file_length_); |
125 file_access_.m_GetBlock = TestLoader::GetBlock; | 124 file_access_.m_GetBlock = TestLoader::GetBlock; |
126 file_access_.m_Param = loader_; | 125 file_access_.m_Param = loader_; |
127 | 126 |
128 file_avail_.version = 1; | 127 file_avail_.version = 1; |
129 file_avail_.IsDataAvail = Is_Data_Avail; | 128 file_avail_.IsDataAvail = Is_Data_Avail; |
130 | 129 |
131 hints_.version = 1; | 130 hints_.version = 1; |
132 hints_.AddSegment = Add_Segment; | 131 hints_.AddSegment = Add_Segment; |
133 | 132 |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 } | 316 } |
318 | 317 |
319 // Can't use gtest-provided main since we need to stash the path to the | 318 // Can't use gtest-provided main since we need to stash the path to the |
320 // executable in order to find the external V8 binary data files. | 319 // executable in order to find the external V8 binary data files. |
321 int main(int argc, char** argv) { | 320 int main(int argc, char** argv) { |
322 g_exe_path_ = argv[0]; | 321 g_exe_path_ = argv[0]; |
323 testing::InitGoogleTest(&argc, argv); | 322 testing::InitGoogleTest(&argc, argv); |
324 testing::InitGoogleMock(&argc, argv); | 323 testing::InitGoogleMock(&argc, argv); |
325 return RUN_ALL_TESTS(); | 324 return RUN_ALL_TESTS(); |
326 } | 325 } |
OLD | NEW |