chromium/chrome/browser/ui/views/plus_addresses/plus_address_creation_dialog_interactive_uitest.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/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[] =;
// Histogram names.
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) {}

}  // namespace

class ScopedPlusAddressFeatureList {};

class PlusAddressCreationDialogInteractiveTest : public InteractiveBrowserTest {};

// An interactive UI test to exercise successful plus address user flow.
IN_PROC_BROWSER_TEST_F(PlusAddressCreationDialogInteractiveTest,
                       ConfirmPlusAddressSucceeds) {}

// An interactive UI test to exercise successful plus address user flow.
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) {}

// Ensure modal handles error report link click when modal encounters error and
// open a new tab.
IN_PROC_BROWSER_TEST_F(PlusAddressCreationDialogInteractiveTest,
                       ErrorReportLinkClicked_OpensNewTab) {}

// User opens the dialog and presses the "Cancel" button.
IN_PROC_BROWSER_TEST_F(PlusAddressCreationDialogInteractiveTest,
                       DialogCanceled) {}

IN_PROC_BROWSER_TEST_F(PlusAddressCreationDialogInteractiveTest,
                       WebContentsClosed) {}

IN_PROC_BROWSER_TEST_F(PlusAddressCreationDialogInteractiveTest, DoubleInit) {}

// A test fixture that has the feature to show the onboarding notice turned on.
class PlusAddressCreationDialogWithNoticeTest
    : public PlusAddressCreationDialogInteractiveTest {};

// Tests showing and cancelling the creation dialog for a user that has not yet
// accepted the notice.
IN_PROC_BROWSER_TEST_F(PlusAddressCreationDialogWithNoticeTest,
                       ShowNoticeAndCancel) {}

// Tests that the notice is not shown if it has already been accepted.
IN_PROC_BROWSER_TEST_F(PlusAddressCreationDialogWithNoticeTest,
                       NoticePreviouslyAccepted) {}

// Tests showing and accepting the creation dialog for a user that has not yet
// accepted the notice.
IN_PROC_BROWSER_TEST_F(PlusAddressCreationDialogWithNoticeTest,
                       ShowNoticeAndAccept) {}

// Tests that clicking the "learn more" link on the notice screen opens a new
// tab with the correct URL.
IN_PROC_BROWSER_TEST_F(PlusAddressCreationDialogWithNoticeTest,
                       ClickLearnMoreLink) {}

class PlusAddressCreationDialogUiVariationsTest
    : public PlusAddressCreationDialogInteractiveTest,
      public testing::WithParamInterface<std::tuple</*force_dark_mode=*/bool,
                                                    /*is_rtl=*/bool>> {};

// An interactive UI test to exercise successful plus address user flow.
IN_PROC_BROWSER_TEST_P(PlusAddressCreationDialogUiVariationsTest,
                       ConfirmPlusAddressSucceeds) {}

IN_PROC_BROWSER_TEST_P(PlusAddressCreationDialogUiVariationsTest,
                       ReserveFailsShowsPlaceholderAndTimesOut) {}

INSTANTIATE_TEST_SUITE_P();

}  // namespace plus_addresses