chromium/components/plus_addresses/metrics/plus_address_submission_logger_unittest.cc

// Copyright 2024 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/plus_addresses/metrics/plus_address_submission_logger.h"

#include <string_view>
#include <utility>
#include <vector>

#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/task_environment.h"
#include "base/types/cxx23_to_underlying.h"
#include "components/autofill/core/browser/autofill_form_test_utils.h"
#include "components/autofill/core/browser/autofill_plus_address_delegate.h"
#include "components/autofill/core/browser/field_types.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/ui/suggestion_type.h"
#include "components/autofill/core/common/autofill_test_utils.h"
#include "components/autofill/core/common/form_data_test_api.h"
#include "components/autofill/core/common/mojom/autofill_types.mojom-shared.h"
#include "components/signin/public/identity_manager/identity_manager.h"
#include "components/signin/public/identity_manager/identity_test_environment.h"
#include "components/ukm/test_ukm_recorder.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"

namespace plus_addresses::metrics {

namespace {
FieldType;
FormData;
SuggestionType;
FormDescription;
ElementsAreArray;
IsEmpty;
PasswordFormType;
SuggestionContext;

constexpr char kGaiaAccount[] =;
constexpr char16_t kGaiaAccount_U16[] =;
constexpr char kSamplePlusAddress[] =;
constexpr char16_t kSamplePlusAddress_U16[] =;
constexpr auto kSubmissionSource =;

constexpr char kNonCommerceUrl[] =;
constexpr char kCommerceUrl[] =;
constexpr char kManagedDomain[] =;

// Short-hands for the bucket enum used to record bucketed plus address counts.
constexpr int64_t kNoPlusAddress =;
constexpr int64_t kOneToThreePlusAddresses =;
constexpr int64_t kMoreThanThreePlusAddresses =;

ukm::TestUkmRecorder::HumanReadableUkmMetrics CreateUkmMetrics(
    size_t field_count_browser_form,
    size_t field_count_renderer_form,
    int64_t plus_address_count,
    bool is_checkout_or_cart_page,
    bool is_managed,
    bool is_newly_created,
    bool submitted_plus_address,
    PasswordFormType password_form_type,
    SuggestionContext suggestion_context,
    bool was_shown_create_suggestion) {}

}  // namespace

class PlusAddressSubmissionLoggerTest : public ::testing::Test {};

// Tests that no metrics are recorded for signed out users.
TEST_F(PlusAddressSubmissionLoggerTest, NoMetricForSignedOutUsers) {}

struct PlusAddressSubmissionTestCase {};

class PlusAddressSubmissionTestWithParam
    : public PlusAddressSubmissionLoggerTest,
      public ::testing::WithParamInterface<PlusAddressSubmissionTestCase> {};

// Parametrized test that checks that the expected UKM is recorded. The test
// simulates that the user is logged in and submits a previously focused form
TEST_P(PlusAddressSubmissionTestWithParam, SubmittingFormRecordsUkm) {}

INSTANTIATE_TEST_SUITE_P();

}  // namespace plus_addresses::metrics