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

Side by Side Diff: testing/embedder_test.h

Issue 2258333002: Fix page leaks in an embedder test (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: new approach Created 4 years, 3 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 | « fpdfsdk/fsdk_baseform_embeddertest.cpp ('k') | testing/embedder_test.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 PDFium Authors. All rights reserved. 1 // Copyright 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 #ifndef TESTING_EMBEDDER_TEST_H_ 5 #ifndef TESTING_EMBEDDER_TEST_H_
6 #define TESTING_EMBEDDER_TEST_H_ 6 #define TESTING_EMBEDDER_TEST_H_
7 7
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 return 0; 44 return 0;
45 } 45 }
46 46
47 // Equivalent to FPDF_FORMFILLINFO::FFI_SetTimer(). 47 // Equivalent to FPDF_FORMFILLINFO::FFI_SetTimer().
48 virtual int SetTimer(int msecs, TimerCallback fn) { return 0; } 48 virtual int SetTimer(int msecs, TimerCallback fn) { return 0; }
49 49
50 // Equivalent to FPDF_FORMFILLINFO::FFI_KillTimer(). 50 // Equivalent to FPDF_FORMFILLINFO::FFI_KillTimer().
51 virtual void KillTimer(int id) {} 51 virtual void KillTimer(int id) {}
52 52
53 // Equivalent to FPDF_FORMFILLINFO::FFI_GetPage(). 53 // Equivalent to FPDF_FORMFILLINFO::FFI_GetPage().
54 virtual FPDF_PAGE GetPage(FPDF_FORMHANDLE form_handle, 54 virtual FPDF_PAGE GetPage(FPDF_FORMFILLINFO* info,
55 FPDF_DOCUMENT document, 55 FPDF_DOCUMENT document,
56 int page_index); 56 int page_index);
57
58 private:
59 std::map<int, FPDF_PAGE> m_pageMap;
60 }; 57 };
61 58
62 EmbedderTest(); 59 EmbedderTest();
63 virtual ~EmbedderTest(); 60 virtual ~EmbedderTest();
64 61
65 void SetUp() override; 62 void SetUp() override;
66 void TearDown() override; 63 void TearDown() override;
67 64
68 #ifdef PDF_ENABLE_V8 65 #ifdef PDF_ENABLE_V8
69 // Call before SetUp to pass shared isolate, otherwise PDFium creates one. 66 // Call before SetUp to pass shared isolate, otherwise PDFium creates one.
(...skipping 24 matching lines...) Expand all
94 // Perform JavaScript actions that are to run at document open time. 91 // Perform JavaScript actions that are to run at document open time.
95 virtual void DoOpenActions(); 92 virtual void DoOpenActions();
96 93
97 // Determine the page numbers present in the document. 94 // Determine the page numbers present in the document.
98 virtual int GetFirstPageNum(); 95 virtual int GetFirstPageNum();
99 virtual int GetPageCount(); 96 virtual int GetPageCount();
100 97
101 // Load a specific page of the open document. 98 // Load a specific page of the open document.
102 virtual FPDF_PAGE LoadPage(int page_number); 99 virtual FPDF_PAGE LoadPage(int page_number);
103 100
104 // Load a specific page of the open document using delegate_->GetPage.
105 // delegate_->GetPage also caches loaded page.
106 virtual FPDF_PAGE LoadAndCachePage(int page_number);
107
108 // Convert a loaded page into a bitmap. 101 // Convert a loaded page into a bitmap.
109 virtual FPDF_BITMAP RenderPage(FPDF_PAGE page); 102 virtual FPDF_BITMAP RenderPage(FPDF_PAGE page);
110 103
111 // Relese the resources obtained from LoadPage(). Further use of |page| 104 // Relese the resources obtained from LoadPage(). Further use of |page|
112 // is prohibited after this call is made. 105 // is prohibited after this call is made.
113 virtual void UnloadPage(FPDF_PAGE page); 106 virtual void UnloadPage(FPDF_PAGE page);
114 107
115 protected: 108 protected:
116 void SetupFormFillEnvironment(); 109 void SetupFormFillEnvironment();
117 110
118 Delegate* delegate_; 111 Delegate* delegate_;
119 std::unique_ptr<Delegate> default_delegate_; 112 std::unique_ptr<Delegate> default_delegate_;
120 FPDF_DOCUMENT document_; 113 FPDF_DOCUMENT document_;
121 FPDF_FORMHANDLE form_handle_; 114 FPDF_FORMHANDLE form_handle_;
122 FPDF_AVAIL avail_; 115 FPDF_AVAIL avail_;
123 FX_DOWNLOADHINTS hints_; 116 FX_DOWNLOADHINTS hints_;
124 FPDF_FILEACCESS file_access_; 117 FPDF_FILEACCESS file_access_;
125 FX_FILEAVAIL file_avail_; 118 FX_FILEAVAIL file_avail_;
126 #ifdef PDF_ENABLE_V8 119 #ifdef PDF_ENABLE_V8
127 v8::Platform* platform_; 120 v8::Platform* platform_;
128 #endif // PDF_ENABLE_V8 121 #endif // PDF_ENABLE_V8
129 void* external_isolate_; 122 void* external_isolate_;
130 TestLoader* loader_; 123 TestLoader* loader_;
131 size_t file_length_; 124 size_t file_length_;
132 std::unique_ptr<char, pdfium::FreeDeleter> file_contents_; 125 std::unique_ptr<char, pdfium::FreeDeleter> file_contents_;
126 std::map<int, FPDF_PAGE> page_map_;
133 127
134 private: 128 private:
135 static void UnsupportedHandlerTrampoline(UNSUPPORT_INFO*, int type); 129 static void UnsupportedHandlerTrampoline(UNSUPPORT_INFO*, int type);
136 static int AlertTrampoline(IPDF_JSPLATFORM* plaform, 130 static int AlertTrampoline(IPDF_JSPLATFORM* plaform,
137 FPDF_WIDESTRING message, 131 FPDF_WIDESTRING message,
138 FPDF_WIDESTRING title, 132 FPDF_WIDESTRING title,
139 int type, 133 int type,
140 int icon); 134 int icon);
141 static int SetTimerTrampoline(FPDF_FORMFILLINFO* info, 135 static int SetTimerTrampoline(FPDF_FORMFILLINFO* info,
142 int msecs, 136 int msecs,
143 TimerCallback fn); 137 TimerCallback fn);
144 static void KillTimerTrampoline(FPDF_FORMFILLINFO* info, int id); 138 static void KillTimerTrampoline(FPDF_FORMFILLINFO* info, int id);
145 static FPDF_PAGE GetPageTrampoline(FPDF_FORMFILLINFO* info, 139 static FPDF_PAGE GetPageTrampoline(FPDF_FORMFILLINFO* info,
146 FPDF_DOCUMENT document, 140 FPDF_DOCUMENT document,
147 int page_index); 141 int page_index);
148 }; 142 };
149 143
150 #endif // TESTING_EMBEDDER_TEST_H_ 144 #endif // TESTING_EMBEDDER_TEST_H_
OLDNEW
« no previous file with comments | « fpdfsdk/fsdk_baseform_embeddertest.cpp ('k') | testing/embedder_test.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698