7#include "build/build_config.h"
8#include "constants/ascii.h"
9#include "core/fxcrt/check.h"
10#include "core/fxcrt/check_op.h"
11#include "core/fxcrt/fx_coordinates.h"
12#include "core/fxcrt/fx_string.h"
13#include "core/fxcrt/fx_system.h"
14#include "core/fxge/cfx_defaultrenderdevice.h"
15#include "public/cpp/fpdf_scopers.h"
16#include "public/fpdf_formfill.h"
17#include "public/fpdf_fwlevent.h"
18#include "public/fpdf_progressive.h"
19#include "testing/embedder_test.h"
20#include "testing/embedder_test_constants.h"
21#include "testing/embedder_test_mock_delegate.h"
22#include "testing/embedder_test_timer_handling_delegate.h"
23#include "testing/gmock/include/gmock/gmock.h"
24#include "testing/gtest/include/gtest/gtest.h"
26using pdfium::TextFormChecksum;
29using testing::InSequence;
30using testing::NiceMock;
64 FPDF_PAGE
page() {
return page_; }
67 return FPDFPage_HasFormFieldAtPoint(
form_handle(), page_, point.x, point.y);
72 FORM_OnMouseMove(
form_handle(), page_, 0, point.x, point.y);
73 FORM_OnLButtonDown(
form_handle(), page_, 0, point.x, point.y);
74 FORM_OnLButtonUp(
form_handle(), page_, 0, point.x, point.y);
79 FORM_OnMouseMove(
form_handle(), page_, 0, point.x, point.y);
80 FORM_OnLButtonDoubleClick(
form_handle(), page_, 0, point.x, point.y);
88 for (
int i = 0; i < num_chars; ++i) {
105 for (
int i = 0; i < num_chars; ++i) {
117 FORM_OnMouseMove(
form_handle(), page_, 0, start.x, start.y);
118 FORM_OnLButtonDown(
form_handle(), page_, 0, start.x, start.y);
121 FORM_OnMouseMove(
form_handle(), page_, 0, end.x, end.y);
122 FORM_OnLButtonUp(
form_handle(), page_, 0, end.x, end.y);
127 EXPECT_TRUE(FORM_SelectAllText(
form_handle(), page_));
131 unsigned long actual_len =
132 FORM_GetSelectedText(
form_handle(), page_,
nullptr, 0);
133 ASSERT_NE(actual_len, 0U);
134 ASSERT_LT(actual_len, 1000U);
135 ASSERT_EQ(actual_len %
sizeof(FPDF_WCHAR), 0U);
137 std::vector<FPDF_WCHAR> buf(actual_len /
sizeof(FPDF_WCHAR));
138 ASSERT_EQ(actual_len, FORM_GetSelectedText(
form_handle(), page_, buf.data(),
140 EXPECT_EQ(expected_string,
ByteStringView(GetPlatformString(buf.data())));
148 unsigned long actual_len =
149 FORM_GetFocusedText(
form_handle(), page_,
nullptr, 0);
150 ASSERT_NE(actual_len, 0U);
151 ASSERT_LT(actual_len, 1000U);
152 ASSERT_EQ(actual_len %
sizeof(FPDF_WCHAR), 0U);
154 std::vector<FPDF_WCHAR> buf(actual_len /
sizeof(FPDF_WCHAR));
155 ASSERT_EQ(actual_len, FORM_GetFocusedText(
form_handle(), page_, buf.data(),
157 EXPECT_EQ(expected_string,
ByteStringView(GetPlatformString(buf.data())));
161 EXPECT_EQ(expected_result, !!FORM_CanUndo(
form_handle(), page_));
165 EXPECT_EQ(expected_result, !!FORM_CanRedo(
form_handle(), page_));
173 EXPECT_TRUE(FORM_SetIndexSelected(
form_handle(), page_, index, selected));
177 EXPECT_FALSE(FORM_SetIndexSelected(
form_handle(), page_, index, selected));
181 EXPECT_EQ(expected, FORM_IsIndexSelected(
form_handle(), page_, index));
185 FPDF_PAGE page_ =
nullptr;
199 return "text_form_multiple.pdf";
220 static const CFX_PointF point = CharLimitFormAtX(kFormBeginX);
225 static const CFX_PointF point = CharLimitFormAtX(kFormEndX);
230 static const CFX_PointF point = RegularFormAtX(kFormBeginX);
235 static const CFX_PointF point = RegularFormAtX(kFormEndX);
242 return CFX_PointF(x, kCharLimitFormY);
248 return CFX_PointF(x, kRegularFormY);
252 static constexpr float kFormBeginX = 102.0;
253 static constexpr float kFormEndX = 195.0;
254 static constexpr float kCharLimitFormY = 60.0;
255 static constexpr float kRegularFormY = 115.0;
269 return "combobox_form.pdf";
304 static const CFX_PointF point = EditableFormAtX(kFormBeginX);
309 static const CFX_PointF point = EditableFormAtX(kFormEndX);
314 static const CFX_PointF point(kFormDropDownX, kEditableFormY);
319 static const CFX_PointF point = NonEditableFormAtX(kFormBeginX);
324 static const CFX_PointF point = NonEditableFormAtX(kFormEndX);
329 static const CFX_PointF point(kFormDropDownX, kNonEditableFormY);
336 return CFX_PointF(x, kEditableFormY);
342 return CFX_PointF(x, kNonEditableFormY);
348 void SelectOption(
int item_index,
const CFX_PointF& point) {
353 constexpr double kChoiceHeight = 15;
355 option_point.y -= kChoiceHeight * (item_index + 1);
358 option_point.x -= 20;
364 static constexpr float kFormBeginX = 102.0;
365 static constexpr float kFormEndX = 183.0;
366 static constexpr float kFormDropDownX = 192.0;
367 static constexpr float kEditableFormY = 360.0;
368 static constexpr float kNonEditableFormY = 410.0;
388 return "listbox_form.pdf";
432 if (item_index == 0) {
444 if (item_index == 0) {
456 if (item_index == 0) {
468 if (item_index == 0) {
500 EXPECT_EQ(
true, FORM_OnFocus(
form_handle(),
page(), 0, point.x, point.y));
504 static const CFX_PointF point(kFormBeginX, kSingleFormYFirstVisibleOption);
509 static const CFX_PointF point(kFormBeginX, kSingleFormYSecondVisibleOption);
514 static const CFX_PointF point(kFormBeginX, kMultiFormYFirstVisibleOption);
519 static const CFX_PointF point(kFormBeginX, kMultiFormYSecondVisibleOption);
525 kMultiFormMultipleIndicesYFirstVisibleOption);
531 kFormBeginX, kMultiFormMultipleIndicesYSecondVisibleOption);
537 kMultiFormMultipleValuesYFirstVisibleOption);
543 kMultiFormMultipleValuesYSecondVisibleOption);
549 kFormBeginX, kMultiFormMultipleMismatchYFirstVisibleOption);
555 kFormBeginX, kMultiFormMultipleMismatchYSecondVisibleOption);
561 kSingleFormLastSelectedYFirstVisibleOption);
567 kSingleFormLastSelectedYSecondVisibleOption);
572 static constexpr float kFormBeginX = 102.0;
573 static constexpr float kSingleFormYFirstVisibleOption = 371.0;
574 static constexpr float kSingleFormYSecondVisibleOption = 358.0;
575 static constexpr float kMultiFormYFirstVisibleOption = 423.0;
576 static constexpr float kMultiFormYSecondVisibleOption = 408.0;
577 static constexpr float kMultiFormMultipleIndicesYFirstVisibleOption = 273.0;
578 static constexpr float kMultiFormMultipleIndicesYSecondVisibleOption = 258.0;
579 static constexpr float kMultiFormMultipleValuesYFirstVisibleOption = 223.0;
580 static constexpr float kMultiFormMultipleValuesYSecondVisibleOption = 208.0;
581 static constexpr float kMultiFormMultipleMismatchYFirstVisibleOption = 173.0;
582 static constexpr float kMultiFormMultipleMismatchYSecondVisibleOption = 158.0;
583 static constexpr float kSingleFormLastSelectedYFirstVisibleOption = 123.0;
584 static constexpr float kSingleFormLastSelectedYSecondVisibleOption = 108.0;
597 EXPECT_CALL(mock, Alert(_, _, _, _)).Times(0);
598 EXPECT_CALL(mock, UnsupportedHandler(_)).Times(0);
599 EXPECT_CALL(mock, SetTimer(_, _)).Times(0);
600 EXPECT_CALL(mock, KillTimer(_)).Times(0);
601 EXPECT_CALL(mock, OnFocusChange(_, _, _)).Times(0);
602 EXPECT_CALL(mock, DoURIAction(_)).Times(0);
603 EXPECT_CALL(mock, DoURIActionWithKeyboardModifier(_, _, _)).Times(0);
604 EXPECT_CALL(mock, DoGoToAction(_, _, _, _, _)).Times(0);
607 ASSERT_TRUE(OpenDocument(
"hello_world.pdf"));
608 FPDF_PAGE page = LoadPage(0);
614 EmbedderTestTimerHandlingDelegate delegate;
615 SetDelegate(&delegate);
617 ASSERT_TRUE(OpenDocument(
"bug_487928.pdf"));
618 FPDF_PAGE page = LoadPage(0);
626 EmbedderTestTimerHandlingDelegate delegate;
627 SetDelegate(&delegate);
629 ASSERT_TRUE(OpenDocument(
"bug_507316.pdf"));
630 FPDF_PAGE page = LoadPage(2);
638 ASSERT_TRUE(OpenDocument(
"hello_world.pdf"));
639 FPDF_PAGE page = LoadPage(0);
644 FORM_OnMouseMove(form_handle(),
nullptr, 0, 10.0, 10.0);
650 EmbedderTestTimerHandlingDelegate delegate;
651 SetDelegate(&delegate);
653 ASSERT_TRUE(OpenDocument(
"bug_900552.pdf"));
654 FPDF_PAGE page = LoadPage(0);
668 EmbedderTestTimerHandlingDelegate delegate;
669 SetDelegate(&delegate);
671 ASSERT_TRUE(OpenDocument(
"bug_901654.pdf"));
672 FPDF_PAGE page = LoadPage(0);
680 FPDF_RenderPageBitmap_Start(bitmap.get(), page, 0, 0, 512, 512, 0, 0,
687 EmbedderTestTimerHandlingDelegate delegate;
688 SetDelegate(&delegate);
690 ASSERT_TRUE(OpenDocument(
"bug_901654_2.pdf"));
691 FPDF_PAGE page = LoadPage(0);
699 FPDF_RenderPageBitmap_Start(bitmap.get(), page, 0, 0, 512, 512, 0, 0,
706 ASSERT_TRUE(OpenDocument(
"annotiter.pdf"));
707 std::vector<FPDF_PAGE> pages;
708 for (size_t i = 0; i < 3; ++i) {
709 pages.push_back(LoadPage(i));
710 ASSERT_TRUE(pages.back());
714 FPDF_ANNOTATION annot =
nullptr;
716 ASSERT_TRUE(FORM_GetFocusedAnnot(form_handle(), &page_index, &annot));
718 EXPECT_EQ(-1, page_index);
722 EXPECT_FALSE(FORM_GetFocusedAnnot(form_handle(), &page_index,
nullptr));
723 EXPECT_FALSE(FORM_GetFocusedAnnot(form_handle(),
nullptr, &annot));
725 const CFX_PointF right_bottom_annot_point(410.0f, 210.0f);
726 constexpr int kExpectedAnnotIndex = 3;
728 for (size_t i = 0; i < pages.size(); ++i) {
730 FORM_OnMouseMove(form_handle(), pages[i], 0, right_bottom_annot_point.x,
731 right_bottom_annot_point.y);
732 FORM_OnLButtonDown(form_handle(), pages[i], 0, right_bottom_annot_point.x,
733 right_bottom_annot_point.y);
734 FORM_OnLButtonUp(form_handle(), pages[i], 0, right_bottom_annot_point.x,
735 right_bottom_annot_point.y);
737 ASSERT_TRUE(FORM_GetFocusedAnnot(form_handle(), &page_index, &annot));
740 EXPECT_EQ(kExpectedAnnotIndex, FPDFPage_GetAnnotIndex(pages[i], annot));
741 EXPECT_EQ(
static_cast<
int>(i), page_index);
746 for (FPDF_PAGE page : pages)
751 ASSERT_TRUE(OpenDocument(
"annotiter.pdf"));
752 std::vector<FPDF_PAGE> pages;
753 for (size_t i = 0; i < 3; ++i) {
754 pages.push_back(LoadPage(i));
755 ASSERT_TRUE(pages.back());
759 FPDF_ANNOTATION annot =
nullptr;
761 ASSERT_TRUE(FORM_GetFocusedAnnot(form_handle(), &page_index, &annot));
763 EXPECT_EQ(-1, page_index);
767 EXPECT_FALSE(FORM_SetFocusedAnnot(form_handle(),
nullptr));
769 constexpr int kExpectedAnnotIndex = 2;
771 for (size_t i = 0; i < pages.size(); ++i) {
773 ScopedFPDFAnnotation focused_annot(
774 FPDFPage_GetAnnot(pages[i], kExpectedAnnotIndex));
775 ASSERT_TRUE(focused_annot);
777 ASSERT_TRUE(FORM_SetFocusedAnnot(form_handle(), focused_annot.get()));
779 ASSERT_TRUE(FORM_GetFocusedAnnot(form_handle(), &page_index, &annot));
780 EXPECT_EQ(kExpectedAnnotIndex, FPDFPage_GetAnnotIndex(pages[i], annot));
781 EXPECT_EQ(
static_cast<
int>(i), page_index);
786 for (FPDF_PAGE page : pages)
791 ASSERT_TRUE(OpenDocument(
"annotiter.pdf"));
792 FPDF_PAGE page = LoadPage(0);
796 ASSERT_TRUE(FORM_OnKeyDown(form_handle(), page,
FWL_VKEY_Tab, 0));
798 FPDF_ANNOTATION annot =
nullptr;
799 EXPECT_TRUE(FORM_GetFocusedAnnot(form_handle(), &page_index, &annot));
800 EXPECT_EQ(0, page_index);
809 ASSERT_TRUE(OpenDocument(
"annotiter.pdf"));
810 FPDF_PAGE page = LoadPage(0);
814 ASSERT_TRUE(FORM_OnKeyDown(form_handle(), page,
FWL_VKEY_Tab,
817 FPDF_ANNOTATION annot =
nullptr;
818 EXPECT_TRUE(FORM_GetFocusedAnnot(form_handle(), &page_index, &annot));
819 EXPECT_EQ(0, page_index);
828 ASSERT_TRUE(OpenDocument(
"annotiter.pdf"));
829 FPDF_PAGE page = LoadPage(0);
833 for (
int expected : {1, 2, 3, 0}) {
834 ASSERT_TRUE(FORM_OnKeyDown(form_handle(), page, FWL_VKEY_Tab, 0));
836 FPDF_ANNOTATION annot =
nullptr;
837 EXPECT_TRUE(FORM_GetFocusedAnnot(form_handle(), &page_index, &annot));
838 EXPECT_EQ(0, page_index);
840 EXPECT_EQ(expected, FPDFPage_GetAnnotIndex(page, annot));
841 FPDFPage_CloseAnnot(annot);
845 ASSERT_FALSE(FORM_OnKeyDown(form_handle(), page,
FWL_VKEY_Tab, 0));
851 ASSERT_TRUE(OpenDocument(
"annotiter.pdf"));
852 FPDF_PAGE page = LoadPage(0);
856 for (
int expected : {0, 3, 2, 1}) {
857 ASSERT_TRUE(FORM_OnKeyDown(form_handle(), page, FWL_VKEY_Tab,
858 FWL_EVENTFLAG_ShiftKey));
860 FPDF_ANNOTATION annot =
nullptr;
861 EXPECT_TRUE(FORM_GetFocusedAnnot(form_handle(), &page_index, &annot));
862 EXPECT_EQ(0, page_index);
864 EXPECT_EQ(expected, FPDFPage_GetAnnotIndex(page, annot));
865 FPDFPage_CloseAnnot(annot);
870 ASSERT_FALSE(FORM_OnKeyDown(form_handle(), page,
FWL_VKEY_Tab,
877 ASSERT_TRUE(OpenDocument(
"annotiter.pdf"));
878 FPDF_PAGE page = LoadPage(0);
881 ASSERT_FALSE(FORM_OnKeyDown(form_handle(), page,
FWL_VKEY_Tab,
891 ASSERT_FALSE(FORM_OnKeyDown(form_handle(), page,
FWL_VKEY_Tab,
898 ASSERT_TRUE(OpenDocument(
"annotiter.pdf"));
899 FPDF_PAGE page = LoadPage(0);
904 FPDF_ANNOTATION annot =
nullptr;
905 EXPECT_TRUE(FORM_GetFocusedAnnot(form_handle(), &page_index, &annot));
906 EXPECT_EQ(-1, page_index);
909 static constexpr int kKeysToPress[] = {
914 for (
int key : kKeysToPress) {
916 EXPECT_FALSE(FORM_OnKeyDown(form_handle(), page, key, 0));
919 EXPECT_TRUE(FORM_GetFocusedAnnot(form_handle(), &page_index, &annot));
920 EXPECT_EQ(-1, page_index);
928TEST_F(FPDFFormFillEmbedderTest, XFAFormFillFirstTab) {
929 ASSERT_TRUE(OpenDocument(
"xfa/email_recommended.pdf"));
930 FPDF_PAGE page = LoadPage(0);
934 ASSERT_TRUE(FORM_OnKeyDown(form_handle(), page, FWL_VKEY_Tab, 0));
939TEST_F(FPDFFormFillEmbedderTest, XFAFormFillFirstShiftTab) {
940 ASSERT_TRUE(OpenDocument(
"xfa/email_recommended.pdf"));
941 FPDF_PAGE page = LoadPage(0);
945 ASSERT_TRUE(FORM_OnKeyDown(form_handle(), page, FWL_VKEY_Tab,
946 FWL_EVENTFLAG_ShiftKey));
951TEST_F(FPDFFormFillEmbedderTest, XFAFormFillContinuousTab) {
952 ASSERT_TRUE(OpenDocument(
"xfa/email_recommended.pdf"));
953 FPDF_PAGE page = LoadPage(0);
957 ASSERT_TRUE(FORM_OnKeyDown(form_handle(), page, FWL_VKEY_Tab, 0));
960 for (size_t i = 0; i < 9; ++i)
961 ASSERT_TRUE(FORM_OnKeyDown(form_handle(), page, FWL_VKEY_Tab, 0));
964 ASSERT_FALSE(FORM_OnKeyDown(form_handle(), page, FWL_VKEY_Tab, 0));
969TEST_F(FPDFFormFillEmbedderTest, XFAFormFillContinuousShiftTab) {
970 ASSERT_TRUE(OpenDocument(
"xfa/email_recommended.pdf"));
971 FPDF_PAGE page = LoadPage(0);
975 ASSERT_TRUE(FORM_OnKeyDown(form_handle(), page, FWL_VKEY_Tab,
976 FWL_EVENTFLAG_ShiftKey));
979 for (size_t i = 0; i < 9; ++i) {
980 ASSERT_TRUE(FORM_OnKeyDown(form_handle(), page, FWL_VKEY_Tab,
981 FWL_EVENTFLAG_ShiftKey));
986 ASSERT_FALSE(FORM_OnKeyDown(form_handle(), page, FWL_VKEY_Tab,
987 FWL_EVENTFLAG_ShiftKey));
996 FAIL() <<
"Navigated to " << uri;
1001 DoURIActionBlockedDelegate delegate;
1002 SetDelegate(&delegate);
1004 ASSERT_TRUE(OpenDocument(
"redirect.pdf"));
1005 FPDF_PAGE page = LoadPage(0);
1013 EmbedderTestTimerHandlingDelegate delegate;
1014 SetDelegate(&delegate);
1016 ASSERT_TRUE(OpenDocument(
"click_form.pdf"));
1017 FPDF_PAGE page = LoadPage(0);
1023 ASSERT_TRUE(FORM_SetFocusedAnnot(form_handle(), focused_annot.get()));
1026 ASSERT_TRUE(FORM_OnKeyDown(form_handle(), page,
FWL_VKEY_Tab,
1028 FPDF_ANNOTATION annot =
nullptr;
1029 int page_index = -1;
1030 ASSERT_TRUE(FORM_GetFocusedAnnot(form_handle(), &page_index, &annot));
1034 EXPECT_TRUE(FPDFAnnot_IsChecked(form_handle(), annot));
1037 EXPECT_TRUE(FPDFAnnot_IsChecked(form_handle(), annot));
1040 EXPECT_TRUE(FPDFAnnot_IsChecked(form_handle(), annot));
1048 EmbedderTestTimerHandlingDelegate delegate;
1049 SetDelegate(&delegate);
1051 ASSERT_TRUE(OpenDocument(
"click_form.pdf"));
1052 FPDF_PAGE page = LoadPage(0);
1058 ASSERT_TRUE(FORM_SetFocusedAnnot(form_handle(), focused_annot.get()));
1061 ASSERT_TRUE(FORM_OnKeyDown(form_handle(), page,
FWL_VKEY_Tab, 0));
1063 FPDF_ANNOTATION annot =
nullptr;
1064 int page_index = -1;
1065 ASSERT_TRUE(FORM_GetFocusedAnnot(form_handle(), &page_index, &annot));
1068 EXPECT_FALSE(FPDFAnnot_IsChecked(form_handle(), annot));
1071 EXPECT_FALSE(FPDFAnnot_IsChecked(form_handle(), annot));
1074 EXPECT_FALSE(FPDFAnnot_IsChecked(form_handle(), annot));
1082TEST_F(FPDFFormFillEmbedderTest, DisableJavaScript) {
1084 EmbedderTestTimerHandlingDelegate delegate;
1085 SetDelegate(&delegate);
1087 ASSERT_TRUE(OpenDocumentWithoutJavaScript(
"bug_551248.pdf"));
1088 FPDF_PAGE page = LoadPage(0);
1092 const auto& alerts = delegate.GetAlerts();
1093 EXPECT_EQ(0U, alerts.size());
1095 delegate.AdvanceTime(1000);
1096 EXPECT_EQ(0U, alerts.size());
1097 delegate.AdvanceTime(1000);
1098 EXPECT_EQ(0U, alerts.size());
1099 delegate.AdvanceTime(1000);
1100 EXPECT_EQ(0U, alerts.size());
1101 delegate.AdvanceTime(1000);
1102 EXPECT_EQ(0U, alerts.size());
1103 delegate.AdvanceTime(1000);
1104 EXPECT_EQ(0U, alerts.size());
1105 delegate.AdvanceTime(1000);
1106 EXPECT_EQ(0U, alerts.size());
1107 delegate.AdvanceTime(1000);
1108 EXPECT_EQ(0U, alerts.size());
1112TEST_F(FPDFFormFillEmbedderTest, DocumentAActions) {
1113 EmbedderTestTimerHandlingDelegate delegate;
1114 SetDelegate(&delegate);
1116 ASSERT_TRUE(OpenDocument(
"document_aactions.pdf"));
1117 FPDF_PAGE page = LoadPage(0);
1120 const auto& alerts = delegate.GetAlerts();
1121 EXPECT_EQ(0U, alerts.size());
1123 FORM_DoDocumentAAction(form_handle(), FPDFDOC_AACTION_WS);
1124 FORM_DoDocumentAAction(form_handle(), FPDFDOC_AACTION_DS);
1125 FORM_DoDocumentAAction(form_handle(), FPDFDOC_AACTION_WP);
1126 FORM_DoDocumentAAction(form_handle(), FPDFDOC_AACTION_DP);
1129 ASSERT_EQ(4U, alerts.size());
1130 EXPECT_EQ(L"Will Save", alerts[0].message);
1131 EXPECT_EQ(L"Did Save", alerts[1].message);
1132 EXPECT_EQ(L"Will Print", alerts[2].message);
1133 EXPECT_EQ(L"Did Print", alerts[3].message);
1136TEST_F(FPDFFormFillEmbedderTest, DocumentAActionsDisableJavaScript) {
1137 EmbedderTestTimerHandlingDelegate delegate;
1138 SetDelegate(&delegate);
1140 ASSERT_TRUE(OpenDocumentWithoutJavaScript(
"document_aactions.pdf"));
1141 FPDF_PAGE page = LoadPage(0);
1144 const auto& alerts = delegate.GetAlerts();
1145 EXPECT_EQ(0U, alerts.size());
1147 FORM_DoDocumentAAction(form_handle(), FPDFDOC_AACTION_WS);
1148 FORM_DoDocumentAAction(form_handle(), FPDFDOC_AACTION_DS);
1149 FORM_DoDocumentAAction(form_handle(), FPDFDOC_AACTION_WP);
1150 FORM_DoDocumentAAction(form_handle(), FPDFDOC_AACTION_DP);
1153 ASSERT_EQ(0U, alerts.size());
1156TEST_F(FPDFFormFillEmbedderTest, Bug551248) {
1158 EmbedderTestTimerHandlingDelegate delegate;
1159 SetDelegate(&delegate);
1161 ASSERT_TRUE(OpenDocument(
"bug_551248.pdf"));
1162 FPDF_PAGE page = LoadPage(0);
1166 const auto& alerts = delegate.GetAlerts();
1167 EXPECT_EQ(0U, alerts.size());
1169 delegate.AdvanceTime(1000);
1170 EXPECT_EQ(0U, alerts.size());
1171 delegate.AdvanceTime(1000);
1172 EXPECT_EQ(1U, alerts.size());
1173 delegate.AdvanceTime(1000);
1174 EXPECT_EQ(2U, alerts.size());
1175 delegate.AdvanceTime(1000);
1176 EXPECT_EQ(3U, alerts.size());
1177 delegate.AdvanceTime(1000);
1178 EXPECT_EQ(3U, alerts.size());
1179 delegate.AdvanceTime(1000);
1180 EXPECT_EQ(4U, alerts.size());
1181 delegate.AdvanceTime(1000);
1182 EXPECT_EQ(4U, alerts.size());
1185 ASSERT_EQ(4U, alerts.size());
1187 EXPECT_EQ(L"interval fired", alerts[0].message);
1188 EXPECT_EQ(L"Alert", alerts[0].title);
1189 EXPECT_EQ(0, alerts[0].type);
1190 EXPECT_EQ(0, alerts[0].icon);
1192 EXPECT_EQ(L"timer fired", alerts[1].message);
1193 EXPECT_EQ(L"Alert", alerts[1].title);
1194 EXPECT_EQ(0, alerts[1].type);
1195 EXPECT_EQ(0, alerts[1].icon);
1197 EXPECT_EQ(L"interval fired", alerts[2].message);
1198 EXPECT_EQ(L"Alert", alerts[2].title);
1199 EXPECT_EQ(0, alerts[2].type);
1200 EXPECT_EQ(0, alerts[2].icon);
1202 EXPECT_EQ(L"interval fired", alerts[3].message);
1203 EXPECT_EQ(L"Alert", alerts[3].title);
1204 EXPECT_EQ(0, alerts[3].type);
1205 EXPECT_EQ(0, alerts[3].icon);
1208TEST_F(FPDFFormFillEmbedderTest, Bug620428) {
1210 EmbedderTestTimerHandlingDelegate delegate;
1211 SetDelegate(&delegate);
1213 ASSERT_TRUE(OpenDocument(
"bug_620428.pdf"));
1214 FPDF_PAGE page = LoadPage(0);
1217 delegate.AdvanceTime(5000);
1220 const auto& alerts = delegate.GetAlerts();
1221 ASSERT_EQ(1U, alerts.size());
1222 EXPECT_EQ(L"done", alerts[0].message);
1225TEST_F(FPDFFormFillEmbedderTest, Bug634394) {
1227 EmbedderTestTimerHandlingDelegate delegate;
1228 SetDelegate(&delegate);
1230 ASSERT_TRUE(OpenDocument(
"bug_634394.pdf"));
1231 FPDF_PAGE page = LoadPage(0);
1237 delegate.AdvanceTime(1000);
1238 delegate.AdvanceTime(1000);
1239 delegate.AdvanceTime(1000);
1240 delegate.AdvanceTime(1000);
1241 delegate.AdvanceTime(1000);
1244 const auto& alerts = delegate.GetAlerts();
1245 EXPECT_EQ(2U, alerts.size());
1248TEST_F(FPDFFormFillEmbedderTest, Bug634716) {
1249 EmbedderTestTimerHandlingDelegate delegate;
1250 SetDelegate(&delegate);
1252 ASSERT_TRUE(OpenDocument(
"bug_634716.pdf"));
1253 FPDF_PAGE page = LoadPage(0);
1259 delegate.AdvanceTime(1000);
1260 delegate.AdvanceTime(1000);
1261 delegate.AdvanceTime(1000);
1262 delegate.AdvanceTime(1000);
1263 delegate.AdvanceTime(1000);
1266 const auto& alerts = delegate.GetAlerts();
1267 EXPECT_EQ(2U, alerts.size());
1270TEST_F(FPDFFormFillEmbedderTest, Bug679649) {
1271 EmbedderTestTimerHandlingDelegate delegate;
1272 SetDelegate(&delegate);
1274 ASSERT_TRUE(OpenDocument(
"bug_679649.pdf"));
1275 FPDF_PAGE page = LoadPage(0);
1278 delegate.SetFailNextTimer();
1280 delegate.AdvanceTime(2000);
1283 const auto& alerts = delegate.GetAlerts();
1284 EXPECT_EQ(0u, alerts.size());
1287TEST_F(FPDFFormFillEmbedderTest, Bug707673) {
1288 EmbedderTestTimerHandlingDelegate delegate;
1289 SetDelegate(&delegate);
1291 ASSERT_TRUE(OpenDocument(
"bug_707673.pdf"));
1292 FPDF_PAGE page = LoadPage(0);
1296 FORM_OnLButtonDown(form_handle(), page, 0, 140, 590);
1297 FORM_OnLButtonUp(form_handle(), page, 0, 140, 590);
1298 delegate.AdvanceTime(1000);
1301 const auto& alerts = delegate.GetAlerts();
1302 EXPECT_EQ(0u, alerts.size());
1305TEST_F(FPDFFormFillEmbedderTest, Bug765384) {
1306 ASSERT_TRUE(OpenDocument(
"bug_765384.pdf"));
1307 FPDF_PAGE page = LoadPage(0);
1311 FORM_OnLButtonDown(form_handle(), page, 0, 140, 590);
1312 FORM_OnLButtonUp(form_handle(), page, 0, 140, 590);
1317TEST_F(FPDFFormFillEmbedderTest, Bug1477093) {
1318 EmbedderTestTimerHandlingDelegate delegate;
1319 SetDelegate(&delegate);
1321 ASSERT_TRUE(OpenDocument(
"bug_1477093.pdf"));
1322 FPDF_PAGE page = LoadPage(0);
1326 delegate.AdvanceTime(1000);
1327 delegate.AdvanceTime(1000);
1334 const char* focused_text_form_with_abc_checksum = []() {
1336#if BUILDFLAG(IS_WIN)
1337 return "8b743c7a6186360862ca6f6db8f55c8f";
1338#elif BUILDFLAG(IS_APPLE)
1339 return "d8cf4e7ef7e1c287441bf350006e66d6";
1341 return "b9fb2245a98ac48146da84237a37f8cc";
1344#if BUILDFLAG(IS_APPLE)
1345 return "9fb14198d75ca0a107060c60ca21b0c7";
1347 return "6e6f790bb14c4fc6107faf8c17d23dbd";
1350 const char* unfocused_text_form_with_abc_checksum = []() {
1352#if BUILDFLAG(IS_WIN)
1353 return "37328bf7614d6fc05b03893ee030aec4";
1354#elif BUILDFLAG(IS_APPLE)
1355 return "b9702814ac50dc5ef413ea2e9c4002f1";
1357 return "5f3205f0189d9dde54665f970838f614";
1360#if BUILDFLAG(IS_APPLE)
1361 return "3c3209357e0c057a0620afa7d83eb784";
1363 return "94b7e10ac8c662b73e33628ca2f5e63b";
1367 ASSERT_TRUE(OpenDocument(
"text_form.pdf"));
1368 FPDF_PAGE page = LoadPage(0);
1370 ScopedFPDFBitmap bitmap1 = RenderLoadedPage(page);
1375 FPDFPage_HasFormFieldAtPoint(form_handle(), page, 120.0, 120.0));
1377 0, FPDFPage_FormFieldZOrderAtPoint(form_handle(), page, 120.0, 120.0));
1378 FORM_OnMouseMove(form_handle(), page, 0, 120.0, 120.0);
1379 FORM_OnLButtonDown(form_handle(), page, 0, 120.0, 120.0);
1380 FORM_OnLButtonUp(form_handle(), page, 0, 120.0, 120.0);
1383 FORM_OnChar(form_handle(), page,
'A', 0);
1384 FORM_OnChar(form_handle(), page,
'B', 0);
1385 FORM_OnChar(form_handle(), page,
'C', 0);
1386 ScopedFPDFBitmap bitmap2 = RenderLoadedPage(page);
1387 CompareBitmap(bitmap2.get(), 300, 300, focused_text_form_with_abc_checksum);
1390 FORM_OnMouseMove(form_handle(), page, 0, 15.0, 15.0);
1391 FORM_OnRButtonDown(form_handle(), page, 0, 15.0, 15.0);
1392 FORM_OnRButtonUp(form_handle(), page, 0, 15.0, 15.0);
1393 ScopedFPDFBitmap bitmap3 = RenderLoadedPage(page);
1394 CompareBitmap(bitmap3.get(), 300, 300, focused_text_form_with_abc_checksum);
1397 FORM_OnMouseMove(form_handle(), page, 0, 15.0, 15.0);
1398 FORM_OnLButtonDown(form_handle(), page, 0, 15.0, 15.0);
1399 FORM_OnLButtonUp(form_handle(), page, 0, 15.0, 15.0);
1400 ScopedFPDFBitmap bitmap4 = RenderLoadedPage(page);
1401 CompareBitmap(bitmap4.get(), 300, 300,
1402 unfocused_text_form_with_abc_checksum);
1404 EXPECT_TRUE(FPDF_SaveAsCopy(document(),
this, 0));
1410 VerifySavedDocument(300, 300, unfocused_text_form_with_abc_checksum);
1416 const char* reverse_byte_order_checksum = []() {
1418 return "8077970bbd10333f18186a9bb459bbe6";
1420 return "24fff03d1e663b7ece5f6e69ad837124";
1423 ASSERT_TRUE(OpenDocument(
"bug_890322.pdf"));
1424 FPDF_PAGE page = LoadPage(0);
1427 ScopedFPDFBitmap bitmap_normal = RenderLoadedPage(page);
1430 ScopedFPDFBitmap bitmap_reverse_byte_order =
1432 CompareBitmap(bitmap_reverse_byte_order.get(), 200, 200,
1433 reverse_byte_order_checksum);
1439 const char* checksum = []() {
1441 return "520c4415c9977f40d6b4af5a0a94d764";
1443 return "bbee92af1daec2340c81f482878744d8";
1446 ASSERT_TRUE(OpenDocument(
"bug_1302455.pdf"));
1447 FPDF_PAGE page = LoadPage(0);
1450 ScopedFPDFBitmap bitmap = RenderLoadedPage(page);
1451 CompareBitmap(bitmap.get(), 300, 300, checksum);
1453 EXPECT_TRUE(FPDF_SaveAsCopy(document(),
this, 0));
1457 VerifySavedDocument(300, 300, checksum);
1461 const char* checksum = []() {
1463#if BUILDFLAG(IS_WIN)
1464 return "2e5d64e4280ca954eb528e82f92abb75";
1465#elif BUILDFLAG(IS_APPLE)
1466 return "79538a800f8eb0b4965d43a052303592";
1468 return "143c2bb79fcaecf24f5aa104dce27beb";
1471#if BUILDFLAG(IS_APPLE)
1472 return "bf5423874f188427d2500a2bc4abebbe";
1474 return "6a4ac9a15d2c34589616c8f2b05fbedd";
1478 ASSERT_TRUE(OpenDocument(
"bug_1302455.pdf"));
1479 FPDF_PAGE page = LoadPage(0);
1483 FPDFPage_HasFormFieldAtPoint(form_handle(), page, 110, 110));
1484 FORM_OnMouseMove(form_handle(), page, 0, 110, 110);
1485 FORM_OnLButtonDown(form_handle(), page, 0, 110, 110);
1486 FORM_OnLButtonUp(form_handle(), page, 0, 110, 110);
1487 FORM_OnChar(form_handle(), page,
'A', 0);
1489 FORM_ForceToKillFocus(form_handle());
1490 ScopedFPDFBitmap bitmap = RenderLoadedPage(page);
1491 CompareBitmap(bitmap.get(), 300, 300, checksum);
1493 EXPECT_TRUE(FPDF_SaveAsCopy(document(),
this, 0));
1497 VerifySavedDocument(300, 300, checksum);
1501 const char* checksum = []() {
1503#if BUILDFLAG(IS_WIN)
1504 return "8408fc1796bf17d48b947ed0e4d65ef2";
1505#elif BUILDFLAG(IS_APPLE)
1506 return "074449f4bd27611a2e12aef3ad121cd8";
1508 return "e36726414acb616dc203e8851b510e2c";
1511#if BUILDFLAG(IS_APPLE)
1512 return "8a0fd8772dba6e1e952e49d159cc64b5";
1514 return "45a7694933c2ba3c5dc8f6cc18b79175";
1518 ASSERT_TRUE(OpenDocument(
"bug_1302455.pdf"));
1519 FPDF_PAGE page = LoadPage(0);
1523 FPDFPage_HasFormFieldAtPoint(form_handle(), page, 110, 170));
1524 FORM_OnMouseMove(form_handle(), page, 0, 110, 170);
1525 FORM_OnLButtonDown(form_handle(), page, 0, 110, 170);
1526 FORM_OnLButtonUp(form_handle(), page, 0, 110, 170);
1527 FORM_OnChar(form_handle(), page,
'B', 0);
1529 FORM_ForceToKillFocus(form_handle());
1530 ScopedFPDFBitmap bitmap = RenderLoadedPage(page);
1531 CompareBitmap(bitmap.get(), 300, 300, checksum);
1533 EXPECT_TRUE(FPDF_SaveAsCopy(document(),
this, 0));
1537 VerifySavedDocument(300, 300, checksum);
1541 const char* checksum = []() {
1543#if BUILDFLAG(IS_WIN)
1544 return "1c2b618f68d1ad2cfa01fcf38efc4831";
1545#elif BUILDFLAG(IS_APPLE)
1546 return "f5a3b8d2db662cad38b4573ef1dd3f1d";
1548 return "f82a807c056e22aa55d3d7228eedfe6f";
1551#if BUILDFLAG(IS_APPLE)
1552 return "1f422ee1c520ad74b1a993b64bd4dc4a";
1554 return "13984969b1e141079ab5f4aa80185463";
1558 ASSERT_TRUE(OpenDocument(
"bug_1302455.pdf"));
1559 FPDF_PAGE page = LoadPage(0);
1563 FPDFPage_HasFormFieldAtPoint(form_handle(), page, 110, 110));
1564 FORM_OnMouseMove(form_handle(), page, 0, 110, 110);
1565 FORM_OnLButtonDown(form_handle(), page, 0, 110, 110);
1566 FORM_OnLButtonUp(form_handle(), page, 0, 110, 110);
1567 FORM_OnChar(form_handle(), page,
'A', 0);
1570 FPDFPage_HasFormFieldAtPoint(form_handle(), page, 110, 170));
1571 FORM_OnMouseMove(form_handle(), page, 0, 110, 170);
1572 FORM_OnLButtonDown(form_handle(), page, 0, 110, 170);
1573 FORM_OnLButtonUp(form_handle(), page, 0, 110, 170);
1574 FORM_OnChar(form_handle(), page,
'B', 0);
1576 FORM_ForceToKillFocus(form_handle());
1577 ScopedFPDFBitmap bitmap = RenderLoadedPage(page);
1578 CompareBitmap(bitmap.get(), 300, 300, checksum);
1580 EXPECT_TRUE(FPDF_SaveAsCopy(document(),
this, 0));
1584 VerifySavedDocument(300, 300, checksum);
1588 const char* no_highlight_checksum = []() {
1590#if BUILDFLAG(IS_WIN)
1591 return "2235e2ba8349552de0c818ae53257949";
1592#elif BUILDFLAG(IS_APPLE)
1593 return "e0ad5b4fe007e2e2c27cf6c6fb5b6529";
1595 return "3bfddb2529085021ad283b7e65f71525";
1598#if BUILDFLAG(IS_APPLE)
1599 return "5c82aa43e3b478aa1e4c94bb9ef1f11f";
1601 return "a6268304f7eedfa9ee98fac3caaf2efb";
1605 ASSERT_TRUE(OpenDocument(
"text_form.pdf"));
1606 FPDF_PAGE page = LoadPage(0);
1608 ScopedFPDFBitmap bitmap1 = RenderLoadedPage(page);
1612 FPDF_RemoveFormFieldHighlight(form_handle());
1613 ScopedFPDFBitmap bitmap2 = RenderLoadedPage(page);
1614 CompareBitmap(bitmap2.get(), 300, 300, no_highlight_checksum);
1617 SetInitialFormFieldHighlight(form_handle());
1618 ScopedFPDFBitmap bitmap3 = RenderLoadedPage(page);
1625 ASSERT_TRUE(OpenDocument(
"hello_world.pdf"));
1630 ASSERT_TRUE(OpenDocument(
"text_form.pdf"));
1635 ASSERT_TRUE(OpenDocument(
"simple_xfa.pdf"));
1640 ASSERT_TRUE(OpenDocument(
"bug_216.pdf"));
1645 ASSERT_TRUE(OpenDocument(
"text_form.pdf"));
1646 FPDF_PAGE page = LoadPage(0);
1651 EXPECT_FALSE(FORM_SetIndexSelected(form_handle(),
nullptr, 0,
true));
1652 EXPECT_FALSE(FORM_SetIndexSelected(form_handle(), page, -1,
true));
1655 EXPECT_FALSE(FORM_IsIndexSelected(form_handle(),
nullptr, 0));
1656 EXPECT_FALSE(FORM_IsIndexSelected(form_handle(), page, -1));
1662 ASSERT_TRUE(OpenDocument(
"combobox_form.pdf"));
1663 FPDF_PAGE page = LoadPage(0);
1666 EXPECT_FALSE(FORM_SetIndexSelected(form_handle(), page, -1,
true));
1667 EXPECT_FALSE(FORM_SetIndexSelected(form_handle(), page, 100,
true));
1668 EXPECT_FALSE(FORM_IsIndexSelected(form_handle(), page, -1));
1669 EXPECT_FALSE(FORM_IsIndexSelected(form_handle(), page, 100));
1675 ASSERT_TRUE(OpenDocument(
"listbox_form.pdf"));
1676 FPDF_PAGE page = LoadPage(0);
1679 EXPECT_FALSE(FORM_SetIndexSelected(form_handle(), page, -1,
true));
1680 EXPECT_FALSE(FORM_SetIndexSelected(form_handle(), page, 100,
true));
1681 EXPECT_FALSE(FORM_IsIndexSelected(form_handle(), page, -1));
1682 EXPECT_FALSE(FORM_IsIndexSelected(form_handle(), page, 100));
1688 ASSERT_TRUE(OpenDocument(
"simple_xfa.pdf"));
1689 FPDF_PAGE page = LoadPage(0);
1692 EXPECT_EQ(-1, FPDFPage_HasFormFieldAtPoint(form_handle(), page, 612, 792));
1694#ifdef PDF_ENABLE_XFA
1695 constexpr int kExpectedFieldType = FPDF_FORMFIELD_XFA_TEXTFIELD;
1697 constexpr int kExpectedFieldType = -1;
1699 EXPECT_EQ(kExpectedFieldType,
1700 FPDFPage_HasFormFieldAtPoint(form_handle(), page, 50, 30));
1706 ASSERT_TRUE(OpenDocument(
"text_form.pdf"));
1707 FPDF_PAGE page = LoadPage(0);
1712 EXPECT_FALSE(FORM_SelectAllText(form_handle(),
nullptr));
1716 EXPECT_TRUE(FORM_OnFocus(form_handle(), page, 0, 115, 115));
1718 FORM_ReplaceSelection(form_handle(), page, text_to_insert.get());
1722 ASSERT_EQ(12u, FORM_GetFocusedText(form_handle(), page,
nullptr, 0));
1724 FORM_GetFocusedText(form_handle(), page, buffer,
sizeof(buffer)));
1728 ASSERT_EQ(2u, FORM_GetSelectedText(form_handle(), page,
nullptr, 0));
1730 FORM_GetSelectedText(form_handle(), page, buffer,
sizeof(buffer)));
1734 EXPECT_TRUE(FORM_SelectAllText(form_handle(), page));
1735 ASSERT_EQ(12u, FORM_GetSelectedText(form_handle(), page,
nullptr, 0));
1737 FORM_GetSelectedText(form_handle(), page, buffer,
sizeof(buffer)));
1745 CheckFocusedFieldText(
"");
1749 TypeTextIntoTextField(3, RegularFormBegin());
1750 CheckFocusedFieldText(
"ABC");
1751 SelectTextWithKeyboard(3,
FWL_VKEY_Left, RegularFormAtX(123.0));
1752 CheckSelection(
"ABC");
1757 CheckFocusedFieldText(
"");
1761 TypeTextIntoTextField(3, RegularFormBegin());
1762 CheckFocusedFieldText(
"ABC");
1763 SelectTextWithMouse(RegularFormAtX(125.0), RegularFormBegin());
1764 CheckSelection(
"ABC");
1768 TypeTextIntoTextField(12, RegularFormBegin());
1769 CheckFocusedFieldText(
"ABCDEFGHIJKL");
1773 CheckSelection(
"A");
1776 SelectTextWithKeyboard(12,
FWL_VKEY_Left, RegularFormEnd());
1777 CheckSelection(
"ABCDEFGHIJKL");
1780 SelectTextWithKeyboard(6,
FWL_VKEY_Left, RegularFormAtX(170.0));
1781 CheckSelection(
"DEFGHI");
1784 SelectTextWithKeyboard(6,
FWL_VKEY_Right, RegularFormAtX(125.0));
1785 CheckSelection(
"DEFGHI");
1789 CheckSelection(
"L");
1790 CheckFocusedFieldText(
"ABCDEFGHIJKL");
1794 TypeTextIntoTextField(12, RegularFormBegin());
1797 SelectTextWithMouse(RegularFormBegin(), RegularFormAtX(106.0));
1798 CheckSelection(
"A");
1801 SelectAllRegularFormTextWithMouse();
1802 CheckSelection(
"ABCDEFGHIJKL");
1805 SelectTextWithMouse(RegularFormAtX(170.0), RegularFormAtX(125.0));
1806 CheckSelection(
"DEFGHI");
1809 SelectTextWithMouse(RegularFormAtX(125.0), RegularFormAtX(170.0));
1810 CheckSelection(
"DEFGHI");
1813 SelectTextWithMouse(RegularFormEnd(), RegularFormAtX(186.0));
1814 CheckSelection(
"L");
1821 CheckFocusedFieldText(
"");
1824 SelectTextWithMouse(NonEditableFormBegin(), NonEditableFormAtX(142.0));
1825 CheckFocusedFieldText(
"Banana");
1826 CheckSelection(
"Banana");
1829 SelectNonEditableFormOption(0);
1830 CheckFocusedFieldText(
"Apple");
1831 CheckSelection(
"Apple");
1838 CheckFocusedFieldText(
"");
1841 TypeTextIntoTextField(3, EditableFormBegin());
1842 CheckFocusedFieldText(
"ABC");
1843 SelectTextWithKeyboard(3,
FWL_VKEY_Left, EditableFormAtX(128.0));
1844 CheckSelection(
"ABC");
1847 SelectEditableFormOption(1);
1848 CheckSelection(
"Bar");
1849 CheckFocusedFieldText(
"Bar");
1858 TypeTextIntoTextField(3, EditableFormBegin());
1859 SelectTextWithMouse(EditableFormAtX(128.0), EditableFormBegin());
1860 CheckSelection(
"ABC");
1863 SelectEditableFormOption(2);
1864 CheckFocusedFieldText(
"Qux");
1865 CheckSelection(
"Qux");
1870 CheckFocusedFieldText(
"");
1873 SelectTextWithMouse(NonEditableFormBegin(), NonEditableFormAtX(107.0));
1874 CheckFocusedFieldText(
"Banana");
1875 CheckSelection(
"B");
1878 SelectTextWithMouse(NonEditableFormAtX(142.0), NonEditableFormBegin());
1879 CheckSelection(
"Banana");
1882 SelectTextWithMouse(NonEditableFormAtX(135.0), NonEditableFormAtX(117.0));
1883 CheckSelection(
"nan");
1886 SelectTextWithMouse(NonEditableFormAtX(117.0), NonEditableFormAtX(135.0));
1887 CheckSelection(
"nan");
1890 SelectTextWithMouse(NonEditableFormAtX(142.0), NonEditableFormAtX(138.0));
1891 CheckSelection(
"a");
1892 CheckFocusedFieldText(
"Banana");
1895 SelectNonEditableFormOption(2);
1896 CheckFocusedFieldText(
"Cherry");
1897 CheckSelection(
"Cherry");
1898 SelectTextWithMouse(NonEditableFormBegin(), NonEditableFormAtX(122.0));
1899 CheckSelection(
"Che");
1904 CheckFocusedFieldText(
"");
1905 TypeTextIntoTextField(10, EditableFormBegin());
1906 CheckFocusedFieldText(
"ABCDEFGHIJ");
1910 CheckSelection(
"A");
1913 SelectTextWithKeyboard(10,
FWL_VKEY_Left, EditableFormEnd());
1914 CheckSelection(
"ABCDEFGHIJ");
1917 SelectTextWithKeyboard(5,
FWL_VKEY_Left, EditableFormAtX(168.0));
1918 CheckSelection(
"DEFGH");
1921 SelectTextWithKeyboard(5,
FWL_VKEY_Right, EditableFormAtX(127.0));
1922 CheckSelection(
"DEFGH");
1925 SelectTextWithKeyboard(1,
FWL_VKEY_Left, EditableFormEnd());
1926 CheckSelection(
"J");
1929 SelectEditableFormOption(0);
1930 CheckSelection(
"Foo");
1932 CheckSelection(
"Fo");
1933 CheckFocusedFieldText(
"Foo");
1938 TypeTextIntoTextField(10, EditableFormBegin());
1941 SelectTextWithMouse(EditableFormBegin(), EditableFormAtX(107.0));
1942 CheckSelection(
"A");
1945 SelectAllEditableFormTextWithMouse();
1946 CheckSelection(
"ABCDEFGHIJ");
1949 SelectTextWithMouse(EditableFormAtX(168.0), EditableFormAtX(127.0));
1950 CheckSelection(
"DEFGH");
1953 SelectTextWithMouse(EditableFormAtX(127.0), EditableFormAtX(168.0));
1954 CheckSelection(
"DEFGH");
1957 SelectTextWithMouse(EditableFormEnd(), EditableFormAtX(174.0));
1958 CheckSelection(
"J");
1959 CheckFocusedFieldText(
"ABCDEFGHIJ");
1967 FocusOnNonEditableForm();
1968 CheckFocusedFieldText(
"Banana");
1972 SetIndexSelectedShouldSucceed(0,
true);
1973 CheckFocusedFieldText(
"Apple");
1976 SetIndexSelectedShouldSucceed(0,
true);
1977 CheckFocusedFieldText(
"Apple");
1979 SetIndexSelectedShouldSucceed(9,
true);
1980 CheckFocusedFieldText(
"Jackfruit");
1983 SetIndexSelectedShouldFail(9,
false);
1984 CheckFocusedFieldText(
"Jackfruit");
1987 SetIndexSelectedShouldFail(100,
true);
1988 SetIndexSelectedShouldFail(-100,
true);
1989 CheckFocusedFieldText(
"Jackfruit");
1993 SelectNonEditableFormOption(1);
1994 CheckFocusedFieldText(
"Banana");
2002 FocusOnEditableForm();
2003 CheckFocusedFieldText(
"");
2007 SetIndexSelectedShouldSucceed(0,
true);
2008 CheckFocusedFieldText(
"Foo");
2010 SetIndexSelectedShouldSucceed(1,
true);
2011 CheckFocusedFieldText(
"Bar");
2014 SetIndexSelectedShouldSucceed(1,
true);
2015 CheckFocusedFieldText(
"Bar");
2018 SetIndexSelectedShouldFail(0,
false);
2019 CheckFocusedFieldText(
"Bar");
2022 SetIndexSelectedShouldFail(100,
true);
2023 SetIndexSelectedShouldFail(-100,
true);
2024 CheckFocusedFieldText(
"Bar");
2028 SelectEditableFormOption(0);
2029 CheckFocusedFieldText(
"Foo");
2035 SetIndexSelectedShouldSucceed(1,
true);
2036 CheckFocusedFieldText(
"Bar");
2037 TypeTextIntoTextField(5, EditableFormBegin());
2038 CheckFocusedFieldText(
"ABCDEBar");
2044 ClickOnFormFieldAtPoint(NonEditableFormBegin());
2045 for (
int i = 0; i < 26; i++) {
2046 bool expected = i == 1;
2047 CheckIsIndexSelected(i, expected);
2050 SelectNonEditableFormOption(0);
2051 CheckIsIndexSelected(0,
true);
2052 for (
int i = 1; i < 26; i++) {
2053 CheckIsIndexSelected(i,
false);
2060 ClickOnFormFieldAtPoint(EditableFormBegin());
2061 CheckIsIndexSelected(0,
false);
2062 CheckIsIndexSelected(1,
false);
2063 CheckIsIndexSelected(2,
false);
2065 SelectEditableFormOption(0);
2066 CheckIsIndexSelected(0,
true);
2067 CheckIsIndexSelected(1,
false);
2068 CheckIsIndexSelected(2,
false);
2073 TypeTextIntoTextField(12, RegularFormBegin());
2074 SelectAllRegularFormTextWithMouse();
2075 CheckFocusedFieldText(
"ABCDEFGHIJKL");
2076 CheckSelection(
"ABCDEFGHIJKL");
2080 FORM_ReplaceSelection(form_handle(), page(),
nullptr);
2081 CheckFocusedFieldText(
"");
2083 SelectTextWithKeyboard(12,
FWL_VKEY_Left, RegularFormEnd());
2089 TypeTextIntoTextField(12, RegularFormBegin());
2090 SelectTextWithMouse(RegularFormAtX(170.0), RegularFormAtX(125.0));
2091 CheckFocusedFieldText(
"ABCDEFGHIJKL");
2092 CheckSelection(
"DEFGHI");
2096 FORM_ReplaceSelection(form_handle(), page(),
nullptr);
2097 CheckFocusedFieldText(
"ABCJKL");
2098 SelectTextWithKeyboard(12,
FWL_VKEY_Left, RegularFormEnd());
2099 CheckSelection(
"ABCJKL");
2104 TypeTextIntoTextField(12, RegularFormBegin());
2105 SelectTextWithMouse(RegularFormBegin(), RegularFormAtX(132.0));
2106 CheckSelection(
"ABCD");
2110 FORM_ReplaceSelection(form_handle(), page(),
nullptr);
2111 CheckFocusedFieldText(
"EFGHIJKL");
2112 SelectTextWithKeyboard(12,
FWL_VKEY_Left, RegularFormEnd());
2113 CheckSelection(
"EFGHIJKL");
2118 TypeTextIntoTextField(12, RegularFormBegin());
2119 SelectTextWithMouse(RegularFormEnd(), RegularFormAtX(165.0));
2120 CheckSelection(
"IJKL");
2124 FORM_ReplaceSelection(form_handle(), page(),
nullptr);
2125 CheckFocusedFieldText(
"ABCDEFGH");
2126 SelectTextWithKeyboard(12,
FWL_VKEY_Left, RegularFormEnd());
2127 CheckSelection(
"ABCDEFGH");
2132 TypeTextIntoTextField(12, RegularFormBegin());
2136 FORM_ReplaceSelection(form_handle(), page(),
nullptr);
2137 CheckFocusedFieldText(
"ABCDEFGHIJKL");
2138 SelectTextWithKeyboard(12,
FWL_VKEY_Left, RegularFormEnd());
2139 CheckSelection(
"ABCDEFGHIJKL");
2145 TypeTextIntoTextField(10, EditableFormBegin());
2146 SelectAllEditableFormTextWithMouse();
2147 CheckSelection(
"ABCDEFGHIJ");
2151 FORM_ReplaceSelection(form_handle(), page(),
nullptr);
2152 CheckFocusedFieldText(
"");
2153 SelectAllEditableFormTextWithMouse();
2160 TypeTextIntoTextField(10, EditableFormBegin());
2161 SelectTextWithMouse(EditableFormAtX(168.0), EditableFormAtX(127.0));
2162 CheckSelection(
"DEFGH");
2166 FORM_ReplaceSelection(form_handle(), page(),
nullptr);
2167 CheckFocusedFieldText(
"ABCIJ");
2168 SelectAllEditableFormTextWithMouse();
2169 CheckSelection(
"ABCIJ");
2175 TypeTextIntoTextField(10, EditableFormBegin());
2176 SelectTextWithMouse(EditableFormBegin(), EditableFormAtX(132.0));
2177 CheckSelection(
"ABCD");
2181 FORM_ReplaceSelection(form_handle(), page(),
nullptr);
2182 SelectAllEditableFormTextWithMouse();
2183 CheckSelection(
"EFGHIJ");
2189 TypeTextIntoTextField(10, EditableFormBegin());
2190 SelectTextWithMouse(EditableFormEnd(), EditableFormAtX(152.0));
2191 CheckSelection(
"GHIJ");
2195 FORM_ReplaceSelection(form_handle(), page(),
nullptr);
2196 SelectAllEditableFormTextWithMouse();
2197 CheckSelection(
"ABCDEF");
2203 TypeTextIntoTextField(10, EditableFormBegin());
2207 FORM_ReplaceSelection(form_handle(), page(),
nullptr);
2208 SelectAllEditableFormTextWithMouse();
2209 CheckSelection(
"ABCDEFGHIJ");
2213 CheckFocusedFieldText(
"");
2214 ClickOnFormFieldAtPoint(RegularFormBegin());
2215 CheckFocusedFieldText(
"");
2219 FORM_ReplaceSelection(form_handle(), page(), text_to_insert.get());
2220 CheckFocusedFieldText(
"Hello");
2225 SelectAllRegularFormTextWithMouse();
2226 CheckSelection(
"Hello");
2230 TypeTextIntoTextField(8, RegularFormBegin());
2231 CheckFocusedFieldText(
"ABCDEFGH");
2234 ClickOnFormFieldAtPoint(RegularFormBegin());
2235 CheckFocusedFieldText(
"ABCDEFGH");
2239 FORM_ReplaceSelection(form_handle(), page(), text_to_insert.get());
2240 CheckFocusedFieldText(
"HelloABCDEFGH");
2245 SelectAllRegularFormTextWithMouse();
2246 CheckSelection(
"HelloABCDEFGH");
2250 TypeTextIntoTextField(8, RegularFormBegin());
2253 ClickOnFormFieldAtPoint(RegularFormAtX(134.0));
2257 FORM_ReplaceSelection(form_handle(), page(), text_to_insert.get());
2258 CheckFocusedFieldText(
"ABCDHelloEFGH");
2263 SelectAllRegularFormTextWithMouse();
2264 CheckSelection(
"ABCDHelloEFGH");
2268 TypeTextIntoTextField(8, RegularFormBegin());
2271 ClickOnFormFieldAtPoint(RegularFormAtX(166.0));
2275 FORM_ReplaceSelection(form_handle(), page(), text_to_insert.get());
2276 CheckFocusedFieldText(
"ABCDEFGHHello");
2281 SelectAllRegularFormTextWithMouse();
2282 CheckSelection(
"ABCDEFGHHello");
2287 TypeTextIntoTextField(12, RegularFormBegin());
2291 SelectTextWithKeyboard(12,
FWL_VKEY_Left, RegularFormEnd());
2292 CheckSelection(
"ABCDEFGHIJKL");
2296 FORM_ReplaceSelection(form_handle(), page(), text_to_insert.get());
2297 CheckFocusedFieldText(
"Hello");
2302 SelectAllRegularFormTextWithMouse();
2303 CheckSelection(
"Hello");
2308 TypeTextIntoTextField(12, RegularFormBegin());
2312 SelectTextWithKeyboard(6,
FWL_VKEY_Left, RegularFormAtX(148.0));
2313 CheckSelection(
"ABCDEF");
2317 FORM_ReplaceSelection(form_handle(), page(), text_to_insert.get());
2318 CheckFocusedFieldText(
"HelloGHIJKL");
2323 SelectAllRegularFormTextWithMouse();
2324 CheckSelection(
"HelloGHIJKL");
2329 TypeTextIntoTextField(12, RegularFormBegin());
2333 SelectTextWithKeyboard(6,
FWL_VKEY_Left, RegularFormAtX(171.0));
2334 CheckSelection(
"DEFGHI");
2338 FORM_ReplaceSelection(form_handle(), page(), text_to_insert.get());
2343 SelectAllRegularFormTextWithMouse();
2344 CheckSelection(
"ABCHelloJKL");
2349 TypeTextIntoTextField(12, RegularFormBegin());
2354 CheckSelection(
"GHIJKL");
2358 FORM_ReplaceSelection(form_handle(), page(), text_to_insert.get());
2363 SelectAllRegularFormTextWithMouse();
2364 CheckSelection(
"ABCDEFHello");
2369 ClickOnFormFieldAtPoint(EditableFormBegin());
2370 CheckFocusedFieldText(
"");
2374 FORM_ReplaceSelection(form_handle(), page(), text_to_insert.get());
2375 CheckFocusedFieldText(
"Hello");
2380 SelectAllEditableFormTextWithMouse();
2381 CheckSelection(
"Hello");
2386 TypeTextIntoTextField(6, EditableFormBegin());
2389 ClickOnFormFieldAtPoint(EditableFormBegin());
2393 FORM_ReplaceSelection(form_handle(), page(), text_to_insert.get());
2398 SelectAllEditableFormTextWithMouse();
2399 CheckSelection(
"HelloABCDEF");
2404 TypeTextIntoTextField(6, EditableFormBegin());
2407 ClickOnFormFieldAtPoint(EditableFormAtX(126.0));
2412 FORM_ReplaceSelection(form_handle(), page(), text_to_insert.get());
2417 SelectAllEditableFormTextWithMouse();
2418 CheckSelection(
"ABCHelloDEF");
2423 TypeTextIntoTextField(6, EditableFormBegin());
2426 ClickOnFormFieldAtPoint(EditableFormEnd());
2430 FORM_ReplaceSelection(form_handle(), page(), text_to_insert.get());
2435 SelectAllEditableFormTextWithMouse();
2436 CheckSelection(
"ABCDEFHello");
2441 TypeTextIntoTextField(10, EditableFormBegin());
2445 SelectTextWithKeyboard(10,
FWL_VKEY_Left, EditableFormEnd());
2446 CheckSelection(
"ABCDEFGHIJ");
2450 FORM_ReplaceSelection(form_handle(), page(), text_to_insert.get());
2455 SelectAllEditableFormTextWithMouse();
2456 CheckSelection(
"Hello");
2461 TypeTextIntoTextField(10, EditableFormBegin());
2465 SelectTextWithKeyboard(5,
FWL_VKEY_Left, EditableFormAtX(142.0));
2466 CheckSelection(
"ABCDE");
2470 FORM_ReplaceSelection(form_handle(), page(), text_to_insert.get());
2475 SelectAllEditableFormTextWithMouse();
2476 CheckSelection(
"HelloFGHIJ");
2481 TypeTextIntoTextField(10, EditableFormBegin());
2485 SelectTextWithKeyboard(5,
FWL_VKEY_Left, EditableFormAtX(167.0));
2486 CheckSelection(
"DEFGH");
2490 FORM_ReplaceSelection(form_handle(), page(), text_to_insert.get());
2495 SelectAllEditableFormTextWithMouse();
2496 CheckSelection(
"ABCHelloIJ");
2501 TypeTextIntoTextField(10, EditableFormBegin());
2505 SelectTextWithKeyboard(5,
FWL_VKEY_Left, EditableFormEnd());
2506 CheckSelection(
"FGHIJ");
2510 FORM_ReplaceSelection(form_handle(), page(), text_to_insert.get());
2515 SelectAllEditableFormTextWithMouse();
2516 CheckSelection(
"ABCDEHello");
2522 ClickOnFormFieldAtPoint(NonEditableFormBegin());
2523 CheckIsIndexSelected(0,
false);
2524 CheckIsIndexSelected(1,
true);
2530 EXPECT_TRUE(FORM_OnKeyDown(form_handle(), page(),
FWL_VKEY_Down, 0));
2531 CheckIsIndexSelected(1,
false);
2532 CheckIsIndexSelected(2,
true);
2542 CheckIsIndexSelected(2,
true);
2548 EXPECT_TRUE(FORM_OnKeyDown(form_handle(), page(),
FWL_VKEY_Down, 0));
2549 CheckIsIndexSelected(3,
true);
2559 CheckIsIndexSelected(3,
true);
2565 ClickOnFormFieldAtPoint(EditableFormBegin());
2566 CheckIsIndexSelected(0,
false);
2567 CheckIsIndexSelected(1,
false);
2573 EXPECT_TRUE(FORM_OnKeyDown(form_handle(), page(),
FWL_VKEY_Down, 0));
2574 CheckIsIndexSelected(0,
true);
2575 CheckIsIndexSelected(1,
false);
2585 CheckIsIndexSelected(0,
true);
2590 CheckFocusedFieldText(
" ");
2591 CheckIsIndexSelected(0,
false);
2597 CheckFocusedFieldText(
"");
2598 ClickOnFormFieldAtPoint(CharLimitFormEnd());
2599 CheckFocusedFieldText(
"Elephant");
2603 SelectAllCharLimitFormTextWithMouse();
2604 CheckSelection(
"Elephant");
2605 FORM_ReplaceSelection(form_handle(), page(),
nullptr);
2606 CheckFocusedFieldText(
"");
2611 FORM_ReplaceSelection(form_handle(), page(), text_to_insert.get());
2612 CheckFocusedFieldText(
"Hippopotam");
2617 SelectAllCharLimitFormTextWithMouse();
2618 CheckSelection(
"Hippopotam");
2624 ClickOnFormFieldAtPoint(CharLimitFormEnd());
2625 CheckFocusedFieldText(
"Elephant");
2629 SelectAllCharLimitFormTextWithMouse();
2630 CheckSelection(
"Elephant");
2631 FORM_ReplaceSelection(form_handle(), page(),
nullptr);
2636 FORM_ReplaceSelection(form_handle(), page(), text_to_insert.get());
2637 CheckFocusedFieldText(
"Zebra");
2642 SelectAllCharLimitFormTextWithMouse();
2643 CheckSelection(
"Zebra");
2649 ClickOnFormFieldAtPoint(CharLimitFormBegin());
2653 FORM_ReplaceSelection(form_handle(), page(), text_to_insert.get());
2658 SelectAllCharLimitFormTextWithMouse();
2659 CheckSelection(
"HiElephant");
2664 CheckFocusedFieldText(
"");
2665 TypeTextIntoTextField(8, RegularFormBegin());
2666 CheckFocusedFieldText(
"ABCDEFGH");
2669 ClickOnFormFieldAtPoint(CharLimitFormAtX(134.0));
2670 CheckFocusedFieldText(
"Elephant");
2674 FORM_ReplaceSelection(form_handle(), page(), text_to_insert.get());
2675 CheckFocusedFieldText(
"ElephHiant");
2680 SelectAllCharLimitFormTextWithMouse();
2681 CheckSelection(
"ElephHiant");
2686 TypeTextIntoTextField(8, RegularFormBegin());
2689 ClickOnFormFieldAtPoint(CharLimitFormAtX(166.0));
2693 FORM_ReplaceSelection(form_handle(), page(), text_to_insert.get());
2698 SelectAllCharLimitFormTextWithMouse();
2699 CheckSelection(
"ElephantHi");
2704 TypeTextIntoTextField(12, RegularFormBegin());
2708 SelectTextWithKeyboard(12,
FWL_VKEY_Left, CharLimitFormEnd());
2709 CheckSelection(
"Elephant");
2713 FORM_ReplaceSelection(form_handle(), page(), text_to_insert.get());
2718 SelectAllCharLimitFormTextWithMouse();
2719 CheckSelection(
"Hippopotam");
2724 TypeTextIntoTextField(12, RegularFormBegin());
2728 SelectTextWithKeyboard(4,
FWL_VKEY_Left, CharLimitFormAtX(122.0));
2729 CheckSelection(
"Elep");
2733 FORM_ReplaceSelection(form_handle(), page(), text_to_insert.get());
2738 SelectAllCharLimitFormTextWithMouse();
2739 CheckSelection(
"Hippophant");
2744 TypeTextIntoTextField(12, RegularFormBegin());
2748 SelectTextWithKeyboard(4,
FWL_VKEY_Left, CharLimitFormAtX(136.0));
2749 CheckSelection(
"epha");
2753 FORM_ReplaceSelection(form_handle(), page(), text_to_insert.get());
2758 SelectAllCharLimitFormTextWithMouse();
2759 CheckSelection(
"ElHippopnt");
2764 TypeTextIntoTextField(12, RegularFormBegin());
2768 SelectTextWithKeyboard(4,
FWL_VKEY_Left, CharLimitFormAtX(152.0));
2769 CheckSelection(
"hant");
2773 FORM_ReplaceSelection(form_handle(), page(), text_to_insert.get());
2778 SelectAllCharLimitFormTextWithMouse();
2779 CheckSelection(
"ElepHippop");
2783 CheckFocusedFieldText(
"");
2784 ClickOnFormFieldAtPoint(RegularFormBegin());
2785 CheckFocusedFieldText(
"");
2789 FORM_ReplaceSelection(form_handle(), page(), text_to_insert.get());
2790 CheckFocusedFieldText(
"Hello World");
2794 DoubleClickOnFormFieldAtPoint(RegularFormBegin());
2795 CheckSelection(
"Hello World");
2799 testing::NiceMock<EmbedderTestMockDelegate> mock;
2801 CheckFocusedFieldText(
"");
2803#ifdef PDF_ENABLE_XFA
2804 EXPECT_CALL(mock, OnFocusChange(_, _, 0)).Times(1);
2806 EXPECT_CALL(mock, OnFocusChange(_, _, 0)).Times(0);
2809 ClickOnFormFieldAtPoint(RegularFormBegin());
2814 testing::NiceMock<EmbedderTestMockDelegate> mock;
2816 CheckFocusedFieldText(
"");
2818 EXPECT_CALL(mock, OnFocusChange(_, _, 0)).Times(1);
2819 ClickOnFormFieldAtPoint(RegularFormBegin());
2824 CheckFocusedFieldText(
"");
2825 ClickOnFormFieldAtPoint(CharLimitFormEnd());
2826 CheckFocusedFieldText(
"Elephant");
2827 ClickOnFormFieldAtPoint(RegularFormBegin());
2828 CheckFocusedFieldText(
"");
2829 TypeTextIntoTextField(3, CharLimitFormBegin());
2830 CheckFocusedFieldText(
"ABElephant");
2831 TypeTextIntoTextField(5, RegularFormBegin());
2832 CheckFocusedFieldText(
"ABCDE");
2833 ClickOnFormFieldAtPoint(CharLimitFormEnd());
2834 CheckFocusedFieldText(
"ABElephant");
2835 ClickOnFormFieldAtPoint(kNonFormPoint);
2836 CheckFocusedFieldText(
"");
2837 ClickOnFormFieldAtPoint(kNonFormPoint);
2838 CheckFocusedFieldText(
"");
2839 ClickOnFormFieldAtPoint(CharLimitFormBegin());
2840 CheckFocusedFieldText(
"ABElephant");
2841 ClickOnFormFieldAtPoint(CharLimitFormEnd());
2842 CheckFocusedFieldText(
"ABElephant");
2843 ClickOnFormFieldAtPoint(RegularFormEnd());
2844 CheckFocusedFieldText(
"ABCDE");
2845 ClickOnFormFieldAtPoint(RegularFormBegin());
2846 CheckFocusedFieldText(
"ABCDE");
2847 ClickOnFormFieldAtPoint(RegularFormBegin());
2848 CheckFocusedFieldText(
"ABCDE");
2849 ClickOnFormFieldAtPoint(CharLimitFormBegin());
2850 CheckFocusedFieldText(
"ABElephant");
2851 FORM_ForceToKillFocus(form_handle());
2852 CheckFocusedFieldText(
"");
2857 CheckFocusedFieldText(
"");
2858 ClickOnFormFieldAtPoint(NonEditableFormBegin());
2859 CheckFocusedFieldText(
"Banana");
2860 ClickOnFormFieldAtPoint(EditableFormBegin());
2861 CheckFocusedFieldText(
"");
2862 ClickOnFormFieldAtPoint(NonEditableFormEnd());
2863 CheckFocusedFieldText(
"Banana");
2864 ClickOnFormFieldAtPoint(NonEditableFormBegin());
2865 CheckFocusedFieldText(
"Banana");
2866 FORM_ForceToKillFocus(form_handle());
2867 CheckFocusedFieldText(
"");
2868 ClickOnFormFieldAtPoint(EditableFormBegin());
2869 CheckFocusedFieldText(
"");
2870 TypeTextIntoTextField(3, EditableFormBegin());
2871 CheckFocusedFieldText(
"ABC");
2872 ClickOnFormFieldAtPoint(kNonFormPoint);
2873 CheckFocusedFieldText(
"");
2874 TypeTextIntoTextField(3, EditableFormEnd());
2875 CheckFocusedFieldText(
"ABCABC");
2876 ClickOnFormFieldAtPoint(kNonFormPoint);
2877 CheckFocusedFieldText(
"");
2878 ClickOnFormFieldAtPoint(EditableFormDropDown());
2879 CheckFocusedFieldText(
"ABCABC");
2880 FORM_ForceToKillFocus(form_handle());
2881 CheckFocusedFieldText(
"");
2882 ClickOnFormFieldAtPoint(NonEditableFormDropDown());
2883 CheckFocusedFieldText(
"Banana");
2884 ClickOnFormFieldAtPoint(kNonFormPoint);
2885 CheckFocusedFieldText(
"");
2886 ClickOnFormFieldAtPoint(NonEditableFormEnd());
2887 CheckFocusedFieldText(
"Banana");
2890 TypeTextIntoTextField(1, NonEditableFormEnd());
2891 CheckFocusedFieldText(
"Apple");
2892 TypeTextIntoTextField(3, NonEditableFormEnd());
2893 CheckFocusedFieldText(
"Cherry");
2894 TypeTextIntoTextField(2, NonEditableFormEnd());
2895 CheckFocusedFieldText(
"Banana");
2897 SelectEditableFormOption(0);
2898 CheckFocusedFieldText(
"Foo");
2899 SelectEditableFormOption(1);
2900 CheckFocusedFieldText(
"Bar");
2901 SelectEditableFormOption(2);
2902 CheckFocusedFieldText(
"Qux");
2903 SelectNonEditableFormOption(1);
2904 CheckFocusedFieldText(
"Banana");
2905 SelectNonEditableFormOption(0);
2906 CheckFocusedFieldText(
"Apple");
2907 SelectNonEditableFormOption(2);
2908 CheckFocusedFieldText(
"Cherry");
2911 SelectEditableFormOption(0);
2912 CheckFocusedFieldText(
"Foo");
2913 TypeTextIntoTextField(5, EditableFormBegin());
2914 CheckFocusedFieldText(
"ABCDEFoo");
2915 SelectEditableFormOption(2);
2916 CheckFocusedFieldText(
"Qux");
2917 TypeTextIntoTextField(2, EditableFormEnd());
2918 CheckFocusedFieldText(
"QuxAB");
2921 SelectEditableFormOption(0);
2922 CheckFocusedFieldText(
"Foo");
2923 TypeTextIntoTextField(1, EditableFormBegin());
2924 CheckFocusedFieldText(
"AFoo");
2925 SelectEditableFormOption(0);
2926 CheckFocusedFieldText(
"Foo");
2930 ClickOnFormFieldAtPoint(RegularFormBegin());
2931 CheckFocusedFieldText(
"");
2932 CheckCanUndo(
false);
2933 CheckCanRedo(
false);
2935 TypeTextIntoTextField(5, RegularFormBegin());
2936 CheckFocusedFieldText(
"ABCDE");
2938 CheckCanRedo(
false);
2941 CheckFocusedFieldText(
"ABCD");
2945 CheckFocusedFieldText(
"ABC");
2950 CheckFocusedFieldText(
"ABCD");
2954 CheckFocusedFieldText(
"ABCDE");
2956 CheckCanRedo(
false);
2963 ClickOnFormFieldAtPoint(CharLimitFormEnd());
2964 CheckFocusedFieldText(
"Elephant");
2966 SetIndexSelectedShouldFail(0,
true);
2967 SetIndexSelectedShouldFail(0,
false);
2968 SetIndexSelectedShouldFail(1,
true);
2969 SetIndexSelectedShouldFail(1,
false);
2970 SetIndexSelectedShouldFail(-1,
true);
2971 SetIndexSelectedShouldFail(-1,
false);
2978 ClickOnFormFieldAtPoint(CharLimitFormEnd());
2979 CheckFocusedFieldText(
"Elephant");
2981 CheckIsIndexSelected(0,
false);
2982 CheckIsIndexSelected(1,
false);
2983 CheckIsIndexSelected(-1,
false);
2987 ClickOnFormFieldAtPoint(NonEditableFormBegin());
2988 CheckFocusedFieldText(
"Banana");
2989 CheckCanUndo(
false);
2990 CheckCanRedo(
false);
2992 ClickOnFormFieldAtPoint(EditableFormBegin());
2993 CheckFocusedFieldText(
"");
2994 CheckCanUndo(
false);
2995 CheckCanRedo(
false);
2997 TypeTextIntoTextField(3, EditableFormBegin());
2998 CheckFocusedFieldText(
"ABC");
3000 CheckCanRedo(
false);
3003 CheckFocusedFieldText(
"AB");
3007 CheckFocusedFieldText(
"A");
3011 CheckFocusedFieldText(
"");
3012 CheckCanUndo(
false);
3016 CheckFocusedFieldText(
"A");
3024 FocusOnSingleSelectForm();
3025 CheckIsIndexSelected(0,
false);
3026 CheckIsIndexSelected(1,
false);
3027 CheckIsIndexSelected(2,
false);
3029 ClickOnSingleSelectFormOption(1);
3030 CheckIsIndexSelected(0,
false);
3031 CheckIsIndexSelected(1,
true);
3032 CheckIsIndexSelected(2,
false);
3038 FocusOnMultiSelectForm();
3039 for (
int i = 0; i < 26; i++) {
3040 bool expected = i == 1;
3041 CheckIsIndexSelected(i, expected);
3048 ClickOnMultiSelectFormOption(1);
3049 for (
int i = 0; i < 26; i++) {
3050 bool expected = i == 1;
3051 CheckIsIndexSelected(i, expected);
3058 FocusOnSingleSelectForm();
3059 CheckFocusedFieldText(
"");
3060 CheckIsIndexSelected(0,
false);
3061 CheckIsIndexSelected(1,
false);
3062 CheckIsIndexSelected(2,
false);
3066 SetIndexSelectedShouldSucceed(0,
true);
3067 CheckFocusedFieldText(
"Foo");
3068 CheckIsIndexSelected(0,
true);
3069 CheckIsIndexSelected(1,
false);
3070 CheckIsIndexSelected(2,
false);
3072 SetIndexSelectedShouldSucceed(1,
true);
3073 CheckFocusedFieldText(
"Bar");
3074 CheckIsIndexSelected(0,
false);
3075 CheckIsIndexSelected(1,
true);
3076 CheckIsIndexSelected(2,
false);
3080 SetIndexSelectedShouldSucceed(1,
true);
3081 CheckFocusedFieldText(
"Bar");
3082 CheckIsIndexSelected(0,
false);
3083 CheckIsIndexSelected(1,
true);
3084 CheckIsIndexSelected(2,
false);
3086 SetIndexSelectedShouldSucceed(2,
false);
3087 CheckFocusedFieldText(
"Bar");
3088 CheckIsIndexSelected(0,
false);
3089 CheckIsIndexSelected(1,
true);
3090 CheckIsIndexSelected(2,
false);
3093 SetIndexSelectedShouldFail(100,
true);
3094 SetIndexSelectedShouldFail(-100,
true);
3095 SetIndexSelectedShouldFail(100,
false);
3096 SetIndexSelectedShouldFail(-100,
false);
3098 CheckFocusedFieldText(
"Bar");
3099 CheckIsIndexSelected(0,
false);
3100 CheckIsIndexSelected(1,
true);
3101 CheckIsIndexSelected(2,
false);
3104 SetIndexSelectedShouldSucceed(1,
false);
3105 CheckFocusedFieldText(
"");
3106 CheckIsIndexSelected(0,
false);
3107 CheckIsIndexSelected(1,
false);
3108 CheckIsIndexSelected(2,
false);
3112 ClickOnSingleSelectFormOption(1);
3113 CheckFocusedFieldText(
"Bar");
3114 CheckIsIndexSelected(0,
false);
3115 CheckIsIndexSelected(1,
true);
3116 CheckIsIndexSelected(2,
false);
3124 FocusOnMultiSelectForm();
3125 for (
int i = 0; i < 26; i++) {
3126 bool expected = i == 1;
3127 CheckIsIndexSelected(i, expected);
3129 CheckFocusedFieldText(
"Banana");
3132 SetIndexSelectedShouldSucceed(5,
true);
3133 SetIndexSelectedShouldSucceed(6,
true);
3134 SetIndexSelectedShouldSucceed(20,
true);
3135 for (
int i = 0; i < 26; i++) {
3136 bool expected = (i == 1 || i == 5 || i == 6 || i == 20);
3137 CheckIsIndexSelected(i, expected);
3139 CheckFocusedFieldText(
"Ugli Fruit");
3142 SetIndexSelectedShouldSucceed(5,
true);
3143 SetIndexSelectedShouldSucceed(6,
true);
3144 SetIndexSelectedShouldSucceed(20,
true);
3145 for (
int i = 0; i < 26; i++) {
3146 bool expected = (i == 1 || i == 5 || i == 6 || i == 20);
3147 CheckIsIndexSelected(i, expected);
3149 CheckFocusedFieldText(
"Ugli Fruit");
3152 SetIndexSelectedShouldSucceed(20,
false);
3153 SetIndexSelectedShouldSucceed(1,
false);
3154 for (
int i = 0; i < 26; i++) {
3155 bool expected = (i == 5 || i == 6);
3156 CheckIsIndexSelected(i, expected);
3158 CheckFocusedFieldText(
"Banana");
3163 SetIndexSelectedShouldSucceed(1,
false);
3164 SetIndexSelectedShouldSucceed(3,
false);
3165 for (
int i = 0; i < 26; i++) {
3166 bool expected = (i == 5 || i == 6);
3167 CheckIsIndexSelected(i, expected);
3169 CheckFocusedFieldText(
"Date");
3172 SetIndexSelectedShouldFail(100,
true);
3173 SetIndexSelectedShouldFail(-100,
true);
3174 SetIndexSelectedShouldFail(100,
false);
3175 SetIndexSelectedShouldFail(-100,
false);
3177 CheckFocusedFieldText(
"Date");
3178 for (
int i = 0; i < 26; i++) {
3179 bool expected = (i == 5 || i == 6);
3180 CheckIsIndexSelected(i, expected);
3186 ClickOnMultiSelectFormOption(1);
3187 for (
int i = 0; i < 26; i++) {
3188 bool expected = i == 1;
3189 CheckIsIndexSelected(i, expected);
3191 CheckFocusedFieldText(
"Banana");
3197 FocusOnMultiSelectMultipleIndicesForm();
3198 for (
int i = 0; i < 5; i++) {
3199 bool expected = (i == 1 || i == 3);
3200 CheckIsIndexSelected(i, expected);
3207 FocusOnMultiSelectMultipleValuesForm();
3208 for (
int i = 0; i < 5; i++) {
3209 bool expected = (i == 2 || i == 4);
3210 CheckIsIndexSelected(i, expected);
3217 FocusOnMultiSelectMultipleMismatchForm();
3218 for (
int i = 0; i < 5; i++) {
3219 bool expected = (i == 0 || i == 2);
3220 CheckIsIndexSelected(i, expected);
3232 ClickOnMultiSelectMultipleValuesFormOption(0);
3233 for (
int i = 0; i < 5; i++) {
3234 bool expected = i == 0;
3235 CheckIsIndexSelected(i, expected);
3241 FocusOnSingleSelectLastSelectedForm();
3242 for (
int i = 0; i < 10; i++) {
3243 bool expected = i == 9;
3244 CheckIsIndexSelected(i, expected);
3251 ClickOnSingleSelectLastSelectedFormOption(0);
3252 for (
int i = 0; i < 10; i++) {
3253 bool expected = i == 8;
3254 CheckIsIndexSelected(i, expected);
3260 ClickOnFormFieldAtPoint(RegularFormBegin());
3261 CheckCanUndo(
false);
3262 CheckCanRedo(
false);
3264 TypeTextIntoTextField(2, RegularFormBegin());
3265 CheckFocusedFieldText(
"AB");
3268 CheckSelection(
"A");
3270 FORM_ReplaceAndKeepSelection(form_handle(), page(), text_to_insert.get());
3271 CheckFocusedFieldText(
"XYZB");
3272 CheckSelection(
"XYZ");
3274 CheckCanRedo(
false);
3277 CheckFocusedFieldText(
"AB");
3282 CheckSelection(
"B");
3284 FORM_ReplaceAndKeepSelection(form_handle(), page(), text_to_insert.get());
3285 CheckFocusedFieldText(
"AXYZ");
3286 CheckSelection(
"XYZ");
3288 CheckCanRedo(
false);
3294 ClickOnFormFieldAtPoint(RegularFormBegin());
3295 CheckFocusedFieldText(
"");
3296 CheckCanUndo(
false);
3297 CheckCanRedo(
false);
3299 FORM_ReplaceAndKeepSelection(form_handle(), page(), text_to_insert1.get());
3300 CheckFocusedFieldText(
"UVW");
3301 CheckSelection(
"UVW");
3304 CheckCanRedo(
false);
3307 CheckFocusedFieldText(
"");
3309 CheckCanUndo(
false);
3312 CheckFocusedFieldText(
"UVW");
3316 FORM_ReplaceAndKeepSelection(form_handle(), page(), text_to_insert2.get());
3317 CheckFocusedFieldText(
"UVWXYZ");
3318 CheckSelection(
"XYZ");
3322 CheckFocusedFieldText(
"UVW");
3328 ClickOnFormFieldAtPoint(RegularFormBegin());
3329 CheckCanUndo(
false);
3330 CheckCanRedo(
false);
3332 TypeTextIntoTextField(2, RegularFormBegin());
3333 CheckFocusedFieldText(
"AB");
3336 CheckSelection(
"A");
3338 FORM_ReplaceSelection(form_handle(), page(), text_to_insert.get());
3339 CheckFocusedFieldText(
"XYZB");
3341 CheckCanRedo(
false);
3344 CheckFocusedFieldText(
"AB");
3349 CheckFocusedFieldText(
"A");
3354 CheckFocusedFieldText(
"");
3355 CheckCanUndo(
false);
3359 CheckFocusedFieldText(
"A");
3364 CheckFocusedFieldText(
"AB");
3369 CheckFocusedFieldText(
"XYZB");
3371 CheckCanRedo(
false);
3377 ClickOnFormFieldAtPoint(RegularFormBegin());
3378 CheckFocusedFieldText(
"");
3379 CheckCanUndo(
false);
3380 CheckCanRedo(
false);
3382 FORM_ReplaceSelection(form_handle(), page(), text_to_insert1.get());
3383 CheckFocusedFieldText(
"UVW");
3387 CheckCanRedo(
false);
3390 CheckFocusedFieldText(
"");
3392 CheckCanUndo(
false);
3395 CheckFocusedFieldText(
"UVW");
3399 FORM_ReplaceSelection(form_handle(), page(), text_to_insert2.get());
3400 CheckFocusedFieldText(
"UVWXYZ");
3403 CheckCanRedo(
false);
3406 CheckFocusedFieldText(
"UVW");
3412 TypeTextIntoTextField(2, RegularFormBegin());
3413 CheckFocusedFieldText(
"AB");
3417#if BUILDFLAG(IS_APPLE)
3418 constexpr int kCorrectModifier = FWL_EVENTFLAG_MetaKey;
3424 CheckSelection(
"AB");
3427 ClickOnFormFieldAtPoint(RegularFormBegin());
3431#if BUILDFLAG(IS_APPLE)
3432 constexpr int kWrongModifier = FWL_EVENTFLAG_ControlKey;
3452 DoubleClickOnFormFieldAtPoint(CFX_PointF(100, 100));
3453 FORM_ReplaceSelection(form_handle(), page(), text_to_insert.get());
3468 DoubleClickOnFormFieldAtPoint(CFX_PointF(22, 22));
3469 FORM_ReplaceSelection(form_handle(), page(), text_to_insert.get());
3479 ASSERT_TRUE(
OpenDocument(
"annots_action_handling.pdf"));
3486 constexpr size_t kSubtypeCount =
std::size(kFocusableSubtypes);
3487 ASSERT_TRUE(FPDFAnnot_SetFocusableSubtypes(
3488 form_handle(), kFocusableSubtypes, kSubtypeCount));
3502 for (size_t i = 1; i < n; i++)
3509 FPDF_PAGE page_ =
nullptr;
3513 NiceMock<EmbedderTestMockDelegate> mock;
3515 EXPECT_CALL(mock, DoURIAction(_)).Times(0);
3518 SetFocusOnNthAnnot(1);
3521 ASSERT_TRUE(FORM_OnKeyDown(form_handle(), page(),
FWL_VKEY_Tab, 0));
3529 NiceMock<EmbedderTestMockDelegate> mock;
3531 InSequence sequence;
3532 const char kExpectedUri[] =
"https://cs.chromium.org/";
3533#ifdef PDF_ENABLE_XFA
3535 DoURIActionWithKeyboardModifier(_, StrEq(kExpectedUri), _))
3538 EXPECT_CALL(mock, DoURIAction(StrEq(kExpectedUri))).Times(4);
3539 EXPECT_CALL(mock, DoURIActionWithKeyboardModifier(_, _, _)).Times(0);
3543 SetFocusOnNthAnnot(3);
3545 ASSERT_TRUE(FORM_OnKeyDown(form_handle(), page(),
FWL_VKEY_Return, modifier));
3547 ASSERT_TRUE(FORM_OnKeyDown(form_handle(), page(),
FWL_VKEY_Return, modifier));
3549 ASSERT_TRUE(FORM_OnKeyDown(form_handle(), page(),
FWL_VKEY_Return, modifier));
3551 ASSERT_TRUE(FORM_OnKeyDown(form_handle(), page(),
FWL_VKEY_Return, modifier));
3553 ASSERT_FALSE(FORM_OnKeyDown(
nullptr, page(),
FWL_VKEY_Return, modifier));
3558 ASSERT_FALSE(FORM_OnKeyDown(form_handle(), page(),
FWL_VKEY_Shift, modifier));
3559 ASSERT_FALSE(FORM_OnKeyDown(form_handle(), page(),
FWL_VKEY_Space, modifier));
3565 NiceMock<EmbedderTestMockDelegate> mock;
3566 EXPECT_CALL(mock, DoGoToAction(_, _, 1, _, _)).Times(12);
3569 SetFocusOnNthAnnot(4);
3571 ASSERT_TRUE(FORM_OnKeyDown(form_handle(), page(),
FWL_VKEY_Return, modifier));
3573 ASSERT_TRUE(FORM_OnKeyDown(form_handle(), page(),
FWL_VKEY_Return, modifier));
3575 ASSERT_TRUE(FORM_OnKeyDown(form_handle(), page(),
FWL_VKEY_Return, modifier));
3577 ASSERT_TRUE(FORM_OnKeyDown(form_handle(), page(),
FWL_VKEY_Return, modifier));
3579 SetFocusOnNthAnnot(5);
3581 ASSERT_TRUE(FORM_OnKeyDown(form_handle(), page(),
FWL_VKEY_Return, modifier));
3583 ASSERT_TRUE(FORM_OnKeyDown(form_handle(), page(),
FWL_VKEY_Return, modifier));
3585 ASSERT_TRUE(FORM_OnKeyDown(form_handle(), page(),
FWL_VKEY_Return, modifier));
3587 ASSERT_TRUE(FORM_OnKeyDown(form_handle(), page(),
FWL_VKEY_Return, modifier));
3589 SetFocusOnNthAnnot(6);
3591 ASSERT_TRUE(FORM_OnKeyDown(form_handle(), page(),
FWL_VKEY_Return, modifier));
3593 ASSERT_TRUE(FORM_OnKeyDown(form_handle(), page(),
FWL_VKEY_Return, modifier));
3595 ASSERT_TRUE(FORM_OnKeyDown(form_handle(), page(),
FWL_VKEY_Return, modifier));
3597 ASSERT_TRUE(FORM_OnKeyDown(form_handle(), page(),
FWL_VKEY_Return, modifier));
3599 ASSERT_FALSE(FORM_OnKeyDown(
nullptr, page(),
FWL_VKEY_Return, modifier));
3604 ASSERT_FALSE(FORM_OnKeyDown(form_handle(), page(),
FWL_VKEY_Shift, modifier));
3605 ASSERT_FALSE(FORM_OnKeyDown(form_handle(), page(),
FWL_VKEY_Space, modifier));
3618 NiceMock<EmbedderTestMockDelegate> mock;
3620 InSequence sequence;
3621 EXPECT_CALL(mock, DoURIAction(_)).Times(0);
3622 const char kExpectedUri[] =
"https://cs.chromium.org/";
3624 DoURIActionWithKeyboardModifier(_, StrEq(kExpectedUri), 0));
3625 EXPECT_CALL(mock, DoURIActionWithKeyboardModifier(
3626 _, StrEq(kExpectedUri), FWL_EVENTFLAG_ControlKey));
3627 EXPECT_CALL(mock, DoURIActionWithKeyboardModifier(_, StrEq(kExpectedUri),
3628 FWL_EVENTFLAG_ShiftKey));
3630 DoURIActionWithKeyboardModifier(_, StrEq(kExpectedUri), 3));
3633 SetFocusOnNthAnnot(3);
3635 ASSERT_TRUE(FORM_OnKeyDown(form_handle(), page(),
FWL_VKEY_Return, modifier));
3637 ASSERT_TRUE(FORM_OnKeyDown(form_handle(), page(),
FWL_VKEY_Return, modifier));
3639 ASSERT_TRUE(FORM_OnKeyDown(form_handle(), page(),
FWL_VKEY_Return, modifier));
3641 ASSERT_TRUE(FORM_OnKeyDown(form_handle(), page(),
FWL_VKEY_Return, modifier));
3643 ASSERT_FALSE(FORM_OnKeyDown(
nullptr, page(),
FWL_VKEY_Return, modifier));
3648 ASSERT_FALSE(FORM_OnKeyDown(form_handle(), page(),
FWL_VKEY_Shift, modifier));
3649 ASSERT_FALSE(FORM_OnKeyDown(form_handle(), page(),
FWL_VKEY_Space, modifier));
static bool UseSkiaRenderer()
void DoURIAction(FPDF_BYTESTRING uri) override
void AdvanceTime(int increment_msecs)
void SetFormFillInfoVersion(int form_fill_info_version)
FPDF_PAGE LoadPage(int page_index)
void UnloadPage(FPDF_PAGE page)
FPDF_FORMHANDLE form_handle() const
bool OpenDocument(const std::string &filename)
const char * GetDocumentName() const override
void SelectAllCharLimitFormTextWithMouse()
const CFX_PointF & RegularFormEnd() const
const CFX_PointF & CharLimitFormBegin() const
static CFX_PointF RegularFormAtX(float x)
void FormSanityChecks() override
const CFX_PointF & RegularFormBegin() const
const CFX_PointF & CharLimitFormEnd() const
void SelectAllRegularFormTextWithMouse()
FPDFFormFillTextFormEmbedderTest()=default
static CFX_PointF CharLimitFormAtX(float x)
~FPDFFormFillTextFormEmbedderTest() override=default
int GetFormType() const override
#define FPDF_ANNOT_WIDGET
FPDF_EXPORT FPDF_ANNOTATION FPDF_CALLCONV FPDFPage_GetAnnot(FPDF_PAGE page, int index)
FPDF_EXPORT void FPDF_CALLCONV FPDFPage_CloseAnnot(FPDF_ANNOTATION annot)
FPDF_EXPORT int FPDF_CALLCONV FPDFPage_GetAnnotIndex(FPDF_PAGE page, FPDF_ANNOTATION annot)
@ FWL_EVENTFLAG_ControlKey
TEST_F(FPDFParserDecodeEmbedderTest, Bug552046)
FPDF_EXPORT int FPDF_CALLCONV FPDF_RenderPageBitmap_Start(FPDF_BITMAP bitmap, FPDF_PAGE page, int start_x, int start_y, int size_x, int size_y, int rotate, int flags, IFSDK_PAUSE *pause)
FPDF_EXPORT void FPDF_CALLCONV FPDFBitmap_Destroy(FPDF_BITMAP bitmap)
FPDF_EXPORT FPDF_BITMAP FPDF_CALLCONV FPDFBitmap_Create(int width, int height, int alpha)
#define FPDF_REVERSE_BYTE_ORDER
CFX_PTemplate< float > CFX_PointF
std::unique_ptr< FPDF_WCHAR, pdfium::FreeDeleter > ScopedFPDFWideString
std::string GetPlatformString(FPDF_WIDESTRING wstr)
constexpr uint8_t kReturn
constexpr uint8_t kControlA
const char * TextFormChecksum()
const char * Bug890322Checksum()
fxcrt::ByteStringView ByteStringView