#include "base/i18n/base_i18n_switches.h"
#include "base/json/json_reader.h"
#include "base/test/bind.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/test_future.h"
#include "base/test/with_feature_override.h"
#include "chrome/browser/plus_addresses/plus_address_service_factory.h"
#include "chrome/browser/plus_addresses/plus_address_setting_service_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_test_util.h"
#include "chrome/browser/signin/identity_test_environment_profile_adaptor.h"
#include "chrome/browser/ui/plus_addresses/plus_address_creation_controller.h"
#include "chrome/browser/ui/plus_addresses/plus_address_creation_controller_desktop.h"
#include "chrome/browser/ui/plus_addresses/plus_address_creation_view.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/interactive_test_utils.h"
#include "chrome/test/interaction/interactive_browser_test.h"
#include "components/autofill/content/browser/content_autofill_client.h"
#include "components/plus_addresses/features.h"
#include "components/plus_addresses/plus_address_test_utils.h"
#include "components/plus_addresses/plus_address_types.h"
#include "components/plus_addresses/settings/mock_plus_address_setting_service.h"
#include "components/plus_addresses/settings/plus_address_setting_service.h"
#include "components/signin/public/identity_manager/identity_test_environment.h"
#include "components/signin/public/identity_manager/identity_test_utils.h"
#include "components/strings/grit/components_strings.h"
#include "content/public/test/browser_test.h"
#include "extensions/browser/api/networking_private/networking_private_delegate_factory.h"
#include "net/dns/mock_host_resolver.h"
#include "net/test/embedded_test_server/controllable_http_response.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/interaction/element_identifier.h"
#include "ui/base/interaction/element_tracker.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/ui_base_switches.h"
#include "ui/views/bubble/bubble_frame_view.h"
#include "ui/views/controls/styled_label.h"
#include "url/origin.h"
namespace plus_addresses {
namespace {
PlusAddressModalCompletionStatus;
Return;
constexpr char kFakeEmailAddress[] = …;
constexpr char16_t kFakeEmailAddressU16[] = …;
constexpr char kFakeManagementUrl[] = …;
constexpr char kFakeOauthScope[] = …;
constexpr char kFakeErrorReportUrl[] = …;
constexpr char kFakeLearnMoreUrl[] = …;
constexpr char kReservePath[] = …;
constexpr char kConfirmPath[] = …;
constexpr char kFakePlusAddress[] = …;
constexpr char16_t kFakePlusAddressU16[] = …;
constexpr char kFakePlusAddressRefresh[] = …;
constexpr char16_t kFakePlusAddressRefreshU16[] = …;
constexpr char kSuppressedScreenshotError[] = …;
constexpr std::string_view kPlusAddressModalEventHistogram = …;
constexpr std::string_view kPlusAddressModalWithNoticeEventHistogram = …;
std::string FormatHistogramNameFor(PlusAddressNetworkRequestType type) { … }
std::string FormatDurationHistogramNameFor(
metrics::PlusAddressModalCompletionStatus status,
bool notice_shown) { … }
std::string FormatRefreshHistogramNameFor(
metrics::PlusAddressModalCompletionStatus status,
bool notice_shown) { … }
void RegisterTestingFactories(content::BrowserContext* context) { … }
}
class ScopedPlusAddressFeatureList { … };
class PlusAddressCreationDialogInteractiveTest : public InteractiveBrowserTest { … };
IN_PROC_BROWSER_TEST_F(PlusAddressCreationDialogInteractiveTest,
ConfirmPlusAddressSucceeds) { … }
IN_PROC_BROWSER_TEST_F(PlusAddressCreationDialogInteractiveTest,
ConfirmPlusAddressSucceedsAfterRefresh) { … }
IN_PROC_BROWSER_TEST_F(PlusAddressCreationDialogInteractiveTest,
ReserveFailsFromNoResponse_ShowsPlaceholderAndTimesOut) { … }
IN_PROC_BROWSER_TEST_F(
PlusAddressCreationDialogInteractiveTest,
ConfirmFailsFromNoResponse_ShowsProgressIndicatorAndTimesout) { … }
IN_PROC_BROWSER_TEST_F(PlusAddressCreationDialogInteractiveTest,
ConfirmFails_ShowsErrorState) { … }
IN_PROC_BROWSER_TEST_F(PlusAddressCreationDialogInteractiveTest,
ErrorReportLinkClicked_OpensNewTab) { … }
IN_PROC_BROWSER_TEST_F(PlusAddressCreationDialogInteractiveTest,
DialogCanceled) { … }
IN_PROC_BROWSER_TEST_F(PlusAddressCreationDialogInteractiveTest,
WebContentsClosed) { … }
IN_PROC_BROWSER_TEST_F(PlusAddressCreationDialogInteractiveTest, DoubleInit) { … }
class PlusAddressCreationDialogWithNoticeTest
: public PlusAddressCreationDialogInteractiveTest { … };
IN_PROC_BROWSER_TEST_F(PlusAddressCreationDialogWithNoticeTest,
ShowNoticeAndCancel) { … }
IN_PROC_BROWSER_TEST_F(PlusAddressCreationDialogWithNoticeTest,
NoticePreviouslyAccepted) { … }
IN_PROC_BROWSER_TEST_F(PlusAddressCreationDialogWithNoticeTest,
ShowNoticeAndAccept) { … }
IN_PROC_BROWSER_TEST_F(PlusAddressCreationDialogWithNoticeTest,
ClickLearnMoreLink) { … }
class PlusAddressCreationDialogUiVariationsTest
: public PlusAddressCreationDialogInteractiveTest,
public testing::WithParamInterface<std::tuple<bool,
bool>> { … };
IN_PROC_BROWSER_TEST_P(PlusAddressCreationDialogUiVariationsTest,
ConfirmPlusAddressSucceeds) { … }
IN_PROC_BROWSER_TEST_P(PlusAddressCreationDialogUiVariationsTest,
ReserveFailsShowsPlaceholderAndTimesOut) { … }
INSTANTIATE_TEST_SUITE_P(…);
}