#include "components/autofill/core/browser/ui/payments/autofill_error_dialog_controller_impl.h"
#include <memory>
#include "base/strings/utf_string_conversions.h"
#include "base/test/metrics/histogram_tester.h"
#include "components/autofill/core/browser/payments/autofill_error_dialog_context.h"
#include "components/autofill/core/browser/ui/payments/autofill_error_dialog_view.h"
#include "components/strings/grit/components_strings.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/l10n/l10n_util.h"
namespace autofill {
class TestAutofillErrorDialogView : public AutofillErrorDialogView { … };
class AutofillErrorDialogControllerImplTest : public testing::Test { … };
#if BUILDFLAG(IS_IOS)
TEST_F(AutofillErrorDialogControllerImplTest, CreditCardUploadError) {
AutofillErrorDialogContext context;
context.type = AutofillErrorDialogType::kCreditCardUploadError;
ShowPrompt(context);
EXPECT_EQ(controller()->GetTitle(),
l10n_util::GetStringUTF16(
IDS_AUTOFILL_SAVE_CARD_CONFIRMATION_FAILURE_TITLE_TEXT));
EXPECT_EQ(controller()->GetDescription(),
l10n_util::GetStringUTF16(
IDS_AUTOFILL_SAVE_CARD_CONFIRMATION_FAILURE_DESCRIPTION_TEXT));
EXPECT_EQ(controller()->GetButtonLabel(), l10n_util::GetStringUTF16(IDS_OK));
}
TEST_F(AutofillErrorDialogControllerImplTest,
VirtualCardEnrollmentTemporaryError) {
AutofillErrorDialogContext context;
context.type = AutofillErrorDialogType::kVirtualCardEnrollmentTemporaryError;
ShowPrompt(context);
EXPECT_EQ(controller()->GetTitle(),
l10n_util::GetStringUTF16(
IDS_AUTOFILL_VIRTUAL_CARD_TEMPORARY_ERROR_TITLE));
EXPECT_EQ(controller()->GetDescription(),
l10n_util::GetStringUTF16(
IDS_AUTOFILL_VIRTUAL_CARD_TEMPORARY_ERROR_DESCRIPTION));
EXPECT_EQ(controller()->GetButtonLabel(), l10n_util::GetStringUTF16(IDS_OK));
}
#endif
class AutofillErrorDialogControllerImplParameterizedTest
: public AutofillErrorDialogControllerImplTest,
public testing::WithParamInterface<bool> { … };
INSTANTIATE_TEST_SUITE_P(…);
TEST_P(AutofillErrorDialogControllerImplParameterizedTest, MetricsTest) { … }
}