diff options
author | Artem Strygin <art-snake@yandex-team.ru> | 2018-06-11 18:19:57 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-06-11 18:19:57 +0000 |
commit | fb72726e51bfd0c7bfc61c9b354e2b60f46adac5 (patch) | |
tree | b2a763c74a07b081a4b176c18c42569e377d6fc8 /core/fpdfapi/parser/cpdf_object_unittest.cpp | |
parent | 5e873f5ce8e407c97e966b9708d2560e908112d3 (diff) | |
download | pdfium-chromium/3456.tar.xz |
Implement CPDF_Object::MakeReference method.chromium/3456
Change-Id: I153747ef587a184eaef58ff09dbf8f214c9ddfb3
Reviewed-on: https://pdfium-review.googlesource.com/17230
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Art Snake <art-snake@yandex-team.ru>
Diffstat (limited to 'core/fpdfapi/parser/cpdf_object_unittest.cpp')
-rw-r--r-- | core/fpdfapi/parser/cpdf_object_unittest.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/core/fpdfapi/parser/cpdf_object_unittest.cpp b/core/fpdfapi/parser/cpdf_object_unittest.cpp index 856dd0ac3b..78a0af7299 100644 --- a/core/fpdfapi/parser/cpdf_object_unittest.cpp +++ b/core/fpdfapi/parser/cpdf_object_unittest.cpp @@ -393,6 +393,18 @@ TEST_F(PDFObjectsTest, IsTypeAndAsType) { } } +TEST_F(PDFObjectsTest, MakeReferenceGeneric) { + auto original_obj = pdfium::MakeUnique<CPDF_Null>(); + original_obj->SetObjNum(42); + ASSERT_FALSE(original_obj->IsInline()); + + auto ref_obj = original_obj->MakeReference(m_ObjHolder.get()); + + ASSERT_TRUE(ref_obj->IsReference()); + EXPECT_EQ(original_obj->GetObjNum(), + ToReference(ref_obj.get())->GetRefObjNum()); +} + TEST(PDFArrayTest, GetMatrix) { float elems[][6] = {{0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, {1, 2, 3, 4, 5, 6}, @@ -971,3 +983,18 @@ TEST(PDFDictionaryTest, ExtractObjectOnRemove) { extracted_object = dict->RemoveFor("non_exists_object"); EXPECT_FALSE(extracted_object); } + +TEST(PDFRefernceTest, MakeReferenceToReference) { + auto obj_holder = pdfium::MakeUnique<CPDF_IndirectObjectHolder>(); + auto original_ref = pdfium::MakeUnique<CPDF_Reference>(obj_holder.get(), 42); + original_ref->SetObjNum(1952); + ASSERT_FALSE(original_ref->IsInline()); + + auto ref_obj = original_ref->MakeReference(obj_holder.get()); + + ASSERT_TRUE(ref_obj->IsReference()); + // We do not allow reference to reference. + // New reference should have same RefObjNum. + EXPECT_EQ(original_ref->GetRefObjNum(), + ToReference(ref_obj.get())->GetRefObjNum()); +} |