chromium/third_party/pdfium/fpdfsdk/fpdf_formfill_embeddertest.cpp

// Copyright 2015 The PDFium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include <vector>

#include "build/build_config.h"
#include "constants/ascii.h"
#include "core/fxcrt/check.h"
#include "core/fxcrt/check_op.h"
#include "core/fxcrt/fx_coordinates.h"
#include "core/fxcrt/fx_string.h"
#include "core/fxcrt/fx_system.h"
#include "core/fxge/cfx_defaultrenderdevice.h"
#include "public/cpp/fpdf_scopers.h"
#include "public/fpdf_formfill.h"
#include "public/fpdf_fwlevent.h"
#include "public/fpdf_progressive.h"
#include "testing/embedder_test.h"
#include "testing/embedder_test_constants.h"
#include "testing/embedder_test_mock_delegate.h"
#include "testing/embedder_test_timer_handling_delegate.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"

TextFormChecksum;

_;
InSequence;
NiceMock;
StrEq;

FPDFFormFillEmbedderTest;

// A base class for many related tests that involve clicking and typing into
// form fields.
class FPDFFormFillInteractiveEmbedderTest : public FPDFFormFillEmbedderTest {};

class FPDFFormFillTextFormEmbedderTest
    : public FPDFFormFillInteractiveEmbedderTest {};

class FPDFFormFillComboBoxFormEmbedderTest
    : public FPDFFormFillInteractiveEmbedderTest {};

class FPDFFormFillListBoxFormEmbedderTest
    : public FPDFFormFillInteractiveEmbedderTest {};

class FPDFFormFillTextFormEmbedderTestVersion2
    : public FPDFFormFillTextFormEmbedderTest {};

TEST_F(FPDFFormFillEmbedderTest, FirstTest) {}

TEST_F(FPDFFormFillEmbedderTest, Bug487928) {}

TEST_F(FPDFFormFillEmbedderTest, Bug507316) {}

TEST_F(FPDFFormFillEmbedderTest, Bug514690) {}

TEST_F(FPDFFormFillEmbedderTest, Bug900552) {}

TEST_F(FPDFFormFillEmbedderTest, Bug901654Case1) {}

TEST_F(FPDFFormFillEmbedderTest, Bug901654Case2) {}

TEST_F(FPDFFormFillEmbedderTest, GetFocusedAnnotation) {}

TEST_F(FPDFFormFillEmbedderTest, SetFocusedAnnotation) {}

TEST_F(FPDFFormFillEmbedderTest, FormFillFirstTab) {}

TEST_F(FPDFFormFillEmbedderTest, FormFillFirstShiftTab) {}

TEST_F(FPDFFormFillEmbedderTest, FormFillContinuousTab) {}

TEST_F(FPDFFormFillEmbedderTest, FormFillContinuousShiftTab) {}

TEST_F(FPDFFormFillEmbedderTest, TabWithModifiers) {}

TEST_F(FPDFFormFillEmbedderTest, KeyPressWithNoFocusedAnnot) {}

#ifdef PDF_ENABLE_XFA
TEST_F(FPDFFormFillEmbedderTest, XFAFormFillFirstTab) {}

TEST_F(FPDFFormFillEmbedderTest, XFAFormFillFirstShiftTab) {}

TEST_F(FPDFFormFillEmbedderTest, XFAFormFillContinuousTab) {}

TEST_F(FPDFFormFillEmbedderTest, XFAFormFillContinuousShiftTab) {}
#endif  // PDF_ENABLE_XFA

class DoURIActionBlockedDelegate final : public EmbedderTest::Delegate {};

TEST_F(FPDFFormFillEmbedderTest, Bug851821) {}

TEST_F(FPDFFormFillEmbedderTest, CheckReadOnlyInCheckbox) {}

TEST_F(FPDFFormFillEmbedderTest, CheckReadOnlyInRadiobutton) {}

#ifdef PDF_ENABLE_V8
TEST_F(FPDFFormFillEmbedderTest, DisableJavaScript) {}

TEST_F(FPDFFormFillEmbedderTest, DocumentAActions) {}

TEST_F(FPDFFormFillEmbedderTest, DocumentAActionsDisableJavaScript) {}

TEST_F(FPDFFormFillEmbedderTest, Bug551248) {}

TEST_F(FPDFFormFillEmbedderTest, Bug620428) {}

TEST_F(FPDFFormFillEmbedderTest, Bug634394) {}

