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

Side by Side Diff: testing/embedder_test.cpp

Issue 1480403002: Allow building non-XFA (master) on the XFA branch. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: warning Created 5 years 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 | « samples/samples.gyp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 UNSUPPORT_INFO* info = static_cast<UNSUPPORT_INFO*>(this); 70 UNSUPPORT_INFO* info = static_cast<UNSUPPORT_INFO*>(this);
71 memset(info, 0, sizeof(UNSUPPORT_INFO)); 71 memset(info, 0, sizeof(UNSUPPORT_INFO));
72 info->version = 1; 72 info->version = 1;
73 info->FSDK_UnSupport_Handler = UnsupportedHandlerTrampoline; 73 info->FSDK_UnSupport_Handler = UnsupportedHandlerTrampoline;
74 FSDK_SetUnSpObjProcessHandler(info); 74 FSDK_SetUnSpObjProcessHandler(info);
75 } 75 }
76 76
77 void EmbedderTest::TearDown() { 77 void EmbedderTest::TearDown() {
78 if (document_) { 78 if (document_) {
79 FORM_DoDocumentAAction(form_handle_, FPDFDOC_AACTION_WC); 79 FORM_DoDocumentAAction(form_handle_, FPDFDOC_AACTION_WC);
80 80 #ifdef PDF_ENABLE_XFA
81 // Note: The shut down order here is the reverse of the non-XFA branch 81 // Note: The shut down order here is the reverse of the non-XFA branch
82 // order. Need to work out if this is required, and if it is, the lifetimes 82 // order. Need to work out if this is required, and if it is, the lifetimes
83 // of objects owned by |doc| that |form| reference. 83 // of objects owned by |doc| that |form| reference.
84 FPDF_CloseDocument(document_); 84 FPDF_CloseDocument(document_);
85 FPDFDOC_ExitFormFillEnvironment(form_handle_); 85 FPDFDOC_ExitFormFillEnvironment(form_handle_);
86 #else // PDF_ENABLE_XFA
87 FPDFDOC_ExitFormFillEnvironment(form_handle_);
88 FPDF_CloseDocument(document_);
89 #endif // PDF_ENABLE_XFA
86 } 90 }
91
87 FPDFAvail_Destroy(avail_); 92 FPDFAvail_Destroy(avail_);
88 FPDF_DestroyLibrary(); 93 FPDF_DestroyLibrary();
89 94
90 #ifdef PDF_ENABLE_V8 95 #ifdef PDF_ENABLE_V8
91 v8::V8::ShutdownPlatform(); 96 v8::V8::ShutdownPlatform();
92 delete platform_; 97 delete platform_;
93 #endif // PDF_ENABLE_V8 98 #endif // PDF_ENABLE_V8
94 99
95 delete loader_; 100 delete loader_;
96 free(file_contents_); 101 free(file_contents_);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 } else { 152 } else {
148 if (must_linearize) { 153 if (must_linearize) {
149 return false; 154 return false;
150 } 155 }
151 document_ = FPDF_LoadCustomDocument(&file_access_, nullptr); 156 document_ = FPDF_LoadCustomDocument(&file_access_, nullptr);
152 if (!document_) { 157 if (!document_) {
153 return false; 158 return false;
154 } 159 }
155 } 160 }
156 161
162 #ifdef PDF_ENABLE_XFA
157 int docType = DOCTYPE_PDF; 163 int docType = DOCTYPE_PDF;
158 if (FPDF_HasXFAField(document_, &docType)) { 164 if (FPDF_HasXFAField(document_, &docType)) {
159 if (docType != DOCTYPE_PDF) 165 if (docType != DOCTYPE_PDF)
160 (void)FPDF_LoadXFA(document_); 166 (void)FPDF_LoadXFA(document_);
161 } 167 }
168 #endif // PDF_ENABLE_XFA
162 169
163 (void)FPDF_GetDocPermissions(document_); 170 (void)FPDF_GetDocPermissions(document_);
164 171
165 IPDF_JSPLATFORM* platform = static_cast<IPDF_JSPLATFORM*>(this); 172 IPDF_JSPLATFORM* platform = static_cast<IPDF_JSPLATFORM*>(this);
166 memset(platform, 0, sizeof(IPDF_JSPLATFORM)); 173 memset(platform, 0, sizeof(IPDF_JSPLATFORM));
167 platform->version = 2; 174 platform->version = 2;
168 platform->app_alert = AlertTrampoline; 175 platform->app_alert = AlertTrampoline;
169 176
170 FPDF_FORMFILLINFO* formfillinfo = static_cast<FPDF_FORMFILLINFO*>(this); 177 FPDF_FORMFILLINFO* formfillinfo = static_cast<FPDF_FORMFILLINFO*>(this);
171 memset(formfillinfo, 0, sizeof(FPDF_FORMFILLINFO)); 178 memset(formfillinfo, 0, sizeof(FPDF_FORMFILLINFO));
172 #ifdef PDF_ENABLE_XFA 179 #ifdef PDF_ENABLE_XFA
173 formfillinfo->version = 2; 180 formfillinfo->version = 2;
174 #else 181 #else // PDF_ENABLE_XFA
175 formfillinfo->version = 1; 182 formfillinfo->version = 1;
176 #endif 183 #endif // PDF_ENABLE_XFA
177 formfillinfo->FFI_SetTimer = SetTimerTrampoline; 184 formfillinfo->FFI_SetTimer = SetTimerTrampoline;
178 formfillinfo->FFI_KillTimer = KillTimerTrampoline; 185 formfillinfo->FFI_KillTimer = KillTimerTrampoline;
179 formfillinfo->FFI_GetPage = GetPageTrampoline; 186 formfillinfo->FFI_GetPage = GetPageTrampoline;
180 formfillinfo->m_pJsPlatform = platform; 187 formfillinfo->m_pJsPlatform = platform;
181 188
182 form_handle_ = FPDFDOC_InitFormFillEnvironment(document_, formfillinfo); 189 form_handle_ = FPDFDOC_InitFormFillEnvironment(document_, formfillinfo);
183 FPDF_SetFormFieldHighlightColor(form_handle_, 0, 0xFFE4DD); 190 FPDF_SetFormFieldHighlightColor(form_handle_, 0, 0xFFE4DD);
184 FPDF_SetFormFieldHighlightAlpha(form_handle_, 100); 191 FPDF_SetFormFieldHighlightAlpha(form_handle_, 100);
185 192
186 return true; 193 return true;
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 } 303 }
297 304
298 // Can't use gtest-provided main since we need to stash the path to the 305 // Can't use gtest-provided main since we need to stash the path to the
299 // executable in order to find the external V8 binary data files. 306 // executable in order to find the external V8 binary data files.
300 int main(int argc, char** argv) { 307 int main(int argc, char** argv) {
301 g_exe_path_ = argv[0]; 308 g_exe_path_ = argv[0];
302 testing::InitGoogleTest(&argc, argv); 309 testing::InitGoogleTest(&argc, argv);
303 testing::InitGoogleMock(&argc, argv); 310 testing::InitGoogleMock(&argc, argv);
304 return RUN_ALL_TESTS(); 311 return RUN_ALL_TESTS();
305 } 312 }
OLDNEW
« no previous file with comments | « samples/samples.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698