Make CFFL_ComboBox embedder test use higher-level methods.
Change-Id: I5d68c1466ba254428d5303f8b0980a5824f279ed
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/100073
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/fpdfsdk/formfiller/cffl_combobox.h b/fpdfsdk/formfiller/cffl_combobox.h
index 2b1a306..724e6ac 100644
--- a/fpdfsdk/formfiller/cffl_combobox.h
+++ b/fpdfsdk/formfiller/cffl_combobox.h
@@ -55,9 +55,8 @@
// CPWL_Wnd::ProviderIface:
void OnSetFocusForEdit(CPWL_Edit* pEdit) override;
- WideString GetSelectExportText();
-
private:
+ WideString GetSelectExportText();
CPWL_ComboBox* GetPWLComboBox(const CPDFSDK_PageView* pPageView) const;
CPWL_ComboBox* CreateOrUpdatePWLComboBox(const CPDFSDK_PageView* pPageView);
diff --git a/fpdfsdk/formfiller/cffl_combobox_embeddertest.cpp b/fpdfsdk/formfiller/cffl_combobox_embeddertest.cpp
index 7444692..921888c 100644
--- a/fpdfsdk/formfiller/cffl_combobox_embeddertest.cpp
+++ b/fpdfsdk/formfiller/cffl_combobox_embeddertest.cpp
@@ -9,9 +9,27 @@
class CFFLComboBoxEmbedderTest : public CPWLComboBoxEmbedderTest {};
-TEST_F(CFFLComboBoxEmbedderTest, ExportText) {
+TEST_F(CFFLComboBoxEmbedderTest, GetActionData) {
FormFillerAndWindowSetup(GetCPDFSDKAnnotNormal());
- auto* pComboBox = static_cast<CFFL_ComboBox*>(GetCFFLFormField());
- ASSERT_TRUE(pComboBox);
- EXPECT_EQ(L"Banana", pComboBox->GetSelectExportText());
+ {
+ CFFL_FieldAction result;
+ GetCFFLFormField()->GetActionData(GetPageView(), CPDF_AAction::kKeyStroke,
+ result);
+ EXPECT_EQ(L"Banana", result.sValue);
+ EXPECT_EQ(L"Banana", result.sChangeEx);
+ }
+ {
+ CFFL_FieldAction result;
+ GetCFFLFormField()->GetActionData(GetPageView(), CPDF_AAction::kValidate,
+ result);
+ EXPECT_EQ(L"Banana", result.sValue);
+ EXPECT_EQ(L"", result.sChangeEx);
+ }
+ {
+ CFFL_FieldAction result;
+ GetCFFLFormField()->GetActionData(GetPageView(), CPDF_AAction::kGetFocus,
+ result);
+ EXPECT_EQ(L"Banana", result.sValue);
+ EXPECT_EQ(L"", result.sChangeEx);
+ }
}
diff --git a/fpdfsdk/pwl/cpwl_combo_box_embeddertest.cpp b/fpdfsdk/pwl/cpwl_combo_box_embeddertest.cpp
index 21faa26..3141a15 100644
--- a/fpdfsdk/pwl/cpwl_combo_box_embeddertest.cpp
+++ b/fpdfsdk/pwl/cpwl_combo_box_embeddertest.cpp
@@ -30,8 +30,8 @@
ASSERT_TRUE(m_page);
m_pFormFillEnv = CPDFSDKFormFillEnvironmentFromFPDFFormHandle(form_handle());
- CPDFSDK_AnnotIterator iter(m_pFormFillEnv->GetPageViewAtIndex(0),
- {CPDF_Annot::Subtype::WIDGET});
+ m_pPageView = m_pFormFillEnv->GetPageViewAtIndex(0);
+ CPDFSDK_AnnotIterator iter(m_pPageView, {CPDF_Annot::Subtype::WIDGET});
// User editable combobox.
m_pAnnotEditable = ToCPDFSDKWidget(iter.GetFirstAnnot());
diff --git a/fpdfsdk/pwl/cpwl_combo_box_embeddertest.h b/fpdfsdk/pwl/cpwl_combo_box_embeddertest.h
index c6e96bc..4f9ab37 100644
--- a/fpdfsdk/pwl/cpwl_combo_box_embeddertest.h
+++ b/fpdfsdk/pwl/cpwl_combo_box_embeddertest.h
@@ -12,6 +12,7 @@
class CFFL_FormField;
class CPDFSDK_FormFillEnvironment;
+class CPDFSDK_PageView;
class CPDFSDK_Widget;
class CPWL_ComboBox;
@@ -33,6 +34,7 @@
CPDFSDK_FormFillEnvironment* GetCPDFSDKFormFillEnv() const {
return m_pFormFillEnv;
}
+ CPDFSDK_PageView* GetPageView() const { return m_pPageView; }
private:
FPDF_PAGE m_page;
@@ -41,6 +43,7 @@
CPDFSDK_Widget* m_pAnnotNormal = nullptr;
CPDFSDK_Widget* m_pAnnotEditable = nullptr;
CPDFSDK_FormFillEnvironment* m_pFormFillEnv = nullptr;
+ CPDFSDK_PageView* m_pPageView = nullptr;
};
#endif // FPDFSDK_PWL_CPWL_COMBO_BOX_EMBEDDERTEST_H_