summaryrefslogtreecommitdiff
path: root/fpdfsdk/fpdfattachment_embeddertest.cpp
diff options
context:
space:
mode:
authorJane Liu <janeliulwq@google.com>2017-07-12 19:55:02 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-07-13 14:07:05 +0000
commit53aafa99985e93c527ea2803400f250025cc7f01 (patch)
treed7a9597118a377baf9fe296b42d7baa48cca1ee0 /fpdfsdk/fpdfattachment_embeddertest.cpp
parent0b6e9aed1756d19ed812895208be5cae5633325b (diff)
downloadpdfium-53aafa99985e93c527ea2803400f250025cc7f01.tar.xz
Basic APIs and test for retrieving embedded attachment count and name
1. Added APIs for retrieving embedded attachment count and file name. * Added an embedder test testing them. Bug=pdfium:174 Change-Id: I181b8e0b81495d8a7fd8c3f79dbbc0f907f5e3fd Reviewed-on: https://pdfium-review.googlesource.com/7490 Commit-Queue: Jane Liu <janeliulwq@google.com> Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'fpdfsdk/fpdfattachment_embeddertest.cpp')
-rw-r--r--fpdfsdk/fpdfattachment_embeddertest.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/fpdfsdk/fpdfattachment_embeddertest.cpp b/fpdfsdk/fpdfattachment_embeddertest.cpp
new file mode 100644
index 0000000000..2cbda8a429
--- /dev/null
+++ b/fpdfsdk/fpdfattachment_embeddertest.cpp
@@ -0,0 +1,22 @@
+// Copyright 2017 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "public/fpdf_attachment.h"
+#include "testing/embedder_test.h"
+
+class FPDFAttachmentEmbeddertest : public EmbedderTest {};
+
+TEST_F(FPDFAttachmentEmbeddertest, ExtractAttachments) {
+ // Open a file with two attachments.
+ ASSERT_TRUE(OpenDocument("embedded_attachments.pdf"));
+ EXPECT_EQ(2, FPDFDoc_GetAttachmentCount(document()));
+
+ // Check that the name of the first attachment is correct.
+ unsigned long len = FPDFDoc_GetAttachmentName(document(), 0, nullptr, 0);
+ std::vector<char> buf(len);
+ EXPECT_EQ(12u, FPDFDoc_GetAttachmentName(document(), 0, buf.data(), len));
+ EXPECT_STREQ(L"1.txt",
+ GetPlatformWString(reinterpret_cast<unsigned short*>(buf.data()))
+ .c_str());
+}