summaryrefslogtreecommitdiff
path: root/fpdfsdk/fpdfdoc_embeddertest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'fpdfsdk/fpdfdoc_embeddertest.cpp')
-rw-r--r--fpdfsdk/fpdfdoc_embeddertest.cpp54
1 files changed, 54 insertions, 0 deletions
diff --git a/fpdfsdk/fpdfdoc_embeddertest.cpp b/fpdfsdk/fpdfdoc_embeddertest.cpp
index d7f1f97117..67934c5626 100644
--- a/fpdfsdk/fpdfdoc_embeddertest.cpp
+++ b/fpdfsdk/fpdfdoc_embeddertest.cpp
@@ -172,3 +172,57 @@ TEST_F(FPDFDocEmbeddertest, DeletePage) {
FPDFPage_Delete(document(), 0);
EXPECT_EQ(0, FPDF_GetPageCount(document()));
}
+
+TEST_F(FPDFDocEmbeddertest, NoPageLabels) {
+ EXPECT_TRUE(OpenDocument("about_blank.pdf"));
+ EXPECT_EQ(1, FPDF_GetPageCount(document()));
+
+ ASSERT_EQ(0u, FPDF_GetPagelLabel(document(), 0, nullptr, 0));
+}
+
+TEST_F(FPDFDocEmbeddertest, GetPageLabels) {
+ EXPECT_TRUE(OpenDocument("page_labels.pdf"));
+ EXPECT_EQ(7, FPDF_GetPageCount(document()));
+
+ unsigned short buf[128];
+ EXPECT_EQ(0u, FPDF_GetPagelLabel(document(), -2, buf, sizeof(buf)));
+ EXPECT_EQ(0u, FPDF_GetPagelLabel(document(), -1, buf, sizeof(buf)));
+
+ const FX_WCHAR kExpectedPageLabel0[] = L"i";
+ ASSERT_EQ(4u, FPDF_GetPagelLabel(document(), 0, buf, sizeof(buf)));
+ EXPECT_EQ(CFX_WideString(kExpectedPageLabel0),
+ CFX_WideString::FromUTF16LE(buf, FXSYS_len(kExpectedPageLabel0)));
+
+ const FX_WCHAR kExpectedPageLabel1[] = L"ii";
+ ASSERT_EQ(6u, FPDF_GetPagelLabel(document(), 1, buf, sizeof(buf)));
+ EXPECT_EQ(CFX_WideString(kExpectedPageLabel1),
+ CFX_WideString::FromUTF16LE(buf, FXSYS_len(kExpectedPageLabel1)));
+
+ const FX_WCHAR kExpectedPageLabel2[] = L"1";
+ ASSERT_EQ(4u, FPDF_GetPagelLabel(document(), 2, buf, sizeof(buf)));
+ EXPECT_EQ(CFX_WideString(kExpectedPageLabel2),
+ CFX_WideString::FromUTF16LE(buf, FXSYS_len(kExpectedPageLabel2)));
+
+ const FX_WCHAR kExpectedPageLabel3[] = L"2";
+ ASSERT_EQ(4u, FPDF_GetPagelLabel(document(), 3, buf, sizeof(buf)));
+ EXPECT_EQ(CFX_WideString(kExpectedPageLabel3),
+ CFX_WideString::FromUTF16LE(buf, FXSYS_len(kExpectedPageLabel3)));
+
+ const FX_WCHAR kExpectedPageLabel4[] = L"zzA";
+ ASSERT_EQ(8u, FPDF_GetPagelLabel(document(), 4, buf, sizeof(buf)));
+ EXPECT_EQ(CFX_WideString(kExpectedPageLabel4),
+ CFX_WideString::FromUTF16LE(buf, FXSYS_len(kExpectedPageLabel4)));
+
+ const FX_WCHAR kExpectedPageLabel5[] = L"zzB";
+ ASSERT_EQ(8u, FPDF_GetPagelLabel(document(), 5, buf, sizeof(buf)));
+ EXPECT_EQ(CFX_WideString(kExpectedPageLabel5),
+ CFX_WideString::FromUTF16LE(buf, FXSYS_len(kExpectedPageLabel5)));
+
+ const FX_WCHAR kExpectedPageLabel6[] = L"";
+ ASSERT_EQ(2u, FPDF_GetPagelLabel(document(), 6, buf, sizeof(buf)));
+ EXPECT_EQ(CFX_WideString(kExpectedPageLabel6),
+ CFX_WideString::FromUTF16LE(buf, FXSYS_len(kExpectedPageLabel6)));
+
+ ASSERT_EQ(0u, FPDF_GetPagelLabel(document(), 7, buf, sizeof(buf)));
+ ASSERT_EQ(0u, FPDF_GetPagelLabel(document(), 8, buf, sizeof(buf)));
+}