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

Side by Side Diff: fpdfsdk/fpdfdoc_embeddertest.cpp

Issue 2521843003: Add API for getting page labels. (Closed)
Patch Set: Add tests, distinguish between failure and empty label Created 4 years 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/fpdfview_c_api_test.c » ('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 <memory> 5 #include <memory>
6 #include <string> 6 #include <string>
7 7
8 #include "core/fxcrt/fx_string.h" 8 #include "core/fxcrt/fx_string.h"
9 #include "public/fpdf_doc.h" 9 #include "public/fpdf_doc.h"
10 #include "public/fpdf_edit.h" 10 #include "public/fpdf_edit.h"
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 GetFPDFWideString(L"anything"); 165 GetFPDFWideString(L"anything");
166 EXPECT_EQ(nullptr, FPDFBookmark_Find(document(), title.get())); 166 EXPECT_EQ(nullptr, FPDFBookmark_Find(document(), title.get()));
167 } 167 }
168 168
169 TEST_F(FPDFDocEmbeddertest, DeletePage) { 169 TEST_F(FPDFDocEmbeddertest, DeletePage) {
170 EXPECT_TRUE(OpenDocument("hello_world.pdf")); 170 EXPECT_TRUE(OpenDocument("hello_world.pdf"));
171 EXPECT_EQ(1, FPDF_GetPageCount(document())); 171 EXPECT_EQ(1, FPDF_GetPageCount(document()));
172 FPDFPage_Delete(document(), 0); 172 FPDFPage_Delete(document(), 0);
173 EXPECT_EQ(0, FPDF_GetPageCount(document())); 173 EXPECT_EQ(0, FPDF_GetPageCount(document()));
174 } 174 }
175
176 TEST_F(FPDFDocEmbeddertest, NoPageLabels) {
177 EXPECT_TRUE(OpenDocument("about_blank.pdf"));
178 EXPECT_EQ(1, FPDF_GetPageCount(document()));
179
180 ASSERT_EQ(0u, FPDF_GetPagelLabel(document(), 0, nullptr, 0));
181 }
182
183 TEST_F(FPDFDocEmbeddertest, GetPageLabels) {
184 EXPECT_TRUE(OpenDocument("page_labels.pdf"));
Lei Zhang 2016/11/23 01:53:42 Created in Acrobat.
185 EXPECT_EQ(7, FPDF_GetPageCount(document()));
186
187 unsigned short buf[128];
188 EXPECT_EQ(0u, FPDF_GetPagelLabel(document(), -2, buf, sizeof(buf)));
189 EXPECT_EQ(0u, FPDF_GetPagelLabel(document(), -1, buf, sizeof(buf)));
190
191 const FX_WCHAR kExpectedPageLabel0[] = L"i";
192 ASSERT_EQ(4u, FPDF_GetPagelLabel(document(), 0, buf, sizeof(buf)));
193 EXPECT_EQ(CFX_WideString(kExpectedPageLabel0),
194 CFX_WideString::FromUTF16LE(buf, FXSYS_len(kExpectedPageLabel0)));
195
196 const FX_WCHAR kExpectedPageLabel1[] = L"ii";
197 ASSERT_EQ(6u, FPDF_GetPagelLabel(document(), 1, buf, sizeof(buf)));
198 EXPECT_EQ(CFX_WideString(kExpectedPageLabel1),
199 CFX_WideString::FromUTF16LE(buf, FXSYS_len(kExpectedPageLabel1)));
200
201 const FX_WCHAR kExpectedPageLabel2[] = L"1";
202 ASSERT_EQ(4u, FPDF_GetPagelLabel(document(), 2, buf, sizeof(buf)));
203 EXPECT_EQ(CFX_WideString(kExpectedPageLabel2),
204 CFX_WideString::FromUTF16LE(buf, FXSYS_len(kExpectedPageLabel2)));
205
206 const FX_WCHAR kExpectedPageLabel3[] = L"2";
207 ASSERT_EQ(4u, FPDF_GetPagelLabel(document(), 3, buf, sizeof(buf)));
208 EXPECT_EQ(CFX_WideString(kExpectedPageLabel3),
209 CFX_WideString::FromUTF16LE(buf, FXSYS_len(kExpectedPageLabel3)));
210
211 const FX_WCHAR kExpectedPageLabel4[] = L"zzA";
212 ASSERT_EQ(8u, FPDF_GetPagelLabel(document(), 4, buf, sizeof(buf)));
213 EXPECT_EQ(CFX_WideString(kExpectedPageLabel4),
214 CFX_WideString::FromUTF16LE(buf, FXSYS_len(kExpectedPageLabel4)));
215
216 const FX_WCHAR kExpectedPageLabel5[] = L"zzB";
217 ASSERT_EQ(8u, FPDF_GetPagelLabel(document(), 5, buf, sizeof(buf)));
218 EXPECT_EQ(CFX_WideString(kExpectedPageLabel5),
219 CFX_WideString::FromUTF16LE(buf, FXSYS_len(kExpectedPageLabel5)));
220
221 const FX_WCHAR kExpectedPageLabel6[] = L"";
222 ASSERT_EQ(2u, FPDF_GetPagelLabel(document(), 6, buf, sizeof(buf)));
223 EXPECT_EQ(CFX_WideString(kExpectedPageLabel6),
224 CFX_WideString::FromUTF16LE(buf, FXSYS_len(kExpectedPageLabel6)));
225
226 ASSERT_EQ(0u, FPDF_GetPagelLabel(document(), 7, buf, sizeof(buf)));
227 ASSERT_EQ(0u, FPDF_GetPagelLabel(document(), 8, buf, sizeof(buf)));
228 }
OLDNEW
« no previous file with comments | « fpdfsdk/fpdfdoc.cpp ('k') | fpdfsdk/fpdfview_c_api_test.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698