Do more checks in a FPDFPage_RemoveObject() test

Add more checks to FPDFEditEmbedderTest.RemovePageObject to ensure the
text object removal works after calling FPDFPage_GenerateContent(), and
after saving/reloading.

Also rename the test case name to "RemoveTextObject" to reflect the
specific type of page object it is removing.

Change-Id: I997aa16656d73f3b3f372a2c56adb0d22273e95c
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/105290
Reviewed-by: Nigi <nigi@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/fpdfsdk/fpdf_edit_embeddertest.cpp b/fpdfsdk/fpdf_edit_embeddertest.cpp
index d704f45..ce462d4 100644
--- a/fpdfsdk/fpdf_edit_embeddertest.cpp
+++ b/fpdfsdk/fpdf_edit_embeddertest.cpp
@@ -887,7 +887,7 @@
   CloseSavedDocument();
 }
 
-TEST_F(FPDFEditEmbedderTest, RemovePageObject) {
+TEST_F(FPDFEditEmbedderTest, RemoveTextObject) {
   // Load document with some text.
   ASSERT_TRUE(OpenDocument("hello_world.pdf"));
   FPDF_PAGE page = LoadPage(0);
@@ -901,19 +901,31 @@
 
   // Get the "Hello, world!" text object and remove it.
   ASSERT_EQ(2, FPDFPage_CountObjects(page));
-  FPDF_PAGEOBJECT page_object = FPDFPage_GetObject(page, 0);
-  ASSERT_TRUE(page_object);
-  EXPECT_TRUE(FPDFPage_RemoveObject(page, page_object));
+  {
+    ScopedFPDFPageObject page_object(FPDFPage_GetObject(page, 0));
+    ASSERT_TRUE(page_object);
+    EXPECT_TRUE(FPDFPage_RemoveObject(page, page_object.get()));
+  }
+  ASSERT_EQ(1, FPDFPage_CountObjects(page));
 
   // Verify the "Hello, world!" text is gone.
   {
     ScopedFPDFBitmap page_bitmap = RenderPage(page);
     CompareBitmap(page_bitmap.get(), 200, 200, FirstRemovedChecksum());
   }
-  ASSERT_EQ(1, FPDFPage_CountObjects(page));
+
+  // Verify the rendering again after calling FPDFPage_GenerateContent().
+  ASSERT_TRUE(FPDFPage_GenerateContent(page));
+  {
+    ScopedFPDFBitmap page_bitmap = RenderPage(page);
+    CompareBitmap(page_bitmap.get(), 200, 200, FirstRemovedChecksum());
+  }
+
+  // Save the document and verify it after reloading.
+  ASSERT_TRUE(FPDF_SaveAsCopy(document(), this, 0));
+  VerifySavedDocument(200, 200, FirstRemovedChecksum());
 
   UnloadPage(page);
-  FPDFPageObj_Destroy(page_object);
 }
 
 void CheckMarkCounts(FPDF_PAGE page,