Check for removed resources in saved output in RemoveTextObject test
FPDFEditEmbedderTest.RemoveTextObject removes a page object, so the
resources associated with only that page object are not needed when
saving the PDF. Add checks to reflect the current situation where they
still exist, with a TODO to remove them.
Along the way, add an extra check to ensure the removed object is indeed
a text object.
Bug: chromium:1428724
Change-Id: Ia934158b5fd72a42fba0125aa1637d1c980bda3c
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/105570
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/fpdfsdk/fpdf_edit_embeddertest.cpp b/fpdfsdk/fpdf_edit_embeddertest.cpp
index c91f092..92728f4 100644
--- a/fpdfsdk/fpdf_edit_embeddertest.cpp
+++ b/fpdfsdk/fpdf_edit_embeddertest.cpp
@@ -37,6 +37,7 @@
#include "third_party/base/check.h"
using pdfium::HelloWorldChecksum;
+using testing::HasSubstr;
namespace {
@@ -904,6 +905,7 @@
{
ScopedFPDFPageObject page_object(FPDFPage_GetObject(page, 0));
ASSERT_TRUE(page_object);
+ ASSERT_EQ(FPDF_PAGEOBJ_TEXT, FPDFPageObj_GetType(page_object.get()));
EXPECT_TRUE(FPDFPage_RemoveObject(page, page_object.get()));
}
ASSERT_EQ(1, FPDFPage_CountObjects(page));
@@ -925,6 +927,12 @@
ASSERT_TRUE(FPDF_SaveAsCopy(document(), this, 0));
VerifySavedDocument(200, 200, FirstRemovedChecksum());
+ // Verify removed/renamed resources are no longer there.
+ // TODO(crbug.com/1428724): Negate these checks.
+ EXPECT_THAT(GetString(), HasSubstr("/F1"));
+ EXPECT_THAT(GetString(), HasSubstr("/F2"));
+ EXPECT_THAT(GetString(), HasSubstr("/Times-Roman"));
+
UnloadPage(page);
}