TEST_F(FPDFFormFillEmbedderTest, Bug634716) {}

TEST_F(FPDFFormFillEmbedderTest, Bug679649) {}

TEST_F(FPDFFormFillEmbedderTest, Bug707673) {}

TEST_F(FPDFFormFillEmbedderTest, Bug765384) {}

// Test passes if DCHECK() not hit.
TEST_F(FPDFFormFillEmbedderTest, Bug1477093) {}

#endif  // PDF_ENABLE_V8

TEST_F(FPDFFormFillEmbedderTest, FormText) {}

// Tests using FPDF_REVERSE_BYTE_ORDER with FPDF_FFLDraw(). The two rendered
// bitmaps should be different.
TEST_F(FPDFFormFillEmbedderTest, Bug1281) {}

TEST_F(FPDFFormFillEmbedderTest, Bug1302455RenderOnly) {}

TEST_F(FPDFFormFillEmbedderTest, Bug1302455EditFirstForm) {}

TEST_F(FPDFFormFillEmbedderTest, Bug1302455EditSecondForm) {}

TEST_F(FPDFFormFillEmbedderTest, Bug1302455EditBothForms) {}

TEST_F(FPDFFormFillEmbedderTest, RemoveFormFieldHighlight) {}

TEST_F(FPDFFormFillEmbedderTest, HasFormInfoNone) {}

TEST_F(FPDFFormFillEmbedderTest, HasFormInfoAcroForm) {}

TEST_F(FPDFFormFillEmbedderTest, HasFormInfoXFAFull) {}

TEST_F(FPDFFormFillEmbedderTest, HasFormInfoXFAForeground) {}

TEST_F(FPDFFormFillEmbedderTest, BadApiInputsText) {}

TEST_F(FPDFFormFillEmbedderTest, BadApiInputsComboBox) {}

TEST_F(FPDFFormFillEmbedderTest, BadApiInputsListBox) {}

TEST_F(FPDFFormFillEmbedderTest, HasFormFieldAtPointForXFADoc) {}

TEST_F(FPDFFormFillEmbedderTest, SelectAllText) {}

TEST_F(FPDFFormFillTextFormEmbedderTest, GetSelectedTextEmptyAndBasicKeyboard) {}

TEST_F(FPDFFormFillTextFormEmbedderTest, GetSelectedTextEmptyAndBasicMouse) {}

TEST_F(FPDFFormFillTextFormEmbedderTest, GetSelectedTextFragmentsKeyBoard) {}

TEST_F(FPDFFormFillTextFormEmbedderTest, GetSelectedTextFragmentsMouse) {}

TEST_F(FPDFFormFillComboBoxFormEmbedderTest,
       GetSelectedTextEmptyAndBasicNormalComboBox) {}

TEST_F(FPDFFormFillComboBoxFormEmbedderTest,
       GetSelectedTextEmptyAndBasicEditableComboBoxKeyboard) {}

TEST_F(FPDFFormFillComboBoxFormEmbedderTest,
       GetSelectedTextEmptyAndBasicEditableComboBoxMouse) {}

TEST_F(FPDFFormFillComboBoxFormEmbedderTest,
       GetSelectedTextFragmentsNormalComboBox) {}

TEST_F(FPDFFormFillComboBoxFormEmbedderTest,
       GetSelectedTextFragmentsEditableComboBoxKeyboard) {}

TEST_F(FPDFFormFillComboBoxFormEmbedderTest,
       GetSelectedTextFragmentsEditableComboBoxMouse) {}

TEST_F(FPDFFormFillComboBoxFormEmbedderTest,
       SetSelectionProgrammaticallyNonEditableField) {}

TEST_F(FPDFFormFillComboBoxFormEmbedderTest,
       SetSelectionProgrammaticallyEditableField) {}

TEST_F(FPDFFormFillComboBoxFormEmbedderTest,
       CheckIfIndexSelectedNonEditableField) {}

TEST_F(FPDFFormFillComboBoxFormEmbedderTest,
       CheckIfIndexSelectedEditableField) {}

TEST_F(FPDFFormFillTextFormEmbedderTest, DeleteTextFieldEntireSelection) {}

TEST_F(FPDFFormFillTextFormEmbedderTest, DeleteTextFieldSelectionMiddle) {}

TEST_F(FPDFFormFillTextFormEmbedderTest, DeleteTextFieldSelectionLeft) {}

