| OLD | NEW |
| 1 // Copyright (c) 2015 PDFium Authors. All rights reserved. | 1 // Copyright (c) 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 "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> |
| 11 #include <utility> | 11 #include <utility> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "public/fpdf_dataavail.h" | 14 #include "public/fpdf_dataavail.h" |
| 15 #include "public/fpdf_text.h" | 15 #include "public/fpdf_text.h" |
| 16 #include "public/fpdfview.h" | 16 #include "public/fpdfview.h" |
| 17 #include "test_support.h" | |
| 18 #include "testing/gmock/include/gmock/gmock.h" | 17 #include "testing/gmock/include/gmock/gmock.h" |
| 18 #include "testing/test_support.h" |
| 19 #include "testing/utils/path_service.h" |
| 19 | 20 |
| 20 #ifdef PDF_ENABLE_V8 | 21 #ifdef PDF_ENABLE_V8 |
| 21 #include "v8/include/v8.h" | 22 #include "v8/include/v8.h" |
| 22 #include "v8/include/v8-platform.h" | 23 #include "v8/include/v8-platform.h" |
| 23 #endif // PDF_ENABLE_V8 | 24 #endif // PDF_ENABLE_V8 |
| 24 | 25 |
| 25 namespace { | 26 namespace { |
| 26 const char* g_exe_path_ = nullptr; | 27 const char* g_exe_path_ = nullptr; |
| 27 } // namespace | 28 } // namespace |
| 28 | 29 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 #ifdef PDF_ENABLE_V8 | 91 #ifdef PDF_ENABLE_V8 |
| 91 v8::V8::ShutdownPlatform(); | 92 v8::V8::ShutdownPlatform(); |
| 92 delete platform_; | 93 delete platform_; |
| 93 #endif // PDF_ENABLE_V8 | 94 #endif // PDF_ENABLE_V8 |
| 94 | 95 |
| 95 delete loader_; | 96 delete loader_; |
| 96 free(file_contents_); | 97 free(file_contents_); |
| 97 } | 98 } |
| 98 | 99 |
| 99 bool EmbedderTest::OpenDocument(const std::string& filename) { | 100 bool EmbedderTest::OpenDocument(const std::string& filename) { |
| 100 file_contents_ = GetFileContents(filename.c_str(), &file_length_); | 101 std::string file_path; |
| 102 if (!PathService::GetTestFilePath(filename, &file_path)) |
| 103 return false; |
| 104 file_contents_ = GetFileContents(file_path.c_str(), &file_length_); |
| 101 if (!file_contents_) | 105 if (!file_contents_) |
| 102 return false; | 106 return false; |
| 103 | 107 |
| 104 loader_ = new TestLoader(file_contents_, file_length_); | 108 loader_ = new TestLoader(file_contents_, file_length_); |
| 105 file_access_.m_FileLen = static_cast<unsigned long>(file_length_); | 109 file_access_.m_FileLen = static_cast<unsigned long>(file_length_); |
| 106 file_access_.m_GetBlock = TestLoader::GetBlock; | 110 file_access_.m_GetBlock = TestLoader::GetBlock; |
| 107 file_access_.m_Param = loader_; | 111 file_access_.m_Param = loader_; |
| 108 | 112 |
| 109 file_avail_.version = 1; | 113 file_avail_.version = 1; |
| 110 file_avail_.IsDataAvail = Is_Data_Avail; | 114 file_avail_.IsDataAvail = Is_Data_Avail; |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 } | 270 } |
| 267 | 271 |
| 268 // Can't use gtest-provided main since we need to stash the path to the | 272 // Can't use gtest-provided main since we need to stash the path to the |
| 269 // executable in order to find the external V8 binary data files. | 273 // executable in order to find the external V8 binary data files. |
| 270 int main(int argc, char** argv) { | 274 int main(int argc, char** argv) { |
| 271 g_exe_path_ = argv[0]; | 275 g_exe_path_ = argv[0]; |
| 272 testing::InitGoogleTest(&argc, argv); | 276 testing::InitGoogleTest(&argc, argv); |
| 273 testing::InitGoogleMock(&argc, argv); | 277 testing::InitGoogleMock(&argc, argv); |
| 274 return RUN_ALL_TESTS(); | 278 return RUN_ALL_TESTS(); |
| 275 } | 279 } |
| OLD | NEW |