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

Side by Side Diff: fpdfsdk/fsdk_baseform_embeddertest.cpp

Issue 2398253002: Convert fpdfformfill to use CPDFSDK_FormFillEnvironment (Closed)
Patch Set: Rebase to master 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 | « fpdfsdk/fpdfformfill.cpp ('k') | 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 2016 PDFium Authors. All rights reserved. 1 // Copyright 2016 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 #include "fpdfsdk/cba_annotiterator.h" 5 #include "fpdfsdk/cba_annotiterator.h"
6 #include "fpdfsdk/cpdfsdk_annot.h" 6 #include "fpdfsdk/cpdfsdk_annot.h"
7 #include "fpdfsdk/cpdfsdk_document.h" 7 #include "fpdfsdk/cpdfsdk_document.h"
8 #include "fpdfsdk/cpdfsdk_formfillenvironment.h"
8 #include "fpdfsdk/fsdk_define.h" 9 #include "fpdfsdk/fsdk_define.h"
9 #include "testing/embedder_test.h" 10 #include "testing/embedder_test.h"
10 #include "testing/embedder_test_mock_delegate.h" 11 #include "testing/embedder_test_mock_delegate.h"
11 #include "testing/embedder_test_timer_handling_delegate.h" 12 #include "testing/embedder_test_timer_handling_delegate.h"
12 #include "testing/gmock/include/gmock/gmock.h" 13 #include "testing/gmock/include/gmock/gmock.h"
13 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
14 15
15 namespace { 16 namespace {
16 17
17 void CheckRect(const CFX_FloatRect& actual, const CFX_FloatRect& expected) { 18 void CheckRect(const CFX_FloatRect& actual, const CFX_FloatRect& expected) {
(...skipping 14 matching lines...) Expand all
32 FPDF_PAGE page2 = LoadPage(2); 33 FPDF_PAGE page2 = LoadPage(2);
33 EXPECT_TRUE(page0); 34 EXPECT_TRUE(page0);
34 EXPECT_TRUE(page1); 35 EXPECT_TRUE(page1);
35 EXPECT_TRUE(page2); 36 EXPECT_TRUE(page2);
36 37
37 CFX_FloatRect LeftBottom(200, 200, 220, 220); 38 CFX_FloatRect LeftBottom(200, 200, 220, 220);
38 CFX_FloatRect RightBottom(400, 201, 420, 221); 39 CFX_FloatRect RightBottom(400, 201, 420, 221);
39 CFX_FloatRect LeftTop(201, 400, 221, 420); 40 CFX_FloatRect LeftTop(201, 400, 221, 420);
40 CFX_FloatRect RightTop(401, 401, 421, 421); 41 CFX_FloatRect RightTop(401, 401, 421, 421);
41 42
42 CPDFSDK_Document* pSDKDoc = 43 CPDFSDK_FormFillEnvironment* pFormFillEnv =
43 CPDFSDK_Document::FromFPDFFormHandle(form_handle()); 44 static_cast<CPDFSDK_FormFillEnvironment*>(form_handle());
45
44 { 46 {
45 // Page 0 specifies "row order". 47 // Page 0 specifies "row order".
46 CBA_AnnotIterator iter(pSDKDoc->GetPageView(0), 48 CBA_AnnotIterator iter(pFormFillEnv->GetSDKDocument()->GetPageView(0),
47 CPDF_Annot::Subtype::WIDGET); 49 CPDF_Annot::Subtype::WIDGET);
48 CPDFSDK_Annot* pAnnot = iter.GetFirstAnnot(); 50 CPDFSDK_Annot* pAnnot = iter.GetFirstAnnot();
49 CheckRect(pAnnot->GetRect(), RightTop); 51 CheckRect(pAnnot->GetRect(), RightTop);
50 pAnnot = iter.GetNextAnnot(pAnnot); 52 pAnnot = iter.GetNextAnnot(pAnnot);
51 CheckRect(pAnnot->GetRect(), LeftTop); 53 CheckRect(pAnnot->GetRect(), LeftTop);
52 pAnnot = iter.GetNextAnnot(pAnnot); 54 pAnnot = iter.GetNextAnnot(pAnnot);
53 CheckRect(pAnnot->GetRect(), RightBottom); 55 CheckRect(pAnnot->GetRect(), RightBottom);
54 pAnnot = iter.GetNextAnnot(pAnnot); 56 pAnnot = iter.GetNextAnnot(pAnnot);
55 CheckRect(pAnnot->GetRect(), LeftBottom); 57 CheckRect(pAnnot->GetRect(), LeftBottom);
56 pAnnot = iter.GetNextAnnot(pAnnot); 58 pAnnot = iter.GetNextAnnot(pAnnot);
57 EXPECT_EQ(iter.GetFirstAnnot(), pAnnot); 59 EXPECT_EQ(iter.GetFirstAnnot(), pAnnot);
58 60
59 pAnnot = iter.GetLastAnnot(); 61 pAnnot = iter.GetLastAnnot();
60 CheckRect(pAnnot->GetRect(), LeftBottom); 62 CheckRect(pAnnot->GetRect(), LeftBottom);
61 pAnnot = iter.GetPrevAnnot(pAnnot); 63 pAnnot = iter.GetPrevAnnot(pAnnot);
62 CheckRect(pAnnot->GetRect(), RightBottom); 64 CheckRect(pAnnot->GetRect(), RightBottom);
63 pAnnot = iter.GetPrevAnnot(pAnnot); 65 pAnnot = iter.GetPrevAnnot(pAnnot);
64 CheckRect(pAnnot->GetRect(), LeftTop); 66 CheckRect(pAnnot->GetRect(), LeftTop);
65 pAnnot = iter.GetPrevAnnot(pAnnot); 67 pAnnot = iter.GetPrevAnnot(pAnnot);
66 CheckRect(pAnnot->GetRect(), RightTop); 68 CheckRect(pAnnot->GetRect(), RightTop);
67 pAnnot = iter.GetPrevAnnot(pAnnot); 69 pAnnot = iter.GetPrevAnnot(pAnnot);
68 EXPECT_EQ(iter.GetLastAnnot(), pAnnot); 70 EXPECT_EQ(iter.GetLastAnnot(), pAnnot);
69 } 71 }
70 { 72 {
71 // Page 1 specifies "column order" 73 // Page 1 specifies "column order"
72 CBA_AnnotIterator iter(pSDKDoc->GetPageView(1), 74 CBA_AnnotIterator iter(pFormFillEnv->GetSDKDocument()->GetPageView(1),
73 CPDF_Annot::Subtype::WIDGET); 75 CPDF_Annot::Subtype::WIDGET);
74 CPDFSDK_Annot* pAnnot = iter.GetFirstAnnot(); 76 CPDFSDK_Annot* pAnnot = iter.GetFirstAnnot();
75 CheckRect(pAnnot->GetRect(), RightTop); 77 CheckRect(pAnnot->GetRect(), RightTop);
76 pAnnot = iter.GetNextAnnot(pAnnot); 78 pAnnot = iter.GetNextAnnot(pAnnot);
77 CheckRect(pAnnot->GetRect(), RightBottom); 79 CheckRect(pAnnot->GetRect(), RightBottom);
78 pAnnot = iter.GetNextAnnot(pAnnot); 80 pAnnot = iter.GetNextAnnot(pAnnot);
79 CheckRect(pAnnot->GetRect(), LeftTop); 81 CheckRect(pAnnot->GetRect(), LeftTop);
80 pAnnot = iter.GetNextAnnot(pAnnot); 82 pAnnot = iter.GetNextAnnot(pAnnot);
81 CheckRect(pAnnot->GetRect(), LeftBottom); 83 CheckRect(pAnnot->GetRect(), LeftBottom);
82 pAnnot = iter.GetNextAnnot(pAnnot); 84 pAnnot = iter.GetNextAnnot(pAnnot);
83 EXPECT_EQ(iter.GetFirstAnnot(), pAnnot); 85 EXPECT_EQ(iter.GetFirstAnnot(), pAnnot);
84 86
85 pAnnot = iter.GetLastAnnot(); 87 pAnnot = iter.GetLastAnnot();
86 CheckRect(pAnnot->GetRect(), LeftBottom); 88 CheckRect(pAnnot->GetRect(), LeftBottom);
87 pAnnot = iter.GetPrevAnnot(pAnnot); 89 pAnnot = iter.GetPrevAnnot(pAnnot);
88 CheckRect(pAnnot->GetRect(), LeftTop); 90 CheckRect(pAnnot->GetRect(), LeftTop);
89 pAnnot = iter.GetPrevAnnot(pAnnot); 91 pAnnot = iter.GetPrevAnnot(pAnnot);
90 CheckRect(pAnnot->GetRect(), RightBottom); 92 CheckRect(pAnnot->GetRect(), RightBottom);
91 pAnnot = iter.GetPrevAnnot(pAnnot); 93 pAnnot = iter.GetPrevAnnot(pAnnot);
92 CheckRect(pAnnot->GetRect(), RightTop); 94 CheckRect(pAnnot->GetRect(), RightTop);
93 pAnnot = iter.GetPrevAnnot(pAnnot); 95 pAnnot = iter.GetPrevAnnot(pAnnot);
94 EXPECT_EQ(iter.GetLastAnnot(), pAnnot); 96 EXPECT_EQ(iter.GetLastAnnot(), pAnnot);
95 } 97 }
96 { 98 {
97 // Page 2 specifies "struct order" 99 // Page 2 specifies "struct order"
98 CBA_AnnotIterator iter(pSDKDoc->GetPageView(2), 100 CBA_AnnotIterator iter(pFormFillEnv->GetSDKDocument()->GetPageView(2),
99 CPDF_Annot::Subtype::WIDGET); 101 CPDF_Annot::Subtype::WIDGET);
100 CPDFSDK_Annot* pAnnot = iter.GetFirstAnnot(); 102 CPDFSDK_Annot* pAnnot = iter.GetFirstAnnot();
101 CheckRect(pAnnot->GetRect(), LeftBottom); 103 CheckRect(pAnnot->GetRect(), LeftBottom);
102 pAnnot = iter.GetNextAnnot(pAnnot); 104 pAnnot = iter.GetNextAnnot(pAnnot);
103 CheckRect(pAnnot->GetRect(), RightTop); 105 CheckRect(pAnnot->GetRect(), RightTop);
104 pAnnot = iter.GetNextAnnot(pAnnot); 106 pAnnot = iter.GetNextAnnot(pAnnot);
105 CheckRect(pAnnot->GetRect(), LeftTop); 107 CheckRect(pAnnot->GetRect(), LeftTop);
106 pAnnot = iter.GetNextAnnot(pAnnot); 108 pAnnot = iter.GetNextAnnot(pAnnot);
107 CheckRect(pAnnot->GetRect(), RightBottom); 109 CheckRect(pAnnot->GetRect(), RightBottom);
108 pAnnot = iter.GetNextAnnot(pAnnot); 110 pAnnot = iter.GetNextAnnot(pAnnot);
109 EXPECT_EQ(iter.GetFirstAnnot(), pAnnot); 111 EXPECT_EQ(iter.GetFirstAnnot(), pAnnot);
110 112
111 pAnnot = iter.GetLastAnnot(); 113 pAnnot = iter.GetLastAnnot();
112 CheckRect(pAnnot->GetRect(), RightBottom); 114 CheckRect(pAnnot->GetRect(), RightBottom);
113 pAnnot = iter.GetPrevAnnot(pAnnot); 115 pAnnot = iter.GetPrevAnnot(pAnnot);
114 CheckRect(pAnnot->GetRect(), LeftTop); 116 CheckRect(pAnnot->GetRect(), LeftTop);
115 pAnnot = iter.GetPrevAnnot(pAnnot); 117 pAnnot = iter.GetPrevAnnot(pAnnot);
116 CheckRect(pAnnot->GetRect(), RightTop); 118 CheckRect(pAnnot->GetRect(), RightTop);
117 pAnnot = iter.GetPrevAnnot(pAnnot); 119 pAnnot = iter.GetPrevAnnot(pAnnot);
118 CheckRect(pAnnot->GetRect(), LeftBottom); 120 CheckRect(pAnnot->GetRect(), LeftBottom);
119 pAnnot = iter.GetPrevAnnot(pAnnot); 121 pAnnot = iter.GetPrevAnnot(pAnnot);
120 EXPECT_EQ(iter.GetLastAnnot(), pAnnot); 122 EXPECT_EQ(iter.GetLastAnnot(), pAnnot);
121 } 123 }
122 UnloadPage(page2); 124 UnloadPage(page2);
123 UnloadPage(page1); 125 UnloadPage(page1);
124 UnloadPage(page0); 126 UnloadPage(page0);
125 } 127 }
OLDNEW
« no previous file with comments | « fpdfsdk/fpdfformfill.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698