From 525147a1f6d6cd736a407d1e189ac25d2f4726e8 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Thu, 3 May 2018 17:19:53 +0000 Subject: 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 Commit-Queue: Tom Sepez --- fpdfsdk/fpdf_doc_unittest.cpp | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'fpdfsdk/fpdf_doc_unittest.cpp') 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(2); array->SetNewAt(3); array->SetNewAt(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(); - 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)); } -- cgit v1.2.3