#include "chrome/browser/ui/views/payments/payment_request_browsertest_base.h"
#include <algorithm>
#include <iostream>
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include "base/command_line.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/run_loop.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/autofill/personal_data_manager_factory.h"
#include "chrome/browser/payments/payment_request_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/views/payments/editor_view_controller.h"
#include "chrome/browser/ui/views/payments/payment_request_dialog_view_ids.h"
#include "chrome/browser/ui/views/payments/validating_combobox.h"
#include "chrome/browser/ui/views/payments/validating_textfield.h"
#include "chrome/browser/ui/views/payments/view_stack.h"
#include "chrome/test/base/ui_test_utils.h"
#include "chrome/test/payments/payment_app_install_util.h"
#include "components/autofill/core/browser/address_data_manager.h"
#include "components/autofill/core/browser/data_model/autofill_profile.h"
#include "components/autofill/core/browser/data_model/credit_card.h"
#include "components/autofill/core/browser/payments_data_manager.h"
#include "components/autofill/core/browser/payments_data_manager_test_api.h"
#include "components/autofill/core/browser/personal_data_manager.h"
#include "components/autofill/core/browser/personal_data_manager_test_utils.h"
#include "components/autofill/core/browser/ui/address_combobox_model.h"
#include "components/network_session_configurator/common/network_switches.h"
#include "components/payments/content/payment_request.h"
#include "components/payments/core/payment_prefs.h"
#include "components/prefs/pref_service.h"
#include "components/web_modal/web_contents_modal_dialog_manager.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/content_switches.h"
#include "content/public/test/browser_test_utils.h"
#include "net/dns/mock_host_resolver.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/test/ui_controls.h"
#include "ui/events/base_event_utils.h"
#include "ui/events/event.h"
#include "ui/gfx/animation/test_animation_delegate.h"
#include "ui/gfx/geometry/point.h"
#include "ui/views/controls/button/button.h"
#include "ui/views/controls/button/md_text_button.h"
#include "ui/views/controls/label.h"
#include "ui/views/controls/styled_label.h"
#include "ui/views/input_event_activation_protector.h"
#include "ui/views/views_switches.h"
namespace payments {
namespace {
void SelectComboboxRowForValue(views::Combobox* combobox,
const std::u16string& text) { … }
}
PersonalDataLoadedObserverMock::PersonalDataLoadedObserverMock() = default;
PersonalDataLoadedObserverMock::~PersonalDataLoadedObserverMock() = default;
PaymentRequestBrowserTestBase::PaymentRequestBrowserTestBase() = default;
PaymentRequestBrowserTestBase::~PaymentRequestBrowserTestBase() = default;
base::WeakPtr<PaymentRequestBrowserTestBase>
PaymentRequestBrowserTestBase::GetWeakPtr() { … }
void PaymentRequestBrowserTestBase::SetUpCommandLine(
base::CommandLine* command_line) { … }
void PaymentRequestBrowserTestBase::SetUpOnMainThread() { … }
void PaymentRequestBrowserTestBase::NavigateTo(const std::string& file_path) { … }
void PaymentRequestBrowserTestBase::NavigateTo(const std::string& hostname,
const std::string& file_path) { … }
void PaymentRequestBrowserTestBase::SetIncognito() { … }
void PaymentRequestBrowserTestBase::SetInvalidSsl() { … }
void PaymentRequestBrowserTestBase::SetBrowserWindowInactive() { … }
void PaymentRequestBrowserTestBase::OnCanMakePaymentCalled() { … }
void PaymentRequestBrowserTestBase::OnCanMakePaymentReturned() { … }
void PaymentRequestBrowserTestBase::OnHasEnrolledInstrumentCalled() { … }
void PaymentRequestBrowserTestBase::OnHasEnrolledInstrumentReturned() { … }
void PaymentRequestBrowserTestBase::OnNotSupportedError() { … }
void PaymentRequestBrowserTestBase::OnConnectionTerminated() { … }
void PaymentRequestBrowserTestBase::OnPayCalled() { … }
void PaymentRequestBrowserTestBase::OnAbortCalled() { … }
void PaymentRequestBrowserTestBase::OnDialogOpened() { … }
void PaymentRequestBrowserTestBase::OnDialogClosed() { … }
void PaymentRequestBrowserTestBase::OnOrderSummaryOpened() { … }
void PaymentRequestBrowserTestBase::OnPaymentMethodOpened() { … }
void PaymentRequestBrowserTestBase::OnShippingAddressSectionOpened() { … }
void PaymentRequestBrowserTestBase::OnShippingOptionSectionOpened() { … }
void PaymentRequestBrowserTestBase::OnShippingAddressEditorOpened() { … }
void PaymentRequestBrowserTestBase::OnContactInfoEditorOpened() { … }
void PaymentRequestBrowserTestBase::OnBackNavigation() { … }
void PaymentRequestBrowserTestBase::OnBackToPaymentSheetNavigation() { … }
void PaymentRequestBrowserTestBase::OnContactInfoOpened() { … }
void PaymentRequestBrowserTestBase::OnEditorViewUpdated() { … }
void PaymentRequestBrowserTestBase::OnErrorMessageShown() { … }
void PaymentRequestBrowserTestBase::OnSpecDoneUpdating() { … }
void PaymentRequestBrowserTestBase::OnProcessingSpinnerShown() { … }
void PaymentRequestBrowserTestBase::OnProcessingSpinnerHidden() { … }
void PaymentRequestBrowserTestBase::OnPaymentHandlerWindowOpened() { … }
void PaymentRequestBrowserTestBase::OnPaymentHandlerTitleSet() { … }
void PaymentRequestBrowserTestBase::InstallPaymentApp(
const std::string& hostname,
const std::string& service_worker_filename,
std::string* url_method_output) { … }
void PaymentRequestBrowserTestBase::InstallPaymentAppWithoutIcon(
const std::string& hostname,
const std::string& service_worker_filename,
std::string* url_method_output) { … }
void PaymentRequestBrowserTestBase::InvokePaymentRequestUI() { … }
void PaymentRequestBrowserTestBase::InvokePaymentRequestUIWithJs(
const std::string& click_buy_button_js) { … }
void PaymentRequestBrowserTestBase::ExpectBodyContains(
const std::vector<std::string>& expected_strings) { … }
void PaymentRequestBrowserTestBase::OpenOrderSummaryScreen() { … }
void PaymentRequestBrowserTestBase::OpenPaymentMethodScreen() { … }
void PaymentRequestBrowserTestBase::OpenShippingAddressSectionScreen() { … }
void PaymentRequestBrowserTestBase::OpenShippingOptionSectionScreen() { … }
void PaymentRequestBrowserTestBase::OpenContactInfoScreen() { … }
void PaymentRequestBrowserTestBase::OpenCreditCardEditorScreen() { … }
void PaymentRequestBrowserTestBase::OpenShippingAddressEditorScreen() { … }
void PaymentRequestBrowserTestBase::OpenContactInfoEditorScreen() { … }
void PaymentRequestBrowserTestBase::ClickOnBackArrow() { … }
void PaymentRequestBrowserTestBase::ClickOnCancel() { … }
content::WebContents* PaymentRequestBrowserTestBase::GetActiveWebContents() { … }
const std::vector<PaymentRequest*>
PaymentRequestBrowserTestBase::GetPaymentRequests() { … }
autofill::PersonalDataManager* PaymentRequestBrowserTestBase::GetDataManager() { … }
void PaymentRequestBrowserTestBase::AddAutofillProfile(
const autofill::AutofillProfile& profile) { … }
void PaymentRequestBrowserTestBase::AddCreditCard(
const autofill::CreditCard& card) { … }
void PaymentRequestBrowserTestBase::WaitForOnPersonalDataChanged() { … }
void PaymentRequestBrowserTestBase::CreatePaymentRequestForTest(
mojo::PendingReceiver<payments::mojom::PaymentRequest> receiver,
content::RenderFrameHost* render_frame_host) { … }
void PaymentRequestBrowserTestBase::ClickOnDialogViewAndWait(
DialogViewID view_id,
bool wait_for_animation) { … }
void PaymentRequestBrowserTestBase::ClickOnDialogViewAndWait(
DialogViewID view_id,
PaymentRequestDialogView* dialog_view,
bool wait_for_animation) { … }
void PaymentRequestBrowserTestBase::ClickOnDialogViewAndWait(
views::View* view,
bool wait_for_animation) { … }
void PaymentRequestBrowserTestBase::ClickOnDialogViewAndWait(
views::View* view,
PaymentRequestDialogView* dialog_view,
bool wait_for_animation) { … }
void PaymentRequestBrowserTestBase::ClickOnDialogView(views::View* view) { … }
void PaymentRequestBrowserTestBase::ClickOnChildInListViewAndWait(
size_t child_index,
size_t total_num_children,
DialogViewID list_view_id,
bool wait_for_animation) { … }
std::vector<std::u16string>
PaymentRequestBrowserTestBase::GetProfileLabelValues(
DialogViewID parent_view_id) { … }
std::vector<std::u16string>
PaymentRequestBrowserTestBase::GetShippingOptionLabelValues(
DialogViewID parent_view_id) { … }
void PaymentRequestBrowserTestBase::OpenCVCPromptWithCVC(
const std::u16string& cvc,
PaymentRequestDialogView* dialog_view) { … }
void PaymentRequestBrowserTestBase::PayWithCreditCard(
const std::u16string& cvc) { … }
void PaymentRequestBrowserTestBase::RetryPaymentRequest(
const std::string& validation_errors,
PaymentRequestDialogView* dialog_view) { … }
void PaymentRequestBrowserTestBase::RetryPaymentRequest(
const std::string& validation_errors,
const DialogEvent& dialog_event,
PaymentRequestDialogView* dialog_view) { … }
bool PaymentRequestBrowserTestBase::IsViewVisible(DialogViewID view_id) const { … }
bool PaymentRequestBrowserTestBase::IsViewVisible(
DialogViewID view_id,
views::View* dialog_view) const { … }
std::u16string PaymentRequestBrowserTestBase::GetEditorTextfieldValue(
autofill::FieldType type) { … }
void PaymentRequestBrowserTestBase::SetEditorTextfieldValue(
const std::u16string& value,
autofill::FieldType type) { … }
std::u16string PaymentRequestBrowserTestBase::GetComboboxValue(
autofill::FieldType type) { … }
void PaymentRequestBrowserTestBase::SetComboboxValue(
const std::u16string& value,
autofill::FieldType type) { … }
void PaymentRequestBrowserTestBase::SelectBillingAddress(
const std::string& billing_address_id) { … }
bool PaymentRequestBrowserTestBase::IsEditorTextfieldInvalid(
autofill::FieldType type) { … }
bool PaymentRequestBrowserTestBase::IsEditorComboboxInvalid(
autofill::FieldType type) { … }
bool PaymentRequestBrowserTestBase::IsPayButtonEnabled() { … }
std::u16string PaymentRequestBrowserTestBase::GetPrimaryButtonLabel() const { … }
void PaymentRequestBrowserTestBase::WaitForAnimation() { … }
void PaymentRequestBrowserTestBase::WaitForAnimation(
PaymentRequestDialogView* dialog_view) { … }
views::View* PaymentRequestBrowserTestBase::GetByDialogViewID(
DialogViewID id) const { … }
views::View* PaymentRequestBrowserTestBase::GetChildByDialogViewID(
views::View* parent,
DialogViewID id) const { … }
const std::u16string& PaymentRequestBrowserTestBase::GetLabelText(
DialogViewID view_id) { … }
const std::u16string& PaymentRequestBrowserTestBase::GetLabelText(
DialogViewID view_id,
views::View* dialog_view) { … }
const std::u16string& PaymentRequestBrowserTestBase::GetStyledLabelText(
DialogViewID view_id) { … }
const std::u16string& PaymentRequestBrowserTestBase::GetErrorLabelForType(
autofill::FieldType type) { … }
void PaymentRequestBrowserTestBase::SetCanMakePaymentEnabledPref(
bool can_make_payment_enabled) { … }
void PaymentRequestBrowserTestBase::ResetEventWaiter(DialogEvent event) { … }
void PaymentRequestBrowserTestBase::ResetEventWaiterForSequence(
std::list<DialogEvent> event_sequence) { … }
void PaymentRequestBrowserTestBase::ResetEventWaiterForDialogOpened() { … }
testing::AssertionResult PaymentRequestBrowserTestBase::WaitForObservedEvent() { … }
base::WeakPtr<CSPChecker>
PaymentRequestBrowserTestBase::GetCSPCheckerForTests() { … }
}
std::ostream& operator<<(
std::ostream& out,
payments::PaymentRequestBrowserTestBase::DialogEvent event) { … }