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

Side by Side Diff: samples/pdfium_test.cc

Issue 2415663003: Reduce missing evt file spam in pdfium_test. (Closed)
Patch Set: R_OK Created 4 years, 2 months 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 | « no previous file | 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium 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 <limits.h> 5 #include <limits.h>
6 #include <stdio.h> 6 #include <stdio.h>
7 #include <stdlib.h> 7 #include <stdlib.h>
8 #include <string.h> 8 #include <string.h>
9 9
10 #include <map> 10 #include <map>
11 #include <sstream> 11 #include <sstream>
12 #include <string> 12 #include <string>
13 #include <utility> 13 #include <utility>
14 #include <vector> 14 #include <vector>
15 15
16 #if defined PDF_ENABLE_SKIA && !defined _SKIA_SUPPORT_ 16 #if defined PDF_ENABLE_SKIA && !defined _SKIA_SUPPORT_
17 #define _SKIA_SUPPORT_ 17 #define _SKIA_SUPPORT_
18 #endif 18 #endif
19 19
20 #include "public/fpdf_dataavail.h" 20 #include "public/fpdf_dataavail.h"
21 #include "public/fpdf_edit.h" 21 #include "public/fpdf_edit.h"
22 #include "public/fpdf_ext.h" 22 #include "public/fpdf_ext.h"
23 #include "public/fpdf_formfill.h" 23 #include "public/fpdf_formfill.h"
24 #include "public/fpdf_text.h" 24 #include "public/fpdf_text.h"
25 #include "public/fpdfview.h" 25 #include "public/fpdfview.h"
26 #include "samples/image_diff_png.h" 26 #include "samples/image_diff_png.h"
27 #include "testing/test_support.h" 27 #include "testing/test_support.h"
28 28
29 #ifdef _WIN32
30 #include <io.h>
31 #else
32 #include <unistd.h>
33 #endif
34
29 #ifdef PDF_ENABLE_V8 35 #ifdef PDF_ENABLE_V8
30 #include "v8/include/libplatform/libplatform.h" 36 #include "v8/include/libplatform/libplatform.h"
31 #include "v8/include/v8.h" 37 #include "v8/include/v8.h"
32 #endif // PDF_ENABLE_V8 38 #endif // PDF_ENABLE_V8
33 39
34 #ifdef _WIN32
35 #define snprintf _snprintf
36 #endif
37
38 #ifdef PDF_ENABLE_SKIA 40 #ifdef PDF_ENABLE_SKIA
39 #include "third_party/skia/include/core/SkPictureRecorder.h" 41 #include "third_party/skia/include/core/SkPictureRecorder.h"
40 #include "third_party/skia/include/core/SkStream.h" 42 #include "third_party/skia/include/core/SkStream.h"
41 #endif 43 #endif
42 44
45 #ifdef _WIN32
46 #define access _access
47 #define snprintf _snprintf
48 #define R_OK 4
49 #endif
50
43 enum OutputFormat { 51 enum OutputFormat {
44 OUTPUT_NONE, 52 OUTPUT_NONE,
45 OUTPUT_TEXT, 53 OUTPUT_TEXT,
46 OUTPUT_PPM, 54 OUTPUT_PPM,
47 OUTPUT_PNG, 55 OUTPUT_PNG,
48 #ifdef _WIN32 56 #ifdef _WIN32
49 OUTPUT_BMP, 57 OUTPUT_BMP,
50 OUTPUT_EMF, 58 OUTPUT_EMF,
51 #endif 59 #endif
52 #ifdef PDF_ENABLE_SKIA 60 #ifdef PDF_ENABLE_SKIA
(...skipping 845 matching lines...) Expand 10 before | Expand all | Expand 10 after
898 if (!file_contents) 906 if (!file_contents)
899 continue; 907 continue;
900 fprintf(stderr, "Rendering PDF file %s.\n", filename.c_str()); 908 fprintf(stderr, "Rendering PDF file %s.\n", filename.c_str());
901 std::string events; 909 std::string events;
902 if (options.send_events) { 910 if (options.send_events) {
903 std::string event_filename = filename; 911 std::string event_filename = filename;
904 size_t event_length = 0; 912 size_t event_length = 0;
905 size_t extension_pos = event_filename.find(".pdf"); 913 size_t extension_pos = event_filename.find(".pdf");
906 if (extension_pos != std::string::npos) { 914 if (extension_pos != std::string::npos) {
907 event_filename.replace(extension_pos, 4, ".evt"); 915 event_filename.replace(extension_pos, 4, ".evt");
908 std::unique_ptr<char, pdfium::FreeDeleter> event_contents = 916 if (access(event_filename.c_str(), R_OK) == 0) {
909 GetFileContents(event_filename.c_str(), &event_length); 917 fprintf(stderr, "Using event file %s.\n", event_filename.c_str());
910 if (event_contents) { 918 std::unique_ptr<char, pdfium::FreeDeleter> event_contents =
911 fprintf(stderr, "Sending events from: %s\n", event_filename.c_str()); 919 GetFileContents(event_filename.c_str(), &event_length);
912 events = std::string(event_contents.get(), event_length); 920 if (event_contents) {
921 fprintf(stderr, "Sending events from: %s\n",
922 event_filename.c_str());
923 events = std::string(event_contents.get(), event_length);
924 }
913 } 925 }
914 } 926 }
915 } 927 }
916 RenderPdf(filename, file_contents.get(), file_length, options, events); 928 RenderPdf(filename, file_contents.get(), file_length, options, events);
917 } 929 }
918 930
919 FPDF_DestroyLibrary(); 931 FPDF_DestroyLibrary();
920 #ifdef PDF_ENABLE_V8 932 #ifdef PDF_ENABLE_V8
921 v8::V8::ShutdownPlatform(); 933 v8::V8::ShutdownPlatform();
922 delete platform; 934 delete platform;
923 935
924 #ifdef V8_USE_EXTERNAL_STARTUP_DATA 936 #ifdef V8_USE_EXTERNAL_STARTUP_DATA
925 free(const_cast<char*>(natives.data)); 937 free(const_cast<char*>(natives.data));
926 free(const_cast<char*>(snapshot.data)); 938 free(const_cast<char*>(snapshot.data));
927 #endif // V8_USE_EXTERNAL_STARTUP_DATA 939 #endif // V8_USE_EXTERNAL_STARTUP_DATA
928 #endif // PDF_ENABLE_V8 940 #endif // PDF_ENABLE_V8
929 941
930 return 0; 942 return 0;
931 } 943 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698