| 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 } | 83 } |
| 84 FPDFAvail_Destroy(avail_); | 84 FPDFAvail_Destroy(avail_); |
| 85 FPDF_DestroyLibrary(); | 85 FPDF_DestroyLibrary(); |
| 86 | 86 |
| 87 #ifdef PDF_ENABLE_V8 | 87 #ifdef PDF_ENABLE_V8 |
| 88 v8::V8::ShutdownPlatform(); | 88 v8::V8::ShutdownPlatform(); |
| 89 delete platform_; | 89 delete platform_; |
| 90 #endif // PDF_ENABLE_V8 | 90 #endif // PDF_ENABLE_V8 |
| 91 | 91 |
| 92 delete loader_; | 92 delete loader_; |
| 93 free(file_contents_); | |
| 94 } | 93 } |
| 95 | 94 |
| 96 bool EmbedderTest::OpenDocument(const std::string& filename, | 95 bool EmbedderTest::OpenDocument(const std::string& filename, |
| 97 bool must_linearize) { | 96 bool must_linearize) { |
| 98 std::string file_path; | 97 std::string file_path; |
| 99 if (!PathService::GetTestFilePath(filename, &file_path)) | 98 if (!PathService::GetTestFilePath(filename, &file_path)) |
| 100 return false; | 99 return false; |
| 101 file_contents_ = GetFileContents(file_path.c_str(), &file_length_); | 100 file_contents_ = GetFileContents(file_path.c_str(), &file_length_); |
| 102 if (!file_contents_) | 101 if (!file_contents_) |
| 103 return false; | 102 return false; |
| 104 | 103 |
| 105 loader_ = new TestLoader(file_contents_, file_length_); | 104 loader_ = new TestLoader(file_contents_.get(), file_length_); |
| 106 file_access_.m_FileLen = static_cast<unsigned long>(file_length_); | 105 file_access_.m_FileLen = static_cast<unsigned long>(file_length_); |
| 107 file_access_.m_GetBlock = TestLoader::GetBlock; | 106 file_access_.m_GetBlock = TestLoader::GetBlock; |
| 108 file_access_.m_Param = loader_; | 107 file_access_.m_Param = loader_; |
| 109 | 108 |
| 110 file_avail_.version = 1; | 109 file_avail_.version = 1; |
| 111 file_avail_.IsDataAvail = Is_Data_Avail; | 110 file_avail_.IsDataAvail = Is_Data_Avail; |
| 112 | 111 |
| 113 hints_.version = 1; | 112 hints_.version = 1; |
| 114 hints_.AddSegment = Add_Segment; | 113 hints_.AddSegment = Add_Segment; |
| 115 | 114 |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 } | 284 } |
| 286 | 285 |
| 287 // Can't use gtest-provided main since we need to stash the path to the | 286 // Can't use gtest-provided main since we need to stash the path to the |
| 288 // executable in order to find the external V8 binary data files. | 287 // executable in order to find the external V8 binary data files. |
| 289 int main(int argc, char** argv) { | 288 int main(int argc, char** argv) { |
| 290 g_exe_path_ = argv[0]; | 289 g_exe_path_ = argv[0]; |
| 291 testing::InitGoogleTest(&argc, argv); | 290 testing::InitGoogleTest(&argc, argv); |
| 292 testing::InitGoogleMock(&argc, argv); | 291 testing::InitGoogleMock(&argc, argv); |
| 293 return RUN_ALL_TESTS(); | 292 return RUN_ALL_TESTS(); |
| 294 } | 293 } |
| OLD | NEW |