diff options
author | Tom Sepez <tsepez@chromium.org> | 2018-05-03 17:19:53 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-05-03 17:19:53 +0000 |
commit | 525147a1f6d6cd736a407d1e189ac25d2f4726e8 (patch) | |
tree | bdc818c52d902a5a4e8ce8a4f0ba29bd11007b05 /fpdfsdk/fpdf_doc_unittest.cpp | |
parent | ccd9421589922b8f35ee5330d7fdac7edea081db (diff) | |
download | pdfium-525147a1f6d6cd736a407d1e189ac25d2f4726e8.tar.xz |
Use strict types in FPDF API, try #3
Rather than messing with actual inheritence, add type-checking wrappers
and just blatantly cast to incomplete types. Along the way, this points
out places where we would downcast without checking, which I fix.
Change-Id: Ieb303eb46ad8522dfe082454f1f10f247ffd52d5
Reviewed-on: https://pdfium-review.googlesource.com/32030
Reviewed-by: dsinclair <dsinclair@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'fpdfsdk/fpdf_doc_unittest.cpp')
-rw-r--r-- | fpdfsdk/fpdf_doc_unittest.cpp | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/fpdfsdk/fpdf_doc_unittest.cpp b/fpdfsdk/fpdf_doc_unittest.cpp index 0f285a14c3..0234d47833 100644 --- a/fpdfsdk/fpdf_doc_unittest.cpp +++ b/fpdfsdk/fpdf_doc_unittest.cpp @@ -127,11 +127,13 @@ TEST_F(PDFDocTest, FindBookmark) { // Title with a match. title = GetFPDFWideString(L"Chapter 2"); - EXPECT_EQ(bookmarks[2].obj, FPDFBookmark_Find(m_pDoc.get(), title.get())); + EXPECT_EQ(FPDFBookmarkFromCPDFDictionary(bookmarks[2].obj), + FPDFBookmark_Find(m_pDoc.get(), title.get())); // Title match is case insensitive. title = GetFPDFWideString(L"cHaPter 2"); - EXPECT_EQ(bookmarks[2].obj, FPDFBookmark_Find(m_pDoc.get(), title.get())); + EXPECT_EQ(FPDFBookmarkFromCPDFDictionary(bookmarks[2].obj), + FPDFBookmark_Find(m_pDoc.get(), title.get())); } { // Circular bookmarks in depth. @@ -166,7 +168,8 @@ TEST_F(PDFDocTest, FindBookmark) { // Title with a match. title = GetFPDFWideString(L"Chapter 2"); - EXPECT_EQ(bookmarks[2].obj, FPDFBookmark_Find(m_pDoc.get(), title.get())); + EXPECT_EQ(FPDFBookmarkFromCPDFDictionary(bookmarks[2].obj), + FPDFBookmark_Find(m_pDoc.get(), title.get())); } { // Circular bookmarks in breadth. @@ -207,7 +210,8 @@ TEST_F(PDFDocTest, FindBookmark) { // Title with a match. title = GetFPDFWideString(L"Chapter 3"); - EXPECT_EQ(bookmarks[3].obj, FPDFBookmark_Find(m_pDoc.get(), title.get())); + EXPECT_EQ(FPDFBookmarkFromCPDFDictionary(bookmarks[3].obj), + FPDFBookmark_Find(m_pDoc.get(), title.get())); } } @@ -226,8 +230,9 @@ TEST_F(PDFDocTest, GetLocationInPage) { FS_FLOAT y; FS_FLOAT zoom; - EXPECT_TRUE(FPDFDest_GetLocationInPage(array.get(), &hasX, &hasY, &hasZoom, - &x, &y, &zoom)); + EXPECT_TRUE(FPDFDest_GetLocationInPage(FPDFDestFromCPDFArray(array.get()), + &hasX, &hasY, &hasZoom, &x, &y, + &zoom)); EXPECT_TRUE(hasX); EXPECT_TRUE(hasY); EXPECT_TRUE(hasZoom); @@ -238,13 +243,15 @@ TEST_F(PDFDocTest, GetLocationInPage) { array->SetNewAt<CPDF_Null>(2); array->SetNewAt<CPDF_Null>(3); array->SetNewAt<CPDF_Null>(4); - EXPECT_TRUE(FPDFDest_GetLocationInPage(array.get(), &hasX, &hasY, &hasZoom, - &x, &y, &zoom)); + EXPECT_TRUE(FPDFDest_GetLocationInPage(FPDFDestFromCPDFArray(array.get()), + &hasX, &hasY, &hasZoom, &x, &y, + &zoom)); EXPECT_FALSE(hasX); EXPECT_FALSE(hasY); EXPECT_FALSE(hasZoom); array = pdfium::MakeUnique<CPDF_Array>(); - EXPECT_FALSE(FPDFDest_GetLocationInPage(array.get(), &hasX, &hasY, &hasZoom, - &x, &y, &zoom)); + EXPECT_FALSE(FPDFDest_GetLocationInPage(FPDFDestFromCPDFArray(array.get()), + &hasX, &hasY, &hasZoom, &x, &y, + &zoom)); } |