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 CPDF_Rect& actual, const CPDF_Rect& 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. | |
Lei Zhang
2016/01/29 23:39:23
just "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 CPDF_Rect LeftBottom(200, 200, 220, 220); | |
34 CPDF_Rect RightBottom(400, 201, 420, 221); | |
35 CPDF_Rect LeftTop(201, 400, 221, 420); | |
36 CPDF_Rect RightTop(401, 401, 421, 421); | |
37 | |
38 { | |
39 // Page 0 specifies "row order". | |
40 CBA_AnnotIterator iter(GetSDKDocument()->GetPageView(0), "Widget", ""); | |
41 CPDFSDK_Annot* pAnnot = iter.GetFirstAnnot(); | |
42 CheckRect(pAnnot->GetRect(), RightTop); | |
43 pAnnot = iter.GetNextAnnot(pAnnot); | |
44 CheckRect(pAnnot->GetRect(), LeftTop); | |
45 pAnnot = iter.GetNextAnnot(pAnnot); | |
46 CheckRect(pAnnot->GetRect(), RightBottom); | |
47 pAnnot = iter.GetNextAnnot(pAnnot); | |
48 CheckRect(pAnnot->GetRect(), LeftBottom); | |
49 pAnnot = iter.GetNextAnnot(pAnnot); | |
50 EXPECT_EQ(iter.GetFirstAnnot(), pAnnot); | |
51 | |
52 pAnnot = iter.GetLastAnnot(); | |
53 CheckRect(pAnnot->GetRect(), LeftBottom); | |
54 pAnnot = iter.GetPrevAnnot(pAnnot); | |
55 CheckRect(pAnnot->GetRect(), RightBottom); | |
56 pAnnot = iter.GetPrevAnnot(pAnnot); | |
57 CheckRect(pAnnot->GetRect(), LeftTop); | |
58 pAnnot = iter.GetPrevAnnot(pAnnot); | |
59 CheckRect(pAnnot->GetRect(), RightTop); | |
60 pAnnot = iter.GetPrevAnnot(pAnnot); | |
61 EXPECT_EQ(iter.GetLastAnnot(), pAnnot); | |
62 } | |
63 { | |
64 // Page 1 specifies "column order" | |
65 CBA_AnnotIterator iter(GetSDKDocument()->GetPageView(1), "Widget", ""); | |
66 CPDFSDK_Annot* pAnnot = iter.GetFirstAnnot(); | |
67 CheckRect(pAnnot->GetRect(), RightTop); | |
68 pAnnot = iter.GetNextAnnot(pAnnot); | |
69 CheckRect(pAnnot->GetRect(), RightBottom); | |
70 pAnnot = iter.GetNextAnnot(pAnnot); | |
71 CheckRect(pAnnot->GetRect(), LeftTop); | |
72 pAnnot = iter.GetNextAnnot(pAnnot); | |
73 CheckRect(pAnnot->GetRect(), LeftBottom); | |
74 pAnnot = iter.GetNextAnnot(pAnnot); | |
75 EXPECT_EQ(iter.GetFirstAnnot(), pAnnot); | |
76 | |
77 pAnnot = iter.GetLastAnnot(); | |
78 CheckRect(pAnnot->GetRect(), LeftBottom); | |
79 pAnnot = iter.GetPrevAnnot(pAnnot); | |
80 CheckRect(pAnnot->GetRect(), LeftTop); | |
81 pAnnot = iter.GetPrevAnnot(pAnnot); | |
82 CheckRect(pAnnot->GetRect(), RightBottom); | |
83 pAnnot = iter.GetPrevAnnot(pAnnot); | |
84 CheckRect(pAnnot->GetRect(), RightTop); | |
85 pAnnot = iter.GetPrevAnnot(pAnnot); | |
86 EXPECT_EQ(iter.GetLastAnnot(), pAnnot); | |
87 } | |
88 { | |
89 // Page 2 specifies "struct order" | |
90 CBA_AnnotIterator iter(GetSDKDocument()->GetPageView(2), "Widget", ""); | |
91 CPDFSDK_Annot* pAnnot = iter.GetFirstAnnot(); | |
92 CheckRect(pAnnot->GetRect(), LeftBottom); | |
93 pAnnot = iter.GetNextAnnot(pAnnot); | |
94 CheckRect(pAnnot->GetRect(), RightTop); | |
95 pAnnot = iter.GetNextAnnot(pAnnot); | |
96 CheckRect(pAnnot->GetRect(), LeftTop); | |
97 pAnnot = iter.GetNextAnnot(pAnnot); | |
98 CheckRect(pAnnot->GetRect(), RightBottom); | |
99 pAnnot = iter.GetNextAnnot(pAnnot); | |
100 EXPECT_EQ(iter.GetFirstAnnot(), pAnnot); | |
101 | |
102 pAnnot = iter.GetLastAnnot(); | |
103 CheckRect(pAnnot->GetRect(), RightBottom); | |
104 pAnnot = iter.GetPrevAnnot(pAnnot); | |
105 CheckRect(pAnnot->GetRect(), LeftTop); | |
106 pAnnot = iter.GetPrevAnnot(pAnnot); | |
107 CheckRect(pAnnot->GetRect(), RightTop); | |
108 pAnnot = iter.GetPrevAnnot(pAnnot); | |
109 CheckRect(pAnnot->GetRect(), LeftBottom); | |
110 pAnnot = iter.GetPrevAnnot(pAnnot); | |
111 EXPECT_EQ(iter.GetLastAnnot(), pAnnot); | |
112 } | |
113 } | |
OLD | NEW |