| 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 "embedder_test.h" |
| 6 | 6 |
| 7 #include <limits.h> | 7 #include <limits.h> |
| 8 #include <stdio.h> | 8 #include <stdio.h> |
| 9 #include <stdlib.h> | 9 #include <stdlib.h> |
| 10 #include <string.h> | 10 #include <string.h> |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 UNSUPPORT_INFO unsuppored_info; | 188 UNSUPPORT_INFO unsuppored_info; |
| 189 memset(&unsuppored_info, '\0', sizeof(unsuppored_info)); | 189 memset(&unsuppored_info, '\0', sizeof(unsuppored_info)); |
| 190 unsuppored_info.version = 1; | 190 unsuppored_info.version = 1; |
| 191 unsuppored_info.FSDK_UnSupport_Handler = Unsupported_Handler; | 191 unsuppored_info.FSDK_UnSupport_Handler = Unsupported_Handler; |
| 192 FSDK_SetUnSpObjProcessHandler(&unsuppored_info); | 192 FSDK_SetUnSpObjProcessHandler(&unsuppored_info); |
| 193 } | 193 } |
| 194 | 194 |
| 195 void EmbedderTest::TearDown() { | 195 void EmbedderTest::TearDown() { |
| 196 FPDF_CloseDocument(document_); | 196 FPDF_CloseDocument(document_); |
| 197 FPDFAvail_Destroy(avail_); | 197 FPDFAvail_Destroy(avail_); |
| 198 if (loader_) { |
| 199 delete loader_; |
| 200 } |
| 198 if (file_contents_) { | 201 if (file_contents_) { |
| 199 free(file_contents_); | 202 free(file_contents_); |
| 200 } | 203 } |
| 201 } | 204 } |
| 202 | 205 |
| 203 bool EmbedderTest::OpenDocument(const std::string& filename) { | 206 bool EmbedderTest::OpenDocument(const std::string& filename) { |
| 204 file_contents_ = GetFileContents(filename.c_str(), &file_length_); | 207 file_contents_ = GetFileContents(filename.c_str(), &file_length_); |
| 205 if (!file_contents_) { | 208 if (!file_contents_) { |
| 206 return false; | 209 return false; |
| 207 } | 210 } |
| 208 | 211 |
| 209 TestLoader loader(file_contents_, file_length_); | 212 loader_ = new TestLoader(file_contents_, file_length_); |
| 210 | |
| 211 file_access_.m_FileLen = static_cast<unsigned long>(file_length_); | 213 file_access_.m_FileLen = static_cast<unsigned long>(file_length_); |
| 212 file_access_.m_GetBlock = Get_Block; | 214 file_access_.m_GetBlock = Get_Block; |
| 213 file_access_.m_Param = &loader; | 215 file_access_.m_Param = loader_; |
| 214 | 216 |
| 215 file_avail_.version = 1; | 217 file_avail_.version = 1; |
| 216 file_avail_.IsDataAvail = Is_Data_Avail; | 218 file_avail_.IsDataAvail = Is_Data_Avail; |
| 217 | 219 |
| 218 hints_.version = 1; | 220 hints_.version = 1; |
| 219 hints_.AddSegment = Add_Segment; | 221 hints_.AddSegment = Add_Segment; |
| 220 | 222 |
| 221 avail_ = FPDFAvail_Create(&file_avail_, &file_access_); | 223 avail_ = FPDFAvail_Create(&file_avail_, &file_access_); |
| 222 (void) FPDFAvail_IsDocAvail(avail_, &hints_); | 224 (void) FPDFAvail_IsDocAvail(avail_, &hints_); |
| 223 | 225 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 FPDF_RenderPageBitmap(bitmap, page, 0, 0, width, height, 0, 0); | 296 FPDF_RenderPageBitmap(bitmap, page, 0, 0, width, height, 0, 0); |
| 295 FPDF_FFLDraw(form, bitmap, page, 0, 0, width, height, 0, 0); | 297 FPDF_FFLDraw(form, bitmap, page, 0, 0, width, height, 0, 0); |
| 296 return bitmap; | 298 return bitmap; |
| 297 } | 299 } |
| 298 | 300 |
| 299 void EmbedderTest::UnloadPage(FPDF_PAGE page, FPDF_FORMHANDLE form) { | 301 void EmbedderTest::UnloadPage(FPDF_PAGE page, FPDF_FORMHANDLE form) { |
| 300 FORM_DoPageAAction(page, form, FPDFPAGE_AACTION_CLOSE); | 302 FORM_DoPageAAction(page, form, FPDFPAGE_AACTION_CLOSE); |
| 301 FORM_OnBeforeClosePage(page, form); | 303 FORM_OnBeforeClosePage(page, form); |
| 302 FPDF_ClosePage(page); | 304 FPDF_ClosePage(page); |
| 303 } | 305 } |
| OLD | NEW |