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

Side by Side Diff: testing/embedder_test.h

Issue 960663002: Implement a delegate for EmbedderTests. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Remove unused member Created 5 years, 10 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 | testing/embedder_test.cpp » ('j') | testing/embedder_test.cpp » ('J')
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 <string> 8 #include <string>
9 9
10 #include "../core/include/fxcrt/fx_system.h" 10 #include "../core/include/fxcrt/fx_system.h"
11 #include "../fpdfsdk/include/fpdf_dataavail.h" 11 #include "../fpdfsdk/include/fpdf_dataavail.h"
12 #include "../fpdfsdk/include/fpdf_ext.h"
12 #include "../fpdfsdk/include/fpdfformfill.h" 13 #include "../fpdfsdk/include/fpdfformfill.h"
13 #include "../fpdfsdk/include/fpdfview.h" 14 #include "../fpdfsdk/include/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;
18 19
19 // This class is used to load a PDF document, and then run programatic 20 // This class is used to load a PDF document, and then run programatic
20 // API tests against it. 21 // API tests against it.
21 class EmbedderTest : public ::testing::Test { 22 class EmbedderTest : public ::testing::Test,
23 public UNSUPPORT_INFO,
24 public IPDF_JSPLATFORM,
25 public FPDF_FORMFILLINFO {
22 public: 26 public:
23 EmbedderTest() : 27 class Delegate {
24 document_(nullptr), 28 public:
25 form_handle_(nullptr), 29 virtual ~Delegate() { }
26 avail_(nullptr), 30 virtual void UnsupportedHandler(int type) { }
Lei Zhang 2015/02/25 23:02:51 Can you document these methods?
Tom Sepez 2015/02/25 23:25:22 Done.
27 loader_(nullptr), 31 virtual int Alert(FPDF_WIDESTRING message, FPDF_WIDESTRING title,
28 file_length_(0), 32 int type, int icon) {
29 file_contents_(nullptr) { 33 return 0;
30 memset(&hints_, 0, sizeof(hints_)); 34 }
31 memset(&file_access_, 0, sizeof(file_access_)); 35 };
32 memset(&file_avail_, 0, sizeof(file_avail_));
33 }
34 36
35 virtual ~EmbedderTest() { } 37 EmbedderTest();
38 virtual ~EmbedderTest();
36 39
37 void SetUp() override; 40 void SetUp() override;
38 void TearDown() override; 41 void TearDown() override;
39 42
43 void SetDelegate(Delegate* delegate) { delegate_ = delegate; }
44
40 FPDF_DOCUMENT document() { return document_; } 45 FPDF_DOCUMENT document() { return document_; }
41 FPDF_FORMHANDLE form_handle() { return form_handle_; } 46 FPDF_FORMHANDLE form_handle() { return form_handle_; }
42 47
43 // Open the document specified by |filename|, and create its form fill 48 // Open the document specified by |filename|, and create its form fill
44 // environment, or return false on failure. 49 // environment, or return false on failure.
45 virtual bool OpenDocument(const std::string& filename); 50 virtual bool OpenDocument(const std::string& filename);
46 51
47 // Perform JavaScript actions that are to run at document open time. 52 // Perform JavaScript actions that are to run at document open time.
48 virtual void DoOpenActions(); 53 virtual void DoOpenActions();
49 54
50 // Determine the page numbers present in the document. 55 // Determine the page numbers present in the document.
51 virtual int GetFirstPageNum(); 56 virtual int GetFirstPageNum();
52 virtual int GetPageCount(); 57 virtual int GetPageCount();
53 58
54 // Load a specific page of the open document. 59 // Load a specific page of the open document.
55 virtual FPDF_PAGE LoadPage(int page_number); 60 virtual FPDF_PAGE LoadPage(int page_number);
56 61
57 // Convert a loaded page into a bitmap. 62 // Convert a loaded page into a bitmap.
58 virtual FPDF_BITMAP RenderPage(FPDF_PAGE page); 63 virtual FPDF_BITMAP RenderPage(FPDF_PAGE page);
59 64
60 // Relese the resources obtained from LoadPage(). Further use of |page| 65 // Relese the resources obtained from LoadPage(). Further use of |page|
61 // is prohibited after this call is made. 66 // is prohibited after this call is made.
62 virtual void UnloadPage(FPDF_PAGE page); 67 virtual void UnloadPage(FPDF_PAGE page);
63 68
64 protected: 69 protected:
70 Delegate* delegate_;
71 Delegate* original_delegate_;
Lei Zhang 2015/02/25 23:02:51 s/original/default/ ?
Tom Sepez 2015/02/25 23:25:22 Done.
65 FPDF_DOCUMENT document_; 72 FPDF_DOCUMENT document_;
66 FPDF_FORMHANDLE form_handle_; 73 FPDF_FORMHANDLE form_handle_;
67 FPDF_AVAIL avail_; 74 FPDF_AVAIL avail_;
68 FX_DOWNLOADHINTS hints_; 75 FX_DOWNLOADHINTS hints_;
69 FPDF_FILEACCESS file_access_; 76 FPDF_FILEACCESS file_access_;
70 FX_FILEAVAIL file_avail_; 77 FX_FILEAVAIL file_avail_;
71 v8::StartupData natives_; 78 v8::StartupData natives_;
72 v8::StartupData snapshot_; 79 v8::StartupData snapshot_;
73 TestLoader* loader_; 80 TestLoader* loader_;
74 size_t file_length_; 81 size_t file_length_;
75 char* file_contents_; 82 char* file_contents_;
83
84 private:
85 static void UnsupportedHandlerTrampoline(UNSUPPORT_INFO*, int type);
86 static int AlertTrampoline(IPDF_JSPLATFORM* plaform, FPDF_WIDESTRING message,
87 FPDF_WIDESTRING title, int type, int icon);
76 }; 88 };
77 89
78 #endif // TESTING_EMBEDDER_TEST_H_ 90 #endif // TESTING_EMBEDDER_TEST_H_
79 91
OLDNEW
« no previous file with comments | « no previous file | testing/embedder_test.cpp » ('j') | testing/embedder_test.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698