summaryrefslogtreecommitdiff
path: root/fpdfsdk/pdfwindow/cpwl_combo_box_embeddertest.cpp
diff options
context:
space:
mode:
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());
+}