chromium/chrome/browser/ui/webui/managed_ui_handler_unittest.cc

// Copyright 2019 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/managed_ui_handler.h"

#include <optional>

#include "base/token.h"
#include "base/values.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/policy/profile_policy_connector.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/test/base/testing_profile.h"
#include "components/policy/core/common/mock_configuration_policy_provider.h"
#include "components/policy/core/common/policy_service_impl.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui_data_source.h"
#include "content/public/test/browser_task_environment.h"
#include "content/public/test/test_web_ui.h"
#include "content/public/test/test_web_ui_data_source.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"

#if !BUILDFLAG(IS_CHROMEOS_ASH)
#include "components/policy/core/browser/browser_policy_connector_base.h"
#endif  // !BUILDFLAG(IS_CHROMEOS_ASH)

class TestManagedUIHandler : public ManagedUIHandler {};

class ManagedUIHandlerTest : public testing::Test {};

// TODO(crbug.com/355288951): fix these tests.
TEST_F(ManagedUIHandlerTest, DISABLED_ManagedUIDisabledByDefault) {}

TEST_F(ManagedUIHandlerTest, DISABLED_ManagedUIEnabledWhenManaged) {}

TEST_F(ManagedUIHandlerTest, DISABLED_ManagedUIBecomesEnabledByProfile) {}

#if BUILDFLAG(IS_CHROMEOS_ASH)
TEST_F(ManagedUIHandlerTest, ManagedUIDisabledForChildAccount) {
  profile_policy_connector()->OverrideIsManagedForTesting(true);
  profile()->SetIsSupervisedProfile();

  InitializeHandler();

  EXPECT_FALSE(IsSourceManaged());
}
#endif