OLD | NEW |
| (Empty) |
1 // Copyright 2016 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 #include "fpdfsdk/include/fsdk_baseform.h" | |
6 #include "fpdfsdk/include/fsdk_define.h" | |
7 #include "fpdfsdk/include/fsdk_mgr.h" | |
8 #include "testing/embedder_test.h" | |
9 #include "testing/embedder_test_mock_delegate.h" | |
10 #include "testing/embedder_test_timer_handling_delegate.h" | |
11 #include "testing/gmock/include/gmock/gmock.h" | |
12 #include "testing/gtest/include/gtest/gtest.h" | |
13 | |
14 namespace { | |
15 | |
16 void CheckRect(const CFX_FloatRect& actual, const CFX_FloatRect& expected) { | |
17 EXPECT_EQ(expected.left, actual.left); | |
18 EXPECT_EQ(expected.bottom, actual.bottom); | |
19 EXPECT_EQ(expected.right, actual.right); | |
20 EXPECT_EQ(expected.top, actual.top); | |
21 } | |
22 | |
23 } // namespace | |
24 | |
25 class FSDKBaseFormEmbeddertest : public EmbedderTest {}; | |
26 | |
27 TEST_F(FSDKBaseFormEmbeddertest, CBA_AnnotIterator) { | |
28 EXPECT_TRUE(OpenDocument("annotiter.pdf")); | |
29 EXPECT_TRUE(LoadPage(0)); | |
30 EXPECT_TRUE(LoadPage(1)); | |
31 EXPECT_TRUE(LoadPage(2)); | |
32 | |
33 CFX_FloatRect LeftBottom(200, 200, 220, 220); | |
34 CFX_FloatRect RightBottom(400, 201, 420, 221); | |
35 CFX_FloatRect LeftTop(201, 400, 221, 420); | |
36 CFX_FloatRect RightTop(401, 401, 421, 421); | |
37 | |
38 CPDFSDK_Document* pSDKDoc = | |
39 CPDFSDK_Document::FromFPDFFormHandle(form_handle()); | |
40 { | |
41 // Page 0 specifies "row order". | |
42 CBA_AnnotIterator iter(pSDKDoc->GetPageView(0), "Widget", ""); | |
43 CPDFSDK_Annot* pAnnot = iter.GetFirstAnnot(); | |
44 CheckRect(pAnnot->GetRect(), RightTop); | |
45 pAnnot = iter.GetNextAnnot(pAnnot); | |
46 CheckRect(pAnnot->GetRect(), LeftTop); | |
47 pAnnot = iter.GetNextAnnot(pAnnot); | |
48 CheckRect(pAnnot->GetRect(), RightBottom); | |
49 pAnnot = iter.GetNextAnnot(pAnnot); | |
50 CheckRect(pAnnot->GetRect(), LeftBottom); | |
51 pAnnot = iter.GetNextAnnot(pAnnot); | |
52 EXPECT_EQ(iter.GetFirstAnnot(), pAnnot); | |
53 | |
54 pAnnot = iter.GetLastAnnot(); | |
55 CheckRect(pAnnot->GetRect(), LeftBottom); | |
56 pAnnot = iter.GetPrevAnnot(pAnnot); | |
57 CheckRect(pAnnot->GetRect(), RightBottom); | |
58 pAnnot = iter.GetPrevAnnot(pAnnot); | |
59 CheckRect(pAnnot->GetRect(), LeftTop); | |
60 pAnnot = iter.GetPrevAnnot(pAnnot); | |
61 CheckRect(pAnnot->GetRect(), RightTop); | |
62 pAnnot = iter.GetPrevAnnot(pAnnot); | |
63 EXPECT_EQ(iter.GetLastAnnot(), pAnnot); | |
64 } | |
65 { | |
66 // Page 1 specifies "column order" | |
67 CBA_AnnotIterator iter(pSDKDoc->GetPageView(1), "Widget", ""); | |
68 CPDFSDK_Annot* pAnnot = iter.GetFirstAnnot(); | |
69 CheckRect(pAnnot->GetRect(), RightTop); | |
70 pAnnot = iter.GetNextAnnot(pAnnot); | |
71 CheckRect(pAnnot->GetRect(), RightBottom); | |
72 pAnnot = iter.GetNextAnnot(pAnnot); | |
73 CheckRect(pAnnot->GetRect(), LeftTop); | |
74 pAnnot = iter.GetNextAnnot(pAnnot); | |
75 CheckRect(pAnnot->GetRect(), LeftBottom); | |
76 pAnnot = iter.GetNextAnnot(pAnnot); | |
77 EXPECT_EQ(iter.GetFirstAnnot(), pAnnot); | |
78 | |
79 pAnnot = iter.GetLastAnnot(); | |
80 CheckRect(pAnnot->GetRect(), LeftBottom); | |
81 pAnnot = iter.GetPrevAnnot(pAnnot); | |
82 CheckRect(pAnnot->GetRect(), LeftTop); | |
83 pAnnot = iter.GetPrevAnnot(pAnnot); | |
84 CheckRect(pAnnot->GetRect(), RightBottom); | |
85 pAnnot = iter.GetPrevAnnot(pAnnot); | |
86 CheckRect(pAnnot->GetRect(), RightTop); | |
87 pAnnot = iter.GetPrevAnnot(pAnnot); | |
88 EXPECT_EQ(iter.GetLastAnnot(), pAnnot); | |
89 } | |
90 { | |
91 // Page 2 specifies "struct order" | |
92 CBA_AnnotIterator iter(pSDKDoc->GetPageView(2), "Widget", ""); | |
93 CPDFSDK_Annot* pAnnot = iter.GetFirstAnnot(); | |
94 CheckRect(pAnnot->GetRect(), LeftBottom); | |
95 pAnnot = iter.GetNextAnnot(pAnnot); | |
96 CheckRect(pAnnot->GetRect(), RightTop); | |
97 pAnnot = iter.GetNextAnnot(pAnnot); | |
98 CheckRect(pAnnot->GetRect(), LeftTop); | |
99 pAnnot = iter.GetNextAnnot(pAnnot); | |
100 CheckRect(pAnnot->GetRect(), RightBottom); | |
101 pAnnot = iter.GetNextAnnot(pAnnot); | |
102 EXPECT_EQ(iter.GetFirstAnnot(), pAnnot); | |
103 | |
104 pAnnot = iter.GetLastAnnot(); | |
105 CheckRect(pAnnot->GetRect(), RightBottom); | |
106 pAnnot = iter.GetPrevAnnot(pAnnot); | |
107 CheckRect(pAnnot->GetRect(), LeftTop); | |
108 pAnnot = iter.GetPrevAnnot(pAnnot); | |
109 CheckRect(pAnnot->GetRect(), RightTop); | |
110 pAnnot = iter.GetPrevAnnot(pAnnot); | |
111 CheckRect(pAnnot->GetRect(), LeftBottom); | |
112 pAnnot = iter.GetPrevAnnot(pAnnot); | |
113 EXPECT_EQ(iter.GetLastAnnot(), pAnnot); | |
114 } | |
115 } | |
OLD | NEW |