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
xfa_basic_data_unittest.cpp
Go to the documentation of this file.
1// Copyright 2018 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 "xfa/fxfa/parser/xfa_basic_data.h"
6
7#include "testing/gtest/include/gtest/gtest.h"
8
10 absl::optional<XFA_PACKETINFO> result = XFA_GetPacketByName(L"");
11 EXPECT_FALSE(result.has_value());
12
13 result = XFA_GetPacketByName(L"nonesuch");
14 EXPECT_FALSE(result.has_value());
15
16 result = XFA_GetPacketByName(L"datasets");
17 ASSERT_TRUE(result.has_value());
18 EXPECT_EQ(XFA_PacketType::Datasets, result.value().packet_type);
19
20 result = XFA_GetPacketByName(L"sourceSet");
21 ASSERT_TRUE(result.has_value());
22 EXPECT_EQ(XFA_PacketType::SourceSet, result.value().packet_type);
23}
24
27 EXPECT_STREQ("datasets", result.name);
28
29 result = XFA_GetPacketByIndex(XFA_PacketType::ConnectionSet);
30 EXPECT_STREQ("connectionSet", result.name);
31}
32
34 EXPECT_EQ(XFA_Element::Unknown, XFA_GetElementByName(L""));
35 EXPECT_EQ(XFA_Element::Unknown, XFA_GetElementByName(L"nonesuch"));
36 EXPECT_EQ(XFA_Element::ConnectionSet, XFA_GetElementByName(L"connectionSet"));
37 EXPECT_EQ(XFA_Element::Items, XFA_GetElementByName(L"items"));
38
39 // Internal elements are not retrievable by name.
40 EXPECT_EQ(XFA_Element::Unknown, XFA_GetElementByName(L"model"));
41}
42
44 EXPECT_EQ("conformance", XFA_ElementToName(XFA_Element::Conformance));
45 EXPECT_EQ("tagged", XFA_ElementToName(XFA_Element::Tagged));
46
47 // Internal elements resolve back to real names.
48 EXPECT_EQ("node", XFA_ElementToName(XFA_Element::Node));
49}
50
52 absl::optional<XFA_ATTRIBUTEINFO> result = XFA_GetAttributeByName(L"");
53 EXPECT_FALSE(result.has_value());
54
55 result = XFA_GetAttributeByName(L"nonesuch");
56 EXPECT_FALSE(result.has_value());
57
58 result = XFA_GetAttributeByName(L"h");
59 ASSERT_TRUE(result.has_value());
60 EXPECT_EQ(XFA_Attribute::H, result.value().attribute);
61
62 result = XFA_GetAttributeByName(L"short");
63 ASSERT_TRUE(result.has_value());
64 EXPECT_EQ(XFA_Attribute::Short, result.value().attribute);
65
66 result = XFA_GetAttributeByName(L"decipherOnly");
67 ASSERT_TRUE(result.has_value());
68 EXPECT_EQ(XFA_Attribute::DecipherOnly, result.value().attribute);
69}
70
72 EXPECT_EQ("spaceBelow", XFA_AttributeToName(XFA_Attribute::SpaceBelow));
73 EXPECT_EQ("decipherOnly", XFA_AttributeToName(XFA_Attribute::DecipherOnly));
74}
75
77 absl::optional<XFA_AttributeValue> result = XFA_GetAttributeValueByName(L"");
78 EXPECT_FALSE(result.has_value());
79
80 result = XFA_GetAttributeValueByName(L"nonesuch");
81 EXPECT_FALSE(result.has_value());
82
83 result = XFA_GetAttributeValueByName(L"*");
84 ASSERT_TRUE(result.has_value());
85 EXPECT_EQ(XFA_AttributeValue::Asterisk, result.value());
86
87 result = XFA_GetAttributeValueByName(L"visible");
88 ASSERT_TRUE(result.has_value());
89 EXPECT_EQ(XFA_AttributeValue::Visible, result.value());
90
91 result = XFA_GetAttributeValueByName(L"lowered");
92 ASSERT_TRUE(result.has_value());
93 EXPECT_EQ(XFA_AttributeValue::Lowered, result.value());
94}
95
97 EXPECT_EQ("rl-tb", XFA_AttributeValueToName(XFA_AttributeValue::Rl_tb));
98 EXPECT_EQ("lowered", XFA_AttributeValueToName(XFA_AttributeValue::Lowered));
99}
TEST(FXCRYPT, MD5GenerateEmtpyData)
XFA_Attribute
Definition fxfa_basic.h:67
XFA_Element
Definition fxfa_basic.h:75
XFA_AttributeValue
Definition fxfa_basic.h:60
XFA_PacketType
Definition fxfa_basic.h:44
const char * name
XFA_PACKETINFO XFA_GetPacketByIndex(XFA_PacketType ePacket)