Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
cpdf_dest_unittest.cpp
Go to the documentation of this file.
1// Copyright 2016 The PDFium Authors
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 "core/fpdfdoc/cpdf_dest.h"
6
7#include <memory>
8
9#include "core/fpdfapi/parser/cpdf_array.h"
10#include "core/fpdfapi/parser/cpdf_name.h"
11#include "core/fpdfapi/parser/cpdf_null.h"
12#include "core/fpdfapi/parser/cpdf_number.h"
13#include "testing/gtest/include/gtest/gtest.h"
14
16 bool hasX;
17 bool hasY;
18 bool hasZoom;
19 float x;
20 float y;
21 float zoom;
22
23 // |array| must outlive |dest|.
24 auto array = pdfium::MakeRetain<CPDF_Array>();
25 array->AppendNew<CPDF_Number>(0); // Page Index.
26 array->AppendNew<CPDF_Name>("XYZ");
27 array->AppendNew<CPDF_Number>(4); // X
28 {
29 CPDF_Dest dest(nullptr);
30 EXPECT_FALSE(dest.GetXYZ(&hasX, &hasY, &hasZoom, &x, &y, &zoom));
31 }
32 {
33 // Not enough entries.
34 CPDF_Dest dest(array);
35 EXPECT_FALSE(dest.GetXYZ(&hasX, &hasY, &hasZoom, &x, &y, &zoom));
36 }
37 array->AppendNew<CPDF_Number>(5); // Y
38 array->AppendNew<CPDF_Number>(6); // Zoom.
39 {
40 CPDF_Dest dest(array);
41 EXPECT_TRUE(dest.GetXYZ(&hasX, &hasY, &hasZoom, &x, &y, &zoom));
42 EXPECT_TRUE(hasX);
43 EXPECT_TRUE(hasY);
44 EXPECT_TRUE(hasZoom);
45 EXPECT_EQ(4, x);
46 EXPECT_EQ(5, y);
47 EXPECT_EQ(6, zoom);
48 }
49 // Set zoom to 0.
50 array->SetNewAt<CPDF_Number>(4, 0);
51 {
52 CPDF_Dest dest(array);
53 EXPECT_TRUE(dest.GetXYZ(&hasX, &hasY, &hasZoom, &x, &y, &zoom));
54 EXPECT_FALSE(hasZoom);
55 }
56 // Set values to null.
57 array->SetNewAt<CPDF_Null>(2);
58 array->SetNewAt<CPDF_Null>(3);
59 array->SetNewAt<CPDF_Null>(4);
60 {
61 CPDF_Dest dest(array);
62 EXPECT_TRUE(dest.GetXYZ(&hasX, &hasY, &hasZoom, &x, &y, &zoom));
63 EXPECT_FALSE(hasX);
64 EXPECT_FALSE(hasY);
65 EXPECT_FALSE(hasZoom);
66 }
67}
bool GetXYZ(bool *pHasX, bool *pHasY, bool *pHasZoom, float *pX, float *pY, float *pZoom) const
Definition cpdf_dest.cpp:98
TEST(FXCRYPT, MD5GenerateEmtpyData)