summaryrefslogtreecommitdiff
path: root/fpdfsdk/pdfwindow/cpwl_combo_box_embeddertest.cpp
diff options
context:
space:
mode:
authorDiana Gage <drgage@google.com>2017-07-24 11:19:52 -0700
committerChromium commit bot <commit-bot@chromium.org>2017-07-24 20:14:25 +0000
commit1c7f1420b78f37ec1619ab1552261e9ce3947a3b (patch)
treefd27fec330d569359d3be308595d41cf9dd02f2a /fpdfsdk/pdfwindow/cpwl_combo_box_embeddertest.cpp
parentbfa2a97ca9f5026ceb8e8c2ce23cfc3c3e8b38a1 (diff)
downloadpdfium-1c7f1420b78f37ec1619ab1552261e9ce3947a3b.tar.xz
Add FORM_DeleteSelectedText() and embedder tests.
This method deletes the current text selection in a form text field or user-editable form combobox text field. If there is no selection, this method does nothing. BUG=chromium:59266 Change-Id: I3229ffad990c62beac1cf769cd366458b9ee5daa Reviewed-on: https://pdfium-review.googlesource.com/8370 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Diana Gage <drgage@google.com>
Diffstat (limited to 'fpdfsdk/pdfwindow/cpwl_combo_box_embeddertest.cpp')
-rw-r--r--fpdfsdk/pdfwindow/cpwl_combo_box_embeddertest.cpp72
1 files changed, 72 insertions, 0 deletions
diff --git a/fpdfsdk/pdfwindow/cpwl_combo_box_embeddertest.cpp b/fpdfsdk/pdfwindow/cpwl_combo_box_embeddertest.cpp
index 9ca994f2e1..3224284ee2 100644
--- a/fpdfsdk/pdfwindow/cpwl_combo_box_embeddertest.cpp
+++ b/fpdfsdk/pdfwindow/cpwl_combo_box_embeddertest.cpp
@@ -194,3 +194,75 @@ TEST_F(CPWLComboBoxEditEmbeddertest, GetSelectedTextFragmentsEditable) {
GetCPWLComboBox()->SetEditSelection(49, 50);
EXPECT_STREQ(L"r", GetCPWLComboBox()->GetSelectedText().c_str());
}
+
+TEST_F(CPWLComboBoxEditEmbeddertest, DeleteEntireTextSelection) {
+ FormFillerAndWindowSetup(GetCPDFSDKAnnotUserEditable());
+ for (int i = 0; i < 50; ++i) {
+ EXPECT_TRUE(
+ GetCFFLFormFiller()->OnChar(GetCPDFSDKAnnotUserEditable(), i + 'A', 0));
+ }
+
+ GetCPWLComboBox()->SetEditSelection(0, -1);
+ EXPECT_STREQ(L"ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqr",
+ GetCPWLComboBox()->GetSelectedText().c_str());
+
+ GetCPWLComboBox()->DeleteSelectedText();
+ EXPECT_TRUE(GetCPWLComboBox()->GetText().IsEmpty());
+}
+
+TEST_F(CPWLComboBoxEditEmbeddertest, DeleteTextSelectionMiddle) {
+ FormFillerAndWindowSetup(GetCPDFSDKAnnotUserEditable());
+ for (int i = 0; i < 50; ++i) {
+ EXPECT_TRUE(
+ GetCFFLFormFiller()->OnChar(GetCPDFSDKAnnotUserEditable(), i + 'A', 0));
+ }
+
+ GetCPWLComboBox()->SetEditSelection(12, 23);
+ EXPECT_STREQ(L"MNOPQRSTUVW", GetCPWLComboBox()->GetSelectedText().c_str());
+
+ GetCPWLComboBox()->DeleteSelectedText();
+ EXPECT_STREQ(L"ABCDEFGHIJKLXYZ[\\]^_`abcdefghijklmnopqr",
+ GetCPWLComboBox()->GetText().c_str());
+}
+
+TEST_F(CPWLComboBoxEditEmbeddertest, DeleteTextSelectionLeft) {
+ FormFillerAndWindowSetup(GetCPDFSDKAnnotUserEditable());
+ for (int i = 0; i < 50; ++i) {
+ EXPECT_TRUE(
+ GetCFFLFormFiller()->OnChar(GetCPDFSDKAnnotUserEditable(), i + 'A', 0));
+ }
+
+ GetCPWLComboBox()->SetEditSelection(0, 5);
+ EXPECT_STREQ(L"ABCDE", GetCPWLComboBox()->GetSelectedText().c_str());
+
+ GetCPWLComboBox()->DeleteSelectedText();
+ EXPECT_STREQ(L"FGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqr",
+ GetCPWLComboBox()->GetText().c_str());
+}
+
+TEST_F(CPWLComboBoxEditEmbeddertest, DeleteTextSelectionRight) {
+ FormFillerAndWindowSetup(GetCPDFSDKAnnotUserEditable());
+ for (int i = 0; i < 50; ++i) {
+ EXPECT_TRUE(
+ GetCFFLFormFiller()->OnChar(GetCPDFSDKAnnotUserEditable(), i + 'A', 0));
+ }
+
+ GetCPWLComboBox()->SetEditSelection(45, 50);
+ EXPECT_STREQ(L"nopqr", GetCPWLComboBox()->GetSelectedText().c_str());
+
+ GetCPWLComboBox()->DeleteSelectedText();
+ EXPECT_STREQ(L"ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklm",
+ GetCPWLComboBox()->GetText().c_str());
+}
+
+TEST_F(CPWLComboBoxEditEmbeddertest, DeleteEmptyTextSelection) {
+ FormFillerAndWindowSetup(GetCPDFSDKAnnotUserEditable());
+ for (int i = 0; i < 50; ++i) {
+ EXPECT_TRUE(
+ GetCFFLFormFiller()->OnChar(GetCPDFSDKAnnotUserEditable(), i + 'A', 0));
+ }
+
+ GetCPWLComboBox()->DeleteSelectedText();
+ EXPECT_STREQ(L"ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqr",
+ GetCPWLComboBox()->GetText().c_str());
+}