summaryrefslogtreecommitdiff
path: root/fpdfsdk/pwl/cpwl_combo_box_embeddertest.cpp
diff options
context:
space:
mode:
authorDiana Gage <drgage@google.com>2017-07-26 20:32:00 -0700
committerChromium commit bot <commit-bot@chromium.org>2017-07-27 03:50:08 +0000
commitbe38e1628821733d6c59443063f641f5747221bf (patch)
tree4f3e5152321d756f616cdfa521479fbee9b06591 /fpdfsdk/pwl/cpwl_combo_box_embeddertest.cpp
parent663e02dfadabb0b7e1049cc7a9a8fe11a0f5bed7 (diff)
downloadpdfium-be38e1628821733d6c59443063f641f5747221bf.tar.xz
Add TypeTextIntoTextField() helper functions to CPWL embeddertests.
These helper methods in CPWLEditEmbeddertest and CPWLComboBoxEditEmbeddertest type text starting with 'A' to as many characters as specified by the parameter |num_chars|. BUG=chromium:59266 Change-Id: I3f8c04ef8f7cf19f3c3bd5c248ad042ce32c7dec Reviewed-on: https://pdfium-review.googlesource.com/9152 Commit-Queue: Diana Gage <drgage@google.com> Reviewed-by: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'fpdfsdk/pwl/cpwl_combo_box_embeddertest.cpp')
-rw-r--r--fpdfsdk/pwl/cpwl_combo_box_embeddertest.cpp38
1 files changed, 14 insertions, 24 deletions
diff --git a/fpdfsdk/pwl/cpwl_combo_box_embeddertest.cpp b/fpdfsdk/pwl/cpwl_combo_box_embeddertest.cpp
index c6bc1b250b..30fe32bc53 100644
--- a/fpdfsdk/pwl/cpwl_combo_box_embeddertest.cpp
+++ b/fpdfsdk/pwl/cpwl_combo_box_embeddertest.cpp
@@ -68,6 +68,14 @@ class CPWLComboBoxEditEmbeddertest : public EmbedderTest {
m_pComboBox = static_cast<CPWL_ComboBox*>(pWindow);
}
+ void TypeTextIntoTextField(int num_chars) {
+ // Type text starting with 'A' to as many chars as specified by |num_chars|.
+ for (int i = 0; i < num_chars; ++i) {
+ EXPECT_TRUE(GetCFFLFormFiller()->OnChar(GetCPDFSDKAnnotUserEditable(),
+ i + 'A', 0));
+ }
+ }
+
FPDF_PAGE GetPage() const { return m_page; }
CPWL_ComboBox* GetCPWLComboBox() const { return m_pComboBox; }
CFFL_FormFiller* GetCFFLFormFiller() const { return m_pFormFiller; }
@@ -167,10 +175,7 @@ TEST_F(CPWLComboBoxEditEmbeddertest, GetSelectedTextEmptyAndBasicEditable) {
TEST_F(CPWLComboBoxEditEmbeddertest, GetSelectedTextFragmentsEditable) {
FormFillerAndWindowSetup(GetCPDFSDKAnnotUserEditable());
- for (int i = 0; i < 50; ++i) {
- EXPECT_TRUE(
- GetCFFLFormFiller()->OnChar(GetCPDFSDKAnnotUserEditable(), i + 'A', 0));
- }
+ TypeTextIntoTextField(50);
GetCPWLComboBox()->SetEditSelection(0, 0);
EXPECT_TRUE(GetCPWLComboBox()->GetSelectedText().IsEmpty());
@@ -200,10 +205,7 @@ TEST_F(CPWLComboBoxEditEmbeddertest, GetSelectedTextFragmentsEditable) {
TEST_F(CPWLComboBoxEditEmbeddertest, DeleteEntireTextSelection) {
FormFillerAndWindowSetup(GetCPDFSDKAnnotUserEditable());
- for (int i = 0; i < 50; ++i) {
- EXPECT_TRUE(
- GetCFFLFormFiller()->OnChar(GetCPDFSDKAnnotUserEditable(), i + 'A', 0));
- }
+ TypeTextIntoTextField(50);
GetCPWLComboBox()->SetEditSelection(0, -1);
EXPECT_STREQ(L"ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqr",
@@ -215,10 +217,7 @@ TEST_F(CPWLComboBoxEditEmbeddertest, DeleteEntireTextSelection) {
TEST_F(CPWLComboBoxEditEmbeddertest, DeleteTextSelectionMiddle) {
FormFillerAndWindowSetup(GetCPDFSDKAnnotUserEditable());
- for (int i = 0; i < 50; ++i) {
- EXPECT_TRUE(
- GetCFFLFormFiller()->OnChar(GetCPDFSDKAnnotUserEditable(), i + 'A', 0));
- }
+ TypeTextIntoTextField(50);
GetCPWLComboBox()->SetEditSelection(12, 23);
EXPECT_STREQ(L"MNOPQRSTUVW", GetCPWLComboBox()->GetSelectedText().c_str());
@@ -230,10 +229,7 @@ TEST_F(CPWLComboBoxEditEmbeddertest, DeleteTextSelectionMiddle) {
TEST_F(CPWLComboBoxEditEmbeddertest, DeleteTextSelectionLeft) {
FormFillerAndWindowSetup(GetCPDFSDKAnnotUserEditable());
- for (int i = 0; i < 50; ++i) {
- EXPECT_TRUE(
- GetCFFLFormFiller()->OnChar(GetCPDFSDKAnnotUserEditable(), i + 'A', 0));
- }
+ TypeTextIntoTextField(50);
GetCPWLComboBox()->SetEditSelection(0, 5);
EXPECT_STREQ(L"ABCDE", GetCPWLComboBox()->GetSelectedText().c_str());
@@ -245,10 +241,7 @@ TEST_F(CPWLComboBoxEditEmbeddertest, DeleteTextSelectionLeft) {
TEST_F(CPWLComboBoxEditEmbeddertest, DeleteTextSelectionRight) {
FormFillerAndWindowSetup(GetCPDFSDKAnnotUserEditable());
- for (int i = 0; i < 50; ++i) {
- EXPECT_TRUE(
- GetCFFLFormFiller()->OnChar(GetCPDFSDKAnnotUserEditable(), i + 'A', 0));
- }
+ TypeTextIntoTextField(50);
GetCPWLComboBox()->SetEditSelection(45, 50);
EXPECT_STREQ(L"nopqr", GetCPWLComboBox()->GetSelectedText().c_str());
@@ -260,10 +253,7 @@ TEST_F(CPWLComboBoxEditEmbeddertest, DeleteTextSelectionRight) {
TEST_F(CPWLComboBoxEditEmbeddertest, DeleteEmptyTextSelection) {
FormFillerAndWindowSetup(GetCPDFSDKAnnotUserEditable());
- for (int i = 0; i < 50; ++i) {
- EXPECT_TRUE(
- GetCFFLFormFiller()->OnChar(GetCPDFSDKAnnotUserEditable(), i + 'A', 0));
- }
+ TypeTextIntoTextField(50);
GetCPWLComboBox()->DeleteSelectedText();
EXPECT_STREQ(L"ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqr",