OLD | NEW |
1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "public/fpdf_doc.h" | 5 #include "public/fpdf_doc.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "core/fpdfapi/cpdf_modulemgr.h" | 10 #include "core/fpdfapi/cpdf_modulemgr.h" |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 EXPECT_EQ(nullptr, FPDFBookmark_Find(m_pDoc.get(), title.get())); | 229 EXPECT_EQ(nullptr, FPDFBookmark_Find(m_pDoc.get(), title.get())); |
230 | 230 |
231 // Title with a match. | 231 // Title with a match. |
232 title = GetFPDFWideString(L"Chapter 3"); | 232 title = GetFPDFWideString(L"Chapter 3"); |
233 EXPECT_EQ(bookmarks[3].obj, FPDFBookmark_Find(m_pDoc.get(), title.get())); | 233 EXPECT_EQ(bookmarks[3].obj, FPDFBookmark_Find(m_pDoc.get(), title.get())); |
234 } | 234 } |
235 } | 235 } |
236 | 236 |
237 TEST_F(PDFDocTest, GetLocationInPage) { | 237 TEST_F(PDFDocTest, GetLocationInPage) { |
238 auto array = pdfium::MakeUnique<CPDF_Array>(); | 238 auto array = pdfium::MakeUnique<CPDF_Array>(); |
239 array->AddInteger(0); // Page Index. | 239 array->AddNew<CPDF_Number>(0); // Page Index. |
240 array->AddName("XYZ"); | 240 array->AddNew<CPDF_Name>("XYZ"); |
241 array->AddNumber(4); // X | 241 array->AddNew<CPDF_Number>(4); // X |
242 array->AddNumber(5); // Y | 242 array->AddNew<CPDF_Number>(5); // Y |
243 array->AddNumber(6); // Zoom. | 243 array->AddNew<CPDF_Number>(6); // Zoom. |
244 | 244 |
245 FPDF_BOOL hasX; | 245 FPDF_BOOL hasX; |
246 FPDF_BOOL hasY; | 246 FPDF_BOOL hasY; |
247 FPDF_BOOL hasZoom; | 247 FPDF_BOOL hasZoom; |
248 FS_FLOAT x; | 248 FS_FLOAT x; |
249 FS_FLOAT y; | 249 FS_FLOAT y; |
250 FS_FLOAT zoom; | 250 FS_FLOAT zoom; |
251 | 251 |
252 EXPECT_TRUE(FPDFDest_GetLocationInPage(array.get(), &hasX, &hasY, &hasZoom, | 252 EXPECT_TRUE(FPDFDest_GetLocationInPage(array.get(), &hasX, &hasY, &hasZoom, |
253 &x, &y, &zoom)); | 253 &x, &y, &zoom)); |
254 EXPECT_TRUE(hasX); | 254 EXPECT_TRUE(hasX); |
255 EXPECT_TRUE(hasY); | 255 EXPECT_TRUE(hasY); |
256 EXPECT_TRUE(hasZoom); | 256 EXPECT_TRUE(hasZoom); |
257 EXPECT_EQ(4, x); | 257 EXPECT_EQ(4, x); |
258 EXPECT_EQ(5, y); | 258 EXPECT_EQ(5, y); |
259 EXPECT_EQ(6, zoom); | 259 EXPECT_EQ(6, zoom); |
260 | 260 |
261 array->SetAt(2, new CPDF_Null); | 261 array->SetNewAt<CPDF_Null>(2); |
262 array->SetAt(3, new CPDF_Null); | 262 array->SetNewAt<CPDF_Null>(3); |
263 array->SetAt(4, new CPDF_Null); | 263 array->SetNewAt<CPDF_Null>(4); |
264 EXPECT_TRUE(FPDFDest_GetLocationInPage(array.get(), &hasX, &hasY, &hasZoom, | 264 EXPECT_TRUE(FPDFDest_GetLocationInPage(array.get(), &hasX, &hasY, &hasZoom, |
265 &x, &y, &zoom)); | 265 &x, &y, &zoom)); |
266 EXPECT_FALSE(hasX); | 266 EXPECT_FALSE(hasX); |
267 EXPECT_FALSE(hasY); | 267 EXPECT_FALSE(hasY); |
268 EXPECT_FALSE(hasZoom); | 268 EXPECT_FALSE(hasZoom); |
269 | 269 |
270 array = pdfium::MakeUnique<CPDF_Array>(); | 270 array = pdfium::MakeUnique<CPDF_Array>(); |
271 EXPECT_FALSE(FPDFDest_GetLocationInPage(array.get(), &hasX, &hasY, &hasZoom, | 271 EXPECT_FALSE(FPDFDest_GetLocationInPage(array.get(), &hasX, &hasY, &hasZoom, |
272 &x, &y, &zoom)); | 272 &x, &y, &zoom)); |
273 } | 273 } |
OLD | NEW |