TEST_F(FPDFFormFillTextFormEmbedderTest, DeleteTextFieldSelectionRight) {}

TEST_F(FPDFFormFillTextFormEmbedderTest, DeleteEmptyTextFieldSelection) {}

TEST_F(FPDFFormFillComboBoxFormEmbedderTest,
       DeleteEditableComboBoxEntireSelection) {}

TEST_F(FPDFFormFillComboBoxFormEmbedderTest,
       DeleteEditableComboBoxSelectionMiddle) {}

TEST_F(FPDFFormFillComboBoxFormEmbedderTest,
       DeleteEditableComboBoxSelectionLeft) {}

TEST_F(FPDFFormFillComboBoxFormEmbedderTest,
       DeleteEditableComboBoxSelectionRight) {}

TEST_F(FPDFFormFillComboBoxFormEmbedderTest,
       DeleteEmptyEditableComboBoxSelection) {}

TEST_F(FPDFFormFillTextFormEmbedderTest, InsertTextInEmptyTextField) {}

TEST_F(FPDFFormFillTextFormEmbedderTest, InsertTextInPopulatedTextFieldLeft) {}

TEST_F(FPDFFormFillTextFormEmbedderTest, InsertTextInPopulatedTextFieldMiddle) {}

TEST_F(FPDFFormFillTextFormEmbedderTest, InsertTextInPopulatedTextFieldRight) {}

TEST_F(FPDFFormFillTextFormEmbedderTest,
       InsertTextAndReplaceSelectionInPopulatedTextFieldWhole) {}

TEST_F(FPDFFormFillTextFormEmbedderTest,
       InsertTextAndReplaceSelectionInPopulatedTextFieldLeft) {}

TEST_F(FPDFFormFillTextFormEmbedderTest,
       InsertTextAndReplaceSelectionInPopulatedTextFieldMiddle) {}

TEST_F(FPDFFormFillTextFormEmbedderTest,
       InsertTextAndReplaceSelectionInPopulatedTextFieldRight) {}

TEST_F(FPDFFormFillComboBoxFormEmbedderTest,
       InsertTextInEmptyEditableComboBox) {}

TEST_F(FPDFFormFillComboBoxFormEmbedderTest,
       InsertTextInPopulatedEditableComboBoxLeft) {}

TEST_F(FPDFFormFillComboBoxFormEmbedderTest,
       InsertTextInPopulatedEditableComboBoxMiddle) {}

TEST_F(FPDFFormFillComboBoxFormEmbedderTest,
       InsertTextInPopulatedEditableComboBoxRight) {}

TEST_F(FPDFFormFillComboBoxFormEmbedderTest,
       InsertTextAndReplaceSelectionInPopulatedEditableComboBoxWhole) {}

TEST_F(FPDFFormFillComboBoxFormEmbedderTest,
       InsertTextAndReplaceSelectionInPopulatedEditableComboBoxLeft) {}

TEST_F(FPDFFormFillComboBoxFormEmbedderTest,
       InsertTextAndReplaceSelectionInPopulatedEditableComboBoxMiddle) {}

TEST_F(FPDFFormFillComboBoxFormEmbedderTest,
       InsertTextAndReplaceSelectionInPopulatedEditableComboBoxRight) {}

TEST_F(FPDFFormFillComboBoxFormEmbedderTest,
       CheckIfEnterAndSpaceKeyAreHandled) {}

TEST_F(FPDFFormFillComboBoxFormEmbedderTest,
       CheckIfEnterAndSpaceKeyAreHandledOnEditableFormField) {}

TEST_F(FPDFFormFillTextFormEmbedderTest,
       InsertTextInEmptyCharLimitTextFieldOverflow) {}

TEST_F(FPDFFormFillTextFormEmbedderTest,
       InsertTextInEmptyCharLimitTextFieldFit) {}

TEST_F(FPDFFormFillTextFormEmbedderTest,
       InsertTextInPopulatedCharLimitTextFieldLeft) {}

TEST_F(FPDFFormFillTextFormEmbedderTest,
       InsertTextInPopulatedCharLimitTextFieldMiddle) {}

TEST_F(FPDFFormFillTextFormEmbedderTest,
       InsertTextInPopulatedCharLimitTextFieldRight) {}

TEST_F(FPDFFormFillTextFormEmbedderTest,
       InsertTextAndReplaceSelectionInPopulatedCharLimitTextFieldWhole) {}

