summaryrefslogtreecommitdiff
path: root/fpdfsdk/pwl/cpwl_edit_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_edit_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_edit_embeddertest.cpp')
-rw-r--r--fpdfsdk/pwl/cpwl_edit_embeddertest.cpp31
1 files changed, 13 insertions, 18 deletions
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",