xref: /aosp_15_r20/external/pdfium/fpdfsdk/formfiller/cffl_combobox_embeddertest.cpp (revision 3ac0a46f773bac49fa9476ec2b1cf3f8da5ec3a4)
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   FormFillerAndWindowSetup(GetCPDFSDKAnnotNormal());
14   {
15     CFFL_FieldAction result;
16     GetCFFLFormField()->GetActionData(GetPageView(), CPDF_AAction::kKeyStroke,
17                                       result);
18     EXPECT_EQ(L"Banana", result.sValue);
19     EXPECT_EQ(L"Banana", result.sChangeEx);
20   }
21   {
22     CFFL_FieldAction result;
23     GetCFFLFormField()->GetActionData(GetPageView(), CPDF_AAction::kValidate,
24                                       result);
25     EXPECT_EQ(L"Banana", result.sValue);
26     EXPECT_EQ(L"", result.sChangeEx);
27   }
28   {
29     CFFL_FieldAction result;
30     GetCFFLFormField()->GetActionData(GetPageView(), CPDF_AAction::kGetFocus,
31                                       result);
32     EXPECT_EQ(L"Banana", result.sValue);
33     EXPECT_EQ(L"", result.sChangeEx);
34   }
35 }
36 
TEST_F(CFFLComboBoxEmbedderTest,SetActionData)37 TEST_F(CFFLComboBoxEmbedderTest, SetActionData) {
38   FormFillerAndWindowSetup(GetCPDFSDKAnnotNormal());
39   CFFL_FieldAction input_fa;
40   input_fa.nSelStart = 2;
41   input_fa.nSelEnd = 4;
42   input_fa.sChange = L"Hamster";
43   GetCFFLFormField()->SetActionData(GetPageView(), CPDF_AAction::kKeyStroke,
44                                     input_fa);
45 
46   CFFL_FieldAction output_fa;
47   GetCFFLFormField()->GetActionData(GetPageView(), CPDF_AAction::kKeyStroke,
48                                     output_fa);
49   EXPECT_EQ(L"BaHamsterna", output_fa.sValue);
50 }
51