Add a regression test for FPDFTextObj_GetText() and space characters [pdfium : main]

0 views
Skip to first unread message

Andy Phan (Gerrit)

unread,
Feb 20, 2026, 7:25:26 PM (2 days ago) Feb 20
to Lei Zhang, Pdfium LUCI CQ, pdfium-...@googlegroups.com
Attention needed from Lei Zhang

Andy Phan voted and added 2 comments

Votes added by Andy Phan

Code-Review+1

2 comments

File fpdfsdk/fpdf_text_embeddertest.cpp
Line 1470, Patchset 1 (Latest): ASSERT_EQ(5, FPDFPage_CountObjects(page.get()));
Andy Phan . unresolved

kExpectedText.size()? Same below.

Line 1477, Patchset 1 (Latest): FPDFTextObj_GetText(text_object, text_page.get(), nullptr, i);
Andy Phan . unresolved

This param is supposed to be the length of the buffer, which is nullptr. Just set to 0?

Open in Gerrit

Related details

Attention is currently required from:
  • Lei Zhang
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: pdfium
Gerrit-Branch: main
Gerrit-Change-Id: Iff5e933c8808c39bb064b949063e5e234123bec0
Gerrit-Change-Number: 143572
Gerrit-PatchSet: 1
Gerrit-Owner: Lei Zhang <the...@chromium.org>
Gerrit-Reviewer: Andy Phan <andy...@chromium.org>
Gerrit-Reviewer: Lei Zhang <the...@chromium.org>
Gerrit-Attention: Lei Zhang <the...@chromium.org>
Gerrit-Comment-Date: Sat, 21 Feb 2026 00:25:24 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
satisfied_requirement
unsatisfied_requirement
open
diffy

Lei Zhang (Gerrit)

unread,
Feb 20, 2026, 7:35:20 PM (2 days ago) Feb 20
to Lei Zhang, Andy Phan, Pdfium LUCI CQ, pdfium-...@googlegroups.com

Lei Zhang voted and added 2 comments

Votes added by Lei Zhang

Commit-Queue+2

2 comments

File fpdfsdk/fpdf_text_embeddertest.cpp
Line 1470, Patchset 1: ASSERT_EQ(5, FPDFPage_CountObjects(page.get()));
Andy Phan . resolved

kExpectedText.size()? Same below.

Lei Zhang

Something like that. Done.

Line 1477, Patchset 1: FPDFTextObj_GetText(text_object, text_page.get(), nullptr, i);
Andy Phan . resolved

This param is supposed to be the length of the buffer, which is nullptr. Just set to 0?

Lei Zhang

Whoops. Done.

Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
    • requirement satisfiedCode-Owners
    • requirement satisfiedCode-Review
    • requirement satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: pdfium
    Gerrit-Branch: main
    Gerrit-Change-Id: Iff5e933c8808c39bb064b949063e5e234123bec0
    Gerrit-Change-Number: 143572
    Gerrit-PatchSet: 2
    Gerrit-Owner: Lei Zhang <the...@chromium.org>
    Gerrit-Reviewer: Andy Phan <andy...@chromium.org>
    Gerrit-Reviewer: Lei Zhang <the...@chromium.org>
    Gerrit-Comment-Date: Sat, 21 Feb 2026 00:35:16 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes
    Comment-In-Reply-To: Andy Phan <andy...@chromium.org>
    satisfied_requirement
    open
    diffy

    Pdfium LUCI CQ (Gerrit)

    unread,
    Feb 20, 2026, 9:04:09 PM (2 days ago) Feb 20
    to Lei Zhang, Andy Phan, pdfium-...@googlegroups.com

    Pdfium LUCI CQ submitted the change with unreviewed changes

    Unreviewed changes

    1 is the latest approved patch-set.
    The change was submitted with unreviewed changes in the following files:

    ```
    The name of the file: fpdfsdk/fpdf_text_embeddertest.cpp
    Insertions: 12, Deletions: 10.

    @@ -1453,13 +1453,15 @@
    }

    TEST_F(FPDFTextEmbedderTest, GetTextShouldNotGetInvisibleSpaces) {
    - static constexpr std::array<std::wstring_view, 5> kExpectedText = {
    - std::wstring_view(L""),
    - std::wstring_view(L""),
    - std::wstring_view(L""),
    - std::wstring_view(L"Hello, world!"),
    - std::wstring_view(L"Goodbye, world!"),
    - };
    + static constexpr int kExpectedPageObjectCount = 5;
    + static constexpr std::array<std::wstring_view, kExpectedPageObjectCount>
    + kExpectedText = {
    + std::wstring_view(L""),
    + std::wstring_view(L""),
    + std::wstring_view(L""),
    + std::wstring_view(L"Hello, world!"),
    + std::wstring_view(L"Goodbye, world!"),
    + };
    ASSERT_TRUE(OpenDocument("hello_world_with_invisible_spaces.pdf"));
    ScopedPage page = LoadScopedPage(0);
    ASSERT_TRUE(page);
    @@ -1467,14 +1469,14 @@
    ScopedFPDFTextPage text_page(FPDFText_LoadPage(page.get()));
    ASSERT_TRUE(text_page);

    - ASSERT_EQ(5, FPDFPage_CountObjects(page.get()));
    - for (int i = 0; i < 5; ++i) {
    + ASSERT_EQ(kExpectedPageObjectCount, FPDFPage_CountObjects(page.get()));
    + for (int i = 0; i < kExpectedPageObjectCount; ++i) {
    SCOPED_TRACE(testing::Message() << "Object " << i);
    FPDF_PAGEOBJECT text_object = FPDFPage_GetObject(page.get(), i);
    ASSERT_TRUE(text_object);

    unsigned long size =
    - FPDFTextObj_GetText(text_object, text_page.get(), nullptr, i);
    + FPDFTextObj_GetText(text_object, text_page.get(), nullptr, 0);
    // `size` is in bytes and includes the terminating NUL.
    ASSERT_EQ(2 * (kExpectedText[i].size() + 1), size);

    ```

    Change information

    Commit message:
    Add a regression test for FPDFTextObj_GetText() and space characters

    Add hello_world_with_invisible_spaces.pdf, which is a copy of
    hello_world.pdf with some extra spaces. Add a new
    FPDFTextEmbedderTest.GetTextShouldNotGetInvisibleSpaces test case to
    check this new PDF and make sure the extra spaces within do not get
    extracted.

    Simplify the adjacent FPDFTextEmbedderTest.GetText test case along the
    way.
    Bug: 485816033
    Change-Id: Iff5e933c8808c39bb064b949063e5e234123bec0
    Commit-Queue: Lei Zhang <the...@chromium.org>
    Reviewed-by: Andy Phan <andy...@chromium.org>
    Files:
    Change size: M
    Delta: 3 files changed, 172 insertions(+), 6 deletions(-)
    Branch: refs/heads/main
    Submit Requirements:
    • requirement satisfiedCode-Review: +1 by Andy Phan
    Open in Gerrit
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: merged
    Gerrit-Project: pdfium
    Gerrit-Branch: main
    Gerrit-Change-Id: Iff5e933c8808c39bb064b949063e5e234123bec0
    Gerrit-Change-Number: 143572
    Gerrit-PatchSet: 3
    Gerrit-Owner: Lei Zhang <the...@chromium.org>
    Gerrit-Reviewer: Andy Phan <andy...@chromium.org>
    Gerrit-Reviewer: Lei Zhang <the...@chromium.org>
    open
    diffy
    satisfied_requirement
    Reply all
    Reply to author
    Forward
    0 new messages