summaryrefslogtreecommitdiff
path: root/fpdfsdk/fpdfannot_embeddertest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'fpdfsdk/fpdfannot_embeddertest.cpp')
-rw-r--r--fpdfsdk/fpdfannot_embeddertest.cpp48
1 files changed, 23 insertions, 25 deletions
diff --git a/fpdfsdk/fpdfannot_embeddertest.cpp b/fpdfsdk/fpdfannot_embeddertest.cpp
index b7dee88b78..4d6ae1c6d8 100644
--- a/fpdfsdk/fpdfannot_embeddertest.cpp
+++ b/fpdfsdk/fpdfannot_embeddertest.cpp
@@ -40,8 +40,8 @@ TEST_F(FPDFAnnotEmbeddertest, ExtractHighlightLongContent) {
EXPECT_EQ(1, FPDFPage_GetAnnotCount(page));
// Check that the annotation is of type "highlight".
- FPDF_ANNOTATION annot;
- ASSERT_TRUE(FPDFPage_GetAnnot(page, 0, &annot));
+ FPDF_ANNOTATION annot = FPDFPage_GetAnnot(page, 0);
+ ASSERT_TRUE(annot);
EXPECT_EQ(FPDF_ANNOT_HIGHLIGHT, FPDFAnnot_GetSubtype(annot));
// Check that the annotation color is yellow.
@@ -98,8 +98,7 @@ TEST_F(FPDFAnnotEmbeddertest, ExtractHighlightLongContent) {
.c_str());
// Check that the quadpoints are correct.
- FS_QUADPOINTSF quadpoints;
- ASSERT_TRUE(FPDFAnnot_GetAttachmentPoints(annot, &quadpoints));
+ FS_QUADPOINTSF quadpoints = FPDFAnnot_GetAttachmentPoints(annot);
EXPECT_EQ(115.802643f, quadpoints.x1);
EXPECT_EQ(718.913940f, quadpoints.y1);
EXPECT_EQ(157.211182f, quadpoints.x4);
@@ -119,8 +118,8 @@ TEST_F(FPDFAnnotEmbeddertest, ExtractInkMultiple) {
EXPECT_EQ(3, FPDFPage_GetAnnotCount(page));
// Check that the third annotation is of type "ink".
- FPDF_ANNOTATION annot;
- ASSERT_TRUE(FPDFPage_GetAnnot(page, 2, &annot));
+ FPDF_ANNOTATION annot = FPDFPage_GetAnnot(page, 2);
+ ASSERT_TRUE(annot);
EXPECT_EQ(FPDF_ANNOT_INK, FPDFAnnot_GetSubtype(annot));
// Check that the annotation color is blue with opacity.
@@ -141,8 +140,7 @@ TEST_F(FPDFAnnotEmbeddertest, ExtractInkMultiple) {
// Check that the rectange coordinates are correct.
// Note that upon rendering, the rectangle coordinates will be adjusted.
- FS_RECTF rect;
- ASSERT_TRUE(FPDFAnnot_GetRect(annot, &rect));
+ FS_RECTF rect = FPDFAnnot_GetRect(annot);
EXPECT_EQ(351.820404f, rect.left);
EXPECT_EQ(583.830688f, rect.bottom);
EXPECT_EQ(475.336090f, rect.right);
@@ -159,8 +157,7 @@ TEST_F(FPDFAnnotEmbeddertest, AddIllegalSubtypeAnnotation) {
ASSERT_TRUE(page);
// Add an annotation with an illegal subtype.
- FPDF_ANNOTATION annot;
- ASSERT_FALSE(FPDFPage_CreateAnnot(page, -1, &annot));
+ ASSERT_FALSE(FPDFPage_CreateAnnot(page, -1));
UnloadPage(page);
}
@@ -173,8 +170,8 @@ TEST_F(FPDFAnnotEmbeddertest, AddFirstTextAnnotation) {
EXPECT_EQ(0, FPDFPage_GetAnnotCount(page));
// Add a text annotation to the page.
- FPDF_ANNOTATION annot;
- ASSERT_TRUE(FPDFPage_CreateAnnot(page, FPDF_ANNOT_TEXT, &annot));
+ FPDF_ANNOTATION annot = FPDFPage_CreateAnnot(page, FPDF_ANNOT_TEXT);
+ ASSERT_TRUE(annot);
// Check that there is now 1 annotations on this page.
EXPECT_EQ(1, FPDFPage_GetAnnotCount(page));
@@ -183,7 +180,8 @@ TEST_F(FPDFAnnotEmbeddertest, AddFirstTextAnnotation) {
EXPECT_EQ(FPDF_ANNOT_TEXT, FPDFAnnot_GetSubtype(annot));
FPDFPage_CloseAnnot(annot);
- ASSERT_TRUE(FPDFPage_GetAnnot(page, 0, &annot));
+ annot = FPDFPage_GetAnnot(page, 0);
+ ASSERT_TRUE(annot);
EXPECT_EQ(FPDF_ANNOT_TEXT, FPDFAnnot_GetSubtype(annot));
// Set the color of the annotation.
@@ -213,15 +211,16 @@ TEST_F(FPDFAnnotEmbeddertest, AddFirstTextAnnotation) {
EXPECT_EQ(51u, A);
// Set the annotation rectangle.
- FS_RECTF rect;
- EXPECT_FALSE(FPDFAnnot_GetRect(annot, &rect));
+ FS_RECTF rect = FPDFAnnot_GetRect(annot);
+ EXPECT_EQ(0.f, rect.left);
+ EXPECT_EQ(0.f, rect.right);
rect.left = 35;
rect.bottom = 150;
rect.right = 53;
rect.top = 165;
ASSERT_TRUE(FPDFAnnot_SetRect(annot, rect));
// Check that the annotation rectangle has been set correctly.
- ASSERT_TRUE(FPDFAnnot_GetRect(annot, &rect));
+ rect = FPDFAnnot_GetRect(annot);
EXPECT_EQ(35.f, rect.left);
EXPECT_EQ(150.f, rect.bottom);
EXPECT_EQ(53.f, rect.right);
@@ -256,10 +255,9 @@ TEST_F(FPDFAnnotEmbeddertest, AddAndSaveUnderlineAnnotation) {
// Check that there is a total of one annotation on its first page, and verify
// its quadpoints.
EXPECT_EQ(1, FPDFPage_GetAnnotCount(page));
- FPDF_ANNOTATION annot;
- ASSERT_TRUE(FPDFPage_GetAnnot(page, 0, &annot));
- FS_QUADPOINTSF quadpoints;
- ASSERT_TRUE(FPDFAnnot_GetAttachmentPoints(annot, &quadpoints));
+ FPDF_ANNOTATION annot = FPDFPage_GetAnnot(page, 0);
+ ASSERT_TRUE(annot);
+ FS_QUADPOINTSF quadpoints = FPDFAnnot_GetAttachmentPoints(annot);
EXPECT_EQ(115.802643f, quadpoints.x1);
EXPECT_EQ(718.913940f, quadpoints.y1);
EXPECT_EQ(157.211182f, quadpoints.x4);
@@ -267,7 +265,8 @@ TEST_F(FPDFAnnotEmbeddertest, AddAndSaveUnderlineAnnotation) {
FPDFPage_CloseAnnot(annot);
// Add an underline annotation to the page and set its quadpoints.
- ASSERT_TRUE(FPDFPage_CreateAnnot(page, FPDF_ANNOT_UNDERLINE, &annot));
+ annot = FPDFPage_CreateAnnot(page, FPDF_ANNOT_UNDERLINE);
+ ASSERT_TRUE(annot);
quadpoints.x1 = 140.802643f;
quadpoints.x3 = 140.802643f;
ASSERT_TRUE(FPDFAnnot_SetAttachmentPoints(annot, quadpoints));
@@ -294,11 +293,10 @@ TEST_F(FPDFAnnotEmbeddertest, AddAndSaveUnderlineAnnotation) {
// Check that the second annotation is an underline annotation and verify
// its quadpoints.
- FPDF_ANNOTATION new_annot;
- ASSERT_TRUE(FPDFPage_GetAnnot(new_page, 1, &new_annot));
+ FPDF_ANNOTATION new_annot = FPDFPage_GetAnnot(new_page, 1);
+ ASSERT_TRUE(new_annot);
EXPECT_EQ(FPDF_ANNOT_UNDERLINE, FPDFAnnot_GetSubtype(new_annot));
- FS_QUADPOINTSF new_quadpoints;
- ASSERT_TRUE(FPDFAnnot_GetAttachmentPoints(new_annot, &new_quadpoints));
+ FS_QUADPOINTSF new_quadpoints = FPDFAnnot_GetAttachmentPoints(new_annot);
EXPECT_NEAR(quadpoints.x1, new_quadpoints.x1, 0.001f);
EXPECT_NEAR(quadpoints.y1, new_quadpoints.y1, 0.001f);
EXPECT_NEAR(quadpoints.x4, new_quadpoints.x4, 0.001f);