#include <memory>
#include <string>
#include <string_view>
#include "base/strings/utf_string_conversions.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/mock_callback.h"
#include "chrome/browser/ui/autofill/payments/desktop_payments_window_manager.h"
#include "chrome/browser/ui/autofill/payments/desktop_payments_window_manager_test_api.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_tabstrip.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/test/test_browser_ui.h"
#include "chrome/browser/ui/views/autofill/payments/payments_window_user_consent_dialog_view.h"
#include "chrome/test/base/interactive_test_utils.h"
#include "chrome/test/base/ui_test_utils.h"
#include "chrome/test/interaction/interactive_browser_test.h"
#include "components/autofill/content/browser/test_autofill_client_injector.h"
#include "components/autofill/content/browser/test_content_autofill_client.h"
#include "components/autofill/core/browser/autofill_test_utils.h"
#include "components/autofill/core/browser/metrics/payments/payments_window_metrics.h"
#include "components/autofill/core/browser/payments/card_unmask_challenge_option.h"
#include "components/autofill/core/browser/payments/payments_autofill_client.h"
#include "components/autofill/core/browser/payments/payments_window_manager.h"
#include "components/autofill/core/browser/payments/test_payments_autofill_client.h"
#include "components/autofill/core/browser/payments/test_payments_network_interface.h"
#include "content/public/browser/site_instance.h"
#include "content/public/browser/web_contents.h"
#include "content/public/test/browser_test.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/views/window/dialog_client_view.h"
namespace autofill {
class TestContentAutofillClientForWindowManagerTest
: public TestContentAutofillClient { … };
namespace payments {
constexpr std::string_view kVcn3dsTestUrl = …;
constexpr std::string_view kTestContextToken = …;
constexpr std::string_view kVcn3dsFlowEventsHistogramName = …;
constexpr std::string_view kVcn3dsFlowEventsConsentAlreadyGivenHistogramName = …;
constexpr std::string_view kVcn3dsFlowEventsConsentNotGivenYetHistogramName = …;
constexpr std::string_view kVcn3dsSuccessLatencyHistogramName = …;
constexpr std::string_view kVcn3dsFailureLatencyHistogramName = …;
class DesktopPaymentsWindowManagerInteractiveUiTest : public UiBrowserTest { … };
IN_PROC_BROWSER_TEST_F(DesktopPaymentsWindowManagerInteractiveUiTest,
InvokeUi_EmptyMetadata_ErrorDialogShown) { … }
IN_PROC_BROWSER_TEST_F(DesktopPaymentsWindowManagerInteractiveUiTest,
InvokeUi_EmptyUrlToOpen_ErrorDialogShown) { … }
IN_PROC_BROWSER_TEST_F(DesktopPaymentsWindowManagerInteractiveUiTest,
InvokeUi_EmptySuccessQueryParamName_ErrorDialogShown) { … }
IN_PROC_BROWSER_TEST_F(DesktopPaymentsWindowManagerInteractiveUiTest,
InvokeUi_EmptyFailureQueryParamName_ErrorDialogShown) { … }
IN_PROC_BROWSER_TEST_F(DesktopPaymentsWindowManagerInteractiveUiTest,
InvokeUi_Vcn3ds_FlowStartedHistogramBucketLogs) { … }
IN_PROC_BROWSER_TEST_F(DesktopPaymentsWindowManagerInteractiveUiTest,
InvokeUi_Vcn3ds_QueryParamsPresent) { … }
IN_PROC_BROWSER_TEST_F(
DesktopPaymentsWindowManagerInteractiveUiTest,
InvokeUi_Vcn3ds_QueryParamsPresent_SuccessHistogramBucketLogs) { … }
IN_PROC_BROWSER_TEST_F(
DesktopPaymentsWindowManagerInteractiveUiTest,
InvokeUi_Vcn3ds_QueryParamsPresent_SuccessLatencyHistogramBucketLogs) { … }
IN_PROC_BROWSER_TEST_F(
DesktopPaymentsWindowManagerInteractiveUiTest,
InvokeUi_Vcn3ds_QueryParamsPresent_FailureLatencyHistogramBucketLogs) { … }
IN_PROC_BROWSER_TEST_F(DesktopPaymentsWindowManagerInteractiveUiTest,
InvokeUi_Vcn3ds_UnmaskCardRequestFailure) { … }
IN_PROC_BROWSER_TEST_F(
DesktopPaymentsWindowManagerInteractiveUiTest,
InvokeUi_Vcn3ds_UnmaskCardRequestFailure_FailureHistogramBucketLogs) { … }
IN_PROC_BROWSER_TEST_F(DesktopPaymentsWindowManagerInteractiveUiTest,
InvokeUi_Vcn3ds_QueryParams_AuthenticationFailed) { … }
IN_PROC_BROWSER_TEST_F(
DesktopPaymentsWindowManagerInteractiveUiTest,
InvokeUi_Vcn3ds_QueryParams_AuthenticationFailed_FailureHistogramBucketLogs) { … }
IN_PROC_BROWSER_TEST_F(DesktopPaymentsWindowManagerInteractiveUiTest,
InvokeUi_Vcn3ds_NoQueryParamsAndPopupClosed) { … }
IN_PROC_BROWSER_TEST_F(
DesktopPaymentsWindowManagerInteractiveUiTest,
InvokeUi_Vcn3ds_NoQueryParamsAndPopupClosed_CancelledHistogramBucketLogs) { … }
IN_PROC_BROWSER_TEST_F(DesktopPaymentsWindowManagerInteractiveUiTest,
InvokeUi_Vcn3ds_InvalidQueryParams) { … }
IN_PROC_BROWSER_TEST_F(DesktopPaymentsWindowManagerInteractiveUiTest,
InvokeUi_Vcn3ds_ProgressDialogCancelled) { … }
IN_PROC_BROWSER_TEST_F(
DesktopPaymentsWindowManagerInteractiveUiTest,
InvokeUi_Vcn3ds_ProgressDialogCancelled_ProgressDialogCancelledHistogramBucketLogs) { … }
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS)
IN_PROC_BROWSER_TEST_F(DesktopPaymentsWindowManagerInteractiveUiTest,
InvokeUi_Vcn3ds_OriginalTabSetLastActive) { … }
#endif
class PaymentsWindowUserConsentDialogIntegrationTest
: public InteractiveBrowserTest { … };
IN_PROC_BROWSER_TEST_F(PaymentsWindowUserConsentDialogIntegrationTest,
FlowStartedConsentNotGivenYetHistogramBucketLogs) { … }
IN_PROC_BROWSER_TEST_F(PaymentsWindowUserConsentDialogIntegrationTest,
DialogAccepted) { … }
IN_PROC_BROWSER_TEST_F(PaymentsWindowUserConsentDialogIntegrationTest,
DialogAccepted_AcceptedHistogramBucketLogs) { … }
IN_PROC_BROWSER_TEST_F(PaymentsWindowUserConsentDialogIntegrationTest,
DialogCancelled) { … }
IN_PROC_BROWSER_TEST_F(PaymentsWindowUserConsentDialogIntegrationTest,
DialogDeclined_DeclinedHistogramBucketLogs) { … }
}
}