diff options
Diffstat (limited to 'fpdfsdk/fpdfedit_embeddertest.cpp')
-rw-r--r-- | fpdfsdk/fpdfedit_embeddertest.cpp | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/fpdfsdk/fpdfedit_embeddertest.cpp b/fpdfsdk/fpdfedit_embeddertest.cpp index c381b25efa..e62ef2149b 100644 --- a/fpdfsdk/fpdfedit_embeddertest.cpp +++ b/fpdfsdk/fpdfedit_embeddertest.cpp @@ -1038,3 +1038,49 @@ TEST_F(FPDFEditEmbeddertest, DestroyPageObject) { // There should be no memory leaks with a call to FPDFPageObj_Destroy(). FPDFPageObj_Destroy(rect); } + +TEST_F(FPDFEditEmbeddertest, GetImageFilters) { + EXPECT_TRUE(OpenDocument("embedded_images.pdf")); + FPDF_PAGE page = LoadPage(0); + ASSERT_TRUE(page); + + // Verify that retrieving the filter of a non-image object would fail. + FPDF_PAGEOBJECT obj = FPDFPage_GetObject(page, 32); + ASSERT_NE(FPDF_PAGEOBJ_IMAGE, FPDFPageObj_GetType(obj)); + ASSERT_EQ(0, FPDFImageObj_GetImageFilterCount(obj)); + EXPECT_EQ(0u, FPDFImageObj_GetImageFilter(obj, 0, nullptr, 0)); + + // Verify the returned filter string for an image object with a single filter. + obj = FPDFPage_GetObject(page, 33); + ASSERT_EQ(FPDF_PAGEOBJ_IMAGE, FPDFPageObj_GetType(obj)); + ASSERT_EQ(1, FPDFImageObj_GetImageFilterCount(obj)); + unsigned long len = FPDFImageObj_GetImageFilter(obj, 0, nullptr, 0); + std::vector<char> buf(len); + EXPECT_EQ(24u, FPDFImageObj_GetImageFilter(obj, 0, buf.data(), len)); + EXPECT_STREQ(L"FlateDecode", + GetPlatformWString(reinterpret_cast<unsigned short*>(buf.data())) + .c_str()); + EXPECT_EQ(0u, FPDFImageObj_GetImageFilter(obj, 1, nullptr, 0)); + + // Verify all the filters for an image object with a list of filters. + obj = FPDFPage_GetObject(page, 38); + ASSERT_EQ(FPDF_PAGEOBJ_IMAGE, FPDFPageObj_GetType(obj)); + ASSERT_EQ(2, FPDFImageObj_GetImageFilterCount(obj)); + len = FPDFImageObj_GetImageFilter(obj, 0, nullptr, 0); + buf.clear(); + buf.resize(len); + EXPECT_EQ(30u, FPDFImageObj_GetImageFilter(obj, 0, buf.data(), len)); + EXPECT_STREQ(L"ASCIIHexDecode", + GetPlatformWString(reinterpret_cast<unsigned short*>(buf.data())) + .c_str()); + + len = FPDFImageObj_GetImageFilter(obj, 1, nullptr, 0); + buf.clear(); + buf.resize(len); + EXPECT_EQ(20u, FPDFImageObj_GetImageFilter(obj, 1, buf.data(), len)); + EXPECT_STREQ(L"DCTDecode", + GetPlatformWString(reinterpret_cast<unsigned short*>(buf.data())) + .c_str()); + + UnloadPage(page); +} |