chromium/components/autofill/content/browser/content_autofill_driver_unittest.cc

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

#include "components/autofill/content/browser/content_autofill_driver.h"

#include <stdint.h>

#include <algorithm>
#include <functional>
#include <memory>
#include <optional>
#include <string>
#include <utility>
#include <vector>

#include "base/check.h"
#include "base/command_line.h"
#include "base/functional/bind.h"
#include "base/memory/raw_ptr.h"
#include "base/run_loop.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/bind.h"
#include "base/test/gmock_move_support.h"
#include "base/test/mock_callback.h"
#include "base/test/scoped_feature_list.h"
#include "components/autofill/content/browser/content_autofill_driver_factory_test_api.h"
#include "components/autofill/content/browser/content_autofill_driver_test_api.h"
#include "components/autofill/content/browser/test_autofill_client_injector.h"
#include "components/autofill/content/browser/test_autofill_driver_injector.h"
#include "components/autofill/content/browser/test_autofill_manager_injector.h"
#include "components/autofill/content/browser/test_content_autofill_client.h"
#include "components/autofill/core/browser/autofill_driver_router.h"
#include "components/autofill/core/browser/autofill_external_delegate.h"
#include "components/autofill/core/browser/autofill_test_utils.h"
#include "components/autofill/core/browser/browser_autofill_manager.h"
#include "components/autofill/core/browser/test_autofill_driver.h"
#include "components/autofill/core/common/aliases.h"
#include "components/autofill/core/common/autofill_constants.h"
#include "components/autofill/core/common/autofill_features.h"
#include "components/autofill/core/common/autofill_switches.h"
#include "components/autofill/core/common/form_data_predictions.h"
#include "components/autofill/core/common/form_data_test_api.h"
#include "components/autofill/core/common/form_field_data.h"
#include "components/autofill/core/common/mojom/autofill_types.mojom-shared.h"
#include "components/autofill/core/common/test_matchers.h"
#include "components/autofill/core/common/unique_ids.h"
#include "components/version_info/version_info.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/ssl_status.h"
#include "content/public/browser/storage_partition.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/content_features.h"
#include "content/public/test/mock_navigation_handle.h"
#include "content/public/test/navigation_simulator.h"
#include "content/public/test/prerender_test_util.h"
#include "content/public/test/test_renderer_host.h"
#include "content/public/test/web_contents_tester.h"
#include "mojo/public/cpp/bindings/associated_receiver_set.h"
#include "mojo/public/cpp/bindings/associated_remote.h"
#include "mojo/public/cpp/bindings/message.h"
#include "mojo/public/cpp/system/functions.h"
#include "net/base/net_errors.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h"

namespace autofill {

namespace {

LazyRef;
SaveArgPtr;
_;
AllOf;
DoAll;
ElementsAre;
Eq;
Field;
Gt;
Invoke;
IsEmpty;
IsNull;
Optional;
Pointwise;
Property;
SaveArg;
SizeIs;
WithArg;

const char kAppLocale[] =;

MATCHER(EqualsFillData, "") {}

class FakeAutofillAgent : public mojom::AutofillAgent {};

class MockBrowserAutofillManager : public BrowserAutofillManager {};

class ContentAutofillDriverWithFakeAutofillAgent
    : public ContentAutofillDriver {};

class ContentAutofillDriverTest : public content::RenderViewHostTestHarness {};

class ContentAutofillDriverTestWithAddressForm
    : public ContentAutofillDriverTest {};

class ContentAutofillDriverWithMultiFrameCreditCardForm
    : public ContentAutofillDriverTest {};

TEST_F(ContentAutofillDriverTest, Lift_Form) {}

// Test that forms in "about:" without parents have an empty FormData::url.
TEST_F(ContentAutofillDriverTest, Lift_Form_AboutScheme) {}

// Test that forms in "about:" subframes inherit the URL of their next
// non-"about:" ancestor in FormData::url.
TEST_F(ContentAutofillDriverTest,
       Lift_Form_AboutSchemeInheritsFromGrandParent) {}

// Tests that the FormData::version of forms passed to AutofillManager
// increases.
TEST_F(ContentAutofillDriverTest, WithNewVersion) {}

// Tests that FormsSeen() for an updated form arrives in the AutofillManager.
// Does not test multiple frames.
TEST_F(ContentAutofillDriverTest, FormsSeen_UpdatedForm) {}

// Tests that FormsSeen() for a removed form arrives in the AutofillManager.
// Does not test multiple frames.
TEST_F(ContentAutofillDriverTest, FormsSeen_RemovedForm) {}

// Tests that FormsSeen() for one updated and one removed form arrives in the
// AutofillManager.
// Does not test multiple frames.
TEST_F(ContentAutofillDriverTest, FormsSeen_UpdatedAndRemovedForm) {}

TEST_F(ContentAutofillDriverTestWithAddressForm,
       FormDataSentToRenderer_FillForm) {}

TEST_F(ContentAutofillDriverTestWithAddressForm,
       FormDataSentToRenderer_PreviewForm) {}

TEST_F(ContentAutofillDriverTest, TypePredictionsSentToRendererWhenEnabled) {}

TEST_F(ContentAutofillDriverTestWithAddressForm, AcceptDataListSuggestion) {}

TEST_F(ContentAutofillDriverTestWithAddressForm,
       ClearPreviewedFormSentToRenderer) {}

// Tests that `AutofillDriver::RendererShouldTriggerSuggestions()` calls make
// it to AutofillAgent.
TEST_F(ContentAutofillDriverTestWithAddressForm, TriggerSuggestions) {}

TEST_F(ContentAutofillDriverTestWithAddressForm, ApplyFieldAction_Fill) {}

TEST_F(ContentAutofillDriverTestWithAddressForm, ApplyFieldAction_Preview) {}

TEST_F(ContentAutofillDriverTest, TriggerFormExtractionInAllFrames) {}

TEST_F(ContentAutofillDriverWithMultiFrameCreditCardForm,
       ExtractForm_NotFound) {}

TEST_F(ContentAutofillDriverWithMultiFrameCreditCardForm, ExtractForm_Found) {}

TEST_F(ContentAutofillDriverTest, GetFourDigitCombinationsFromDom_NoMatches) {}

TEST_F(ContentAutofillDriverTest,
       GetFourDigitCombinationsFromDom_SuccessfulMatches) {}

// RAII type that intercepts mojom::ReportBadMessage() calls.
class BadMessageHelper {};

class ContentAutofillDriverTest_PrerenderBadMessage
    : public ContentAutofillDriverTest {};

// Tests that a renderer event during prerendering causes a bad message.
TEST_F(ContentAutofillDriverTest_PrerenderBadMessage,
       BadMessageIfPrerendering) {}

// Tests that a renderer event with a FieldRendererId that doesn't belong to the
// associated FormData causes a bad message.
TEST_F(ContentAutofillDriverTest, BadMessageIfFieldWithoutForm) {}

}  // namespace

}  // namespace autofill