diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2017-05-11 16:05:32 -0400 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-05-11 20:18:00 +0000 |
commit | cb377bec7023723b23a015921ef781cb355b3c92 (patch) | |
tree | e51bab43af676f2d9ed19c7e767d631109861e09 /fpdfsdk/fpdfview_embeddertest.cpp | |
parent | 0dc8571d1354b8c319510be625a446218449f532 (diff) | |
download | pdfium-cb377bec7023723b23a015921ef781cb355b3c92.tar.xz |
Add missing CheckUnsupportedError
The FPDF_LoadDocument call was missing the CheckUnSupportedError so, if
the document contained unsuppoted information the user would not be
notified. This brings the method in line with the other loading methods.
Change-Id: I308b25335a228eb02c51562f9caf91cda9193b73
Reviewed-on: https://pdfium-review.googlesource.com/5336
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'fpdfsdk/fpdfview_embeddertest.cpp')
-rw-r--r-- | fpdfsdk/fpdfview_embeddertest.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/fpdfsdk/fpdfview_embeddertest.cpp b/fpdfsdk/fpdfview_embeddertest.cpp index 1d94b72553..f36edbc4d6 100644 --- a/fpdfsdk/fpdfview_embeddertest.cpp +++ b/fpdfsdk/fpdfview_embeddertest.cpp @@ -9,6 +9,7 @@ #include "public/fpdfview.h" #include "testing/embedder_test.h" #include "testing/gtest/include/gtest/gtest.h" +#include "testing/utils/path_service.h" TEST(fpdf, CApiTest) { EXPECT_TRUE(CheckPDFiumCApi()); @@ -378,3 +379,43 @@ TEST_F(FPDFViewEmbeddertest, FPDF_RenderPageBitmapWithMatrix) { UnloadPage(page); } + +class UnSupRecordDelegate : public EmbedderTest::Delegate { + public: + UnSupRecordDelegate() : type_(-1) {} + ~UnSupRecordDelegate() override {} + + void UnsupportedHandler(int type) override { type_ = type; } + + int type_; +}; + +TEST_F(FPDFViewEmbeddertest, UnSupportedOperations_NotFound) { + UnSupRecordDelegate delegate; + SetDelegate(&delegate); + ASSERT_TRUE(OpenDocument("hello_world.pdf")); + EXPECT_EQ(delegate.type_, -1); + SetDelegate(nullptr); +} + +TEST_F(FPDFViewEmbeddertest, UnSupportedOperations_LoadCustomDocument) { + UnSupRecordDelegate delegate; + SetDelegate(&delegate); + ASSERT_TRUE(OpenDocument("unsupported_feature.pdf")); + EXPECT_EQ(FPDF_UNSP_DOC_PORTABLECOLLECTION, delegate.type_); + SetDelegate(nullptr); +} + +TEST_F(FPDFViewEmbeddertest, UnSupportedOperations_LoadDocument) { + std::string file_path; + ASSERT_TRUE( + PathService::GetTestFilePath("unsupported_feature.pdf", &file_path)); + + UnSupRecordDelegate delegate; + SetDelegate(&delegate); + FPDF_DOCUMENT doc = FPDF_LoadDocument(file_path.c_str(), ""); + EXPECT_TRUE(doc != nullptr); + EXPECT_EQ(FPDF_UNSP_DOC_PORTABLECOLLECTION, delegate.type_); + FPDF_CloseDocument(doc); + SetDelegate(nullptr); +} |