Add FPDFViewEmbedderTest.RepeatedInitDestroy.
Show calling FPDF_InitLibrary() and FPDF_DestroyLibrary() in a loop does
not cause any problems that the CI tests can detect.
Bug: pdfium:1876
Change-Id: Ib85c84c1af92801a70c8c11d5abc3110bf334fed
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/96571
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/fpdfsdk/fpdf_view_embeddertest.cpp b/fpdfsdk/fpdf_view_embeddertest.cpp
index c635a9c..5a1ae31 100644
--- a/fpdfsdk/fpdf_view_embeddertest.cpp
+++ b/fpdfsdk/fpdf_view_embeddertest.cpp
@@ -379,6 +379,21 @@
EmbedderTestEnvironment::GetInstance()->SetUp();
}
+TEST_F(FPDFViewEmbedderTest, RepeatedInitDestroy) {
+ for (int i = 0; i < 3; ++i) {
+ if (!OpenDocument("about_blank.pdf"))
+ ADD_FAILURE();
+ CloseDocument();
+
+ FPDF_DestroyLibrary();
+ FPDF_InitLibrary();
+ }
+
+ // Puts the test environment back the way it was.
+ EmbedderTestEnvironment::GetInstance()->TearDown();
+ EmbedderTestEnvironment::GetInstance()->SetUp();
+}
+
TEST_F(FPDFViewEmbedderTest, Document) {
ASSERT_TRUE(OpenDocument("about_blank.pdf"));
EXPECT_EQ(1, GetPageCount());