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

// Copyright 2023 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/managed_user_profile_notice_ui.h"

#include <memory>

#include "base/functional/callback_forward.h"
#include "base/strings/strcat.h"
#include "base/test/bind.h"
#include "base/test/scoped_feature_list.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/ui_features.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/common/webui_url_constants.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 "content/public/test/browser_test.h"
#include "content/public/test/test_navigation_observer.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

// Tests for the chrome://managed-user-profile-notice/ WebUI page. They
// live here and not in the webui directory because they manipulate views.

namespace {
struct ManagedUserNoticeTestParam {};

// 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<ManagedUserNoticeTestParam>& info) {}

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

const ManagedUserNoticeTestParam kDialogTestParams[] =;

// Creates a step to represent the managed-user-profile-notice
class ManagedUserNoticeStepControllerForTest
    : public ProfileManagementStepController {};
}  // namespace

class ManagedUserNoticeUIWindowPixelTest
    : public ProfilesPixelTestBaseT<UiBrowserTest>,
      public testing::WithParamInterface<ManagedUserNoticeTestParam> {};

// TODO(https://crbug.com/1504935, https://crbug.com/1505546): Fails too often
// on Windows tester bot.
#if BUILDFLAG(IS_WIN)
#define MAYBE_InvokeUi_default
#else
#define MAYBE_InvokeUi_default
#endif
IN_PROC_BROWSER_TEST_P(ManagedUserNoticeUIWindowPixelTest,
                       MAYBE_InvokeUi_default) {}

INSTANTIATE_TEST_SUITE_P();

class ManagedUserNoticeUIDialogPixelTest
    : public ProfilesPixelTestBaseT<DialogBrowserTest>,
      public testing::WithParamInterface<ManagedUserNoticeTestParam> {};

IN_PROC_BROWSER_TEST_P(ManagedUserNoticeUIDialogPixelTest,
                       MAYBE_InvokeUi_default) {}

INSTANTIATE_TEST_SUITE_P();