Commit c1b544a8 authored by Roger Tawa's avatar Roger Tawa Committed by Commit Bot

Replace deprecated SetDomainStateForTesting with scoping class.

Bug: None
Change-Id: I9370b99599f128d7379761c77ba9195be59baf71
Reviewed-on: https://chromium-review.googlesource.com/1187270
Commit-Queue: Roger Tawa <rogerta@chromium.org>
Reviewed-by: default avatarGreg Thompson <grt@chromium.org>
Reviewed-by: default avatarJulian Pastarmov <pastarmovj@chromium.org>
Reviewed-by: default avatarDevlin <rdevlin.cronin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#585863}
parent fe009796
...@@ -563,11 +563,6 @@ bool IsEnrolledToDomain() { ...@@ -563,11 +563,6 @@ bool IsEnrolledToDomain() {
return *GetDomainEnrollmentStateStorage(); return *GetDomainEnrollmentStateStorage();
} }
// This function is deprecated, prefer class ScopedDomainStateForTesting.
void SetDomainStateForTesting(bool state) {
*GetDomainEnrollmentStateStorage() = state;
}
bool IsDeviceRegisteredWithManagement() { bool IsDeviceRegisteredWithManagement() {
return *GetRegisteredWithManagementStateStorage(); return *GetRegisteredWithManagementStateStorage();
} }
......
...@@ -163,11 +163,6 @@ BASE_EXPORT bool IsDeviceRegisteredWithManagement(); ...@@ -163,11 +163,6 @@ BASE_EXPORT bool IsDeviceRegisteredWithManagement();
// or registered with an MDM. // or registered with an MDM.
BASE_EXPORT bool IsEnterpriseManaged(); BASE_EXPORT bool IsEnterpriseManaged();
// Used by tests to mock any wanted state. Call with |state| set to true to
// simulate being in a domain and false otherwise.
// This function is deprecated, prefer class ScopedDomainStateForTesting below.
BASE_EXPORT void SetDomainStateForTesting(bool state);
// Returns true if the current process can make USER32 or GDI32 calls such as // Returns true if the current process can make USER32 or GDI32 calls such as
// CreateWindow and CreateDC. Windows 8 and above allow the kernel component // CreateWindow and CreateDC. Windows 8 and above allow the kernel component
// of these calls to be disabled which can cause undefined behaviour such as // of these calls to be disabled which can cause undefined behaviour such as
......
...@@ -375,7 +375,7 @@ TEST(ExtensionSettingsPolicyHandlerTest, CheckPolicySettings) { ...@@ -375,7 +375,7 @@ TEST(ExtensionSettingsPolicyHandlerTest, CheckPolicySettings) {
TEST(ExtensionSettingsPolicyHandlerTest, ApplyPolicySettings) { TEST(ExtensionSettingsPolicyHandlerTest, ApplyPolicySettings) {
// Mark as enterprise managed. // Mark as enterprise managed.
#if defined(OS_WIN) #if defined(OS_WIN)
base::win::SetDomainStateForTesting(true); base::win::ScopedDomainStateForTesting scoped_domain(true);
#endif #endif
std::string error; std::string error;
...@@ -408,7 +408,7 @@ TEST(ExtensionSettingsPolicyHandlerTest, ApplyPolicySettings) { ...@@ -408,7 +408,7 @@ TEST(ExtensionSettingsPolicyHandlerTest, ApplyPolicySettings) {
#if defined(OS_WIN) #if defined(OS_WIN)
TEST(ExtensionSettingsPolicyHandlerTest, NonManagedOffWebstoreExtension) { TEST(ExtensionSettingsPolicyHandlerTest, NonManagedOffWebstoreExtension) {
// Mark as not enterprise managed. // Mark as not enterprise managed.
base::win::SetDomainStateForTesting(false); base::win::ScopedDomainStateForTesting scoped_domain(false);
std::string error; std::string error;
std::unique_ptr<base::Value> policy_value = std::unique_ptr<base::Value> policy_value =
......
...@@ -2582,7 +2582,7 @@ IN_PROC_BROWSER_TEST_F(PolicyTest, ExtensionRecommendedInstallationMode) { ...@@ -2582,7 +2582,7 @@ IN_PROC_BROWSER_TEST_F(PolicyTest, ExtensionRecommendedInstallationMode) {
// Mark as enterprise managed. // Mark as enterprise managed.
#if defined(OS_WIN) #if defined(OS_WIN)
base::win::SetDomainStateForTesting(true); base::win::ScopedDomainStateForTesting scoped_domain(true);
#endif #endif
extensions::ExtensionService* service = extension_service(); extensions::ExtensionService* service = extension_service();
...@@ -2875,7 +2875,7 @@ IN_PROC_BROWSER_TEST_F(PolicyTest, ExtensionMinimumVersionForceInstalled) { ...@@ -2875,7 +2875,7 @@ IN_PROC_BROWSER_TEST_F(PolicyTest, ExtensionMinimumVersionForceInstalled) {
// Mark as enterprise managed. // Mark as enterprise managed.
#if defined(OS_WIN) #if defined(OS_WIN)
base::win::SetDomainStateForTesting(true); base::win::ScopedDomainStateForTesting scoped_domain(true);
#endif #endif
extensions::ExtensionRegistry* registry = extensions::ExtensionRegistry* registry =
extensions::ExtensionRegistry::Get(browser()->profile()); extensions::ExtensionRegistry::Get(browser()->profile());
......
...@@ -286,7 +286,7 @@ void RegistryTestHarness::SetUp() { ...@@ -286,7 +286,7 @@ void RegistryTestHarness::SetUp() {
ConfigurationPolicyProvider* RegistryTestHarness::CreateProvider( ConfigurationPolicyProvider* RegistryTestHarness::CreateProvider(
SchemaRegistry* registry, SchemaRegistry* registry,
scoped_refptr<base::SequencedTaskRunner> task_runner) { scoped_refptr<base::SequencedTaskRunner> task_runner) {
base::win::SetDomainStateForTesting(true); base::win::ScopedDomainStateForTesting scoped_domain(true);
std::unique_ptr<AsyncPolicyLoader> loader( std::unique_ptr<AsyncPolicyLoader> loader(
new PolicyLoaderWin(task_runner, kTestPolicyKey)); new PolicyLoaderWin(task_runner, kTestPolicyKey));
return new AsyncPolicyProvider(registry, std::move(loader)); return new AsyncPolicyProvider(registry, std::move(loader));
...@@ -406,11 +406,10 @@ class PolicyLoaderWinTest : public PolicyTestBase { ...@@ -406,11 +406,10 @@ class PolicyLoaderWinTest : public PolicyTestBase {
// files in chrome/test/data/policy/gpo. // files in chrome/test/data/policy/gpo.
static const base::char16 kTestPolicyKey[]; static const base::char16 kTestPolicyKey[];
PolicyLoaderWinTest() {} PolicyLoaderWinTest() : scoped_domain_(false) {}
~PolicyLoaderWinTest() override {} ~PolicyLoaderWinTest() override {}
void SetUp() override { void SetUp() override {
base::win::SetDomainStateForTesting(false);
PolicyTestBase::SetUp(); PolicyTestBase::SetUp();
// Activate overrides of registry keys. gtest documentation guarantees // Activate overrides of registry keys. gtest documentation guarantees
...@@ -428,6 +427,7 @@ class PolicyLoaderWinTest : public PolicyTestBase { ...@@ -428,6 +427,7 @@ class PolicyLoaderWinTest : public PolicyTestBase {
} }
ScopedGroupPolicyRegistrySandbox registry_sandbox_; ScopedGroupPolicyRegistrySandbox registry_sandbox_;
base::win::ScopedDomainStateForTesting scoped_domain_;
}; };
const base::char16 PolicyLoaderWinTest::kTestPolicyKey[] = const base::char16 PolicyLoaderWinTest::kTestPolicyKey[] =
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment