summaryrefslogtreecommitdiff
path: root/core/fpdfdoc/cpdf_dest_unittest.cpp
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2017-05-23 17:10:46 -0700
committerChromium commit bot <commit-bot@chromium.org>2017-05-24 00:49:21 +0000
commit655c783b8077f18e17418a3aab9b5a07c8055049 (patch)
treee121b850ead5af67156b126c2e8d2fdcfa4be6a9 /core/fpdfdoc/cpdf_dest_unittest.cpp
parent6f3593c5cdf62915fc086448312671ce1fce5291 (diff)
downloadpdfium-655c783b8077f18e17418a3aab9b5a07c8055049.tar.xz
Convert to CFX_UnownedPtr, part 3.
Remove an explicit clear to re-order the member destruction order. Change-Id: I33da3f3de4b8e8e0cfbdceaf5140e98f5d6f904a Reviewed-on: https://pdfium-review.googlesource.com/5791 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'core/fpdfdoc/cpdf_dest_unittest.cpp')
-rw-r--r--core/fpdfdoc/cpdf_dest_unittest.cpp59
1 files changed, 32 insertions, 27 deletions
diff --git a/core/fpdfdoc/cpdf_dest_unittest.cpp b/core/fpdfdoc/cpdf_dest_unittest.cpp
index 7c35371085..2b3c86a882 100644
--- a/core/fpdfdoc/cpdf_dest_unittest.cpp
+++ b/core/fpdfdoc/cpdf_dest_unittest.cpp
@@ -19,43 +19,48 @@ TEST(cpdf_dest, GetXYZ) {
float y;
float zoom;
- auto dest = pdfium::MakeUnique<CPDF_Dest>();
- EXPECT_FALSE(dest->GetXYZ(&hasX, &hasY, &hasZoom, &x, &y, &zoom));
-
+ // |array| must outlive |dest|.
auto array = pdfium::MakeUnique<CPDF_Array>();
array->AddNew<CPDF_Number>(0); // Page Index.
array->AddNew<CPDF_Name>("XYZ");
array->AddNew<CPDF_Number>(4); // X
-
- // Not enough entries.
- dest = pdfium::MakeUnique<CPDF_Dest>(array.get());
- EXPECT_FALSE(dest->GetXYZ(&hasX, &hasY, &hasZoom, &x, &y, &zoom));
-
+ {
+ auto dest = pdfium::MakeUnique<CPDF_Dest>();
+ EXPECT_FALSE(dest->GetXYZ(&hasX, &hasY, &hasZoom, &x, &y, &zoom));
+ }
+ {
+ // Not enough entries.
+ auto dest = pdfium::MakeUnique<CPDF_Dest>(array.get());
+ EXPECT_FALSE(dest->GetXYZ(&hasX, &hasY, &hasZoom, &x, &y, &zoom));
+ }
array->AddNew<CPDF_Number>(5); // Y
array->AddNew<CPDF_Number>(6); // Zoom.
-
- dest = pdfium::MakeUnique<CPDF_Dest>(array.get());
- EXPECT_TRUE(dest->GetXYZ(&hasX, &hasY, &hasZoom, &x, &y, &zoom));
- EXPECT_TRUE(hasX);
- EXPECT_TRUE(hasY);
- EXPECT_TRUE(hasZoom);
- EXPECT_EQ(4, x);
- EXPECT_EQ(5, y);
- EXPECT_EQ(6, zoom);
-
+ {
+ auto dest = pdfium::MakeUnique<CPDF_Dest>(array.get());
+ EXPECT_TRUE(dest->GetXYZ(&hasX, &hasY, &hasZoom, &x, &y, &zoom));
+ EXPECT_TRUE(hasX);
+ EXPECT_TRUE(hasY);
+ EXPECT_TRUE(hasZoom);
+ EXPECT_EQ(4, x);
+ EXPECT_EQ(5, y);
+ EXPECT_EQ(6, zoom);
+ }
// Set zoom to 0.
array->SetNewAt<CPDF_Number>(4, 0);
- dest = pdfium::MakeUnique<CPDF_Dest>(array.get());
- EXPECT_TRUE(dest->GetXYZ(&hasX, &hasY, &hasZoom, &x, &y, &zoom));
- EXPECT_FALSE(hasZoom);
-
+ {
+ auto dest = pdfium::MakeUnique<CPDF_Dest>(array.get());
+ EXPECT_TRUE(dest->GetXYZ(&hasX, &hasY, &hasZoom, &x, &y, &zoom));
+ EXPECT_FALSE(hasZoom);
+ }
// Set values to null.
array->SetNewAt<CPDF_Null>(2);
array->SetNewAt<CPDF_Null>(3);
array->SetNewAt<CPDF_Null>(4);
- dest = pdfium::MakeUnique<CPDF_Dest>(array.get());
- EXPECT_TRUE(dest->GetXYZ(&hasX, &hasY, &hasZoom, &x, &y, &zoom));
- EXPECT_FALSE(hasX);
- EXPECT_FALSE(hasY);
- EXPECT_FALSE(hasZoom);
+ {
+ auto dest = pdfium::MakeUnique<CPDF_Dest>(array.get());
+ EXPECT_TRUE(dest->GetXYZ(&hasX, &hasY, &hasZoom, &x, &y, &zoom));
+ EXPECT_FALSE(hasX);
+ EXPECT_FALSE(hasY);
+ EXPECT_FALSE(hasZoom);
+ }
}