chromium/components/autofill/core/browser/profile_token_quality_unittest.cc

// Copyright 2023 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/core/browser/profile_token_quality.h"

#include <memory>
#include <string>
#include <string_view>
#include <vector>

#include "base/ranges/algorithm.h"
#include "base/test/task_environment.h"
#include "base/types/cxx23_to_underlying.h"
#include "components/autofill/core/browser/address_data_manager.h"
#include "components/autofill/core/browser/autofill_field.h"
#include "components/autofill/core/browser/autofill_form_test_utils.h"
#include "components/autofill/core/browser/autofill_test_utils.h"
#include "components/autofill/core/browser/autofill_trigger_details.h"
#include "components/autofill/core/browser/country_type.h"
#include "components/autofill/core/browser/data_model/autofill_profile.h"
#include "components/autofill/core/browser/field_types.h"
#include "components/autofill/core/browser/form_structure.h"
#include "components/autofill/core/browser/profile_token_quality_test_api.h"
#include "components/autofill/core/browser/test_autofill_client.h"
#include "components/autofill/core/browser/test_autofill_driver.h"
#include "components/autofill/core/browser/test_browser_autofill_manager.h"
#include "components/autofill/core/browser/test_personal_data_manager.h"
#include "components/autofill/core/common/form_data.h"
#include "components/autofill/core/common/form_data_test_api.h"
#include "components/autofill/core/common/form_field_data.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace autofill {

ObservationType;
UnorderedElementsAre;

class ProfileTokenQualityTest : public testing::Test {};

TEST_F(ProfileTokenQualityTest, GetObservationTypesForFieldType) {}

// Tests that `AddObservationsForFilledForm()` derives the correct observation
// types when fields are not edited.
TEST_F(ProfileTokenQualityTest, AddObservationsForFilledForm_Accepted) {}

// Tests that `AddObservationsForFilledForm()` derives the correct observation
// types when fields are edited to values that don't occur in another profile.
TEST_F(ProfileTokenQualityTest, AddObservationsForFilledForm_Edited) {}

// Tests that `AddObservationsForFilledForm()` derives the correct observation
// types when fields are edited to values occurring in another profile.
TEST_F(ProfileTokenQualityTest,
       AddObservationsForFilledForm_Edited_DifferentProfile) {}

// Tests that only a single observation is collected per field.
TEST_F(ProfileTokenQualityTest, AddObservationsForFilledForm_SameField) {}

// Tests that when the type of a field changes between filling and submission,
// observations are collected for the type the field had when it was filled.
TEST_F(ProfileTokenQualityTest, AddObservationsForFilledForm_DynamicChange) {}

// Tests that `SaveObservationsForFilledFormForAllSubmittedProfiles()` collects
// observations for all profiles that were used to fill the form.
TEST_F(ProfileTokenQualityTest,
       SaveObservationsForFilledFormForAllSubmittedProfiles) {}

// Tests that calling `LoadSerializedObservationsForStoredType()` with invalid
// data doesn't lead to a CHECK() failure. This is important, since the function
// is called with whatever data is read from disk by `AddressAutofillTable`.
// The expectation of this test is that it doesn't crash.
// The `serialized_observations` contain pairs of (observation type, form hash).
// Since the form hash is a hash, the code performs no validation against it and
// the test simply uses a hash of 0.
TEST_F(ProfileTokenQualityTest,
       LoadSerializedObservationsForStoredType_InvalidData) {}

// Tests the dropping of random observations during
// `AddObservationsForFilledForm()`. In particular, tests that for a form
// containing fields of the the given `form_types`, the
// `expected_number_of_observations` are collected.
struct DropObservationTest {};

class ProfileTokenQualityObservationDroppingTest
    : public ProfileTokenQualityTest,
      public testing::WithParamInterface<DropObservationTest> {};

TEST_P(ProfileTokenQualityObservationDroppingTest,
       AddObservationsForFilledForm_DropObservations) {}

INSTANTIATE_TEST_SUITE_P();

}  // namespace autofill