chromium/chrome/browser/ui/views/autofill/payments/card_unmask_authentication_selection_dialog_browsertest.cc

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

#include "base/test/metrics/histogram_tester.h"
#include "build/build_config.h"
#include "chrome/browser/ui/autofill/payments/view_factory.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/test/test_browser_dialog.h"
#include "chrome/browser/ui/views/autofill/payments/card_unmask_authentication_selection_dialog_view.h"
#include "chrome/test/base/ui_test_utils.h"
#include "components/autofill/core/browser/autofill_test_utils.h"
#include "components/autofill/core/browser/metrics/autofill_metrics.h"
#include "components/autofill/core/browser/ui/payments/card_unmask_authentication_selection_dialog_controller_impl.h"
#include "content/public/test/browser_test.h"

namespace autofill {

class CardUnmaskAuthenticationSelectionDialogBrowserTestBase
    : public DialogBrowserTest {};

// Non-parameterized version of
// CardUnmaskAuthenticationSelectionDialogBrowserTestBase. Should be used to
// test the specific functionality of a certain type of challenge option being
// selected, instead of the overall functionality of the dialog.
// TODO(crbug.com/40247985): Add browser tests for specific SMS OTP challenge
// selection logging.
class CardUnmaskAuthenticationSelectionDialogBrowserTestNonParameterized
    : public CardUnmaskAuthenticationSelectionDialogBrowserTestBase {};

// Ensure accepting the CVC challenge option in the selection dialog is
// correctly handled.
IN_PROC_BROWSER_TEST_F(
    CardUnmaskAuthenticationSelectionDialogBrowserTestNonParameterized,
    AcceptedByUserAfterSelectingCvcAuthResultsMetricsLoggedAsExpected) {}

// Parameters of the
// CardUnmaskAuthenticationSelectionDialogBrowserTestParameterized.
ChallengeOptionTypes;

// Parameterized version of
// CardUnmaskAuthenticationSelectionDialogBrowserTestBase. Should be used to
// test the overall functionality of the dialog, across all combinations of
// challenge options related to the dialog.
class CardUnmaskAuthenticationSelectionDialogBrowserTestParameterized
    : public CardUnmaskAuthenticationSelectionDialogBrowserTestBase,
      public testing::WithParamInterface<ChallengeOptionTypes> {};

INSTANTIATE_TEST_SUITE_P();

// Ensures the UI can be shown.
IN_PROC_BROWSER_TEST_P(
    CardUnmaskAuthenticationSelectionDialogBrowserTestParameterized,
    InvokeUi_CardUnmaskAuthSelectionDialogDisplays) {}

// Ensures closing tab while dialog being visible is correctly handled.
IN_PROC_BROWSER_TEST_P(
    CardUnmaskAuthenticationSelectionDialogBrowserTestParameterized,
    CanCloseTabWhileDialogShowing) {}

// Ensures closing browser while dialog being visible is correctly handled.
IN_PROC_BROWSER_TEST_P(
    CardUnmaskAuthenticationSelectionDialogBrowserTestParameterized,
    CanCloseBrowserWhileDialogShowing) {}

// Ensure cancelling dialog is correctly handled.
IN_PROC_BROWSER_TEST_P(
    CardUnmaskAuthenticationSelectionDialogBrowserTestParameterized,
    CanceledByUserAfterSelectionResultsMetricsLoggedAsExpected) {}

}  // namespace autofill