Lines Matching defs:attachment

23   // Retrieve the first attachment.
24 FPDF_ATTACHMENT attachment = FPDFDoc_GetAttachment(document(), 0);
25 ASSERT_TRUE(attachment);
27 // Check that the name of the first attachment is correct.
28 unsigned long len = FPDFAttachment_GetName(attachment, nullptr, 0);
30 EXPECT_EQ(12u, FPDFAttachment_GetName(attachment, buf.data(), len));
35 // Check that the content of the first attachment is correct.
36 len = FPDFAttachment_GetFile(attachment, nullptr, 0);
39 ASSERT_EQ(4u, FPDFAttachment_GetFile(attachment, buf.data(), len));
43 EXPECT_FALSE(FPDFAttachment_HasKey(attachment, "none"));
48 FPDFAttachment_GetValueType(attachment, kSizeKey));
50 FPDFAttachment_GetStringValue(attachment, kSizeKey, nullptr, 0));
52 // Check that the creation date of the first attachment is correct.
53 len = FPDFAttachment_GetStringValue(attachment, kDateKey, nullptr, 0);
56 EXPECT_EQ(48u, FPDFAttachment_GetStringValue(attachment, kDateKey, buf.data(),
62 // Retrieve the second attachment.
63 attachment = FPDFDoc_GetAttachment(document(), 1);
64 ASSERT_TRUE(attachment);
66 // Retrieve the second attachment file.
67 len = FPDFAttachment_GetFile(attachment, nullptr, 0);
70 EXPECT_EQ(5869u, FPDFAttachment_GetFile(attachment, buf.data(), len));
80 len = FPDFAttachment_GetStringValue(attachment, kChecksumKey, nullptr, 0);
83 EXPECT_EQ(70u, FPDFAttachment_GetStringValue(attachment, kChecksumKey,
94 // Check that adding an attachment with an empty name would fail.
97 // Add an attachment to the beginning of the embedded file list.
100 FPDF_ATTACHMENT attachment =
104 EXPECT_FALSE(FPDFAttachment_SetFile(attachment, document(), nullptr, 10));
106 // Set the new attachment's file.
108 EXPECT_TRUE(FPDFAttachment_SetFile(attachment, document(), kContents1,
111 // Verify the name of the new attachment (i.e. the first attachment).
112 attachment = FPDFDoc_GetAttachment(document(), 0);
113 ASSERT_TRUE(attachment);
114 unsigned long len = FPDFAttachment_GetName(attachment, nullptr, 0);
116 EXPECT_EQ(12u, FPDFAttachment_GetName(attachment, buf.data(), len));
121 // Verify the content of the new attachment (i.e. the first attachment).
122 len = FPDFAttachment_GetFile(attachment, nullptr, 0);
125 ASSERT_EQ(6u, FPDFAttachment_GetFile(attachment, buf.data(), len));
128 // Add an attachment to the end of the embedded file list and set its file.
130 attachment = FPDFDoc_AddAttachment(document(), file_name.get());
132 EXPECT_TRUE(FPDFAttachment_SetFile(attachment, document(), kContents2,
136 // Verify the name of the new attachment (i.e. the fourth attachment).
137 attachment = FPDFDoc_GetAttachment(document(), 3);
138 ASSERT_TRUE(attachment);
139 len = FPDFAttachment_GetName(attachment, nullptr, 0);
142 EXPECT_EQ(12u, FPDFAttachment_GetName(attachment, buf.data(), len));
147 // Verify the content of the new attachment (i.e. the fourth attachment).
148 len = FPDFAttachment_GetFile(attachment, nullptr, 0);
151 ASSERT_EQ(6u, FPDFAttachment_GetFile(attachment, buf.data(), len));
160 // Add an attachment to the embedded file list.
163 FPDF_ATTACHMENT attachment =
166 EXPECT_TRUE(FPDFAttachment_SetFile(attachment, document(), kContents,
174 FPDFAttachment_SetStringValue(attachment, kDateKey, ws_date.get()));
180 EXPECT_TRUE(FPDFAttachment_SetStringValue(attachment, kChecksumKey,
183 // Verify the name of the new attachment (i.e. the second attachment).
184 attachment = FPDFDoc_GetAttachment(document(), 1);
185 ASSERT_TRUE(attachment);
186 unsigned long len = FPDFAttachment_GetName(attachment, nullptr, 0);
188 EXPECT_EQ(12u, FPDFAttachment_GetName(attachment, buf.data(), len));
193 // Verify the content of the new attachment.
194 len = FPDFAttachment_GetFile(attachment, nullptr, 0);
197 ASSERT_EQ(12u, FPDFAttachment_GetFile(attachment, buf.data(), len));
200 // Verify the creation date of the new attachment.
201 len = FPDFAttachment_GetStringValue(attachment, kDateKey, nullptr, 0);
204 EXPECT_EQ(48u, FPDFAttachment_GetStringValue(attachment, kDateKey, buf.data(),
210 // Verify the checksum of the new attachment.
211 len = FPDFAttachment_GetStringValue(attachment, kChecksumKey, nullptr, 0);
214 EXPECT_EQ(70u, FPDFAttachment_GetStringValue(attachment, kChecksumKey,
222 EXPECT_TRUE(FPDFAttachment_SetFile(attachment, document(), nullptr, 0));
223 EXPECT_EQ(0u, FPDFAttachment_GetFile(attachment, nullptr, 0));
224 len = FPDFAttachment_GetStringValue(attachment, kChecksumKey, nullptr, 0);
227 EXPECT_EQ(70u, FPDFAttachment_GetStringValue(attachment, kChecksumKey,
238 // Verify the name of the first attachment.
239 FPDF_ATTACHMENT attachment = FPDFDoc_GetAttachment(document(), 0);
240 unsigned long len = FPDFAttachment_GetName(attachment, nullptr, 0);
242 EXPECT_EQ(12u, FPDFAttachment_GetName(attachment, buf.data(), len));
247 // Delete the first attachment.
251 // Verify the name of the new first attachment.
252 attachment = FPDFDoc_GetAttachment(document(), 0);
253 len = FPDFAttachment_GetName(attachment, nullptr, 0);
256 EXPECT_EQ(26u, FPDFAttachment_GetName(attachment, buf.data(), len));