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>
diff --git a/fpdfsdk/fpdfview.cpp b/fpdfsdk/fpdfview.cpp
index fea1aba..bda9111 100644
--- a/fpdfsdk/fpdfview.cpp
+++ b/fpdfsdk/fpdfview.cpp
@@ -470,6 +470,7 @@
     ProcessParseError(error);
     return nullptr;
   }
+  CheckUnSupportError(pDocument.get(), error);
   return FPDFDocumentFromCPDFDocument(pDocument.release());
 }
 
diff --git a/fpdfsdk/fpdfview_embeddertest.cpp b/fpdfsdk/fpdfview_embeddertest.cpp
index 1d94b72..f36edbc 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 @@
 
   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);
+}
diff --git a/testing/resources/unsupported_feature.in b/testing/resources/unsupported_feature.in
new file mode 100644
index 0000000..3aa8632
--- /dev/null
+++ b/testing/resources/unsupported_feature.in
@@ -0,0 +1,32 @@
+{{header}}
+{{object 1 0}} <<
+  /Type /Catalog
+  /Pages 2 0 R
+  /Collection /Test
+>>
+endobj
+{{object 2 0}} <<
+  /Type /Pages
+  /Count 3
+  /Kids [
+    10 0 R
+  ]
+>>
+endobj
+% Page number 0.
+{{object 10 0}} <<
+  /Type /Page
+  /Parent 2 0 R
+  /Resources <<
+    /Font <</F1 15 0 R>>
+  >>
+  /MediaBox [0 0 612 792]
+  /Tabs /R
+>>
+endobj
+{{xref}}
+trailer <<
+  /Root 1 0 R
+>>
+{{startxref}}
+%%EOF
diff --git a/testing/resources/unsupported_feature.pdf b/testing/resources/unsupported_feature.pdf
new file mode 100644
index 0000000..f7091c5
--- /dev/null
+++ b/testing/resources/unsupported_feature.pdf
@@ -0,0 +1,46 @@
+%PDF-1.7
+% ò¤ô
+1 0 obj <<
+  /Type /Catalog
+  /Pages 2 0 R
+  /Collection /Test
+>>
+endobj
+2 0 obj <<
+  /Type /Pages
+  /Count 3
+  /Kids [
+    10 0 R
+  ]
+>>
+endobj
+% Page number 0.
+10 0 obj <<
+  /Type /Page
+  /Parent 2 0 R
+  /Resources <<
+    /Font <</F1 15 0 R>>
+  >>
+  /MediaBox [0 0 612 792]
+  /Tabs /R
+>>
+endobj
+xref
+0 11
+0000000000 65535 f 
+0000000015 00000 n 
+0000000088 00000 n 
+0000000000 65535 f 
+0000000000 65535 f 
+0000000000 65535 f 
+0000000000 65535 f 
+0000000000 65535 f 
+0000000000 65535 f 
+0000000000 65535 f 
+0000000177 00000 n 
+trailer <<
+  /Root 1 0 R
+>>
+startxref
+312
+%%EOF