chromium/chrome/browser/ui/views/autofill/payments/payments_window_user_consent_dialog_browsertest.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 "base/functional/callback_helpers.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/mock_callback.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/views/autofill/payments/payments_window_user_consent_dialog_view.h"
#include "chrome/test/interaction/interactive_browser_test.h"
#include "components/autofill/core/browser/metrics/payments/payments_window_metrics.h"
#include "components/autofill/core/browser/ui/payments/payments_window_user_consent_dialog_controller.h"
#include "components/autofill/core/browser/ui/payments/payments_window_user_consent_dialog_controller_impl.h"
#include "content/public/test/browser_test.h"
#include "ui/views/window/dialog_client_view.h"

namespace autofill::payments {

constexpr char kSuppressedScreenshotError[] =;
constexpr std::string_view
    kPaymentsWindowUserConsentDialogResultVcn3dsHistogramName =;
constexpr std::string_view
    kPaymentsWindowUserConsentDialogShownVcn3dsHistogramName =;

class PaymentsWindowUserConsentDialogBrowserTest
    : public InteractiveBrowserTest {};

// Ensures the UI can be shown, and verifies that it looks as expected.
IN_PROC_BROWSER_TEST_F(PaymentsWindowUserConsentDialogBrowserTest,
                       InvokeUi_PaymentsWindowUserConsentDialogDisplays) {}

// Ensures the UI can be shown, and verifies that the dialog shown histogram
// bucket is logged to.
IN_PROC_BROWSER_TEST_F(PaymentsWindowUserConsentDialogBrowserTest,
                       InvokeUi_DialogShownHistogramBucketLogs) {}

// Ensures the UI can be shown, and verifies that accepting the dialog runs the
// accept callback and hides the view.
IN_PROC_BROWSER_TEST_F(PaymentsWindowUserConsentDialogBrowserTest,
                       InvokeUi_DialogAcceptance) {}

// Ensures the UI can be shown, and verifies that accepting the dialog logs to
// the dialog acceptance histogram bucket.
IN_PROC_BROWSER_TEST_F(PaymentsWindowUserConsentDialogBrowserTest,
                       InvokeUi_DialogAcceptanceHistogramBucketLogs) {}

// Ensures the UI can be shown, and verifies that cancelling the dialog runs the
// cancel callback and hides the view.
IN_PROC_BROWSER_TEST_F(PaymentsWindowUserConsentDialogBrowserTest,
                       InvokeUi_DialogCancelled) {}

// Ensures the UI can be shown, and verifies that cancelling the dialog logs to
// the dialog cancelled histogram bucket.
IN_PROC_BROWSER_TEST_F(PaymentsWindowUserConsentDialogBrowserTest,
                       InvokeUi_DialogCancelledHistogramBucketLogs) {}

// Ensures the UI can be shown, and verifies that pressing the escape key on the
// dialog hides the view.
IN_PROC_BROWSER_TEST_F(PaymentsWindowUserConsentDialogBrowserTest,
                       InvokeUi_EscKeyPressed) {}

// Ensures the UI can be shown, and verifies that pressing the escape key on the
// dialog logs to the escape key pressed histogram bucket.
IN_PROC_BROWSER_TEST_F(PaymentsWindowUserConsentDialogBrowserTest,
                       InvokeUi_EscKeyPressedHistogramBucketLogs) {}

// Ensures the UI can be shown, and verifies that closing the tab while the
// dialog is present does not crash.
IN_PROC_BROWSER_TEST_F(PaymentsWindowUserConsentDialogBrowserTest,
                       InvokeUi_CanCloseTabWhileDialogShowing) {}

// Ensures the UI can be shown, and verifies that closing the tab while the
// dialog is present logs to the tab or browser closed histogram bucket.
IN_PROC_BROWSER_TEST_F(PaymentsWindowUserConsentDialogBrowserTest,
                       InvokeUi_CloseTabWhileDialogShowingHistogramBucketLogs) {}

// Ensures the UI can be shown, and verifies that closing the browser while the
// dialog is present does not crash.
IN_PROC_BROWSER_TEST_F(PaymentsWindowUserConsentDialogBrowserTest,
                       InvokeUi_CanCloseBrowserWhileDialogShowing) {}

// Ensures the UI can be shown, and verifies that closing the browser while the
// dialog is present logs to the tab or browser closed histogram bucket.
IN_PROC_BROWSER_TEST_F(
    PaymentsWindowUserConsentDialogBrowserTest,
    InvokeUi_CloseBrowserWhileDialogShowingHistogramBucketLogs) {}

}  // namespace autofill::payments