OLD | NEW |
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_formfillenvironment.h" | 7 #include "fpdfsdk/cpdfsdk_formfillenvironment.h" |
8 #include "fpdfsdk/fsdk_define.h" | 8 #include "fpdfsdk/fsdk_define.h" |
9 #include "testing/embedder_test.h" | 9 #include "testing/embedder_test.h" |
10 #include "testing/embedder_test_mock_delegate.h" | 10 #include "testing/embedder_test_mock_delegate.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 CFX_FloatRect LeftBottom(200, 200, 220, 220); | 37 CFX_FloatRect LeftBottom(200, 200, 220, 220); |
38 CFX_FloatRect RightBottom(400, 201, 420, 221); | 38 CFX_FloatRect RightBottom(400, 201, 420, 221); |
39 CFX_FloatRect LeftTop(201, 400, 221, 420); | 39 CFX_FloatRect LeftTop(201, 400, 221, 420); |
40 CFX_FloatRect RightTop(401, 401, 421, 421); | 40 CFX_FloatRect RightTop(401, 401, 421, 421); |
41 | 41 |
42 CPDFSDK_FormFillEnvironment* pFormFillEnv = | 42 CPDFSDK_FormFillEnvironment* pFormFillEnv = |
43 static_cast<CPDFSDK_FormFillEnvironment*>(form_handle()); | 43 static_cast<CPDFSDK_FormFillEnvironment*>(form_handle()); |
44 | 44 |
45 { | 45 { |
46 // Page 0 specifies "row order". | 46 // Page 0 specifies "row order". |
47 CBA_AnnotIterator iter(pFormFillEnv->GetSDKDocument()->GetPageView(0), | 47 CBA_AnnotIterator iter(pFormFillEnv->GetPageView(0), |
48 CPDF_Annot::Subtype::WIDGET); | 48 CPDF_Annot::Subtype::WIDGET); |
49 CPDFSDK_Annot* pAnnot = iter.GetFirstAnnot(); | 49 CPDFSDK_Annot* pAnnot = iter.GetFirstAnnot(); |
50 CheckRect(pAnnot->GetRect(), RightTop); | 50 CheckRect(pAnnot->GetRect(), RightTop); |
51 pAnnot = iter.GetNextAnnot(pAnnot); | 51 pAnnot = iter.GetNextAnnot(pAnnot); |
52 CheckRect(pAnnot->GetRect(), LeftTop); | 52 CheckRect(pAnnot->GetRect(), LeftTop); |
53 pAnnot = iter.GetNextAnnot(pAnnot); | 53 pAnnot = iter.GetNextAnnot(pAnnot); |
54 CheckRect(pAnnot->GetRect(), RightBottom); | 54 CheckRect(pAnnot->GetRect(), RightBottom); |
55 pAnnot = iter.GetNextAnnot(pAnnot); | 55 pAnnot = iter.GetNextAnnot(pAnnot); |
56 CheckRect(pAnnot->GetRect(), LeftBottom); | 56 CheckRect(pAnnot->GetRect(), LeftBottom); |
57 pAnnot = iter.GetNextAnnot(pAnnot); | 57 pAnnot = iter.GetNextAnnot(pAnnot); |
58 EXPECT_EQ(iter.GetFirstAnnot(), pAnnot); | 58 EXPECT_EQ(iter.GetFirstAnnot(), pAnnot); |
59 | 59 |
60 pAnnot = iter.GetLastAnnot(); | 60 pAnnot = iter.GetLastAnnot(); |
61 CheckRect(pAnnot->GetRect(), LeftBottom); | 61 CheckRect(pAnnot->GetRect(), LeftBottom); |
62 pAnnot = iter.GetPrevAnnot(pAnnot); | 62 pAnnot = iter.GetPrevAnnot(pAnnot); |
63 CheckRect(pAnnot->GetRect(), RightBottom); | 63 CheckRect(pAnnot->GetRect(), RightBottom); |
64 pAnnot = iter.GetPrevAnnot(pAnnot); | 64 pAnnot = iter.GetPrevAnnot(pAnnot); |
65 CheckRect(pAnnot->GetRect(), LeftTop); | 65 CheckRect(pAnnot->GetRect(), LeftTop); |
66 pAnnot = iter.GetPrevAnnot(pAnnot); | 66 pAnnot = iter.GetPrevAnnot(pAnnot); |
67 CheckRect(pAnnot->GetRect(), RightTop); | 67 CheckRect(pAnnot->GetRect(), RightTop); |
68 pAnnot = iter.GetPrevAnnot(pAnnot); | 68 pAnnot = iter.GetPrevAnnot(pAnnot); |
69 EXPECT_EQ(iter.GetLastAnnot(), pAnnot); | 69 EXPECT_EQ(iter.GetLastAnnot(), pAnnot); |
70 } | 70 } |
71 { | 71 { |
72 // Page 1 specifies "column order" | 72 // Page 1 specifies "column order" |
73 CBA_AnnotIterator iter(pFormFillEnv->GetSDKDocument()->GetPageView(1), | 73 CBA_AnnotIterator iter(pFormFillEnv->GetPageView(1), |
74 CPDF_Annot::Subtype::WIDGET); | 74 CPDF_Annot::Subtype::WIDGET); |
75 CPDFSDK_Annot* pAnnot = iter.GetFirstAnnot(); | 75 CPDFSDK_Annot* pAnnot = iter.GetFirstAnnot(); |
76 CheckRect(pAnnot->GetRect(), RightTop); | 76 CheckRect(pAnnot->GetRect(), RightTop); |
77 pAnnot = iter.GetNextAnnot(pAnnot); | 77 pAnnot = iter.GetNextAnnot(pAnnot); |
78 CheckRect(pAnnot->GetRect(), RightBottom); | 78 CheckRect(pAnnot->GetRect(), RightBottom); |
79 pAnnot = iter.GetNextAnnot(pAnnot); | 79 pAnnot = iter.GetNextAnnot(pAnnot); |
80 CheckRect(pAnnot->GetRect(), LeftTop); | 80 CheckRect(pAnnot->GetRect(), LeftTop); |
81 pAnnot = iter.GetNextAnnot(pAnnot); | 81 pAnnot = iter.GetNextAnnot(pAnnot); |
82 CheckRect(pAnnot->GetRect(), LeftBottom); | 82 CheckRect(pAnnot->GetRect(), LeftBottom); |
83 pAnnot = iter.GetNextAnnot(pAnnot); | 83 pAnnot = iter.GetNextAnnot(pAnnot); |
84 EXPECT_EQ(iter.GetFirstAnnot(), pAnnot); | 84 EXPECT_EQ(iter.GetFirstAnnot(), pAnnot); |
85 | 85 |
86 pAnnot = iter.GetLastAnnot(); | 86 pAnnot = iter.GetLastAnnot(); |
87 CheckRect(pAnnot->GetRect(), LeftBottom); | 87 CheckRect(pAnnot->GetRect(), LeftBottom); |
88 pAnnot = iter.GetPrevAnnot(pAnnot); | 88 pAnnot = iter.GetPrevAnnot(pAnnot); |
89 CheckRect(pAnnot->GetRect(), LeftTop); | 89 CheckRect(pAnnot->GetRect(), LeftTop); |
90 pAnnot = iter.GetPrevAnnot(pAnnot); | 90 pAnnot = iter.GetPrevAnnot(pAnnot); |
91 CheckRect(pAnnot->GetRect(), RightBottom); | 91 CheckRect(pAnnot->GetRect(), RightBottom); |
92 pAnnot = iter.GetPrevAnnot(pAnnot); | 92 pAnnot = iter.GetPrevAnnot(pAnnot); |
93 CheckRect(pAnnot->GetRect(), RightTop); | 93 CheckRect(pAnnot->GetRect(), RightTop); |
94 pAnnot = iter.GetPrevAnnot(pAnnot); | 94 pAnnot = iter.GetPrevAnnot(pAnnot); |
95 EXPECT_EQ(iter.GetLastAnnot(), pAnnot); | 95 EXPECT_EQ(iter.GetLastAnnot(), pAnnot); |
96 } | 96 } |
97 { | 97 { |
98 // Page 2 specifies "struct order" | 98 // Page 2 specifies "struct order" |
99 CBA_AnnotIterator iter(pFormFillEnv->GetSDKDocument()->GetPageView(2), | 99 CBA_AnnotIterator iter(pFormFillEnv->GetPageView(2), |
100 CPDF_Annot::Subtype::WIDGET); | 100 CPDF_Annot::Subtype::WIDGET); |
101 CPDFSDK_Annot* pAnnot = iter.GetFirstAnnot(); | 101 CPDFSDK_Annot* pAnnot = iter.GetFirstAnnot(); |
102 CheckRect(pAnnot->GetRect(), LeftBottom); | 102 CheckRect(pAnnot->GetRect(), LeftBottom); |
103 pAnnot = iter.GetNextAnnot(pAnnot); | 103 pAnnot = iter.GetNextAnnot(pAnnot); |
104 CheckRect(pAnnot->GetRect(), RightTop); | 104 CheckRect(pAnnot->GetRect(), RightTop); |
105 pAnnot = iter.GetNextAnnot(pAnnot); | 105 pAnnot = iter.GetNextAnnot(pAnnot); |
106 CheckRect(pAnnot->GetRect(), LeftTop); | 106 CheckRect(pAnnot->GetRect(), LeftTop); |
107 pAnnot = iter.GetNextAnnot(pAnnot); | 107 pAnnot = iter.GetNextAnnot(pAnnot); |
108 CheckRect(pAnnot->GetRect(), RightBottom); | 108 CheckRect(pAnnot->GetRect(), RightBottom); |
109 pAnnot = iter.GetNextAnnot(pAnnot); | 109 pAnnot = iter.GetNextAnnot(pAnnot); |
110 EXPECT_EQ(iter.GetFirstAnnot(), pAnnot); | 110 EXPECT_EQ(iter.GetFirstAnnot(), pAnnot); |
111 | 111 |
112 pAnnot = iter.GetLastAnnot(); | 112 pAnnot = iter.GetLastAnnot(); |
113 CheckRect(pAnnot->GetRect(), RightBottom); | 113 CheckRect(pAnnot->GetRect(), RightBottom); |
114 pAnnot = iter.GetPrevAnnot(pAnnot); | 114 pAnnot = iter.GetPrevAnnot(pAnnot); |
115 CheckRect(pAnnot->GetRect(), LeftTop); | 115 CheckRect(pAnnot->GetRect(), LeftTop); |
116 pAnnot = iter.GetPrevAnnot(pAnnot); | 116 pAnnot = iter.GetPrevAnnot(pAnnot); |
117 CheckRect(pAnnot->GetRect(), RightTop); | 117 CheckRect(pAnnot->GetRect(), RightTop); |
118 pAnnot = iter.GetPrevAnnot(pAnnot); | 118 pAnnot = iter.GetPrevAnnot(pAnnot); |
119 CheckRect(pAnnot->GetRect(), LeftBottom); | 119 CheckRect(pAnnot->GetRect(), LeftBottom); |
120 pAnnot = iter.GetPrevAnnot(pAnnot); | 120 pAnnot = iter.GetPrevAnnot(pAnnot); |
121 EXPECT_EQ(iter.GetLastAnnot(), pAnnot); | 121 EXPECT_EQ(iter.GetLastAnnot(), pAnnot); |
122 } | 122 } |
123 UnloadPage(page2); | 123 UnloadPage(page2); |
124 UnloadPage(page1); | 124 UnloadPage(page1); |
125 UnloadPage(page0); | 125 UnloadPage(page0); |
126 } | 126 } |
OLD | NEW |