diff options
author | Jane Liu <janeliulwq@google.com> | 2017-07-05 15:04:33 -0400 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-07-06 13:09:26 +0000 |
commit | b137e75343cada31ddcf905fc581a3a86a63b5d5 (patch) | |
tree | 69c8a46658e61739da60852b522b5dbfcc3b9cac /fpdfsdk/fpdfannot_embeddertest.cpp | |
parent | ddf2418ba8e5d925909d7955ac22b33f37ccce44 (diff) | |
download | pdfium-b137e75343cada31ddcf905fc581a3a86a63b5d5.tar.xz |
Added APIs for setting annotation flag values
1. Added APIs for getting/setting/unsetting annotation flag values in
annotation dictionaries.
* Added an embedder test testing all the new functions.
Bug=pdfium:737
Change-Id: Ib6bbcf05d6e93c43ec4dcd7120db71bc244afdbf
Reviewed-on: https://pdfium-review.googlesource.com/7154
Reviewed-by: dsinclair <dsinclair@chromium.org>
Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'fpdfsdk/fpdfannot_embeddertest.cpp')
-rw-r--r-- | fpdfsdk/fpdfannot_embeddertest.cpp | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/fpdfsdk/fpdfannot_embeddertest.cpp b/fpdfsdk/fpdfannot_embeddertest.cpp index 6c56c06396..beaedf91af 100644 --- a/fpdfsdk/fpdfannot_embeddertest.cpp +++ b/fpdfsdk/fpdfannot_embeddertest.cpp @@ -555,3 +555,53 @@ TEST_F(FPDFAnnotEmbeddertest, AddAndModifyPath) { FPDFPage_CloseAnnot(annot); CloseSaved(); } + +TEST_F(FPDFAnnotEmbeddertest, ModifyAnnotationFlags) { + // Open a file with an annotation and load its first page. + ASSERT_TRUE(OpenDocument("annotation_highlight_rollover_ap.pdf")); + FPDF_PAGE page = FPDF_LoadPage(document(), 0); + ASSERT_TRUE(page); + + // Check that the page renders correctly. + FPDF_BITMAP bitmap = RenderPageWithFlags(page, form_handle_, FPDF_ANNOT); + CompareBitmap(bitmap, 612, 792, "dc98f06da047bd8aabfa99562d2cbd1e"); + FPDFBitmap_Destroy(bitmap); + + // Retrieve the annotation. + FPDF_ANNOTATION annot = FPDFPage_GetAnnot(page, 0); + ASSERT_TRUE(annot); + + // Check that the original flag values are as expected. + int flags = FPDFAnnot_GetFlags(annot); + EXPECT_FALSE(flags & FPDF_ANNOT_FLAG_HIDDEN); + EXPECT_TRUE(flags & FPDF_ANNOT_FLAG_PRINT); + + // Set the HIDDEN flag. + flags |= FPDF_ANNOT_FLAG_HIDDEN; + EXPECT_TRUE(FPDFAnnot_SetFlags(annot, flags)); + flags = FPDFAnnot_GetFlags(annot); + EXPECT_TRUE(flags & FPDF_ANNOT_FLAG_HIDDEN); + EXPECT_TRUE(flags & FPDF_ANNOT_FLAG_PRINT); + + // Check that the page renders correctly without rendering the annotation. + bitmap = RenderPageWithFlags(page, form_handle_, FPDF_ANNOT); + CompareBitmap(bitmap, 612, 792, "1940568c9ba33bac5d0b1ee9558c76b3"); + FPDFBitmap_Destroy(bitmap); + + // Unset the HIDDEN flag. + EXPECT_TRUE(FPDFAnnot_SetFlags(annot, FPDF_ANNOT_FLAG_NONE)); + EXPECT_FALSE(FPDFAnnot_GetFlags(annot)); + flags &= ~FPDF_ANNOT_FLAG_HIDDEN; + EXPECT_TRUE(FPDFAnnot_SetFlags(annot, flags)); + flags = FPDFAnnot_GetFlags(annot); + EXPECT_FALSE(flags & FPDF_ANNOT_FLAG_HIDDEN); + EXPECT_TRUE(flags & FPDF_ANNOT_FLAG_PRINT); + + // Check that the page renders correctly as before. + bitmap = RenderPageWithFlags(page, form_handle_, FPDF_ANNOT); + CompareBitmap(bitmap, 612, 792, "dc98f06da047bd8aabfa99562d2cbd1e"); + FPDFBitmap_Destroy(bitmap); + + FPDFPage_CloseAnnot(annot); + UnloadPage(page); +} |