summaryrefslogtreecommitdiff
path: root/fpdfsdk/fpdf_formfill_embeddertest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'fpdfsdk/fpdf_formfill_embeddertest.cpp')
-rw-r--r--fpdfsdk/fpdf_formfill_embeddertest.cpp77
1 files changed, 77 insertions, 0 deletions
diff --git a/fpdfsdk/fpdf_formfill_embeddertest.cpp b/fpdfsdk/fpdf_formfill_embeddertest.cpp
index 5dd4d1e1c1..09e0c200d3 100644
--- a/fpdfsdk/fpdf_formfill_embeddertest.cpp
+++ b/fpdfsdk/fpdf_formfill_embeddertest.cpp
@@ -134,6 +134,18 @@ class FPDFFormFillInteractiveEmbeddertest : public FPDFFormFillEmbeddertest {
EXPECT_EQ(expected_string, WideString::FromUTF16LE(buf.data(), num_chars));
}
+ void CheckCanUndo(bool expected_result) {
+ EXPECT_EQ(expected_result, !!FORM_CanUndo(form_handle(), page_));
+ }
+
+ void CheckCanRedo(bool expected_result) {
+ EXPECT_EQ(expected_result, !!FORM_CanRedo(form_handle(), page_));
+ }
+
+ void PerformUndo() { EXPECT_TRUE(FORM_Undo(form_handle(), page_)); }
+
+ void PerformRedo() { EXPECT_TRUE(FORM_Redo(form_handle(), page_)); }
+
private:
FPDF_PAGE page_ = nullptr;
};
@@ -1544,3 +1556,68 @@ TEST_F(FPDFFormFillComboBoxFormEmbeddertest, FocusChanges) {
SelectEditableFormOption(0);
CheckFocusedFieldText(L"Foo");
}
+
+TEST_F(FPDFFormFillTextFormEmbeddertest, UndoRedo) {
+ ClickOnFormFieldAtPoint(RegularFormBegin());
+ CheckFocusedFieldText(L"");
+ CheckCanUndo(false);
+ CheckCanRedo(false);
+
+ TypeTextIntoTextField(5, RegularFormBegin());
+ CheckFocusedFieldText(L"ABCDE");
+ CheckCanUndo(true);
+ CheckCanRedo(false);
+
+ PerformUndo();
+ CheckFocusedFieldText(L"ABCD");
+ CheckCanUndo(true);
+ CheckCanRedo(true);
+ PerformUndo();
+ CheckFocusedFieldText(L"ABC");
+ CheckCanUndo(true);
+ CheckCanRedo(true);
+
+ PerformRedo();
+ CheckFocusedFieldText(L"ABCD");
+ CheckCanUndo(true);
+ CheckCanRedo(true);
+ PerformRedo();
+ CheckFocusedFieldText(L"ABCDE");
+ CheckCanUndo(true);
+ CheckCanRedo(false);
+}
+
+TEST_F(FPDFFormFillComboBoxFormEmbeddertest, UndoRedo) {
+ ClickOnFormFieldAtPoint(NonEditableFormBegin());
+ CheckFocusedFieldText(L"Banana");
+ CheckCanUndo(false);
+ CheckCanRedo(false);
+
+ ClickOnFormFieldAtPoint(EditableFormBegin());
+ CheckFocusedFieldText(L"");
+ CheckCanUndo(false);
+ CheckCanRedo(false);
+
+ TypeTextIntoTextField(3, EditableFormBegin());
+ CheckFocusedFieldText(L"ABC");
+ CheckCanUndo(true);
+ CheckCanRedo(false);
+
+ PerformUndo();
+ CheckFocusedFieldText(L"AB");
+ CheckCanUndo(true);
+ CheckCanRedo(true);
+ PerformUndo();
+ CheckFocusedFieldText(L"A");
+ CheckCanUndo(true);
+ CheckCanRedo(true);
+ PerformUndo();
+ CheckFocusedFieldText(L"");
+ CheckCanUndo(false);
+ CheckCanRedo(true);
+
+ PerformRedo();
+ CheckFocusedFieldText(L"A");
+ CheckCanUndo(true);
+ CheckCanRedo(true);
+}