5#include "core/fpdfdoc/cpdf_action.h"
7#include "core/fpdfapi/parser/cpdf_dictionary.h"
8#include "core/fpdfapi/parser/cpdf_name.h"
9#include "core/fpdfapi/parser/cpdf_string.h"
10#include "core/fxcrt/retain_ptr.h"
11#include "testing/gtest/include/gtest/gtest.h"
15RetainPtr<CPDF_Dictionary> CreateActionDictWithType(
16 const ByteString& action_type) {
17 auto dict = pdfium::MakeRetain<CPDF_Dictionary>();
18 dict->SetNewFor<CPDF_Name>(
"Type",
"Action");
19 dict->SetNewFor<CPDF_Name>(
"S", action_type);
23RetainPtr<CPDF_Dictionary> CreateActionDictWithoutType(
24 const ByteString& action_type) {
25 auto dict = pdfium::MakeRetain<CPDF_Dictionary>();
26 dict->SetNewFor<CPDF_Name>(
"S", action_type);
30RetainPtr<CPDF_Dictionary> CreateActionDictWithInvalidType(
31 const ByteString& action_type) {
32 auto dict = pdfium::MakeRetain<CPDF_Dictionary>();
33 dict->SetNewFor<CPDF_Name>(
"Type",
"Lights");
34 dict->SetNewFor<CPDF_Name>(
"S", action_type);
38RetainPtr<CPDF_Dictionary> CreateInvalidActionDictWithType(
39 const ByteString& action_type) {
40 auto dict = pdfium::MakeRetain<CPDF_Dictionary>();
41 dict->SetNewFor<CPDF_Name>(
"Type",
"Action");
42 dict->SetNewFor<CPDF_String>(
"S", action_type,
false);
46RetainPtr<CPDF_Dictionary> CreateInvalidActionDictWithoutType(
47 const ByteString& action_type) {
48 auto dict = pdfium::MakeRetain<CPDF_Dictionary>();
49 dict->SetNewFor<CPDF_String>(
"S", action_type,
false);
56 static constexpr struct {
57 const char* action_type;
59 } kValidTestCases[] = {
81 for (
const auto& test_case : kValidTestCases) {
84 CPDF_Action action(CreateActionDictWithType(test_case.action_type));
85 EXPECT_EQ(test_case.expected_type, action
.GetType());
89 CPDF_Action action(CreateActionDictWithoutType(test_case.action_type));
90 EXPECT_EQ(test_case.expected_type, action
.GetType());
95 for (
const auto& test_case : kValidTestCases) {
99 CreateActionDictWithInvalidType(test_case.action_type));
105 CreateInvalidActionDictWithType(test_case.action_type));
111 CreateInvalidActionDictWithoutType(test_case.action_type));
116 static constexpr const char* kInvalidTestCases[] = {
123 for (
const char* test_case : kInvalidTestCases) {
124 CPDF_Action action(CreateActionDictWithType(test_case));
TEST(FXCRYPT, MD5GenerateEmtpyData)