Add test to show FPDF_DestroyLibrary() didn't reset the default renderer

Add an embedder test that should be rendering with AGG and then Skia,
but instead is always rendering with AGG.

Bug: pdfium:2087
Change-Id: Ibf45a1f65615bfe8880002f69120d1dec2702fcc
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/113051
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Nigi <nigi@chromium.org>
diff --git a/fpdfsdk/fpdf_view_embeddertest.cpp b/fpdfsdk/fpdf_view_embeddertest.cpp
index 08cc387..72ab956 100644
--- a/fpdfsdk/fpdf_view_embeddertest.cpp
+++ b/fpdfsdk/fpdf_view_embeddertest.cpp
@@ -2089,6 +2089,55 @@
 
   UnloadPage(page);
 }
+
+TEST_F(FPDFViewEmbedderTest, Bug2087) {
+  FPDF_DestroyLibrary();
+
+  std::string agg_checksum;
+  {
+    FPDF_LIBRARY_CONFIG config = {
+        .version = 4,
+        .m_pUserFontPaths = nullptr,
+        .m_pIsolate = nullptr,
+        .m_v8EmbedderSlot = 0,
+        .m_pPlatform = nullptr,
+        .m_RendererType = FPDF_RENDERERTYPE_AGG,
+    };
+    FPDF_InitLibraryWithConfig(&config);
+
+    ASSERT_TRUE(OpenDocument("rectangles.pdf"));
+    FPDF_PAGE page = LoadPage(0);
+    ScopedFPDFBitmap bitmap = RenderPage(page);
+    agg_checksum = HashBitmap(bitmap.get());
+    UnloadPage(page);
+    CloseDocument();
+    FPDF_DestroyLibrary();
+  }
+
+  std::string skia_checksum;
+  {
+    FPDF_LIBRARY_CONFIG config = {
+        .version = 2,
+        .m_pUserFontPaths = nullptr,
+        .m_pIsolate = nullptr,
+        .m_v8EmbedderSlot = 0,
+    };
+    FPDF_InitLibraryWithConfig(&config);
+
+    ASSERT_TRUE(OpenDocument("rectangles.pdf"));
+    FPDF_PAGE page = LoadPage(0);
+    ScopedFPDFBitmap bitmap = RenderPage(page);
+    skia_checksum = HashBitmap(bitmap.get());
+    UnloadPage(page);
+    CloseDocument();
+  }
+
+  // TODO(pdfium:2087): These checksums should not be equal.
+  EXPECT_EQ(agg_checksum, skia_checksum);
+
+  EmbedderTestEnvironment::GetInstance()->TearDown();
+  EmbedderTestEnvironment::GetInstance()->SetUp();
+}
 #endif  // defined(_SKIA_SUPPORT_)
 
 TEST_F(FPDFViewEmbedderTest, NoSmoothTextItalicOverlappingGlyphs) {