Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(393)

Unified Diff: fpdfsdk/src/fpdfdoc_embeddertest.cpp

Issue 1554363002: Make FPDF_WIDESTRING work regardless of endianness. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | fpdfsdk/src/fpdftext_embeddertest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: fpdfsdk/src/fpdfdoc_embeddertest.cpp
diff --git a/fpdfsdk/src/fpdfdoc_embeddertest.cpp b/fpdfsdk/src/fpdfdoc_embeddertest.cpp
index 38a366268c59588599eff7e873f707dfea1bcb40..260f25f3099958afd12665a33ba3b9d228c7690b 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".
Lei Zhang 2016/01/05 02:34:09 Do you want to make a custom unique_ptr deleter fo
Tom Sepez 2016/01/05 18:06:23 I'll do that in a follow-up. The GetFileContents(
+ free(const_cast<unsigned short*>(title));
+ free(const_cast<unsigned short*>(bad_title));
}
« no previous file with comments | « no previous file | fpdfsdk/src/fpdftext_embeddertest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698