summaryrefslogtreecommitdiff
path: root/fpdfsdk/src/fpdfdoc_embeddertest.cpp
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2016-01-05 10:17:30 -0800
committerTom Sepez <tsepez@chromium.org>2016-01-05 10:17:30 -0800
commit8ab45eafebfd510554920e09e5ee85e94701dea9 (patch)
tree5395b97d113552edc0c4c6bf3142302441da666e /fpdfsdk/src/fpdfdoc_embeddertest.cpp
parent0861c161376074bce453de31fdf96e120c482696 (diff)
downloadpdfium-8ab45eafebfd510554920e09e5ee85e94701dea9.tar.xz
Merge to XFA: Make FPDF_WIDESTRING work regardless of endianness.
Original Review URL: https://codereview.chromium.org/1554363002 . (cherry picked from commit ed34cdf99d5a4b33e57f81f9244a311f6fb86db3) TBR=thestig@chromium.org Review URL: https://codereview.chromium.org/1559373002 .
Diffstat (limited to 'fpdfsdk/src/fpdfdoc_embeddertest.cpp')
-rw-r--r--fpdfsdk/src/fpdfdoc_embeddertest.cpp23
1 files changed, 16 insertions, 7 deletions
diff --git a/fpdfsdk/src/fpdfdoc_embeddertest.cpp b/fpdfsdk/src/fpdfdoc_embeddertest.cpp
index 38a366268c..260f25f309 100644
--- a/fpdfsdk/src/fpdfdoc_embeddertest.cpp
+++ b/fpdfsdk/src/fpdfdoc_embeddertest.cpp
@@ -7,6 +7,7 @@
#include "public/fpdfview.h"
#include "testing/embedder_test.h"
#include "testing/fx_string_testhelpers.h"
+#include "testing/test_support.h"
#include "testing/gtest/include/gtest/gtest.h"
class FPDFDocEmbeddertest : public EmbedderTest {};
@@ -101,20 +102,28 @@ TEST_F(FPDFDocEmbeddertest, Bookmarks) {
}
TEST_F(FPDFDocEmbeddertest, FindBookmarks) {
- // Open a file with two bookmarks, and extract the first.
+ // Open a file with two bookmarks.
EXPECT_TRUE(OpenDocument("bookmarks.pdf"));
- unsigned short buf[128];
- FPDF_BOOKMARK child = FPDFBookmark_GetFirstChild(document(), nullptr);
+ // Find the first one, based on its known title.
+ FPDF_WIDESTRING title = GetFPDFWideString(L"A Good Beginning");
+ FPDF_BOOKMARK child = FPDFBookmark_Find(document(), title);
EXPECT_NE(nullptr, child);
+
+ // Check that the string matches.
+ unsigned short buf[128];
EXPECT_EQ(34, FPDFBookmark_GetTitle(child, buf, sizeof(buf)));
EXPECT_EQ(CFX_WideString(L"A Good Beginning"),
CFX_WideString::FromUTF16LE(buf, 16));
- // Find the same one again using the title.
- EXPECT_EQ(child, FPDFBookmark_Find(document(), buf));
+ // Check that it is them same as the one returned by GetFirstChild.
+ EXPECT_EQ(child, FPDFBookmark_GetFirstChild(document(), nullptr));
// Try to find one using a non-existent title.
- buf[0] = 'X';
- EXPECT_EQ(nullptr, FPDFBookmark_Find(document(), buf));
+ FPDF_WIDESTRING bad_title = GetFPDFWideString(L"A BAD Beginning");
+ EXPECT_EQ(nullptr, FPDFBookmark_Find(document(), bad_title));
+
+ // Alas, the typedef includes the "const".
+ free(const_cast<unsigned short*>(title));
+ free(const_cast<unsigned short*>(bad_title));
}