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

Side by Side Diff: testing/embedder_test.h

Issue 827733006: Create first pdfium embedder test. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Tidy. Created 5 years, 11 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 | « testing/basic_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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef TESTING_EMBEDDER_TEST_H_
6 #define TESTING_EMBEDDER_TEST_H_
7
8 #include <string>
9
10 #include "../core/include/fxcrt/fx_system.h"
11 #include "../fpdfsdk/include/fpdf_dataavail.h"
12 #include "../fpdfsdk/include/fpdfformfill.h"
13 #include "../fpdfsdk/include/fpdfview.h"
14 #include "testing/gtest/include/gtest/gtest.h"
15 #include "v8/include/v8.h"
16
17 // This class is used to load a PDF document, and then run programatic
18 // API tests against it.
19 class EmbedderTest : public ::testing::Test {
20 public:
21 EmbedderTest() :
22 document_(nullptr),
23 avail_(nullptr),
24 file_length_(0),
25 file_contents_(nullptr) {
26 memset(&hints_, 0, sizeof(hints_));
27 memset(&file_access_, 0, sizeof(file_access_));
28 memset(&file_avail_, 0, sizeof(file_avail_));
29 }
30
31 virtual ~EmbedderTest() { }
32
33 void SetUp() override;
34 void TearDown() override;
35
36 FPDF_DOCUMENT document() { return document_; }
37
38 // Open the document specified by |filename|, or return false on failure.
39 virtual bool OpenDocument(const std::string& filename);
40
41 // Create and return a handle to the form fill module for use with the
42 // FORM_ family of functions from fpdfformfill.h, or return NULL on failure.
43 virtual FPDF_FORMHANDLE SetFormFillEnvironment();
44
45 // Release the resources obtained from SetFormFillEnvironment().
46 virtual void ClearFormFillEnvironment(FPDF_FORMHANDLE form);
47
48 // Perform JavaScript actions that are to run at document open time.
49 virtual void DoOpenActions(FPDF_FORMHANDLE form);
50
51 // Determine the page numbers present in the document.
52 virtual int GetFirstPageNum();
53 virtual int GetPageCount();
54
55 // Load a specific page of the open document.
56 virtual FPDF_PAGE LoadPage(int page_number, FPDF_FORMHANDLE form);
57
58 // Convert a loaded page into a bitmap.
59 virtual FPDF_BITMAP RenderPage(FPDF_PAGE page, FPDF_FORMHANDLE form);
60
61 // Relese the resources obtained from LoadPage(). Further use of |page|
62 // is prohibited after this call is made.
63 virtual void UnloadPage(FPDF_PAGE page, FPDF_FORMHANDLE form);
64
65 private:
66 FPDF_DOCUMENT document_;
67 FPDF_AVAIL avail_;
68 FX_DOWNLOADHINTS hints_;
69 FPDF_FILEACCESS file_access_;
70 FX_FILEAVAIL file_avail_;
71 v8::StartupData natives_;
72 v8::StartupData snapshot_;
73 size_t file_length_;
74 char* file_contents_;
75 };
76
77 #endif // TESTING_EMBEDDER_TEST_H_
78
OLDNEW
« no previous file with comments | « testing/basic_embeddertest.cpp ('k') | testing/embedder_test.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698