chromium/chrome/browser/ui/views/profiles/sync_confirmation_ui_browsertest.cc

// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/ui/webui/signin/sync_confirmation_ui.h"

#include "base/functional/bind_internal.h"
#include "base/functional/callback_forward.h"
#include "base/scoped_environment_variable_override.h"
#include "base/scoped_observation.h"
#include "base/strings/strcat.h"
#include "base/test/scoped_feature_list.h"
#include "chrome/browser/consent_auditor/consent_auditor_factory.h"
#include "chrome/browser/consent_auditor/consent_auditor_test_utils.h"
#include "chrome/browser/signin/signin_browser_test_base.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/test/test_browser_dialog.h"
#include "chrome/browser/ui/test/test_browser_ui.h"
#include "chrome/browser/ui/views/profiles/profile_management_step_controller.h"
#include "chrome/browser/ui/views/profiles/profile_picker_view_test_utils.h"
#include "chrome/browser/ui/views/profiles/profiles_pixel_test_utils.h"
#include "chrome/browser/ui/webui/signin/login_ui_service.h"
#include "chrome/browser/ui/webui/signin/login_ui_service_factory.h"
#include "chrome/browser/ui/webui/signin/login_ui_test_utils.h"
#include "chrome/browser/ui/webui/signin/signin_url_utils.h"
#include "chrome/common/webui_url_constants.h"
#include "chrome/grit/generated_resources.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "components/consent_auditor/consent_auditor.h"
#include "components/consent_auditor/fake_consent_auditor.h"
#include "components/signin/public/base/consent_level.h"
#include "components/signin/public/base/signin_buildflags.h"
#include "components/signin/public/base/signin_switches.h"
#include "components/signin/public/identity_manager/account_info.h"
#include "components/signin/public/identity_manager/tribool.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/test_navigation_observer.h"
#include "ui/base/ui_base_switches.h"
#include "ui/compositor/scoped_animation_duration_scale_mode.h"
#include "ui/views/widget/any_widget_observer.h"

#if !BUILDFLAG(ENABLE_DICE_SUPPORT) && !BUILDFLAG(IS_CHROMEOS_LACROS)
#error Platform not supported
#endif

// TODO(crbug.com/40242558): Move this file next to sync_confirmation_ui.cc.
// Render the page in a browser instead of a profile_picker_view to be able to
// do so.

// Tests for the chrome://sync-confirmation WebUI page. They live here and not
// in the webui directory because they manipulate views.
namespace {

AllOf;
Contains;
ElementsAre;

// Configures the state of ::switches::kMinorModeRestrictionsForHistorySyncOptIn
// that relies on can_show_history_sync_opt_ins_without_minor_mode_restrictions
// capability.
struct MinorModeRestrictions {};

#if BUILDFLAG(IS_MAC) || BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_WIN)
constexpr MinorModeRestrictions kWithMinorModeRestrictionsWithUnrestrictedUser{};
constexpr MinorModeRestrictions kWithMinorModeRestrictionsWithRestrictedUser{};
#endif

struct SyncConfirmationTestParam {};

// To be passed as 4th argument to `INSTANTIATE_TEST_SUITE_P()`, allows the test
// to be named like `<TestClassName>.InvokeUi_default/<TestSuffix>` instead
// of using the index of the param in `TestParam` as suffix.
std::string ParamToTestSuffix(
    const ::testing::TestParamInfo<SyncConfirmationTestParam>& info) {}

// Permutations of supported parameters.
const SyncConfirmationTestParam kWindowTestParams[] =;

const SyncConfirmationTestParam kDialogTestParams[] =;

GURL BuildSyncConfirmationWindowURL() {}

// Creates a step to represent the sync-confirmation.
class SyncConfirmationStepControllerForTest
    : public ProfileManagementStepController {};
}  // namespace

class SyncConfirmationUIWindowPixelTest
    : public ProfilesPixelTestBaseT<UiBrowserTest>,
      public testing::WithParamInterface<SyncConfirmationTestParam> {};

IN_PROC_BROWSER_TEST_P(SyncConfirmationUIWindowPixelTest, InvokeUi_default) {}

INSTANTIATE_TEST_SUITE_P();

class SyncConfirmationUIDialogPixelTest
    : public ProfilesPixelTestBaseT<DialogBrowserTest>,
      public testing::WithParamInterface<SyncConfirmationTestParam> {};

IN_PROC_BROWSER_TEST_P(SyncConfirmationUIDialogPixelTest, InvokeUi_default) {}

INSTANTIATE_TEST_SUITE_P();

enum class SyncConfirmationUIAction {};

class SyncConfirmationUITest
    : public SigninBrowserTestBase,
      public testing::WithParamInterface<
          std::tuple<bool, SyncConfirmationUIAction, std::string>>,
      public LoginUIService::Observer {};

// Regression test for https://crbug.com/325749258.
IN_PROC_BROWSER_TEST_P(SyncConfirmationUITest,
                       RecordConsentWithEscapedHtmlCharacters) {}

std::string SyncConfirmationUITestParamToTestSuffix(
    const testing::TestParamInfo<SyncConfirmationUITest::ParamType>& info) {}

INSTANTIATE_TEST_SUITE_P();