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

Side by Side Diff: testing/embedder_test.h

Issue 1332653002: Merge to XFA:Fix heap use after free in CPDFSDK_Annot::GetPDFAnnot. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Created 5 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/src/fsdk_mgr.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 (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 #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 <string> 9 #include <string>
9 10
10 #include "../public/fpdf_dataavail.h" 11 #include "../public/fpdf_dataavail.h"
11 #include "../public/fpdf_ext.h" 12 #include "../public/fpdf_ext.h"
12 #include "../public/fpdf_formfill.h" 13 #include "../public/fpdf_formfill.h"
13 #include "../public/fpdfview.h" 14 #include "../public/fpdfview.h"
14 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
15 #include "v8/include/v8.h" 16 #include "v8/include/v8.h"
16 17
17 class TestLoader; 18 class TestLoader;
(...skipping 18 matching lines...) Expand all
36 int type, 37 int type,
37 int icon) { 38 int icon) {
38 return 0; 39 return 0;
39 } 40 }
40 41
41 // Equivalent to FPDF_FORMFILLINFO::FFI_SetTimer(). 42 // Equivalent to FPDF_FORMFILLINFO::FFI_SetTimer().
42 virtual int SetTimer(int msecs, TimerCallback fn) { return 0; } 43 virtual int SetTimer(int msecs, TimerCallback fn) { return 0; }
43 44
44 // Equivalent to FPDF_FORMFILLINFO::FFI_KillTimer(). 45 // Equivalent to FPDF_FORMFILLINFO::FFI_KillTimer().
45 virtual void KillTimer(int id) {} 46 virtual void KillTimer(int id) {}
47
48 // Equivalent to FPDF_FORMFILLINFO::FFI_GetPage().
49 virtual FPDF_PAGE GetPage(FPDF_FORMHANDLE form_handle,
50 FPDF_DOCUMENT document,
51 int page_index);
52
53 private:
54 std::map<int, FPDF_PAGE> m_pageMap;
46 }; 55 };
47 56
48 EmbedderTest(); 57 EmbedderTest();
49 virtual ~EmbedderTest(); 58 virtual ~EmbedderTest();
50 59
51 void SetUp() override; 60 void SetUp() override;
52 void TearDown() override; 61 void TearDown() override;
53 62
54 void SetDelegate(Delegate* delegate) { 63 void SetDelegate(Delegate* delegate) {
55 delegate_ = delegate ? delegate : default_delegate_; 64 delegate_ = delegate ? delegate : default_delegate_;
56 } 65 }
57 66
58 FPDF_DOCUMENT document() { return document_; } 67 FPDF_DOCUMENT document() { return document_; }
59 FPDF_FORMHANDLE form_handle() { return form_handle_; } 68 FPDF_FORMHANDLE form_handle() { return form_handle_; }
60 69
61 // Open the document specified by |filename|, and create its form fill 70 // Open the document specified by |filename|, and create its form fill
62 // environment, or return false on failure. 71 // environment, or return false on failure.
63 virtual bool OpenDocument(const std::string& filename); 72 virtual bool OpenDocument(const std::string& filename);
64 73
65 // Perform JavaScript actions that are to run at document open time. 74 // Perform JavaScript actions that are to run at document open time.
66 virtual void DoOpenActions(); 75 virtual void DoOpenActions();
67 76
68 // Determine the page numbers present in the document. 77 // Determine the page numbers present in the document.
69 virtual int GetFirstPageNum(); 78 virtual int GetFirstPageNum();
70 virtual int GetPageCount(); 79 virtual int GetPageCount();
71 80
72 // Load a specific page of the open document. 81 // Load a specific page of the open document.
73 virtual FPDF_PAGE LoadPage(int page_number); 82 virtual FPDF_PAGE LoadPage(int page_number);
74 83
84 // Load a specific page of the open document using delegate_->GetPage.
85 // delegate_->GetPage also caches loaded page.
86 virtual FPDF_PAGE LoadAndCachePage(int page_number);
87
75 // Convert a loaded page into a bitmap. 88 // Convert a loaded page into a bitmap.
76 virtual FPDF_BITMAP RenderPage(FPDF_PAGE page); 89 virtual FPDF_BITMAP RenderPage(FPDF_PAGE page);
77 90
78 // Relese the resources obtained from LoadPage(). Further use of |page| 91 // Relese the resources obtained from LoadPage(). Further use of |page|
79 // is prohibited after this call is made. 92 // is prohibited after this call is made.
80 virtual void UnloadPage(FPDF_PAGE page); 93 virtual void UnloadPage(FPDF_PAGE page);
81 94
82 protected: 95 protected:
83 Delegate* delegate_; 96 Delegate* delegate_;
84 Delegate* default_delegate_; 97 Delegate* default_delegate_;
(...skipping 14 matching lines...) Expand all
99 static void UnsupportedHandlerTrampoline(UNSUPPORT_INFO*, int type); 112 static void UnsupportedHandlerTrampoline(UNSUPPORT_INFO*, int type);
100 static int AlertTrampoline(IPDF_JSPLATFORM* plaform, 113 static int AlertTrampoline(IPDF_JSPLATFORM* plaform,
101 FPDF_WIDESTRING message, 114 FPDF_WIDESTRING message,
102 FPDF_WIDESTRING title, 115 FPDF_WIDESTRING title,
103 int type, 116 int type,
104 int icon); 117 int icon);
105 static int SetTimerTrampoline(FPDF_FORMFILLINFO* info, 118 static int SetTimerTrampoline(FPDF_FORMFILLINFO* info,
106 int msecs, 119 int msecs,
107 TimerCallback fn); 120 TimerCallback fn);
108 static void KillTimerTrampoline(FPDF_FORMFILLINFO* info, int id); 121 static void KillTimerTrampoline(FPDF_FORMFILLINFO* info, int id);
122 static FPDF_PAGE GetPageTrampoline(FPDF_FORMFILLINFO* info,
123 FPDF_DOCUMENT document,
124 int page_index);
109 }; 125 };
110 126
111 #endif // TESTING_EMBEDDER_TEST_H_ 127 #endif // TESTING_EMBEDDER_TEST_H_
OLDNEW
« no previous file with comments | « fpdfsdk/src/fsdk_mgr.cpp ('k') | testing/embedder_test.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698