Jane Liu | 53aafa9 | 2017-07-12 19:55:02 -0400 | [diff] [blame^] | 1 | // Copyright 2017 PDFium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "public/fpdf_attachment.h" |
| 6 | #include "testing/embedder_test.h" |
| 7 | |
| 8 | class FPDFAttachmentEmbeddertest : public EmbedderTest {}; |
| 9 | |
| 10 | TEST_F(FPDFAttachmentEmbeddertest, ExtractAttachments) { |
| 11 | // Open a file with two attachments. |
| 12 | ASSERT_TRUE(OpenDocument("embedded_attachments.pdf")); |
| 13 | EXPECT_EQ(2, FPDFDoc_GetAttachmentCount(document())); |
| 14 | |
| 15 | // Check that the name of the first attachment is correct. |
| 16 | unsigned long len = FPDFDoc_GetAttachmentName(document(), 0, nullptr, 0); |
| 17 | std::vector<char> buf(len); |
| 18 | EXPECT_EQ(12u, FPDFDoc_GetAttachmentName(document(), 0, buf.data(), len)); |
| 19 | EXPECT_STREQ(L"1.txt", |
| 20 | GetPlatformWString(reinterpret_cast<unsigned short*>(buf.data())) |
| 21 | .c_str()); |
| 22 | } |