summaryrefslogtreecommitdiff
path: root/fpdfsdk/pwl
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
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')
-rw-r--r--fpdfsdk/pwl/cpwl_combo_box_embeddertest.cpp38
-rw-r--r--fpdfsdk/pwl/cpwl_edit_embeddertest.cpp31
2 files changed, 27 insertions, 42 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",
diff --git a/fpdfsdk/pwl/cpwl_edit_embeddertest.cpp b/fpdfsdk/pwl/cpwl_edit_embeddertest.cpp
index 6ab0ae4792..98cc44ab86 100644
--- a/fpdfsdk/pwl/cpwl_edit_embeddertest.cpp
+++ b/fpdfsdk/pwl/cpwl_edit_embeddertest.cpp
@@ -59,6 +59,13 @@ class CPWLEditEmbeddertest : public EmbedderTest {
m_pEdit = static_cast<CPWL_Edit*>(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(GetCPDFSDKAnnot(), i + 'A', 0));
+ }
+ }
+
FPDF_PAGE GetPage() { return m_page; }
CPWL_Edit* GetCPWLEdit() { return m_pEdit; }
CFFL_FormFiller* GetCFFLFormFiller() { return m_pFormFiller; }
@@ -97,9 +104,7 @@ TEST_F(CPWLEditEmbeddertest, GetSelectedTextEmptyAndBasic) {
}
TEST_F(CPWLEditEmbeddertest, GetSelectedTextFragments) {
- for (int i = 0; i < 50; ++i) {
- EXPECT_TRUE(GetCFFLFormFiller()->OnChar(GetCPDFSDKAnnot(), i + 'A', 0));
- }
+ TypeTextIntoTextField(50);
GetCPWLEdit()->SetSelection(0, 0);
EXPECT_TRUE(GetCPWLEdit()->GetSelectedText().IsEmpty());
@@ -128,9 +133,7 @@ TEST_F(CPWLEditEmbeddertest, GetSelectedTextFragments) {
}
TEST_F(CPWLEditEmbeddertest, DeleteEntireTextSelection) {
- for (int i = 0; i < 50; ++i) {
- EXPECT_TRUE(GetCFFLFormFiller()->OnChar(GetCPDFSDKAnnot(), i + 'A', 0));
- }
+ TypeTextIntoTextField(50);
GetCPWLEdit()->SetSelection(0, -1);
EXPECT_STREQ(L"ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqr",
@@ -141,9 +144,7 @@ TEST_F(CPWLEditEmbeddertest, DeleteEntireTextSelection) {
}
TEST_F(CPWLEditEmbeddertest, DeleteTextSelectionMiddle) {
- for (int i = 0; i < 50; ++i) {
- EXPECT_TRUE(GetCFFLFormFiller()->OnChar(GetCPDFSDKAnnot(), i + 'A', 0));
- }
+ TypeTextIntoTextField(50);
GetCPWLEdit()->SetSelection(12, 23);
EXPECT_STREQ(L"MNOPQRSTUVW", GetCPWLEdit()->GetSelectedText().c_str());
@@ -154,9 +155,7 @@ TEST_F(CPWLEditEmbeddertest, DeleteTextSelectionMiddle) {
}
TEST_F(CPWLEditEmbeddertest, DeleteTextSelectionLeft) {
- for (int i = 0; i < 50; ++i) {
- EXPECT_TRUE(GetCFFLFormFiller()->OnChar(GetCPDFSDKAnnot(), i + 'A', 0));
- }
+ TypeTextIntoTextField(50);
GetCPWLEdit()->SetSelection(0, 5);
EXPECT_STREQ(L"ABCDE", GetCPWLEdit()->GetSelectedText().c_str());
@@ -167,9 +166,7 @@ TEST_F(CPWLEditEmbeddertest, DeleteTextSelectionLeft) {
}
TEST_F(CPWLEditEmbeddertest, DeleteTextSelectionRight) {
- for (int i = 0; i < 50; ++i) {
- EXPECT_TRUE(GetCFFLFormFiller()->OnChar(GetCPDFSDKAnnot(), i + 'A', 0));
- }
+ TypeTextIntoTextField(50);
GetCPWLEdit()->SetSelection(45, 50);
EXPECT_STREQ(L"nopqr", GetCPWLEdit()->GetSelectedText().c_str());
@@ -180,9 +177,7 @@ TEST_F(CPWLEditEmbeddertest, DeleteTextSelectionRight) {
}
TEST_F(CPWLEditEmbeddertest, DeleteEmptyTextSelection) {
- for (int i = 0; i < 50; ++i) {
- EXPECT_TRUE(GetCFFLFormFiller()->OnChar(GetCPDFSDKAnnot(), i + 'A', 0));
- }
+ TypeTextIntoTextField(50);
GetCPWLEdit()->DeleteSelectedText();
EXPECT_STREQ(L"ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqr",