• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2022 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 "fpdfsdk/formfiller/cffl_combobox.h"
6 
7 #include "fpdfsdk/pwl/cpwl_combo_box_embeddertest.h"
8 #include "testing/gtest/include/gtest/gtest.h"
9 
10 class CFFLComboBoxEmbedderTest : public CPWLComboBoxEmbedderTest {};
11 
TEST_F(CFFLComboBoxEmbedderTest,GetActionData)12 TEST_F(CFFLComboBoxEmbedderTest, GetActionData) {
13   ScopedEmbedderTestPage page = CreateAndInitializeFormComboboxPDF();
14   ASSERT_TRUE(page);
15   FormFillerAndWindowSetup(GetCPDFSDKAnnotNormal());
16   {
17     CFFL_FieldAction result;
18     GetCFFLFormField()->GetActionData(GetPageView(), CPDF_AAction::kKeyStroke,
19                                       result);
20     EXPECT_EQ(L"Banana", result.sValue);
21     EXPECT_EQ(L"Banana", result.sChangeEx);
22   }
23   {
24     CFFL_FieldAction result;
25     GetCFFLFormField()->GetActionData(GetPageView(), CPDF_AAction::kValidate,
26                                       result);
27     EXPECT_EQ(L"Banana", result.sValue);
28     EXPECT_EQ(L"", result.sChangeEx);
29   }
30   {
31     CFFL_FieldAction result;
32     GetCFFLFormField()->GetActionData(GetPageView(), CPDF_AAction::kGetFocus,
33                                       result);
34     EXPECT_EQ(L"Banana", result.sValue);
35     EXPECT_EQ(L"", result.sChangeEx);
36   }
37 }
38 
TEST_F(CFFLComboBoxEmbedderTest,SetActionData)39 TEST_F(CFFLComboBoxEmbedderTest, SetActionData) {
40   ScopedEmbedderTestPage page = CreateAndInitializeFormComboboxPDF();
41   ASSERT_TRUE(page);
42   FormFillerAndWindowSetup(GetCPDFSDKAnnotNormal());
43   CFFL_FieldAction input_fa;
44   input_fa.nSelStart = 2;
45   input_fa.nSelEnd = 4;
46   input_fa.sChange = L"Hamster";
47   GetCFFLFormField()->SetActionData(GetPageView(), CPDF_AAction::kKeyStroke,
48                                     input_fa);
49 
50   CFFL_FieldAction output_fa;
51   GetCFFLFormField()->GetActionData(GetPageView(), CPDF_AAction::kKeyStroke,
52                                     output_fa);
53   EXPECT_EQ(L"BaHamsterna", output_fa.sValue);
54 }
55