#include <stddef.h>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <memory>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
#include "base/base_paths.h"
#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/no_destructor.h"
#include "base/path_service.h"
#include "base/run_loop.h"
#include "base/threading/thread_restrictions.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/test/base/chrome_test_utils.h"
#include "chrome/test/base/platform_browser_test.h"
#include "components/policy/core/browser/browser_policy_connector.h"
#include "components/policy/core/browser/policy_pref_mapping_test.h"
#include "components/policy/core/common/mock_configuration_policy_provider.h"
#include "components/policy/core/common/policy_map.h"
#include "components/prefs/pref_service.h"
#include "components/variations/variations_test_utils.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "ash/constants/ash_switches.h"
#include "chrome/browser/ash/profiles/profile_helper.h"
#else
#include "components/enterprise/browser/controller/fake_browser_dm_token_storage.h"
#endif
namespace policy {
const size_t kNumChunks = …;
namespace {
base::FilePath GetTestCaseDir() { … }
size_t GetNumChunks() { … }
}
PolicyPrefsTestCoverageTest;
IN_PROC_BROWSER_TEST_F(PolicyPrefsTestCoverageTest, AllPoliciesHaveATestCase) { … }
class PolicyPrefsTest : public PlatformBrowserTest { … };
class ChunkedPolicyPrefsTest : public PolicyPrefsTest,
public ::testing::WithParamInterface<size_t> { … };
IN_PROC_BROWSER_TEST_P(ChunkedPolicyPrefsTest, PolicyToPrefsMapping) { … }
INSTANTIATE_TEST_SUITE_P(…);
#if BUILDFLAG(IS_CHROMEOS_ASH)
class SigninPolicyPrefsTest : public PolicyPrefsTest {
public:
SigninPolicyPrefsTest() = default;
SigninPolicyPrefsTest(const SigninPolicyPrefsTest&) = delete;
SigninPolicyPrefsTest& operator=(const SigninPolicyPrefsTest&) = delete;
~SigninPolicyPrefsTest() override = default;
protected:
void SetUpCommandLine(base::CommandLine* command_line) override {
PolicyPrefsTest::SetUpCommandLine(command_line);
command_line->AppendSwitch(ash::switches::kLoginManager);
command_line->AppendSwitch(ash::switches::kForceLoginManagerInTests);
}
};
IN_PROC_BROWSER_TEST_F(SigninPolicyPrefsTest, PolicyToPrefsMapping) {
PrefService* signin_profile_prefs =
ash::ProfileHelper::GetSigninProfile()->GetPrefs();
VerifyPolicyToPrefMappings(GetTestCaseDir(), nullptr,
nullptr, signin_profile_prefs,
GetMockPolicyProvider());
}
#endif
}