TEST_F(FPDFFormFillTextFormEmbedderTest,
       InsertTextAndReplaceSelectionInPopulatedCharLimitTextFieldLeft) {}

TEST_F(FPDFFormFillTextFormEmbedderTest,
       InsertTextAndReplaceSelectionInPopulatedCharLimitTextFieldMiddle) {}

TEST_F(FPDFFormFillTextFormEmbedderTest,
       InsertTextAndReplaceSelectionInPopulatedCharLimitTextFieldRight) {}

TEST_F(FPDFFormFillTextFormEmbedderTest, DoubleClickInTextField) {}

TEST_F(FPDFFormFillTextFormEmbedderTest, FocusAnnotationUpdateToEmbedder) {}

TEST_F(FPDFFormFillTextFormEmbedderTestVersion2,
       FocusAnnotationUpdateToEmbedder) {}

TEST_F(FPDFFormFillTextFormEmbedderTest, FocusChanges) {}

TEST_F(FPDFFormFillComboBoxFormEmbedderTest, FocusChanges) {}

TEST_F(FPDFFormFillTextFormEmbedderTest, UndoRedo) {}

// This action only applies to Listboxes and Comboboxes so should fail
// gracefully for Textboxes by returning false to all operations.
TEST_F(FPDFFormFillTextFormEmbedderTest, SetIndexSelectedShouldFailGracefully) {}

// This action only applies to Listboxes and Comboboxes so should fail
// gracefully for Textboxes by returning false to all operations.
TEST_F(FPDFFormFillTextFormEmbedderTest, IsIndexSelectedShouldFailGracefully) {}

TEST_F(FPDFFormFillComboBoxFormEmbedderTest, UndoRedo) {}

TEST_F(FPDFFormFillListBoxFormEmbedderTest,
       CheckIfIndexSelectedSingleSelectField) {}

TEST_F(FPDFFormFillListBoxFormEmbedderTest,
       CheckIfIndexSelectedMultiSelectField) {}

TEST_F(FPDFFormFillListBoxFormEmbedderTest,
       SetSelectionProgrammaticallySingleSelectField) {}

// Re: Focus Field Text - For multiselect listboxes a caret is set on the last
// item to be selected/deselected. The text of that item should be returned.
TEST_F(FPDFFormFillListBoxFormEmbedderTest,
       SetSelectionProgrammaticallyMultiSelectField) {}

TEST_F(FPDFFormFillListBoxFormEmbedderTest, CheckIfMultipleSelectedIndices) {}

TEST_F(FPDFFormFillListBoxFormEmbedderTest, CheckIfMultipleSelectedValues) {}

TEST_F(FPDFFormFillListBoxFormEmbedderTest, CheckIfMultipleSelectedMismatch) {}

TEST_F(FPDFFormFillListBoxFormEmbedderTest,
       CheckIfVerticalScrollIsAtFirstSelected) {}

TEST_F(FPDFFormFillListBoxFormEmbedderTest, CheckForNoOverscroll) {}

TEST_F(FPDFFormFillTextFormEmbedderTest, ReplaceAndKeepSelection) {}

TEST_F(FPDFFormFillTextFormEmbedderTest, ContinuouslyReplaceAndKeepSelection) {}

TEST_F(FPDFFormFillTextFormEmbedderTest, ReplaceSelection) {}

TEST_F(FPDFFormFillTextFormEmbedderTest, ContinuouslyReplaceSelection) {}

TEST_F(FPDFFormFillTextFormEmbedderTest, SelectAllWithKeyboardShortcut) {}

class FPDFXFAFormBug1055869EmbedderTest
    : public FPDFFormFillInteractiveEmbedderTest {};

TEST_F(FPDFXFAFormBug1055869EmbedderTest, Paste) {}

class FPDFXFAFormBug1058653EmbedderTest
    : public FPDFFormFillInteractiveEmbedderTest {};

TEST_F(FPDFXFAFormBug1058653EmbedderTest, Paste) {}

class FPDFFormFillActionUriTest : public EmbedderTest {};

TEST_F(FPDFFormFillActionUriTest, ButtonActionInvokeTest) {}

TEST_F(FPDFFormFillActionUriTest, LinkActionInvokeTest) {}

TEST_F(FPDFFormFillActionUriTest, InternalLinkActionInvokeTest) {}

class FPDFFormFillActionUriTestVersion2 : public FPDFFormFillActionUriTest {};

TEST_F(FPDFFormFillActionUriTestVersion2, LinkActionInvokeTest) {}