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

Side by Side Diff: fpdfsdk/fpdfdoc_embeddertest.cpp

Issue 2481743004: Add FPDFDest_GetLocationInPage API (Closed)
Patch Set: Review feedback Created 4 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « fpdfsdk/fpdfdoc.cpp ('k') | fpdfsdk/fpdfdoc_unittest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 PDFium Authors. All rights reserved. 1 // Copyright 2015 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 <string> 5 #include <string>
6 6
7 #include "core/fxcrt/fx_string.h" 7 #include "core/fxcrt/fx_string.h"
8 #include "public/fpdf_doc.h" 8 #include "public/fpdf_doc.h"
9 #include "public/fpdf_edit.h" 9 #include "public/fpdf_edit.h"
10 #include "public/fpdfview.h" 10 #include "public/fpdfview.h"
(...skipping 24 matching lines...) Expand all
35 dest = FPDF_GetNamedDestByName(document(), "FirstAlternate"); 35 dest = FPDF_GetNamedDestByName(document(), "FirstAlternate");
36 EXPECT_TRUE(dest); 36 EXPECT_TRUE(dest);
37 EXPECT_EQ(11U, FPDFDest_GetPageIndex(document(), dest)); 37 EXPECT_EQ(11U, FPDFDest_GetPageIndex(document(), dest));
38 38
39 // Invalid object reference in item from Dests NameTree. 39 // Invalid object reference in item from Dests NameTree.
40 dest = FPDF_GetNamedDestByName(document(), "LastAlternate"); 40 dest = FPDF_GetNamedDestByName(document(), "LastAlternate");
41 EXPECT_TRUE(dest); 41 EXPECT_TRUE(dest);
42 EXPECT_EQ(0U, FPDFDest_GetPageIndex(document(), dest)); 42 EXPECT_EQ(0U, FPDFDest_GetPageIndex(document(), dest));
43 } 43 }
44 44
45 TEST_F(FPDFDocEmbeddertest, DestGetLocationInPage) {
46 EXPECT_TRUE(OpenDocument("named_dests.pdf"));
47
48 // NULL FPDF_DEST case.
49 EXPECT_EQ(0U, FPDFDest_GetPageIndex(document(), nullptr));
50
51 FPDF_DEST dest = FPDF_GetNamedDestByName(document(), "First");
52 EXPECT_TRUE(dest);
53
54 FPDF_BOOL hasX;
55 FPDF_BOOL hasY;
56 FPDF_BOOL hasZoom;
57 FS_FLOAT x;
58 FS_FLOAT y;
59 FS_FLOAT zoom;
60 EXPECT_TRUE(
61 FPDFDest_GetLocationInPage(dest, &hasX, &hasY, &hasZoom, &x, &y, &zoom));
62 EXPECT_TRUE(hasX);
63 EXPECT_TRUE(hasY);
64 EXPECT_TRUE(hasZoom);
65 EXPECT_EQ(0, x);
66 EXPECT_EQ(0, y);
67 EXPECT_EQ(1, zoom);
68 }
69
45 TEST_F(FPDFDocEmbeddertest, ActionGetFilePath) { 70 TEST_F(FPDFDocEmbeddertest, ActionGetFilePath) {
46 EXPECT_TRUE(OpenDocument("launch_action.pdf")); 71 EXPECT_TRUE(OpenDocument("launch_action.pdf"));
47 72
48 FPDF_PAGE page = FPDF_LoadPage(document(), 0); 73 FPDF_PAGE page = FPDF_LoadPage(document(), 0);
49 ASSERT_TRUE(page); 74 ASSERT_TRUE(page);
50 75
51 // The target action is nearly the size of the whole page. 76 // The target action is nearly the size of the whole page.
52 FPDF_LINK link = FPDFLink_GetLinkAtPoint(page, 100, 100); 77 FPDF_LINK link = FPDFLink_GetLinkAtPoint(page, 100, 100);
53 ASSERT_TRUE(link); 78 ASSERT_TRUE(link);
54 79
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 GetFPDFWideString(L"anything"); 164 GetFPDFWideString(L"anything");
140 EXPECT_EQ(nullptr, FPDFBookmark_Find(document(), title.get())); 165 EXPECT_EQ(nullptr, FPDFBookmark_Find(document(), title.get()));
141 } 166 }
142 167
143 TEST_F(FPDFDocEmbeddertest, DeletePage) { 168 TEST_F(FPDFDocEmbeddertest, DeletePage) {
144 EXPECT_TRUE(OpenDocument("hello_world.pdf")); 169 EXPECT_TRUE(OpenDocument("hello_world.pdf"));
145 EXPECT_EQ(1, FPDF_GetPageCount(document())); 170 EXPECT_EQ(1, FPDF_GetPageCount(document()));
146 FPDFPage_Delete(document(), 0); 171 FPDFPage_Delete(document(), 0);
147 EXPECT_EQ(0, FPDF_GetPageCount(document())); 172 EXPECT_EQ(0, FPDF_GetPageCount(document()));
148 } 173 }
OLDNEW
« no previous file with comments | « fpdfsdk/fpdfdoc.cpp ('k') | fpdfsdk/fpdfdoc_unittest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698