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

Side by Side Diff: testing/embedder_test.cpp

Issue 1408003014: Retrieve test data directory at run time (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: fix headers Created 5 years, 1 month 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
OLDNEW
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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 86
86 #ifdef PDF_ENABLE_V8 87 #ifdef PDF_ENABLE_V8
87 v8::V8::ShutdownPlatform(); 88 v8::V8::ShutdownPlatform();
88 delete platform_; 89 delete platform_;
89 #endif // PDF_ENABLE_V8 90 #endif // PDF_ENABLE_V8
90 91
91 delete loader_; 92 delete loader_;
92 free(file_contents_); 93 free(file_contents_);
93 } 94 }
94 95
95 bool EmbedderTest::OpenDocument(const std::string& filename, 96 bool EmbedderTest::OpenDocument(const std::string& filename,
Lei Zhang 2015/11/07 01:48:51 Can you update the comment in testing/embedder_tes
Wei Li 2015/11/07 02:36:12 Done.
96 bool must_linearize) { 97 bool must_linearize) {
97 file_contents_ = GetFileContents(filename.c_str(), &file_length_); 98 std::string file_path;
99 if (!PathService::GetTestFilePath(filename, &file_path))
100 return false;
101 file_contents_ = GetFileContents(file_path.c_str(), &file_length_);
98 if (!file_contents_) 102 if (!file_contents_)
99 return false; 103 return false;
100 104
101 loader_ = new TestLoader(file_contents_, file_length_); 105 loader_ = new TestLoader(file_contents_, file_length_);
102 file_access_.m_FileLen = static_cast<unsigned long>(file_length_); 106 file_access_.m_FileLen = static_cast<unsigned long>(file_length_);
103 file_access_.m_GetBlock = TestLoader::GetBlock; 107 file_access_.m_GetBlock = TestLoader::GetBlock;
104 file_access_.m_Param = loader_; 108 file_access_.m_Param = loader_;
105 109
106 file_avail_.version = 1; 110 file_avail_.version = 1;
107 file_avail_.IsDataAvail = Is_Data_Avail; 111 file_avail_.IsDataAvail = Is_Data_Avail;
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 } 283 }
280 284
281 // Can't use gtest-provided main since we need to stash the path to the 285 // Can't use gtest-provided main since we need to stash the path to the
282 // executable in order to find the external V8 binary data files. 286 // executable in order to find the external V8 binary data files.
283 int main(int argc, char** argv) { 287 int main(int argc, char** argv) {
284 g_exe_path_ = argv[0]; 288 g_exe_path_ = argv[0];
285 testing::InitGoogleTest(&argc, argv); 289 testing::InitGoogleTest(&argc, argv);
286 testing::InitGoogleMock(&argc, argv); 290 testing::InitGoogleMock(&argc, argv);
287 return RUN_ALL_TESTS(); 291 return RUN_ALL_TESTS();
288 } 292 }
OLDNEW
« no previous file with comments | « pdfium.gyp ('k') | testing/test_support.cpp » ('j') | testing/utils/path_service.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698