summaryrefslogtreecommitdiff
path: root/samples/pdfium_test.cc
AgeCommit message (Collapse)Author
2017-07-19Added testing flag --save-attachments that saves embedded attachmentsJane Liu
1. Added --save-attachments flag in pdfium_test to save embedded attachments using fpdf_attachment APIs. Bug=pdfium:174 Change-Id: I62f09aeb0ab1431f6e127da389518878a7214423 Reviewed-on: https://pdfium-review.googlesource.com/7990 Commit-Queue: Jane Liu <janeliulwq@google.com> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-07-18Make progressive renderer default for pdfium_test.Dan Sinclair
When Chrome renders PDF pages it uses the progressive renderer. The one shot renderer is used to render print preview pages. This CL changes pdfium_test to use the progressive renderer by default to better match Chrome. This also adds a --render-oneshot flag which will use the non-progressive renderer. Bug: chromium:736695 Change-Id: If79333ae10a0ed1c9bce1290caad8d531e6709aa Reviewed-on: https://pdfium-review.googlesource.com/8130 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-07-14Updated pdfium_test's WriteAnnot()Jane Liu
Updated pdfium_test's WriteAnnot() (corresponding to the --annot flag) to output more annotation info using the new APIs. Also fixed some nits in the annotation API code. Bug=pdfium:737 Change-Id: I3f40e83279ec82529f732eb94f309ab7d4992d3c Reviewed-on: https://pdfium-review.googlesource.com/7791 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Jane Liu <janeliulwq@google.com>
2017-07-13Added Callgrind instrumentation delimiters to pdfium_test.Henrique Nakashima
Change-Id: I664497b5bab640e642bde3f80aaeb62467237407 Reviewed-on: https://pdfium-review.googlesource.com/7281 Reviewed-by: dsinclair <dsinclair@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
2017-07-11Add Windows generic / text only printer driver support.rbpotter
BUG=chromium:734850 Change-Id: Icc0947e2e99e77a36d8963fcf0b6d3deea161d3e Reviewed-on: https://pdfium-review.googlesource.com/7194 Commit-Queue: Rebekah Potter <rbpotter@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2017-07-06Added APIs for getting/setting string pairs in annotation dictionariesJane Liu
1. Added APIs for getting/setting arbitary key + value string pairs in annotation dictionaries. * Added an embedder test testing all the new functions. Bug=pdfium:737 Change-Id: I93c9ca6fccf787028e106607ef8cf549ebca95d8 Reviewed-on: https://pdfium-review.googlesource.com/7150 Commit-Queue: Jane Liu <janeliulwq@google.com> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-06-27Changed the return type for annotation APIsJane Liu
Before: When returning FPDF_ANNOTATION, the APIs would take in a FPDF_ANNTOATION* and write the handle of the annotation to it, while returning a boolean as status. This CL: This CL changes the APIs to directly return FPDF_ANNOTATION, which would be null on failure. Also adds more null checks within the annotation APIs. Bug=pdfium:737 Change-Id: I4f77dd1b16d43eab3f16c303598b76591da0dcab Reviewed-on: https://pdfium-review.googlesource.com/6952 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Jane Liu <janeliulwq@google.com>
2017-06-22Move image_diff code into testing/image_diff/Lei Zhang
It is not actually a sample program to demonstrate how to use PDFium APIs. It is more of a test utility program. Remove header include dependency from samples/ to core/, to set a good example. Change-Id: Idd5d567c82314bcf0e4a7bec8a3210e7d57226ee Reviewed-on: https://pdfium-review.googlesource.com/6871 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2017-06-22Clean up includes in testing/test_support.hLei Zhang
Change-Id: Id558c36d10501ce488717045bbf00bfed32e4b92 Reviewed-on: https://pdfium-review.googlesource.com/6870 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-06-19Fixing metadata not read from linearized file.chromium/3136Henrique Nakashima
This still won't work if the info dict is not on the first page without first calling FPDFAvail_IsFormAvail or FPDFAvail_IsPageAvail, as these are the methods that trigger parsing the rest of the data. Bug: pdfium:664 Change-Id: I0b0193e415a1153dcfb8bfba0e0482da6b6ba53c Reviewed-on: https://pdfium-review.googlesource.com/6610 Commit-Queue: Henrique Nakashima <hnakashima@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org> Reviewed-by: Nicolás Peña <npm@chromium.org>
2017-06-19Consistently pass FPDF handles by value.Lei Zhang
Change-Id: I1b31217c756620873f59527768464aec02a82900 Reviewed-on: https://pdfium-review.googlesource.com/6677 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-06-01Basic APIs and tests for extracting annotationsJane Liu
1. Added API for extracting annotation properties: * Added testing flag "--annot" that outputs the annotation properties into a .txt file. * Added two embedder tests covering all the API functions. Bug=pdfium:737 Change-Id: I95943a9b2b3d5d431bc8a74a31b27b4f4b521026 Reviewed-on: https://pdfium-review.googlesource.com/6092 Commit-Queue: Jane Liu <janeliulwq@google.com> Reviewed-by: Lei Zhang <thestig@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-05-18Add pixel test for bug 113910Nicolas Pena
Bug: chromium:113910 Change-Id: I52d712828a0adde02b1e867421ee06f1ca8be1e2 Reviewed-on: https://pdfium-review.googlesource.com/5636 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Nicolás Peña <npm@chromium.org>
2017-05-08Add raw PostScript output to pdfium_test on Windows.Lei Zhang
Activated by --ps2 and --ps3 for PostScript level 2 and 3, respectively. The raw output is not formatted in a way for most PostScript processing tools to recognize as actually PostScript. Also fix the type of the parameter to FPDF_SetPrintPostscriptLevel() even though it ends up being a no-op. Change-Id: Iaa34fd3dfaedad2b016fefe1227cbed9c974ae2a Reviewed-on: https://pdfium-review.googlesource.com/4996 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-04-08Add title (/T) extraction for PDF tagged structureschromium/3067chromium/3066dan sinclair
This CL adds the ability to extract the title from a tagged structure element if one exists. Bug: pdfium:672 Change-Id: I22e2a8371db4f08b8a70dd77002f1befab97f530 Reviewed-on: https://pdfium-review.googlesource.com/3819 Reviewed-by: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-04-05Update to make show structure clearerDan Sinclair
Change-Id: I0b52246e72fb2243288e8edef361d47bc00b9469 Reviewed-on: https://pdfium-review.googlesource.com/3812 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-04-05Add option to pdfium_test to dump structure elementsDan Sinclair
This Cl adds a --show-structure to pdfium_test which will dump out the StructElement items for the selected pages. Bug: pdfium:672 Change-Id: I90aceda71c13c54abfe4ac242a62375643cdfd9d Reviewed-on: https://pdfium-review.googlesource.com/3750 Reviewed-by: Nicolás Peña <npm@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-03-16Introduce unique_ptr compatible deleters for FPDF typeschromium/3044Tom Sepez
Pre-requisite for easily fixing some leaks in sample code, fuzzers, etc. Kill off some types completely unused in the C API. Change-Id: I67f0a5c6eef63d8e062ca4bc97c9db03970fe337 Reviewed-on: https://pdfium-review.googlesource.com/3095 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2017-01-31Fixup test harnessdan sinclair
When the results of the test runner were converted to return a tuple the following code which checked the results for true/false were not updated to extract the success value from the tuple. This caused the code to think that the results always passed even when they failed. This CL fixes the two tests which were broken (both just minor image result differences) which slipped in during this breakage. Change-Id: I01b56dd7b05013c2c12c83543746cf59b145e561 Reviewed-on: https://pdfium-review.googlesource.com/2456 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-01-02Gold support in PDFiumchromium/2970stephana
Extends the PDFium tests to collect images and meta data to be uploaded to Gold. This feature is triggered by adding the --gold_* flags. It extends pdfium_test to output the MD5 hash of the underlying pixel buffer for each page it renders. That output is then processed by test_runner.py to generate the gold meta data. This behavior is modeled after the 'dm' tool in skia. See https://skia.googlesource.com/skia/+/master/dm/DM.cpp#1090 This should not cause any change in the current behavior of the tests, it will be trigger once we update the buildbot recipe. BUG=skia:5973 Review-Url: https://codereview.chromium.org/2578893004
2016-11-14Fix some nits in pdfium_testnpm
Fixed a couple of nits: - Renaming variables with correct format. - Add comments regarding the fact that pages are 0-based. Review-Url: https://codereview.chromium.org/2499143003
2016-11-14Add --pages option in pdfium_test so it renders only some of the pages.chromium/2920npm
The --pages option is set up to be 0-indexed. --pages=<number> will render the specific page. --pages=<number>-<number> will render the range of pages given. Review-Url: https://codereview.chromium.org/2495333002
2016-10-13Reduce missing evt file spam in pdfium_test.thestig
Review-Url: https://codereview.chromium.org/2415663003
2016-10-05Remove ownership of CPDFSDK_Document from CPDFXFA_Documentdsinclair
This CL updates CPDFXFA_Document so it never owns the CPDFSDK_Document. The CPDFSDK_Document is now always owned by the CPDFXFA_Environment. This also cleans up the strange need to reverse the order of document and form destruction when using XFA. Review-Url: https://codereview.chromium.org/2397473006
2016-09-28Fix leaks in pdfium_test.thestig
Review-Url: https://codereview.chromium.org/2375263002
2016-09-21Avoid static initializers and global variables in 'pdfium_test'.tonikitoo
This CL aims to follow up on thestig's past-land feedback receveid on https://codereview.chromium.org/2277063003/#msg15 . In order to avoid static initializers and global data declaration, CL adds a data struct named PDFiumTest_FPDF_FORMFILLINFO, which has FPDF_FORMFILLINFO as the first struct member definition. This allows the use of reinterpret_cast to/from PDFiumTest_FPDF_FORMFILLINFO and PDF_FORMFILLINFO. PDFiumTest_FPDF_FORMFILLINFO also two more struct members, 'loadedPages' and 'formHandle', which were previously global variables. Review-Url: https://codereview.chromium.org/2330043002
2016-09-09Define behaviors of FPDF_RenderPageBitmap_Retail and FPDF_FFLDraw.chromium/2858chromium/2857chromium/2856jaepark
Previously, PDFium only supported widget annotations to draw forms. As we've implemented other annotations, the behavior of FPDF_RenderPageBitmap_Retail and FPDF_FFLDraw changed. So, this CL clearly defines what needs to be done in FPDF_RenderPageBitmap_Retail and FPDF_FFLDraw. This CL first assumes that PDFium users will always call FPDF_RenderPageBitmap_Retail and FPDF_FFLDraw to render PDF pages, because otherwise they are not able to support PDF forms. FPDF_RenderPageBitmap_Retail should only deal with non-widget annotations, such as highlight, underline, text, etc. If FPDF_ANNOT flag is passed, non-widget annotations are drawn. Otherwise, they are hidden. FPDF_FFLDraw should only deal with annotations that requires user-interaction, such as widget annotations and popup annotation. Since popup annotation is associated with non-widget annotation, they should not be drawn if the associated annotation is hidden. Thus, if FPDF_ANNOT flag is passed, popup annotations are drawn. Otherwise, they are hidden. Widget annotations should be always drawn regardless of FPDF_ANNOT flag since they need to be always displayed for PDF forms. Also, roll DEPS for testing/corpus to 8485b30. BUG=pdfium:594 Review-Url: https://codereview.chromium.org/2323203002
2016-08-26Extend pdfium_test capability so that more Javascript can be executedchromium/2841tonikitoo
In [1], the lack of support of pdfium_test to some application level hooks was felt. More specifically, the lack of implementation of the hook FFI_GetPage, called when 'this.getAnnot()' is executed in an Acrobar JS context, makes it non-trivial to JS texts that manipulate PDF annotations. [1] https://codereview.chromium.org/2265313002/ Here is the failing call stack in pdfium_test: 0 ::RenderPdf (samples/pdfium_test.cc) 1 ::FORM_DoDocumentOpenAction (fpdfsdk/fpdfformfill.cpp) 2 CPDFSDK_Document::ProcOpenAction (fpdfsdk/fsdk_mgr.cpp) 3 CPDFSDK_ActionHandler::DoAction_DocOpen (fpdfsdk/fsdk_actionhandler.cpp) <----v8----> 4 Document::getAnnot (fpdfsdk/javascript/Document.cpp) 5 CPDFSDK_Document::GetPageView (fpdfsdk/fsdk_mgr.cpp) 6 CPDFDoc_Environment::FFI_GetPage (fpdfsdk/include/fsdk_mgr.h) (frame 6 returns nullptr, and getAnnot call in frame 4 bails) CL extends pdfium_test app with a FFI_GetPage hook implementation. Basically what FFI_GetPage does is returning a FPDF_PAGE instance. In case of pdfium_test, FPDF_PAGE instances were only created on demand when the page was going to get rendered, and then discarded. Since FFI_GetPage can be called by JS before pages are rendered, CL moved the page creation code into a helper function, and cached the FPDF_PAGE instances created in a map, so it does not recreate them needlessly. BUG=pdfium:492 Review-Url: https://codereview.chromium.org/2277063003
2016-07-15Clean up some nits in pdfium_test.cc.thestig
TBR=weili@chromium.org Review-Url: https://codereview.chromium.org/2149773003
2016-06-27Fix memory leaks with V8 startup data.thestig
Review-Url: https://codereview.chromium.org/2068563002
2016-06-16Add text dump to pdfium_test.dsinclair
This Cl adds a '--txt' flag to pdfium_test. When provided the text from the PDF will be extracted and written into page numbered text files. The files are written in UTF32-LE as that's what FPDFText_GetUnicode() provides. Review-Url: https://codereview.chromium.org/2060983005
2016-06-09Roll V8 and its deps and update ICU initialization callchromium/2764jochen
R=machenbach@chromium.org,thestig@chromium.org BUG= Review-Url: https://codereview.chromium.org/2053603002
2016-05-19Fix memory leaks in pdfium_test.thestig
BUG=603903 Review-Url: https://codereview.chromium.org/1994113002
2016-05-11fix skia buildcaryclark
Fix some bit rot with the Skia build; update the gypi to current and switch a deprecated call for the current one. R=tsepez@chromium.org Review-Url: https://codereview.chromium.org/1958263002
2016-05-04Fix event sending in pdfium_test.tsepez
Passing bad args in pdfium_test -- all void* pointers look alike. Make output less verbose while we're here. Turn on event sending mode for corups tests. No effect until .evt files added to corpus. Review-Url: https://codereview.chromium.org/1946873004
2016-04-18Allow pdfium_test to send simple events to each page.tsepez
We add the --send-events flag, which causes pdfium_test to look for a .evt file with the same base name as the .pdf file being rendered, and to use its contents to drive calls to FORM_* APIs. The .evt file syntax is crude, roughly: # comments keycode,65 mousedown,right,300,300 # more comments mouseup,right,300,300 mousemove,300,300 Review URL: https://codereview.chromium.org/1898993002
2016-03-14Add bitmaps and skp output to Skia portCary Clark
This is a first-cut at supporting bitmaps. Also added a --skp option to pdfium_test to generate a Skia picture file. The picture file can be loaded in Skia's SampleApp, debugger, or skiaserver to examine the generated picture. (This also includes fixes suggested in the prior Skia CL. My apologies for fat-fingers abandoning that one.) R=dsinclair@chromium.org, tsepez@chromium.org, dsinclair Review URL: https://codereview.chromium.org/1776313002 .
2016-03-01Fix and enable lint checks.Dan Sinclair
This CL fixes and enables: * readability/namespace * readability/multiline_string * readability/multiline_comment * readability/inheritance * readability/function * readability/braces R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1747123002 .
2016-02-24Fixing whitespace lint errors.Dan Sinclair
This CL enables several of the diabled whitelist/* lint checks. R=thestig@chromium.org, tsepez@chromium.org Review URL: https://codereview.chromium.org/1730553002 .
2016-02-17Expand all paths to be based off pdfium/ directoryDan Sinclair
This CL runs a script over the source and updates the include files to be a full path from the pdfium/ directory. BUG=pdfium:65 R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1707923002 .
2016-02-01Merge to XFA: Use JS_ExpandKeywordParams() in app.response()Tom Sepez
Original Review URL: https://codereview.chromium.org/1654523002 . (cherry picked from commit 3859258ebe9e81e1f766b57e7f78c786ae4ed495) TBR=thestig@chromium.org Review URL: https://codereview.chromium.org/1658753002 .
2016-01-29Merge to XFA: Fix botched "CC:" parameter passing in JS_DocmailForm().Tom Sepez
Original Review URL: https://codereview.chromium.org/1645413002 . (cherry picked from commit 6902db5cbaf0afb8f2cb4df325e1a4e7d6acd53f) TBR=thestig@chromium.org Review URL: https://codereview.chromium.org/1648793006 .
2016-01-29Merge to XFA: Fix behaviour of app.alert() with a single object argument.Tom Sepez
Original Review URL: https://codereview.chromium.org/1641693003 . (cherry picked from commit 66519af52b61ca158044651d0507d47efb364f87) TBR=thestig@chromium.org Review URL: https://codereview.chromium.org/1639253008 .
2016-01-15Merge to XFA: Make pdfium_test report build options.Tom Sepez
Review URL: https://codereview.chromium.org/1587023005 . (cherry picked from commit 041ed75701d1edc15923daf6080224a67b480869) TBR=thestig@chromium.org Review URL: https://codereview.chromium.org/1595763002 .
2016-01-06Merge to XFA: Return unique_ptrs from test_support functionsTom Sepez
Orignal Review URL: https://codereview.chromium.org/1563513002 . (cherry picked from commit aa326bd6b169dc1b5b9b83048c71799799ab34c6) TBR=thestig@chromium.org Review URL: https://codereview.chromium.org/1564583004 .
2016-01-05Merge to XFA: Make FPDF_WIDESTRING work regardless of endianness.Tom Sepez
Original Review URL: https://codereview.chromium.org/1554363002 . (cherry picked from commit ed34cdf99d5a4b33e57f81f9244a311f6fb86db3) TBR=thestig@chromium.org Review URL: https://codereview.chromium.org/1559373002 .
2015-12-31Merge to XFA: Reapply "Fix a partial rendering problem"Lei Zhang
This reverts commit 054fc955c153eb5c581fd14946848b8b2a77136a. Additionally, this rolls DEPS for the testing corpus to update test expectations. BUG=pdfium:336 TBR=jun_fang@foxitsoftware.com Review URL: https://codereview.chromium.org/1555833002 . (cherry picked from commit 5594538fcc96c38db34f336223140cf703e3cca0) Review URL: https://codereview.chromium.org/1553013002 .
2015-11-30Allow building non-XFA (master) on the XFA branch.Tom Sepez
This first pass is GYP-only, will do GN in the next CL. R=ochang@chromium.org Review URL: https://codereview.chromium.org/1480403002 .
2015-11-24Make xfa samples/ look more like masterTom Sepez
R=thestig@chromium.org Review URL: https://codereview.chromium.org/1476683002 .
2015-11-12Merge to XFA: Remove relative includes.Lei Zhang
That refer to parent directories. TBR=dsinclair@chromium.org Review URL: https://codereview.chromium.org/1434223002 . (cherry picked from commit 22bc4227fbbda5a5e9abad2a2c0a98c04fe7f228) Review URL: https://codereview.chromium.org/1439223003 .