7#include "build/build_config.h"
8#include "constants/ascii.h"
9#include "core/fxcrt/fx_coordinates.h"
10#include "core/fxcrt/fx_string.h"
11#include "core/fxcrt/fx_system.h"
12#include "core/fxge/cfx_defaultrenderdevice.h"
13#include "public/cpp/fpdf_scopers.h"
14#include "public/fpdf_formfill.h"
15#include "public/fpdf_fwlevent.h"
16#include "public/fpdf_progressive.h"
17#include "testing/embedder_test.h"
18#include "testing/embedder_test_constants.h"
19#include "testing/embedder_test_mock_delegate.h"
20#include "testing/embedder_test_timer_handling_delegate.h"
21#include "testing/gmock/include/gmock/gmock.h"
22#include "testing/gtest/include/gtest/gtest.h"
23#include "third_party/base/check.h"
24#include "third_party/base/check_op.h"
26using pdfium::TextFormChecksum;
29using testing::InSequence;
30using testing::NiceMock;
43 FPDFFormFillEmbedderTest
::SetUp();
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) {
97 const CFX_PointF& point) {
105 for (
int i = 0; i < num_chars; ++i) {
114 DCHECK_EQ(start.y, end.y);
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);
240 DCHECK(x >= kFormBeginX);
241 DCHECK(x <= kFormEndX);
242 return CFX_PointF(x, kCharLimitFormY);
246 DCHECK(x >= kFormBeginX);
247 DCHECK(x <= kFormEndX);
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";
284 DCHECK(item_index >= 0);
285 DCHECK(item_index < 3);
290 DCHECK(item_index >= 0);
291 DCHECK(item_index < 26);
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);
334 DCHECK(x >= kFormBeginX);
335 DCHECK(x <= kFormEndX);
336 return CFX_PointF(x, kEditableFormY);
340 DCHECK(x >= kFormBeginX);
341 DCHECK(x <= kFormEndX);
342 return CFX_PointF(x, kNonEditableFormY);
348 void SelectOption(
int item_index,
const CFX_PointF& point) {
353 constexpr double kChoiceHeight = 15;
354 CFX_PointF option_point = point;
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";
430 DCHECK(item_index >= 0);
431 DCHECK(item_index < 2);
432 if (item_index == 0) {
442 DCHECK(item_index >= 0);
443 DCHECK(item_index < 2);
444 if (item_index == 0) {
454 DCHECK(item_index >= 0);
455 DCHECK(item_index < 2);
456 if (item_index == 0) {
466 DCHECK(item_index >= 0);
467 DCHECK(item_index < 2);
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);
524 static const CFX_PointF point(kFormBeginX,
525 kMultiFormMultipleIndicesYFirstVisibleOption);
530 static const CFX_PointF point(
531 kFormBeginX, kMultiFormMultipleIndicesYSecondVisibleOption);
536 static const CFX_PointF point(kFormBeginX,
537 kMultiFormMultipleValuesYFirstVisibleOption);
542 static const CFX_PointF point(kFormBeginX,
543 kMultiFormMultipleValuesYSecondVisibleOption);
548 static const CFX_PointF point(
549 kFormBeginX, kMultiFormMultipleMismatchYFirstVisibleOption);
554 static const CFX_PointF point(
555 kFormBeginX, kMultiFormMultipleMismatchYSecondVisibleOption);
560 static const CFX_PointF point(kFormBeginX,
561 kSingleFormLastSelectedYFirstVisibleOption);
566 static const CFX_PointF point(kFormBeginX,
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);
679 ScopedFPDFBitmap bitmap(FPDFBitmap_Create(512, 512, 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);
698 ScopedFPDFBitmap bitmap(FPDFBitmap_Create(512, 512, 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);
832 static constexpr int kExpectedAnnotIndex[] = {1, 2, 3, 0};
834 for (size_t i = 0; i <
std::size(kExpectedAnnotIndex); ++i) {
835 ASSERT_TRUE(FORM_OnKeyDown(form_handle(), page,
FWL_VKEY_Tab, 0));
837 FPDF_ANNOTATION annot =
nullptr;
838 EXPECT_TRUE(FORM_GetFocusedAnnot(form_handle(), &page_index, &annot));
839 EXPECT_EQ(0, page_index);
846 ASSERT_FALSE(FORM_OnKeyDown(form_handle(), page,
FWL_VKEY_Tab, 0));
852 ASSERT_TRUE(OpenDocument(
"annotiter.pdf"));
853 FPDF_PAGE page = LoadPage(0);
856 static constexpr int kExpectedAnnotIndex[] = {0, 3, 2, 1};
858 for (size_t i = 0; i <
std::size(kExpectedAnnotIndex); ++i) {
859 ASSERT_TRUE(FORM_OnKeyDown(form_handle(), page,
FWL_VKEY_Tab,
862 FPDF_ANNOTATION annot =
nullptr;
863 EXPECT_TRUE(FORM_GetFocusedAnnot(form_handle(), &page_index, &annot));
864 EXPECT_EQ(0, page_index);
872 ASSERT_FALSE(FORM_OnKeyDown(form_handle(), page,
FWL_VKEY_Tab,
879 ASSERT_TRUE(OpenDocument(
"annotiter.pdf"));
880 FPDF_PAGE page = LoadPage(0);
883 ASSERT_FALSE(FORM_OnKeyDown(form_handle(), page,
FWL_VKEY_Tab,
893 ASSERT_FALSE(FORM_OnKeyDown(form_handle(), page,
FWL_VKEY_Tab,
900 ASSERT_TRUE(OpenDocument(
"annotiter.pdf"));
901 FPDF_PAGE page = LoadPage(0);
906 FPDF_ANNOTATION annot =
nullptr;
907 EXPECT_TRUE(FORM_GetFocusedAnnot(form_handle(), &page_index, &annot));
908 EXPECT_EQ(-1, page_index);
911 static constexpr int kKeysToPress[] = {
916 for (
int key : kKeysToPress) {
918 EXPECT_FALSE(FORM_OnKeyDown(form_handle(), page, key, 0));
921 EXPECT_TRUE(FORM_GetFocusedAnnot(form_handle(), &page_index, &annot));
922 EXPECT_EQ(-1, page_index);
930TEST_F(FPDFFormFillEmbedderTest, XFAFormFillFirstTab) {
931 ASSERT_TRUE(OpenDocument(
"xfa/email_recommended.pdf"));
932 FPDF_PAGE page = LoadPage(0);
936 ASSERT_TRUE(FORM_OnKeyDown(form_handle(), page, FWL_VKEY_Tab, 0));
941TEST_F(FPDFFormFillEmbedderTest, XFAFormFillFirstShiftTab) {
942 ASSERT_TRUE(OpenDocument(
"xfa/email_recommended.pdf"));
943 FPDF_PAGE page = LoadPage(0);
947 ASSERT_TRUE(FORM_OnKeyDown(form_handle(), page, FWL_VKEY_Tab,
948 FWL_EVENTFLAG_ShiftKey));
953TEST_F(FPDFFormFillEmbedderTest, XFAFormFillContinuousTab) {
954 ASSERT_TRUE(OpenDocument(
"xfa/email_recommended.pdf"));
955 FPDF_PAGE page = LoadPage(0);
959 ASSERT_TRUE(FORM_OnKeyDown(form_handle(), page, FWL_VKEY_Tab, 0));
962 for (size_t i = 0; i < 9; ++i)
963 ASSERT_TRUE(FORM_OnKeyDown(form_handle(), page, FWL_VKEY_Tab, 0));
966 ASSERT_FALSE(FORM_OnKeyDown(form_handle(), page, FWL_VKEY_Tab, 0));
971TEST_F(FPDFFormFillEmbedderTest, XFAFormFillContinuousShiftTab) {
972 ASSERT_TRUE(OpenDocument(
"xfa/email_recommended.pdf"));
973 FPDF_PAGE page = LoadPage(0);
977 ASSERT_TRUE(FORM_OnKeyDown(form_handle(), page, FWL_VKEY_Tab,
978 FWL_EVENTFLAG_ShiftKey));
981 for (size_t i = 0; i < 9; ++i) {
982 ASSERT_TRUE(FORM_OnKeyDown(form_handle(), page, FWL_VKEY_Tab,
983 FWL_EVENTFLAG_ShiftKey));
988 ASSERT_FALSE(FORM_OnKeyDown(form_handle(), page, FWL_VKEY_Tab,
989 FWL_EVENTFLAG_ShiftKey));
998 FAIL() <<
"Navigated to " << uri;
1003 DoURIActionBlockedDelegate delegate;
1004 SetDelegate(&delegate);
1006 ASSERT_TRUE(OpenDocument(
"redirect.pdf"));
1007 FPDF_PAGE page = LoadPage(0);
1015 EmbedderTestTimerHandlingDelegate delegate;
1016 SetDelegate(&delegate);
1018 ASSERT_TRUE(OpenDocument(
"click_form.pdf"));
1019 FPDF_PAGE page = LoadPage(0);
1024 ScopedFPDFAnnotation focused_annot(FPDFPage_GetAnnot(page, 1));
1025 ASSERT_TRUE(FORM_SetFocusedAnnot(form_handle(), focused_annot.get()));
1028 ASSERT_TRUE(FORM_OnKeyDown(form_handle(), page,
FWL_VKEY_Tab,
1030 FPDF_ANNOTATION annot =
nullptr;
1031 int page_index = -1;
1032 ASSERT_TRUE(FORM_GetFocusedAnnot(form_handle(), &page_index, &annot));
1036 EXPECT_TRUE(FPDFAnnot_IsChecked(form_handle(), annot));
1039 EXPECT_TRUE(FPDFAnnot_IsChecked(form_handle(), annot));
1041 EXPECT_TRUE(FORM_OnChar(form_handle(), page, pdfium
::ascii::kSpace, 0));
1042 EXPECT_TRUE(FPDFAnnot_IsChecked(form_handle(), annot));
1050 EmbedderTestTimerHandlingDelegate delegate;
1051 SetDelegate(&delegate);
1053 ASSERT_TRUE(OpenDocument(
"click_form.pdf"));
1054 FPDF_PAGE page = LoadPage(0);
1059 ScopedFPDFAnnotation focused_annot(FPDFPage_GetAnnot(page, 1));
1060 ASSERT_TRUE(FORM_SetFocusedAnnot(form_handle(), focused_annot.get()));
1063 ASSERT_TRUE(FORM_OnKeyDown(form_handle(), page,
FWL_VKEY_Tab, 0));
1065 FPDF_ANNOTATION annot =
nullptr;
1066 int page_index = -1;
1067 ASSERT_TRUE(FORM_GetFocusedAnnot(form_handle(), &page_index, &annot));
1070 EXPECT_FALSE(FPDFAnnot_IsChecked(form_handle(), annot));
1073 EXPECT_FALSE(FPDFAnnot_IsChecked(form_handle(), annot));
1075 EXPECT_TRUE(FORM_OnChar(form_handle(), page, pdfium
::ascii::kSpace, 0));
1076 EXPECT_FALSE(FPDFAnnot_IsChecked(form_handle(), annot));
1084TEST_F(FPDFFormFillEmbedderTest, DisableJavaScript) {
1086 EmbedderTestTimerHandlingDelegate delegate;
1087 SetDelegate(&delegate);
1089 ASSERT_TRUE(OpenDocumentWithoutJavaScript(
"bug_551248.pdf"));
1090 FPDF_PAGE page = LoadPage(0);
1094 const auto& alerts = delegate.GetAlerts();
1095 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());
1109 delegate.AdvanceTime(1000);
1110 EXPECT_EQ(0U, alerts.size());
1114TEST_F(FPDFFormFillEmbedderTest, DocumentAActions) {
1115 EmbedderTestTimerHandlingDelegate delegate;
1116 SetDelegate(&delegate);
1118 ASSERT_TRUE(OpenDocument(
"document_aactions.pdf"));
1119 FPDF_PAGE page = LoadPage(0);
1122 const auto& alerts = delegate.GetAlerts();
1123 EXPECT_EQ(0U, alerts.size());
1125 FORM_DoDocumentAAction(form_handle(), FPDFDOC_AACTION_WS);
1126 FORM_DoDocumentAAction(form_handle(), FPDFDOC_AACTION_DS);
1127 FORM_DoDocumentAAction(form_handle(), FPDFDOC_AACTION_WP);
1128 FORM_DoDocumentAAction(form_handle(), FPDFDOC_AACTION_DP);
1131 ASSERT_EQ(4U, alerts.size());
1132 EXPECT_STREQ(L"Will Save", alerts[0].message.c_str());
1133 EXPECT_STREQ(L"Did Save", alerts[1].message.c_str());
1134 EXPECT_STREQ(L"Will Print", alerts[2].message.c_str());
1135 EXPECT_STREQ(L"Did Print", alerts[3].message.c_str());
1138TEST_F(FPDFFormFillEmbedderTest, DocumentAActionsDisableJavaScript) {
1139 EmbedderTestTimerHandlingDelegate delegate;
1140 SetDelegate(&delegate);
1142 ASSERT_TRUE(OpenDocumentWithoutJavaScript(
"document_aactions.pdf"));
1143 FPDF_PAGE page = LoadPage(0);
1146 const auto& alerts = delegate.GetAlerts();
1147 EXPECT_EQ(0U, alerts.size());
1149 FORM_DoDocumentAAction(form_handle(), FPDFDOC_AACTION_WS);
1150 FORM_DoDocumentAAction(form_handle(), FPDFDOC_AACTION_DS);
1151 FORM_DoDocumentAAction(form_handle(), FPDFDOC_AACTION_WP);
1152 FORM_DoDocumentAAction(form_handle(), FPDFDOC_AACTION_DP);
1155 ASSERT_EQ(0U, alerts.size());
1158TEST_F(FPDFFormFillEmbedderTest, BUG_551248) {
1160 EmbedderTestTimerHandlingDelegate delegate;
1161 SetDelegate(&delegate);
1163 ASSERT_TRUE(OpenDocument(
"bug_551248.pdf"));
1164 FPDF_PAGE page = LoadPage(0);
1168 const auto& alerts = delegate.GetAlerts();
1169 EXPECT_EQ(0U, alerts.size());
1171 delegate.AdvanceTime(1000);
1172 EXPECT_EQ(0U, alerts.size());
1173 delegate.AdvanceTime(1000);
1174 EXPECT_EQ(1U, alerts.size());
1175 delegate.AdvanceTime(1000);
1176 EXPECT_EQ(2U, alerts.size());
1177 delegate.AdvanceTime(1000);
1178 EXPECT_EQ(3U, alerts.size());
1179 delegate.AdvanceTime(1000);
1180 EXPECT_EQ(3U, alerts.size());
1181 delegate.AdvanceTime(1000);
1182 EXPECT_EQ(4U, alerts.size());
1183 delegate.AdvanceTime(1000);
1184 EXPECT_EQ(4U, alerts.size());
1187 ASSERT_EQ(4U, alerts.size());
1189 EXPECT_STREQ(L"interval fired", alerts[0].message.c_str());
1190 EXPECT_STREQ(L"Alert", alerts[0].title.c_str());
1191 EXPECT_EQ(0, alerts[0].type);
1192 EXPECT_EQ(0, alerts[0].icon);
1194 EXPECT_STREQ(L"timer fired", alerts[1].message.c_str());
1195 EXPECT_STREQ(L"Alert", alerts[1].title.c_str());
1196 EXPECT_EQ(0, alerts[1].type);
1197 EXPECT_EQ(0, alerts[1].icon);
1199 EXPECT_STREQ(L"interval fired", alerts[2].message.c_str());
1200 EXPECT_STREQ(L"Alert", alerts[2].title.c_str());
1201 EXPECT_EQ(0, alerts[2].type);
1202 EXPECT_EQ(0, alerts[2].icon);
1204 EXPECT_STREQ(L"interval fired", alerts[3].message.c_str());
1205 EXPECT_STREQ(L"Alert", alerts[3].title.c_str());
1206 EXPECT_EQ(0, alerts[3].type);
1207 EXPECT_EQ(0, alerts[3].icon);
1210TEST_F(FPDFFormFillEmbedderTest, BUG_620428) {
1212 EmbedderTestTimerHandlingDelegate delegate;
1213 SetDelegate(&delegate);
1215 ASSERT_TRUE(OpenDocument(
"bug_620428.pdf"));
1216 FPDF_PAGE page = LoadPage(0);
1219 delegate.AdvanceTime(5000);
1222 const auto& alerts = delegate.GetAlerts();
1223 ASSERT_EQ(1U, alerts.size());
1224 EXPECT_STREQ(L"done", alerts[0].message.c_str());
1227TEST_F(FPDFFormFillEmbedderTest, BUG_634394) {
1229 EmbedderTestTimerHandlingDelegate delegate;
1230 SetDelegate(&delegate);
1232 ASSERT_TRUE(OpenDocument(
"bug_634394.pdf"));
1233 FPDF_PAGE page = LoadPage(0);
1239 delegate.AdvanceTime(1000);
1240 delegate.AdvanceTime(1000);
1241 delegate.AdvanceTime(1000);
1242 delegate.AdvanceTime(1000);
1243 delegate.AdvanceTime(1000);
1246 const auto& alerts = delegate.GetAlerts();
1247 EXPECT_EQ(2U, alerts.size());
1250TEST_F(FPDFFormFillEmbedderTest, BUG_634716) {
1251 EmbedderTestTimerHandlingDelegate delegate;
1252 SetDelegate(&delegate);
1254 ASSERT_TRUE(OpenDocument(
"bug_634716.pdf"));
1255 FPDF_PAGE page = LoadPage(0);
1261 delegate.AdvanceTime(1000);
1262 delegate.AdvanceTime(1000);
1263 delegate.AdvanceTime(1000);
1264 delegate.AdvanceTime(1000);
1265 delegate.AdvanceTime(1000);
1268 const auto& alerts = delegate.GetAlerts();
1269 EXPECT_EQ(2U, alerts.size());
1272TEST_F(FPDFFormFillEmbedderTest, BUG_679649) {
1273 EmbedderTestTimerHandlingDelegate delegate;
1274 SetDelegate(&delegate);
1276 ASSERT_TRUE(OpenDocument(
"bug_679649.pdf"));
1277 FPDF_PAGE page = LoadPage(0);
1280 delegate.SetFailNextTimer();
1282 delegate.AdvanceTime(2000);
1285 const auto& alerts = delegate.GetAlerts();
1286 EXPECT_EQ(0u, alerts.size());
1289TEST_F(FPDFFormFillEmbedderTest, BUG_707673) {
1290 EmbedderTestTimerHandlingDelegate delegate;
1291 SetDelegate(&delegate);
1293 ASSERT_TRUE(OpenDocument(
"bug_707673.pdf"));
1294 FPDF_PAGE page = LoadPage(0);
1298 FORM_OnLButtonDown(form_handle(), page, 0, 140, 590);
1299 FORM_OnLButtonUp(form_handle(), page, 0, 140, 590);
1300 delegate.AdvanceTime(1000);
1303 const auto& alerts = delegate.GetAlerts();
1304 EXPECT_EQ(0u, alerts.size());
1307TEST_F(FPDFFormFillEmbedderTest, BUG_765384) {
1308 ASSERT_TRUE(OpenDocument(
"bug_765384.pdf"));
1309 FPDF_PAGE page = LoadPage(0);
1313 FORM_OnLButtonDown(form_handle(), page, 0, 140, 590);
1314 FORM_OnLButtonUp(form_handle(), page, 0, 140, 590);
1319TEST_F(FPDFFormFillEmbedderTest, BUG_1477093) {
1320 EmbedderTestTimerHandlingDelegate delegate;
1321 SetDelegate(&delegate);
1323 ASSERT_TRUE(OpenDocument(
"bug_1477093.pdf"));
1324 FPDF_PAGE page = LoadPage(0);
1328 delegate.AdvanceTime(1000);
1329 delegate.AdvanceTime(1000);
1336 const char* focused_text_form_with_abc_checksum = []() {
1338#if BUILDFLAG(IS_WIN)
1339 return "8b743c7a6186360862ca6f6db8f55c8f";
1340#elif BUILDFLAG(IS_APPLE)
1341 return "d8cf4e7ef7e1c287441bf350006e66d6";
1343 return "b9fb2245a98ac48146da84237a37f8cc";
1346#if BUILDFLAG(IS_APPLE)
1347 return "9fb14198d75ca0a107060c60ca21b0c7";
1349 return "6e6f790bb14c4fc6107faf8c17d23dbd";
1352 const char* unfocused_text_form_with_abc_checksum = []() {
1354#if BUILDFLAG(IS_WIN)
1355 return "37328bf7614d6fc05b03893ee030aec4";
1356#elif BUILDFLAG(IS_APPLE)
1357 return "b9702814ac50dc5ef413ea2e9c4002f1";
1359 return "5f3205f0189d9dde54665f970838f614";
1362#if BUILDFLAG(IS_APPLE)
1363 return "3c3209357e0c057a0620afa7d83eb784";
1365 return "94b7e10ac8c662b73e33628ca2f5e63b";
1369 ASSERT_TRUE(OpenDocument(
"text_form.pdf"));
1370 FPDF_PAGE page = LoadPage(0);
1372 ScopedFPDFBitmap bitmap1 = RenderLoadedPage(page);
1377 FPDFPage_HasFormFieldAtPoint(form_handle(), page, 120.0, 120.0));
1379 0, FPDFPage_FormFieldZOrderAtPoint(form_handle(), page, 120.0, 120.0));
1380 FORM_OnMouseMove(form_handle(), page, 0, 120.0, 120.0);
1381 FORM_OnLButtonDown(form_handle(), page, 0, 120.0, 120.0);
1382 FORM_OnLButtonUp(form_handle(), page, 0, 120.0, 120.0);
1385 FORM_OnChar(form_handle(), page,
'A', 0);
1386 FORM_OnChar(form_handle(), page,
'B', 0);
1387 FORM_OnChar(form_handle(), page,
'C', 0);
1388 ScopedFPDFBitmap bitmap2 = RenderLoadedPage(page);
1389 CompareBitmap(bitmap2.get(), 300, 300, focused_text_form_with_abc_checksum);
1392 FORM_OnMouseMove(form_handle(), page, 0, 15.0, 15.0);
1393 FORM_OnRButtonDown(form_handle(), page, 0, 15.0, 15.0);
1394 FORM_OnRButtonUp(form_handle(), page, 0, 15.0, 15.0);
1395 ScopedFPDFBitmap bitmap3 = RenderLoadedPage(page);
1396 CompareBitmap(bitmap3.get(), 300, 300, focused_text_form_with_abc_checksum);
1399 FORM_OnMouseMove(form_handle(), page, 0, 15.0, 15.0);
1400 FORM_OnLButtonDown(form_handle(), page, 0, 15.0, 15.0);
1401 FORM_OnLButtonUp(form_handle(), page, 0, 15.0, 15.0);
1402 ScopedFPDFBitmap bitmap4 = RenderLoadedPage(page);
1403 CompareBitmap(bitmap4.get(), 300, 300,
1404 unfocused_text_form_with_abc_checksum);
1406 EXPECT_TRUE(FPDF_SaveAsCopy(document(),
this, 0));
1412 VerifySavedDocument(300, 300, unfocused_text_form_with_abc_checksum);
1418 const char* reverse_byte_order_checksum = []() {
1420 return "8077970bbd10333f18186a9bb459bbe6";
1422 return "24fff03d1e663b7ece5f6e69ad837124";
1425 ASSERT_TRUE(OpenDocument(
"bug_890322.pdf"));
1426 FPDF_PAGE page = LoadPage(0);
1429 ScopedFPDFBitmap bitmap_normal = RenderLoadedPage(page);
1432 ScopedFPDFBitmap bitmap_reverse_byte_order =
1434 CompareBitmap(bitmap_reverse_byte_order.get(), 200, 200,
1435 reverse_byte_order_checksum);
1441 const char* checksum = []() {
1443 return "520c4415c9977f40d6b4af5a0a94d764";
1445 return "bbee92af1daec2340c81f482878744d8";
1448 ASSERT_TRUE(OpenDocument(
"bug_1302455.pdf"));
1449 FPDF_PAGE page = LoadPage(0);
1452 ScopedFPDFBitmap bitmap = RenderLoadedPage(page);
1453 CompareBitmap(bitmap.get(), 300, 300, checksum);
1455 EXPECT_TRUE(FPDF_SaveAsCopy(document(),
this, 0));
1459 VerifySavedDocument(300, 300, checksum);
1463 const char* checksum = []() {
1465#if BUILDFLAG(IS_WIN)
1466 return "2e5d64e4280ca954eb528e82f92abb75";
1467#elif BUILDFLAG(IS_APPLE)
1468 return "79538a800f8eb0b4965d43a052303592";
1470 return "143c2bb79fcaecf24f5aa104dce27beb";
1473#if BUILDFLAG(IS_APPLE)
1474 return "bf5423874f188427d2500a2bc4abebbe";
1476 return "6a4ac9a15d2c34589616c8f2b05fbedd";
1480 ASSERT_TRUE(OpenDocument(
"bug_1302455.pdf"));
1481 FPDF_PAGE page = LoadPage(0);
1485 FPDFPage_HasFormFieldAtPoint(form_handle(), page, 110, 110));
1486 FORM_OnMouseMove(form_handle(), page, 0, 110, 110);
1487 FORM_OnLButtonDown(form_handle(), page, 0, 110, 110);
1488 FORM_OnLButtonUp(form_handle(), page, 0, 110, 110);
1489 FORM_OnChar(form_handle(), page,
'A', 0);
1491 FORM_ForceToKillFocus(form_handle());
1492 ScopedFPDFBitmap bitmap = RenderLoadedPage(page);
1493 CompareBitmap(bitmap.get(), 300, 300, checksum);
1495 EXPECT_TRUE(FPDF_SaveAsCopy(document(),
this, 0));
1499 VerifySavedDocument(300, 300, checksum);
1503 const char* checksum = []() {
1505#if BUILDFLAG(IS_WIN)
1506 return "8408fc1796bf17d48b947ed0e4d65ef2";
1507#elif BUILDFLAG(IS_APPLE)
1508 return "074449f4bd27611a2e12aef3ad121cd8";
1510 return "e36726414acb616dc203e8851b510e2c";
1513#if BUILDFLAG(IS_APPLE)
1514 return "8a0fd8772dba6e1e952e49d159cc64b5";
1516 return "45a7694933c2ba3c5dc8f6cc18b79175";
1520 ASSERT_TRUE(OpenDocument(
"bug_1302455.pdf"));
1521 FPDF_PAGE page = LoadPage(0);
1525 FPDFPage_HasFormFieldAtPoint(form_handle(), page, 110, 170));
1526 FORM_OnMouseMove(form_handle(), page, 0, 110, 170);
1527 FORM_OnLButtonDown(form_handle(), page, 0, 110, 170);
1528 FORM_OnLButtonUp(form_handle(), page, 0, 110, 170);
1529 FORM_OnChar(form_handle(), page,
'B', 0);
1531 FORM_ForceToKillFocus(form_handle());
1532 ScopedFPDFBitmap bitmap = RenderLoadedPage(page);
1533 CompareBitmap(bitmap.get(), 300, 300, checksum);
1535 EXPECT_TRUE(FPDF_SaveAsCopy(document(),
this, 0));
1539 VerifySavedDocument(300, 300, checksum);
1543 const char* checksum = []() {
1545#if BUILDFLAG(IS_WIN)
1546 return "1c2b618f68d1ad2cfa01fcf38efc4831";
1547#elif BUILDFLAG(IS_APPLE)
1548 return "f5a3b8d2db662cad38b4573ef1dd3f1d";
1550 return "f82a807c056e22aa55d3d7228eedfe6f";
1553#if BUILDFLAG(IS_APPLE)
1554 return "1f422ee1c520ad74b1a993b64bd4dc4a";
1556 return "13984969b1e141079ab5f4aa80185463";
1560 ASSERT_TRUE(OpenDocument(
"bug_1302455.pdf"));
1561 FPDF_PAGE page = LoadPage(0);
1565 FPDFPage_HasFormFieldAtPoint(form_handle(), page, 110, 110));
1566 FORM_OnMouseMove(form_handle(), page, 0, 110, 110);
1567 FORM_OnLButtonDown(form_handle(), page, 0, 110, 110);
1568 FORM_OnLButtonUp(form_handle(), page, 0, 110, 110);
1569 FORM_OnChar(form_handle(), page,
'A', 0);
1572 FPDFPage_HasFormFieldAtPoint(form_handle(), page, 110, 170));
1573 FORM_OnMouseMove(form_handle(), page, 0, 110, 170);
1574 FORM_OnLButtonDown(form_handle(), page, 0, 110, 170);
1575 FORM_OnLButtonUp(form_handle(), page, 0, 110, 170);
1576 FORM_OnChar(form_handle(), page,
'B', 0);
1578 FORM_ForceToKillFocus(form_handle());
1579 ScopedFPDFBitmap bitmap = RenderLoadedPage(page);
1580 CompareBitmap(bitmap.get(), 300, 300, checksum);
1582 EXPECT_TRUE(FPDF_SaveAsCopy(document(),
this, 0));
1586 VerifySavedDocument(300, 300, checksum);
1590 const char* no_highlight_checksum = []() {
1592#if BUILDFLAG(IS_WIN)
1593 return "2235e2ba8349552de0c818ae53257949";
1594#elif BUILDFLAG(IS_APPLE)
1595 return "e0ad5b4fe007e2e2c27cf6c6fb5b6529";
1597 return "3bfddb2529085021ad283b7e65f71525";
1600#if BUILDFLAG(IS_APPLE)
1601 return "5c82aa43e3b478aa1e4c94bb9ef1f11f";
1603 return "a6268304f7eedfa9ee98fac3caaf2efb";
1607 ASSERT_TRUE(OpenDocument(
"text_form.pdf"));
1608 FPDF_PAGE page = LoadPage(0);
1610 ScopedFPDFBitmap bitmap1 = RenderLoadedPage(page);
1614 FPDF_RemoveFormFieldHighlight(form_handle());
1615 ScopedFPDFBitmap bitmap2 = RenderLoadedPage(page);
1616 CompareBitmap(bitmap2.get(), 300, 300, no_highlight_checksum);
1619 SetInitialFormFieldHighlight(form_handle());
1620 ScopedFPDFBitmap bitmap3 = RenderLoadedPage(page);
1627 ASSERT_TRUE(OpenDocument(
"hello_world.pdf"));
1632 ASSERT_TRUE(OpenDocument(
"text_form.pdf"));
1637 ASSERT_TRUE(OpenDocument(
"simple_xfa.pdf"));
1642 ASSERT_TRUE(OpenDocument(
"bug_216.pdf"));
1647 ASSERT_TRUE(OpenDocument(
"text_form.pdf"));
1648 FPDF_PAGE page = LoadPage(0);
1653 EXPECT_FALSE(FORM_SetIndexSelected(form_handle(),
nullptr, 0,
true));
1654 EXPECT_FALSE(FORM_SetIndexSelected(form_handle(), page, -1,
true));
1657 EXPECT_FALSE(FORM_IsIndexSelected(form_handle(),
nullptr, 0));
1658 EXPECT_FALSE(FORM_IsIndexSelected(form_handle(), page, -1));
1664 ASSERT_TRUE(OpenDocument(
"combobox_form.pdf"));
1665 FPDF_PAGE page = LoadPage(0);
1668 EXPECT_FALSE(FORM_SetIndexSelected(form_handle(), page, -1,
true));
1669 EXPECT_FALSE(FORM_SetIndexSelected(form_handle(), page, 100,
true));
1670 EXPECT_FALSE(FORM_IsIndexSelected(form_handle(), page, -1));
1671 EXPECT_FALSE(FORM_IsIndexSelected(form_handle(), page, 100));
1677 ASSERT_TRUE(OpenDocument(
"listbox_form.pdf"));
1678 FPDF_PAGE page = LoadPage(0);
1681 EXPECT_FALSE(FORM_SetIndexSelected(form_handle(), page, -1,
true));
1682 EXPECT_FALSE(FORM_SetIndexSelected(form_handle(), page, 100,
true));
1683 EXPECT_FALSE(FORM_IsIndexSelected(form_handle(), page, -1));
1684 EXPECT_FALSE(FORM_IsIndexSelected(form_handle(), page, 100));
1690 ASSERT_TRUE(OpenDocument(
"simple_xfa.pdf"));
1691 FPDF_PAGE page = LoadPage(0);
1694 EXPECT_EQ(-1, FPDFPage_HasFormFieldAtPoint(form_handle(), page, 612, 792));
1696#ifdef PDF_ENABLE_XFA
1697 constexpr int kExpectedFieldType = FPDF_FORMFIELD_XFA_TEXTFIELD;
1699 constexpr int kExpectedFieldType = -1;
1701 EXPECT_EQ(kExpectedFieldType,
1702 FPDFPage_HasFormFieldAtPoint(form_handle(), page, 50, 30));
1708 ASSERT_TRUE(OpenDocument(
"text_form.pdf"));
1709 FPDF_PAGE page = LoadPage(0);
1714 EXPECT_FALSE(FORM_SelectAllText(form_handle(),
nullptr));
1718 EXPECT_TRUE(FORM_OnFocus(form_handle(), page, 0, 115, 115));
1719 ScopedFPDFWideString text_to_insert = GetFPDFWideString(L"Hello");
1720 FORM_ReplaceSelection(form_handle(), page, text_to_insert.get());
1724 ASSERT_EQ(12u, FORM_GetFocusedText(form_handle(), page,
nullptr, 0));
1726 FORM_GetFocusedText(form_handle(), page, buffer,
sizeof(buffer)));
1730 ASSERT_EQ(2u, FORM_GetSelectedText(form_handle(), page,
nullptr, 0));
1732 FORM_GetSelectedText(form_handle(), page, buffer,
sizeof(buffer)));
1736 EXPECT_TRUE(FORM_SelectAllText(form_handle(), page));
1737 ASSERT_EQ(12u, FORM_GetSelectedText(form_handle(), page,
nullptr, 0));
1739 FORM_GetSelectedText(form_handle(), page, buffer,
sizeof(buffer)));
1747 CheckFocusedFieldText(
"");
1751 TypeTextIntoTextField(3, RegularFormBegin());
1752 CheckFocusedFieldText(
"ABC");
1753 SelectTextWithKeyboard(3,
FWL_VKEY_Left, RegularFormAtX(123.0));
1754 CheckSelection(
"ABC");
1759 CheckFocusedFieldText(
"");
1763 TypeTextIntoTextField(3, RegularFormBegin());
1764 CheckFocusedFieldText(
"ABC");
1765 SelectTextWithMouse(RegularFormAtX(125.0), RegularFormBegin());
1766 CheckSelection(
"ABC");
1770 TypeTextIntoTextField(12, RegularFormBegin());
1771 CheckFocusedFieldText(
"ABCDEFGHIJKL");
1775 CheckSelection(
"A");
1778 SelectTextWithKeyboard(12,
FWL_VKEY_Left, RegularFormEnd());
1779 CheckSelection(
"ABCDEFGHIJKL");
1782 SelectTextWithKeyboard(6,
FWL_VKEY_Left, RegularFormAtX(170.0));
1783 CheckSelection(
"DEFGHI");
1786 SelectTextWithKeyboard(6,
FWL_VKEY_Right, RegularFormAtX(125.0));
1787 CheckSelection(
"DEFGHI");
1791 CheckSelection(
"L");
1792 CheckFocusedFieldText(
"ABCDEFGHIJKL");
1796 TypeTextIntoTextField(12, RegularFormBegin());
1799 SelectTextWithMouse(RegularFormBegin(), RegularFormAtX(106.0));
1800 CheckSelection(
"A");
1803 SelectAllRegularFormTextWithMouse();
1804 CheckSelection(
"ABCDEFGHIJKL");
1807 SelectTextWithMouse(RegularFormAtX(170.0), RegularFormAtX(125.0));
1808 CheckSelection(
"DEFGHI");
1811 SelectTextWithMouse(RegularFormAtX(125.0), RegularFormAtX(170.0));
1812 CheckSelection(
"DEFGHI");
1815 SelectTextWithMouse(RegularFormEnd(), RegularFormAtX(186.0));
1816 CheckSelection(
"L");
1823 CheckFocusedFieldText(
"");
1826 SelectTextWithMouse(NonEditableFormBegin(), NonEditableFormAtX(142.0));
1827 CheckFocusedFieldText(
"Banana");
1828 CheckSelection(
"Banana");
1831 SelectNonEditableFormOption(0);
1832 CheckFocusedFieldText(
"Apple");
1833 CheckSelection(
"Apple");
1840 CheckFocusedFieldText(
"");
1843 TypeTextIntoTextField(3, EditableFormBegin());
1844 CheckFocusedFieldText(
"ABC");
1845 SelectTextWithKeyboard(3,
FWL_VKEY_Left, EditableFormAtX(128.0));
1846 CheckSelection(
"ABC");
1849 SelectEditableFormOption(1);
1850 CheckSelection(
"Bar");
1851 CheckFocusedFieldText(
"Bar");
1860 TypeTextIntoTextField(3, EditableFormBegin());
1861 SelectTextWithMouse(EditableFormAtX(128.0), EditableFormBegin());
1862 CheckSelection(
"ABC");
1865 SelectEditableFormOption(2);
1866 CheckFocusedFieldText(
"Qux");
1867 CheckSelection(
"Qux");
1872 CheckFocusedFieldText(
"");
1875 SelectTextWithMouse(NonEditableFormBegin(), NonEditableFormAtX(107.0));
1876 CheckFocusedFieldText(
"Banana");
1877 CheckSelection(
"B");
1880 SelectTextWithMouse(NonEditableFormAtX(142.0), NonEditableFormBegin());
1881 CheckSelection(
"Banana");
1884 SelectTextWithMouse(NonEditableFormAtX(135.0), NonEditableFormAtX(117.0));
1885 CheckSelection(
"nan");
1888 SelectTextWithMouse(NonEditableFormAtX(117.0), NonEditableFormAtX(135.0));
1889 CheckSelection(
"nan");
1892 SelectTextWithMouse(NonEditableFormAtX(142.0), NonEditableFormAtX(138.0));
1893 CheckSelection(
"a");
1894 CheckFocusedFieldText(
"Banana");
1897 SelectNonEditableFormOption(2);
1898 CheckFocusedFieldText(
"Cherry");
1899 CheckSelection(
"Cherry");
1900 SelectTextWithMouse(NonEditableFormBegin(), NonEditableFormAtX(122.0));
1901 CheckSelection(
"Che");
1906 CheckFocusedFieldText(
"");
1907 TypeTextIntoTextField(10, EditableFormBegin());
1908 CheckFocusedFieldText(
"ABCDEFGHIJ");
1912 CheckSelection(
"A");
1915 SelectTextWithKeyboard(10,
FWL_VKEY_Left, EditableFormEnd());
1916 CheckSelection(
"ABCDEFGHIJ");
1919 SelectTextWithKeyboard(5,
FWL_VKEY_Left, EditableFormAtX(168.0));
1920 CheckSelection(
"DEFGH");
1923 SelectTextWithKeyboard(5,
FWL_VKEY_Right, EditableFormAtX(127.0));
1924 CheckSelection(
"DEFGH");
1927 SelectTextWithKeyboard(1,
FWL_VKEY_Left, EditableFormEnd());
1928 CheckSelection(
"J");
1931 SelectEditableFormOption(0);
1932 CheckSelection(
"Foo");
1934 CheckSelection(
"Fo");
1935 CheckFocusedFieldText(
"Foo");
1940 TypeTextIntoTextField(10, EditableFormBegin());
1943 SelectTextWithMouse(EditableFormBegin(), EditableFormAtX(107.0));
1944 CheckSelection(
"A");
1947 SelectAllEditableFormTextWithMouse();
1948 CheckSelection(
"ABCDEFGHIJ");
1951 SelectTextWithMouse(EditableFormAtX(168.0), EditableFormAtX(127.0));
1952 CheckSelection(
"DEFGH");
1955 SelectTextWithMouse(EditableFormAtX(127.0), EditableFormAtX(168.0));
1956 CheckSelection(
"DEFGH");
1959 SelectTextWithMouse(EditableFormEnd(), EditableFormAtX(174.0));
1960 CheckSelection(
"J");
1961 CheckFocusedFieldText(
"ABCDEFGHIJ");
1969 FocusOnNonEditableForm();
1970 CheckFocusedFieldText(
"Banana");
1974 SetIndexSelectedShouldSucceed(0,
true);
1975 CheckFocusedFieldText(
"Apple");
1978 SetIndexSelectedShouldSucceed(0,
true);
1979 CheckFocusedFieldText(
"Apple");
1981 SetIndexSelectedShouldSucceed(9,
true);
1982 CheckFocusedFieldText(
"Jackfruit");
1985 SetIndexSelectedShouldFail(9,
false);
1986 CheckFocusedFieldText(
"Jackfruit");
1989 SetIndexSelectedShouldFail(100,
true);
1990 SetIndexSelectedShouldFail(-100,
true);
1991 CheckFocusedFieldText(
"Jackfruit");
1995 SelectNonEditableFormOption(1);
1996 CheckFocusedFieldText(
"Banana");
2004 FocusOnEditableForm();
2005 CheckFocusedFieldText(
"");
2009 SetIndexSelectedShouldSucceed(0,
true);
2010 CheckFocusedFieldText(
"Foo");
2012 SetIndexSelectedShouldSucceed(1,
true);
2013 CheckFocusedFieldText(
"Bar");
2016 SetIndexSelectedShouldSucceed(1,
true);
2017 CheckFocusedFieldText(
"Bar");
2020 SetIndexSelectedShouldFail(0,
false);
2021 CheckFocusedFieldText(
"Bar");
2024 SetIndexSelectedShouldFail(100,
true);
2025 SetIndexSelectedShouldFail(-100,
true);
2026 CheckFocusedFieldText(
"Bar");
2030 SelectEditableFormOption(0);
2031 CheckFocusedFieldText(
"Foo");
2037 SetIndexSelectedShouldSucceed(1,
true);
2038 CheckFocusedFieldText(
"Bar");
2039 TypeTextIntoTextField(5, EditableFormBegin());
2040 CheckFocusedFieldText(
"ABCDEBar");
2046 ClickOnFormFieldAtPoint(NonEditableFormBegin());
2047 for (
int i = 0; i < 26; i++) {
2048 bool expected = i == 1;
2049 CheckIsIndexSelected(i, expected);
2052 SelectNonEditableFormOption(0);
2053 CheckIsIndexSelected(0,
true);
2054 for (
int i = 1; i < 26; i++) {
2055 CheckIsIndexSelected(i,
false);
2062 ClickOnFormFieldAtPoint(EditableFormBegin());
2063 CheckIsIndexSelected(0,
false);
2064 CheckIsIndexSelected(1,
false);
2065 CheckIsIndexSelected(2,
false);
2067 SelectEditableFormOption(0);
2068 CheckIsIndexSelected(0,
true);
2069 CheckIsIndexSelected(1,
false);
2070 CheckIsIndexSelected(2,
false);
2075 TypeTextIntoTextField(12, RegularFormBegin());
2076 SelectAllRegularFormTextWithMouse();
2077 CheckFocusedFieldText(
"ABCDEFGHIJKL");
2078 CheckSelection(
"ABCDEFGHIJKL");
2082 FORM_ReplaceSelection(form_handle(), page(),
nullptr);
2083 CheckFocusedFieldText(
"");
2085 SelectTextWithKeyboard(12,
FWL_VKEY_Left, RegularFormEnd());
2091 TypeTextIntoTextField(12, RegularFormBegin());
2092 SelectTextWithMouse(RegularFormAtX(170.0), RegularFormAtX(125.0));
2093 CheckFocusedFieldText(
"ABCDEFGHIJKL");
2094 CheckSelection(
"DEFGHI");
2098 FORM_ReplaceSelection(form_handle(), page(),
nullptr);
2099 CheckFocusedFieldText(
"ABCJKL");
2100 SelectTextWithKeyboard(12,
FWL_VKEY_Left, RegularFormEnd());
2101 CheckSelection(
"ABCJKL");
2106 TypeTextIntoTextField(12, RegularFormBegin());
2107 SelectTextWithMouse(RegularFormBegin(), RegularFormAtX(132.0));
2108 CheckSelection(
"ABCD");
2112 FORM_ReplaceSelection(form_handle(), page(),
nullptr);
2113 CheckFocusedFieldText(
"EFGHIJKL");
2114 SelectTextWithKeyboard(12,
FWL_VKEY_Left, RegularFormEnd());
2115 CheckSelection(
"EFGHIJKL");
2120 TypeTextIntoTextField(12, RegularFormBegin());
2121 SelectTextWithMouse(RegularFormEnd(), RegularFormAtX(165.0));
2122 CheckSelection(
"IJKL");
2126 FORM_ReplaceSelection(form_handle(), page(),
nullptr);
2127 CheckFocusedFieldText(
"ABCDEFGH");
2128 SelectTextWithKeyboard(12,
FWL_VKEY_Left, RegularFormEnd());
2129 CheckSelection(
"ABCDEFGH");
2134 TypeTextIntoTextField(12, RegularFormBegin());
2138 FORM_ReplaceSelection(form_handle(), page(),
nullptr);
2139 CheckFocusedFieldText(
"ABCDEFGHIJKL");
2140 SelectTextWithKeyboard(12,
FWL_VKEY_Left, RegularFormEnd());
2141 CheckSelection(
"ABCDEFGHIJKL");
2147 TypeTextIntoTextField(10, EditableFormBegin());
2148 SelectAllEditableFormTextWithMouse();
2149 CheckSelection(
"ABCDEFGHIJ");
2153 FORM_ReplaceSelection(form_handle(), page(),
nullptr);
2154 CheckFocusedFieldText(
"");
2155 SelectAllEditableFormTextWithMouse();
2162 TypeTextIntoTextField(10, EditableFormBegin());
2163 SelectTextWithMouse(EditableFormAtX(168.0), EditableFormAtX(127.0));
2164 CheckSelection(
"DEFGH");
2168 FORM_ReplaceSelection(form_handle(), page(),
nullptr);
2169 CheckFocusedFieldText(
"ABCIJ");
2170 SelectAllEditableFormTextWithMouse();
2171 CheckSelection(
"ABCIJ");
2177 TypeTextIntoTextField(10, EditableFormBegin());
2178 SelectTextWithMouse(EditableFormBegin(), EditableFormAtX(132.0));
2179 CheckSelection(
"ABCD");
2183 FORM_ReplaceSelection(form_handle(), page(),
nullptr);
2184 SelectAllEditableFormTextWithMouse();
2185 CheckSelection(
"EFGHIJ");
2191 TypeTextIntoTextField(10, EditableFormBegin());
2192 SelectTextWithMouse(EditableFormEnd(), EditableFormAtX(152.0));
2193 CheckSelection(
"GHIJ");
2197 FORM_ReplaceSelection(form_handle(), page(),
nullptr);
2198 SelectAllEditableFormTextWithMouse();
2199 CheckSelection(
"ABCDEF");
2205 TypeTextIntoTextField(10, EditableFormBegin());
2209 FORM_ReplaceSelection(form_handle(), page(),
nullptr);
2210 SelectAllEditableFormTextWithMouse();
2211 CheckSelection(
"ABCDEFGHIJ");
2215 CheckFocusedFieldText(
"");
2216 ClickOnFormFieldAtPoint(RegularFormBegin());
2217 CheckFocusedFieldText(
"");
2220 ScopedFPDFWideString text_to_insert = GetFPDFWideString(L"Hello");
2221 FORM_ReplaceSelection(form_handle(), page(), text_to_insert.get());
2222 CheckFocusedFieldText(
"Hello");
2227 SelectAllRegularFormTextWithMouse();
2228 CheckSelection(
"Hello");
2232 TypeTextIntoTextField(8, RegularFormBegin());
2233 CheckFocusedFieldText(
"ABCDEFGH");
2236 ClickOnFormFieldAtPoint(RegularFormBegin());
2237 CheckFocusedFieldText(
"ABCDEFGH");
2240 ScopedFPDFWideString text_to_insert = GetFPDFWideString(L"Hello");
2241 FORM_ReplaceSelection(form_handle(), page(), text_to_insert.get());
2242 CheckFocusedFieldText(
"HelloABCDEFGH");
2247 SelectAllRegularFormTextWithMouse();
2248 CheckSelection(
"HelloABCDEFGH");
2252 TypeTextIntoTextField(8, RegularFormBegin());
2255 ClickOnFormFieldAtPoint(RegularFormAtX(134.0));
2258 ScopedFPDFWideString text_to_insert = GetFPDFWideString(L"Hello");
2259 FORM_ReplaceSelection(form_handle(), page(), text_to_insert.get());
2260 CheckFocusedFieldText(
"ABCDHelloEFGH");
2265 SelectAllRegularFormTextWithMouse();
2266 CheckSelection(
"ABCDHelloEFGH");
2270 TypeTextIntoTextField(8, RegularFormBegin());
2273 ClickOnFormFieldAtPoint(RegularFormAtX(166.0));
2276 ScopedFPDFWideString text_to_insert = GetFPDFWideString(L"Hello");
2277 FORM_ReplaceSelection(form_handle(), page(), text_to_insert.get());
2278 CheckFocusedFieldText(
"ABCDEFGHHello");
2283 SelectAllRegularFormTextWithMouse();
2284 CheckSelection(
"ABCDEFGHHello");
2289 TypeTextIntoTextField(12, RegularFormBegin());
2293 SelectTextWithKeyboard(12,
FWL_VKEY_Left, RegularFormEnd());
2294 CheckSelection(
"ABCDEFGHIJKL");
2297 ScopedFPDFWideString text_to_insert = GetFPDFWideString(L"Hello");
2298 FORM_ReplaceSelection(form_handle(), page(), text_to_insert.get());
2299 CheckFocusedFieldText(
"Hello");
2304 SelectAllRegularFormTextWithMouse();
2305 CheckSelection(
"Hello");
2310 TypeTextIntoTextField(12, RegularFormBegin());
2314 SelectTextWithKeyboard(6,
FWL_VKEY_Left, RegularFormAtX(148.0));
2315 CheckSelection(
"ABCDEF");
2318 ScopedFPDFWideString text_to_insert = GetFPDFWideString(L"Hello");
2319 FORM_ReplaceSelection(form_handle(), page(), text_to_insert.get());
2320 CheckFocusedFieldText(
"HelloGHIJKL");
2325 SelectAllRegularFormTextWithMouse();
2326 CheckSelection(
"HelloGHIJKL");
2331 TypeTextIntoTextField(12, RegularFormBegin());
2335 SelectTextWithKeyboard(6,
FWL_VKEY_Left, RegularFormAtX(171.0));
2336 CheckSelection(
"DEFGHI");
2339 ScopedFPDFWideString text_to_insert = GetFPDFWideString(L"Hello");
2340 FORM_ReplaceSelection(form_handle(), page(), text_to_insert.get());
2345 SelectAllRegularFormTextWithMouse();
2346 CheckSelection(
"ABCHelloJKL");
2351 TypeTextIntoTextField(12, RegularFormBegin());
2356 CheckSelection(
"GHIJKL");
2359 ScopedFPDFWideString text_to_insert = GetFPDFWideString(L"Hello");
2360 FORM_ReplaceSelection(form_handle(), page(), text_to_insert.get());
2365 SelectAllRegularFormTextWithMouse();
2366 CheckSelection(
"ABCDEFHello");
2371 ClickOnFormFieldAtPoint(EditableFormBegin());
2372 CheckFocusedFieldText(
"");
2375 ScopedFPDFWideString text_to_insert = GetFPDFWideString(L"Hello");
2376 FORM_ReplaceSelection(form_handle(), page(), text_to_insert.get());
2377 CheckFocusedFieldText(
"Hello");
2382 SelectAllEditableFormTextWithMouse();
2383 CheckSelection(
"Hello");
2388 TypeTextIntoTextField(6, EditableFormBegin());
2391 ClickOnFormFieldAtPoint(EditableFormBegin());
2394 ScopedFPDFWideString text_to_insert = GetFPDFWideString(L"Hello");
2395 FORM_ReplaceSelection(form_handle(), page(), text_to_insert.get());
2400 SelectAllEditableFormTextWithMouse();
2401 CheckSelection(
"HelloABCDEF");
2406 TypeTextIntoTextField(6, EditableFormBegin());
2409 ClickOnFormFieldAtPoint(EditableFormAtX(126.0));
2413 ScopedFPDFWideString text_to_insert = GetFPDFWideString(L"Hello");
2414 FORM_ReplaceSelection(form_handle(), page(), text_to_insert.get());
2419 SelectAllEditableFormTextWithMouse();
2420 CheckSelection(
"ABCHelloDEF");
2425 TypeTextIntoTextField(6, EditableFormBegin());
2428 ClickOnFormFieldAtPoint(EditableFormEnd());
2431 ScopedFPDFWideString text_to_insert = GetFPDFWideString(L"Hello");
2432 FORM_ReplaceSelection(form_handle(), page(), text_to_insert.get());
2437 SelectAllEditableFormTextWithMouse();
2438 CheckSelection(
"ABCDEFHello");
2443 TypeTextIntoTextField(10, EditableFormBegin());
2447 SelectTextWithKeyboard(10,
FWL_VKEY_Left, EditableFormEnd());
2448 CheckSelection(
"ABCDEFGHIJ");
2451 ScopedFPDFWideString text_to_insert = GetFPDFWideString(L"Hello");
2452 FORM_ReplaceSelection(form_handle(), page(), text_to_insert.get());
2457 SelectAllEditableFormTextWithMouse();
2458 CheckSelection(
"Hello");
2463 TypeTextIntoTextField(10, EditableFormBegin());
2467 SelectTextWithKeyboard(5,
FWL_VKEY_Left, EditableFormAtX(142.0));
2468 CheckSelection(
"ABCDE");
2471 ScopedFPDFWideString text_to_insert = GetFPDFWideString(L"Hello");
2472 FORM_ReplaceSelection(form_handle(), page(), text_to_insert.get());
2477 SelectAllEditableFormTextWithMouse();
2478 CheckSelection(
"HelloFGHIJ");
2483 TypeTextIntoTextField(10, EditableFormBegin());
2487 SelectTextWithKeyboard(5,
FWL_VKEY_Left, EditableFormAtX(167.0));
2488 CheckSelection(
"DEFGH");
2491 ScopedFPDFWideString text_to_insert = GetFPDFWideString(L"Hello");
2492 FORM_ReplaceSelection(form_handle(), page(), text_to_insert.get());
2497 SelectAllEditableFormTextWithMouse();
2498 CheckSelection(
"ABCHelloIJ");
2503 TypeTextIntoTextField(10, EditableFormBegin());
2507 SelectTextWithKeyboard(5,
FWL_VKEY_Left, EditableFormEnd());
2508 CheckSelection(
"FGHIJ");
2511 ScopedFPDFWideString text_to_insert = GetFPDFWideString(L"Hello");
2512 FORM_ReplaceSelection(form_handle(), page(), text_to_insert.get());
2517 SelectAllEditableFormTextWithMouse();
2518 CheckSelection(
"ABCDEHello");
2524 ClickOnFormFieldAtPoint(NonEditableFormBegin());
2525 CheckIsIndexSelected(0,
false);
2526 CheckIsIndexSelected(1,
true);
2529 EXPECT_TRUE(FORM_OnChar(form_handle(), page(), pdfium
::ascii::kReturn, 0));
2532 EXPECT_TRUE(FORM_OnKeyDown(form_handle(), page(),
FWL_VKEY_Down, 0));
2533 CheckIsIndexSelected(1,
false);
2534 CheckIsIndexSelected(2,
true);
2537 EXPECT_TRUE(FORM_OnChar(form_handle(), page(), pdfium
::ascii::kTab, 0));
2540 EXPECT_TRUE(FORM_OnChar(form_handle(), page(), pdfium
::ascii::kTab,
2544 CheckIsIndexSelected(2,
true);
2547 EXPECT_TRUE(FORM_OnChar(form_handle(), page(), pdfium
::ascii::kSpace, 0));
2550 EXPECT_TRUE(FORM_OnKeyDown(form_handle(), page(),
FWL_VKEY_Down, 0));
2551 CheckIsIndexSelected(3,
true);
2554 EXPECT_TRUE(FORM_OnChar(form_handle(), page(), pdfium
::ascii::kTab, 0));
2557 EXPECT_TRUE(FORM_OnChar(form_handle(), page(), pdfium
::ascii::kTab,
2561 CheckIsIndexSelected(3,
true);
2567 ClickOnFormFieldAtPoint(EditableFormBegin());
2568 CheckIsIndexSelected(0,
false);
2569 CheckIsIndexSelected(1,
false);
2572 EXPECT_TRUE(FORM_OnChar(form_handle(), page(), pdfium
::ascii::kReturn, 0));
2575 EXPECT_TRUE(FORM_OnKeyDown(form_handle(), page(),
FWL_VKEY_Down, 0));
2576 CheckIsIndexSelected(0,
true);
2577 CheckIsIndexSelected(1,
false);
2580 EXPECT_TRUE(FORM_OnChar(form_handle(), page(), pdfium
::ascii::kTab, 0));
2583 EXPECT_TRUE(FORM_OnChar(form_handle(), page(), pdfium
::ascii::kTab,
2587 CheckIsIndexSelected(0,
true);
2590 EXPECT_TRUE(FORM_OnChar(form_handle(), page(), pdfium
::ascii::kSpace, 0));
2592 CheckFocusedFieldText(
" ");
2593 CheckIsIndexSelected(0,
false);
2599 CheckFocusedFieldText(
"");
2600 ClickOnFormFieldAtPoint(CharLimitFormEnd());
2601 CheckFocusedFieldText(
"Elephant");
2605 SelectAllCharLimitFormTextWithMouse();
2606 CheckSelection(
"Elephant");
2607 FORM_ReplaceSelection(form_handle(), page(),
nullptr);
2608 CheckFocusedFieldText(
"");
2612 ScopedFPDFWideString text_to_insert = GetFPDFWideString(L"Hippopotamus");
2613 FORM_ReplaceSelection(form_handle(), page(), text_to_insert.get());
2614 CheckFocusedFieldText(
"Hippopotam");
2619 SelectAllCharLimitFormTextWithMouse();
2620 CheckSelection(
"Hippopotam");
2626 ClickOnFormFieldAtPoint(CharLimitFormEnd());
2627 CheckFocusedFieldText(
"Elephant");
2631 SelectAllCharLimitFormTextWithMouse();
2632 CheckSelection(
"Elephant");
2633 FORM_ReplaceSelection(form_handle(), page(),
nullptr);
2637 ScopedFPDFWideString text_to_insert = GetFPDFWideString(L"Zebra");
2638 FORM_ReplaceSelection(form_handle(), page(), text_to_insert.get());
2639 CheckFocusedFieldText(
"Zebra");
2644 SelectAllCharLimitFormTextWithMouse();
2645 CheckSelection(
"Zebra");
2651 ClickOnFormFieldAtPoint(CharLimitFormBegin());
2654 ScopedFPDFWideString text_to_insert = GetFPDFWideString(L"Hippopotamus");
2655 FORM_ReplaceSelection(form_handle(), page(), text_to_insert.get());
2660 SelectAllCharLimitFormTextWithMouse();
2661 CheckSelection(
"HiElephant");
2666 CheckFocusedFieldText(
"");
2667 TypeTextIntoTextField(8, RegularFormBegin());
2668 CheckFocusedFieldText(
"ABCDEFGH");
2671 ClickOnFormFieldAtPoint(CharLimitFormAtX(134.0));
2672 CheckFocusedFieldText(
"Elephant");
2675 ScopedFPDFWideString text_to_insert = GetFPDFWideString(L"Hippopotamus");
2676 FORM_ReplaceSelection(form_handle(), page(), text_to_insert.get());
2677 CheckFocusedFieldText(
"ElephHiant");
2682 SelectAllCharLimitFormTextWithMouse();
2683 CheckSelection(
"ElephHiant");
2688 TypeTextIntoTextField(8, RegularFormBegin());
2691 ClickOnFormFieldAtPoint(CharLimitFormAtX(166.0));
2694 ScopedFPDFWideString text_to_insert = GetFPDFWideString(L"Hippopotamus");
2695 FORM_ReplaceSelection(form_handle(), page(), text_to_insert.get());
2700 SelectAllCharLimitFormTextWithMouse();
2701 CheckSelection(
"ElephantHi");
2706 TypeTextIntoTextField(12, RegularFormBegin());
2710 SelectTextWithKeyboard(12,
FWL_VKEY_Left, CharLimitFormEnd());
2711 CheckSelection(
"Elephant");
2714 ScopedFPDFWideString text_to_insert = GetFPDFWideString(L"Hippopotamus");
2715 FORM_ReplaceSelection(form_handle(), page(), text_to_insert.get());
2720 SelectAllCharLimitFormTextWithMouse();
2721 CheckSelection(
"Hippopotam");
2726 TypeTextIntoTextField(12, RegularFormBegin());
2730 SelectTextWithKeyboard(4,
FWL_VKEY_Left, CharLimitFormAtX(122.0));
2731 CheckSelection(
"Elep");
2734 ScopedFPDFWideString text_to_insert = GetFPDFWideString(L"Hippopotamus");
2735 FORM_ReplaceSelection(form_handle(), page(), text_to_insert.get());
2740 SelectAllCharLimitFormTextWithMouse();
2741 CheckSelection(
"Hippophant");
2746 TypeTextIntoTextField(12, RegularFormBegin());
2750 SelectTextWithKeyboard(4,
FWL_VKEY_Left, CharLimitFormAtX(136.0));
2751 CheckSelection(
"epha");
2754 ScopedFPDFWideString text_to_insert = GetFPDFWideString(L"Hippopotamus");
2755 FORM_ReplaceSelection(form_handle(), page(), text_to_insert.get());
2760 SelectAllCharLimitFormTextWithMouse();
2761 CheckSelection(
"ElHippopnt");
2766 TypeTextIntoTextField(12, RegularFormBegin());
2770 SelectTextWithKeyboard(4,
FWL_VKEY_Left, CharLimitFormAtX(152.0));
2771 CheckSelection(
"hant");
2774 ScopedFPDFWideString text_to_insert = GetFPDFWideString(L"Hippopotamus");
2775 FORM_ReplaceSelection(form_handle(), page(), text_to_insert.get());
2780 SelectAllCharLimitFormTextWithMouse();
2781 CheckSelection(
"ElepHippop");
2785 CheckFocusedFieldText(
"");
2786 ClickOnFormFieldAtPoint(RegularFormBegin());
2787 CheckFocusedFieldText(
"");
2790 ScopedFPDFWideString text_to_insert = GetFPDFWideString(L"Hello World");
2791 FORM_ReplaceSelection(form_handle(), page(), text_to_insert.get());
2792 CheckFocusedFieldText(
"Hello World");
2796 DoubleClickOnFormFieldAtPoint(RegularFormBegin());
2797 CheckSelection(
"Hello World");
2801 testing::NiceMock<EmbedderTestMockDelegate> mock;
2803 CheckFocusedFieldText(
"");
2805#ifdef PDF_ENABLE_XFA
2806 EXPECT_CALL(mock, OnFocusChange(_, _, 0)).Times(1);
2808 EXPECT_CALL(mock, OnFocusChange(_, _, 0)).Times(0);
2811 ClickOnFormFieldAtPoint(RegularFormBegin());
2816 testing::NiceMock<EmbedderTestMockDelegate> mock;
2818 CheckFocusedFieldText(
"");
2820 EXPECT_CALL(mock, OnFocusChange(_, _, 0)).Times(1);
2821 ClickOnFormFieldAtPoint(RegularFormBegin());
2825 static const CFX_PointF kNonFormPoint(1, 1);
2826 CheckFocusedFieldText(
"");
2827 ClickOnFormFieldAtPoint(CharLimitFormEnd());
2828 CheckFocusedFieldText(
"Elephant");
2829 ClickOnFormFieldAtPoint(RegularFormBegin());
2830 CheckFocusedFieldText(
"");
2831 TypeTextIntoTextField(3, CharLimitFormBegin());
2832 CheckFocusedFieldText(
"ABElephant");
2833 TypeTextIntoTextField(5, RegularFormBegin());
2834 CheckFocusedFieldText(
"ABCDE");
2835 ClickOnFormFieldAtPoint(CharLimitFormEnd());
2836 CheckFocusedFieldText(
"ABElephant");
2837 ClickOnFormFieldAtPoint(kNonFormPoint);
2838 CheckFocusedFieldText(
"");
2839 ClickOnFormFieldAtPoint(kNonFormPoint);
2840 CheckFocusedFieldText(
"");
2841 ClickOnFormFieldAtPoint(CharLimitFormBegin());
2842 CheckFocusedFieldText(
"ABElephant");
2843 ClickOnFormFieldAtPoint(CharLimitFormEnd());
2844 CheckFocusedFieldText(
"ABElephant");
2845 ClickOnFormFieldAtPoint(RegularFormEnd());
2846 CheckFocusedFieldText(
"ABCDE");
2847 ClickOnFormFieldAtPoint(RegularFormBegin());
2848 CheckFocusedFieldText(
"ABCDE");
2849 ClickOnFormFieldAtPoint(RegularFormBegin());
2850 CheckFocusedFieldText(
"ABCDE");
2851 ClickOnFormFieldAtPoint(CharLimitFormBegin());
2852 CheckFocusedFieldText(
"ABElephant");
2853 FORM_ForceToKillFocus(form_handle());
2854 CheckFocusedFieldText(
"");
2858 static const CFX_PointF kNonFormPoint(1, 1);
2859 CheckFocusedFieldText(
"");
2860 ClickOnFormFieldAtPoint(NonEditableFormBegin());
2861 CheckFocusedFieldText(
"Banana");
2862 ClickOnFormFieldAtPoint(EditableFormBegin());
2863 CheckFocusedFieldText(
"");
2864 ClickOnFormFieldAtPoint(NonEditableFormEnd());
2865 CheckFocusedFieldText(
"Banana");
2866 ClickOnFormFieldAtPoint(NonEditableFormBegin());
2867 CheckFocusedFieldText(
"Banana");
2868 FORM_ForceToKillFocus(form_handle());
2869 CheckFocusedFieldText(
"");
2870 ClickOnFormFieldAtPoint(EditableFormBegin());
2871 CheckFocusedFieldText(
"");
2872 TypeTextIntoTextField(3, EditableFormBegin());
2873 CheckFocusedFieldText(
"ABC");
2874 ClickOnFormFieldAtPoint(kNonFormPoint);
2875 CheckFocusedFieldText(
"");
2876 TypeTextIntoTextField(3, EditableFormEnd());
2877 CheckFocusedFieldText(
"ABCABC");
2878 ClickOnFormFieldAtPoint(kNonFormPoint);
2879 CheckFocusedFieldText(
"");
2880 ClickOnFormFieldAtPoint(EditableFormDropDown());
2881 CheckFocusedFieldText(
"ABCABC");
2882 FORM_ForceToKillFocus(form_handle());
2883 CheckFocusedFieldText(
"");
2884 ClickOnFormFieldAtPoint(NonEditableFormDropDown());
2885 CheckFocusedFieldText(
"Banana");
2886 ClickOnFormFieldAtPoint(kNonFormPoint);
2887 CheckFocusedFieldText(
"");
2888 ClickOnFormFieldAtPoint(NonEditableFormEnd());
2889 CheckFocusedFieldText(
"Banana");
2892 TypeTextIntoTextField(1, NonEditableFormEnd());
2893 CheckFocusedFieldText(
"Apple");
2894 TypeTextIntoTextField(3, NonEditableFormEnd());
2895 CheckFocusedFieldText(
"Cherry");
2896 TypeTextIntoTextField(2, NonEditableFormEnd());
2897 CheckFocusedFieldText(
"Banana");
2899 SelectEditableFormOption(0);
2900 CheckFocusedFieldText(
"Foo");
2901 SelectEditableFormOption(1);
2902 CheckFocusedFieldText(
"Bar");
2903 SelectEditableFormOption(2);
2904 CheckFocusedFieldText(
"Qux");
2905 SelectNonEditableFormOption(1);
2906 CheckFocusedFieldText(
"Banana");
2907 SelectNonEditableFormOption(0);
2908 CheckFocusedFieldText(
"Apple");
2909 SelectNonEditableFormOption(2);
2910 CheckFocusedFieldText(
"Cherry");
2913 SelectEditableFormOption(0);
2914 CheckFocusedFieldText(
"Foo");
2915 TypeTextIntoTextField(5, EditableFormBegin());
2916 CheckFocusedFieldText(
"ABCDEFoo");
2917 SelectEditableFormOption(2);
2918 CheckFocusedFieldText(
"Qux");
2919 TypeTextIntoTextField(2, EditableFormEnd());
2920 CheckFocusedFieldText(
"QuxAB");
2923 SelectEditableFormOption(0);
2924 CheckFocusedFieldText(
"Foo");
2925 TypeTextIntoTextField(1, EditableFormBegin());
2926 CheckFocusedFieldText(
"AFoo");
2927 SelectEditableFormOption(0);
2928 CheckFocusedFieldText(
"Foo");
2932 ClickOnFormFieldAtPoint(RegularFormBegin());
2933 CheckFocusedFieldText(
"");
2934 CheckCanUndo(
false);
2935 CheckCanRedo(
false);
2937 TypeTextIntoTextField(5, RegularFormBegin());
2938 CheckFocusedFieldText(
"ABCDE");
2940 CheckCanRedo(
false);
2943 CheckFocusedFieldText(
"ABCD");
2947 CheckFocusedFieldText(
"ABC");
2952 CheckFocusedFieldText(
"ABCD");
2956 CheckFocusedFieldText(
"ABCDE");
2958 CheckCanRedo(
false);
2965 ClickOnFormFieldAtPoint(CharLimitFormEnd());
2966 CheckFocusedFieldText(
"Elephant");
2968 SetIndexSelectedShouldFail(0,
true);
2969 SetIndexSelectedShouldFail(0,
false);
2970 SetIndexSelectedShouldFail(1,
true);
2971 SetIndexSelectedShouldFail(1,
false);
2972 SetIndexSelectedShouldFail(-1,
true);
2973 SetIndexSelectedShouldFail(-1,
false);
2980 ClickOnFormFieldAtPoint(CharLimitFormEnd());
2981 CheckFocusedFieldText(
"Elephant");
2983 CheckIsIndexSelected(0,
false);
2984 CheckIsIndexSelected(1,
false);
2985 CheckIsIndexSelected(-1,
false);
2989 ClickOnFormFieldAtPoint(NonEditableFormBegin());
2990 CheckFocusedFieldText(
"Banana");
2991 CheckCanUndo(
false);
2992 CheckCanRedo(
false);
2994 ClickOnFormFieldAtPoint(EditableFormBegin());
2995 CheckFocusedFieldText(
"");
2996 CheckCanUndo(
false);
2997 CheckCanRedo(
false);
2999 TypeTextIntoTextField(3, EditableFormBegin());
3000 CheckFocusedFieldText(
"ABC");
3002 CheckCanRedo(
false);
3005 CheckFocusedFieldText(
"AB");
3009 CheckFocusedFieldText(
"A");
3013 CheckFocusedFieldText(
"");
3014 CheckCanUndo(
false);
3018 CheckFocusedFieldText(
"A");
3026 FocusOnSingleSelectForm();
3027 CheckIsIndexSelected(0,
false);
3028 CheckIsIndexSelected(1,
false);
3029 CheckIsIndexSelected(2,
false);
3031 ClickOnSingleSelectFormOption(1);
3032 CheckIsIndexSelected(0,
false);
3033 CheckIsIndexSelected(1,
true);
3034 CheckIsIndexSelected(2,
false);
3040 FocusOnMultiSelectForm();
3041 for (
int i = 0; i < 26; i++) {
3042 bool expected = i == 1;
3043 CheckIsIndexSelected(i, expected);
3050 ClickOnMultiSelectFormOption(1);
3051 for (
int i = 0; i < 26; i++) {
3052 bool expected = i == 1;
3053 CheckIsIndexSelected(i, expected);
3060 FocusOnSingleSelectForm();
3061 CheckFocusedFieldText(
"");
3062 CheckIsIndexSelected(0,
false);
3063 CheckIsIndexSelected(1,
false);
3064 CheckIsIndexSelected(2,
false);
3068 SetIndexSelectedShouldSucceed(0,
true);
3069 CheckFocusedFieldText(
"Foo");
3070 CheckIsIndexSelected(0,
true);
3071 CheckIsIndexSelected(1,
false);
3072 CheckIsIndexSelected(2,
false);
3074 SetIndexSelectedShouldSucceed(1,
true);
3075 CheckFocusedFieldText(
"Bar");
3076 CheckIsIndexSelected(0,
false);
3077 CheckIsIndexSelected(1,
true);
3078 CheckIsIndexSelected(2,
false);
3082 SetIndexSelectedShouldSucceed(1,
true);
3083 CheckFocusedFieldText(
"Bar");
3084 CheckIsIndexSelected(0,
false);
3085 CheckIsIndexSelected(1,
true);
3086 CheckIsIndexSelected(2,
false);
3088 SetIndexSelectedShouldSucceed(2,
false);
3089 CheckFocusedFieldText(
"Bar");
3090 CheckIsIndexSelected(0,
false);
3091 CheckIsIndexSelected(1,
true);
3092 CheckIsIndexSelected(2,
false);
3095 SetIndexSelectedShouldFail(100,
true);
3096 SetIndexSelectedShouldFail(-100,
true);
3097 SetIndexSelectedShouldFail(100,
false);
3098 SetIndexSelectedShouldFail(-100,
false);
3100 CheckFocusedFieldText(
"Bar");
3101 CheckIsIndexSelected(0,
false);
3102 CheckIsIndexSelected(1,
true);
3103 CheckIsIndexSelected(2,
false);
3106 SetIndexSelectedShouldSucceed(1,
false);
3107 CheckFocusedFieldText(
"");
3108 CheckIsIndexSelected(0,
false);
3109 CheckIsIndexSelected(1,
false);
3110 CheckIsIndexSelected(2,
false);
3114 ClickOnSingleSelectFormOption(1);
3115 CheckFocusedFieldText(
"Bar");
3116 CheckIsIndexSelected(0,
false);
3117 CheckIsIndexSelected(1,
true);
3118 CheckIsIndexSelected(2,
false);
3126 FocusOnMultiSelectForm();
3127 for (
int i = 0; i < 26; i++) {
3128 bool expected = i == 1;
3129 CheckIsIndexSelected(i, expected);
3131 CheckFocusedFieldText(
"Banana");
3134 SetIndexSelectedShouldSucceed(5,
true);
3135 SetIndexSelectedShouldSucceed(6,
true);
3136 SetIndexSelectedShouldSucceed(20,
true);
3137 for (
int i = 0; i < 26; i++) {
3138 bool expected = (i == 1 || i == 5 || i == 6 || i == 20);
3139 CheckIsIndexSelected(i, expected);
3141 CheckFocusedFieldText(
"Ugli Fruit");
3144 SetIndexSelectedShouldSucceed(5,
true);
3145 SetIndexSelectedShouldSucceed(6,
true);
3146 SetIndexSelectedShouldSucceed(20,
true);
3147 for (
int i = 0; i < 26; i++) {
3148 bool expected = (i == 1 || i == 5 || i == 6 || i == 20);
3149 CheckIsIndexSelected(i, expected);
3151 CheckFocusedFieldText(
"Ugli Fruit");
3154 SetIndexSelectedShouldSucceed(20,
false);
3155 SetIndexSelectedShouldSucceed(1,
false);
3156 for (
int i = 0; i < 26; i++) {
3157 bool expected = (i == 5 || i == 6);
3158 CheckIsIndexSelected(i, expected);
3160 CheckFocusedFieldText(
"Banana");
3165 SetIndexSelectedShouldSucceed(1,
false);
3166 SetIndexSelectedShouldSucceed(3,
false);
3167 for (
int i = 0; i < 26; i++) {
3168 bool expected = (i == 5 || i == 6);
3169 CheckIsIndexSelected(i, expected);
3171 CheckFocusedFieldText(
"Date");
3174 SetIndexSelectedShouldFail(100,
true);
3175 SetIndexSelectedShouldFail(-100,
true);
3176 SetIndexSelectedShouldFail(100,
false);
3177 SetIndexSelectedShouldFail(-100,
false);
3179 CheckFocusedFieldText(
"Date");
3180 for (
int i = 0; i < 26; i++) {
3181 bool expected = (i == 5 || i == 6);
3182 CheckIsIndexSelected(i, expected);
3188 ClickOnMultiSelectFormOption(1);
3189 for (
int i = 0; i < 26; i++) {
3190 bool expected = i == 1;
3191 CheckIsIndexSelected(i, expected);
3193 CheckFocusedFieldText(
"Banana");
3199 FocusOnMultiSelectMultipleIndicesForm();
3200 for (
int i = 0; i < 5; i++) {
3201 bool expected = (i == 1 || i == 3);
3202 CheckIsIndexSelected(i, expected);
3209 FocusOnMultiSelectMultipleValuesForm();
3210 for (
int i = 0; i < 5; i++) {
3211 bool expected = (i == 2 || i == 4);
3212 CheckIsIndexSelected(i, expected);
3219 FocusOnMultiSelectMultipleMismatchForm();
3220 for (
int i = 0; i < 5; i++) {
3221 bool expected = (i == 0 || i == 2);
3222 CheckIsIndexSelected(i, expected);
3234 ClickOnMultiSelectMultipleValuesFormOption(0);
3235 for (
int i = 0; i < 5; i++) {
3236 bool expected = i == 0;
3237 CheckIsIndexSelected(i, expected);
3243 FocusOnSingleSelectLastSelectedForm();
3244 for (
int i = 0; i < 10; i++) {
3245 bool expected = i == 9;
3246 CheckIsIndexSelected(i, expected);
3253 ClickOnSingleSelectLastSelectedFormOption(0);
3254 for (
int i = 0; i < 10; i++) {
3255 bool expected = i == 8;
3256 CheckIsIndexSelected(i, expected);
3261 ScopedFPDFWideString text_to_insert = GetFPDFWideString(L"XYZ");
3262 ClickOnFormFieldAtPoint(RegularFormBegin());
3263 CheckCanUndo(
false);
3264 CheckCanRedo(
false);
3266 TypeTextIntoTextField(2, RegularFormBegin());
3267 CheckFocusedFieldText(
"AB");
3270 CheckSelection(
"A");
3272 FORM_ReplaceAndKeepSelection(form_handle(), page(), text_to_insert.get());
3273 CheckFocusedFieldText(
"XYZB");
3274 CheckSelection(
"XYZ");
3276 CheckCanRedo(
false);
3279 CheckFocusedFieldText(
"AB");
3284 CheckSelection(
"B");
3286 FORM_ReplaceAndKeepSelection(form_handle(), page(), text_to_insert.get());
3287 CheckFocusedFieldText(
"AXYZ");
3288 CheckSelection(
"XYZ");
3290 CheckCanRedo(
false);
3294 ScopedFPDFWideString text_to_insert1 = GetFPDFWideString(L"UVW");
3296 ClickOnFormFieldAtPoint(RegularFormBegin());
3297 CheckFocusedFieldText(
"");
3298 CheckCanUndo(
false);
3299 CheckCanRedo(
false);
3301 FORM_ReplaceAndKeepSelection(form_handle(), page(), text_to_insert1.get());
3302 CheckFocusedFieldText(
"UVW");
3303 CheckSelection(
"UVW");
3306 CheckCanRedo(
false);
3309 CheckFocusedFieldText(
"");
3311 CheckCanUndo(
false);
3314 CheckFocusedFieldText(
"UVW");
3317 ScopedFPDFWideString text_to_insert2 = GetFPDFWideString(L"XYZ");
3318 FORM_ReplaceAndKeepSelection(form_handle(), page(), text_to_insert2.get());
3319 CheckFocusedFieldText(
"UVWXYZ");
3320 CheckSelection(
"XYZ");
3324 CheckFocusedFieldText(
"UVW");
3329 ScopedFPDFWideString text_to_insert = GetFPDFWideString(L"XYZ");
3330 ClickOnFormFieldAtPoint(RegularFormBegin());
3331 CheckCanUndo(
false);
3332 CheckCanRedo(
false);
3334 TypeTextIntoTextField(2, RegularFormBegin());
3335 CheckFocusedFieldText(
"AB");
3338 CheckSelection(
"A");
3340 FORM_ReplaceSelection(form_handle(), page(), text_to_insert.get());
3341 CheckFocusedFieldText(
"XYZB");
3343 CheckCanRedo(
false);
3346 CheckFocusedFieldText(
"AB");
3351 CheckFocusedFieldText(
"A");
3356 CheckFocusedFieldText(
"");
3357 CheckCanUndo(
false);
3361 CheckFocusedFieldText(
"A");
3366 CheckFocusedFieldText(
"AB");
3371 CheckFocusedFieldText(
"XYZB");
3373 CheckCanRedo(
false);
3377 ScopedFPDFWideString text_to_insert1 = GetFPDFWideString(L"UVW");
3379 ClickOnFormFieldAtPoint(RegularFormBegin());
3380 CheckFocusedFieldText(
"");
3381 CheckCanUndo(
false);
3382 CheckCanRedo(
false);
3384 FORM_ReplaceSelection(form_handle(), page(), text_to_insert1.get());
3385 CheckFocusedFieldText(
"UVW");
3389 CheckCanRedo(
false);
3392 CheckFocusedFieldText(
"");
3394 CheckCanUndo(
false);
3397 CheckFocusedFieldText(
"UVW");
3400 ScopedFPDFWideString text_to_insert2 = GetFPDFWideString(L"XYZ");
3401 FORM_ReplaceSelection(form_handle(), page(), text_to_insert2.get());
3402 CheckFocusedFieldText(
"UVWXYZ");
3405 CheckCanRedo(
false);
3408 CheckFocusedFieldText(
"UVW");
3414 TypeTextIntoTextField(2, RegularFormBegin());
3415 CheckFocusedFieldText(
"AB");
3419#if BUILDFLAG(IS_APPLE)
3420 constexpr int kCorrectModifier = FWL_EVENTFLAG_MetaKey;
3426 CheckSelection(
"AB");
3429 ClickOnFormFieldAtPoint(RegularFormBegin());
3433#if BUILDFLAG(IS_APPLE)
3434 constexpr int kWrongModifier = FWL_EVENTFLAG_ControlKey;
3453 ScopedFPDFWideString text_to_insert = GetFPDFWideString(L"XYZ");
3454 DoubleClickOnFormFieldAtPoint(CFX_PointF(100, 100));
3455 FORM_ReplaceSelection(form_handle(), page(), text_to_insert.get());
3469 ScopedFPDFWideString text_to_insert = GetFPDFWideString(L"");
3470 DoubleClickOnFormFieldAtPoint(CFX_PointF(22, 22));
3471 FORM_ReplaceSelection(form_handle(), page(), text_to_insert.get());
3481 ASSERT_TRUE(
OpenDocument(
"annots_action_handling.pdf"));
3488 constexpr size_t kSubtypeCount = std::size(kFocusableSubtypes);
3489 ASSERT_TRUE(FPDFAnnot_SetFocusableSubtypes(
3490 form_handle(), kFocusableSubtypes, kSubtypeCount));
3504 for (size_t i = 1; i < n; i++)
3511 FPDF_PAGE page_ =
nullptr;
3515 NiceMock<EmbedderTestMockDelegate> mock;
3517 EXPECT_CALL(mock, DoURIAction(_)).Times(0);
3520 SetFocusOnNthAnnot(1);
3523 ASSERT_TRUE(FORM_OnKeyDown(form_handle(), page(),
FWL_VKEY_Tab, 0));
3527 ASSERT_FALSE(FORM_OnChar(form_handle(), page(), pdfium
::ascii::kReturn, 0));
3531 NiceMock<EmbedderTestMockDelegate> mock;
3533 InSequence sequence;
3534 const char kExpectedUri[] =
"https://cs.chromium.org/";
3535#ifdef PDF_ENABLE_XFA
3537 DoURIActionWithKeyboardModifier(_, StrEq(kExpectedUri), _))
3540 EXPECT_CALL(mock, DoURIAction(StrEq(kExpectedUri))).Times(4);
3541 EXPECT_CALL(mock, DoURIActionWithKeyboardModifier(_, _, _)).Times(0);
3545 SetFocusOnNthAnnot(3);
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_TRUE(FORM_OnKeyDown(form_handle(), page(),
FWL_VKEY_Return, modifier));
3555 ASSERT_FALSE(FORM_OnKeyDown(
nullptr, page(),
FWL_VKEY_Return, modifier));
3560 ASSERT_FALSE(FORM_OnKeyDown(form_handle(), page(),
FWL_VKEY_Shift, modifier));
3561 ASSERT_FALSE(FORM_OnKeyDown(form_handle(), page(),
FWL_VKEY_Space, modifier));
3567 NiceMock<EmbedderTestMockDelegate> mock;
3568 EXPECT_CALL(mock, DoGoToAction(_, _, 1, _, _)).Times(12);
3571 SetFocusOnNthAnnot(4);
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 ASSERT_TRUE(FORM_OnKeyDown(form_handle(), page(),
FWL_VKEY_Return, modifier));
3581 SetFocusOnNthAnnot(5);
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 ASSERT_TRUE(FORM_OnKeyDown(form_handle(), page(),
FWL_VKEY_Return, modifier));
3591 SetFocusOnNthAnnot(6);
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_TRUE(FORM_OnKeyDown(form_handle(), page(),
FWL_VKEY_Return, modifier));
3601 ASSERT_FALSE(FORM_OnKeyDown(
nullptr, page(),
FWL_VKEY_Return, modifier));
3606 ASSERT_FALSE(FORM_OnKeyDown(form_handle(), page(),
FWL_VKEY_Shift, modifier));
3607 ASSERT_FALSE(FORM_OnKeyDown(form_handle(), page(),
FWL_VKEY_Space, modifier));
3620 NiceMock<EmbedderTestMockDelegate> mock;
3622 InSequence sequence;
3623 EXPECT_CALL(mock, DoURIAction(_)).Times(0);
3624 const char kExpectedUri[] =
"https://cs.chromium.org/";
3626 DoURIActionWithKeyboardModifier(_, StrEq(kExpectedUri), 0));
3627 EXPECT_CALL(mock, DoURIActionWithKeyboardModifier(
3628 _, StrEq(kExpectedUri), FWL_EVENTFLAG_ControlKey));
3629 EXPECT_CALL(mock, DoURIActionWithKeyboardModifier(_, StrEq(kExpectedUri),
3630 FWL_EVENTFLAG_ShiftKey));
3632 DoURIActionWithKeyboardModifier(_, StrEq(kExpectedUri), 3));
3635 SetFocusOnNthAnnot(3);
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_TRUE(FORM_OnKeyDown(form_handle(), page(),
FWL_VKEY_Return, modifier));
3645 ASSERT_FALSE(FORM_OnKeyDown(
nullptr, page(),
FWL_VKEY_Return, modifier));
3650 ASSERT_FALSE(FORM_OnKeyDown(form_handle(), page(),
FWL_VKEY_Shift, modifier));
3651 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)
void UnloadPage(FPDF_PAGE page)
FPDF_PAGE LoadPage(int page_number)
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 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
std::string GetPlatformString(FPDF_WIDESTRING wstr)
constexpr uint8_t kReturn
constexpr uint8_t kControlA
const char * TextFormChecksum()
const char * Bug890322Checksum()