Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4162)

Unified Diff: chrome/browser/policy/config_dir_policy_provider_unittest.cc

Issue 10443108: Implement the ConfigDirPolicyProvider based on the AsyncPolicyLoader (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update the connector too Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/policy/config_dir_policy_provider_unittest.cc
diff --git a/chrome/browser/policy/config_dir_policy_provider_unittest.cc b/chrome/browser/policy/config_dir_policy_provider_unittest.cc
index 087878b267d6f5308b33dfe9331a89a2f9391e9a..24312f2b5d20425a2a190f5f125865eb3054185a 100644
--- a/chrome/browser/policy/config_dir_policy_provider_unittest.cc
+++ b/chrome/browser/policy/config_dir_policy_provider_unittest.cc
@@ -18,6 +18,10 @@ namespace policy {
namespace {
+// Subdirectory of the ConfigDirPolicyProvider config dir that contains
+// mandatory policies.
+const char kManagedPath[] = "managed";
+
class TestHarness : public PolicyProviderTestHarness {
public:
TestHarness();
@@ -68,7 +72,6 @@ void TestHarness::SetUp() {
AsynchronousPolicyProvider* TestHarness::CreateProvider(
const PolicyDefinitionList* policy_definition_list) {
return new ConfigDirPolicyProvider(policy_definition_list,
- POLICY_LEVEL_MANDATORY,
POLICY_SCOPE_MACHINE,
test_dir());
}
@@ -119,8 +122,11 @@ void TestHarness::WriteConfigFile(const base::DictionaryValue& dict,
std::string data;
JSONStringValueSerializer serializer(&data);
serializer.Serialize(dict);
- const FilePath file_path(test_dir().AppendASCII(file_name));
- ASSERT_TRUE(file_util::WriteFile(file_path, data.c_str(), data.size()));
+ const FilePath dir_path(test_dir().AppendASCII(kManagedPath));
+ ASSERT_TRUE(file_util::CreateDirectory(dir_path));
+ const FilePath file_path(dir_path.AppendASCII(file_name));
+ ASSERT_EQ((int) data.size(),
+ file_util::WriteFile(file_path, data.c_str(), data.size()));
}
// static
@@ -150,7 +156,6 @@ class ConfigDirPolicyLoaderTest : public testing::Test {
// load.
TEST_F(ConfigDirPolicyLoaderTest, ReadPrefsEmpty) {
ConfigDirPolicyProviderDelegate loader(harness_.test_dir(),
- POLICY_LEVEL_MANDATORY,
POLICY_SCOPE_MACHINE);
scoped_ptr<PolicyBundle> bundle(loader.Load());
ASSERT_TRUE(bundle.get());
@@ -164,7 +169,6 @@ TEST_F(ConfigDirPolicyLoaderTest, ReadPrefsNonExistentDirectory) {
FilePath non_existent_dir(
harness_.test_dir().Append(FILE_PATH_LITERAL("not_there")));
ConfigDirPolicyProviderDelegate loader(non_existent_dir,
- POLICY_LEVEL_MANDATORY,
POLICY_SCOPE_MACHINE);
scoped_ptr<PolicyBundle> bundle(loader.Load());
ASSERT_TRUE(bundle.get());
@@ -189,7 +193,6 @@ TEST_F(ConfigDirPolicyLoaderTest, ReadPrefsMergePrefs) {
harness_.WriteConfigFile(test_dict_bar, base::IntToString(i));
ConfigDirPolicyProviderDelegate loader(harness_.test_dir(),
- POLICY_LEVEL_MANDATORY,
POLICY_SCOPE_USER);
scoped_ptr<PolicyBundle> bundle(loader.Load());
ASSERT_TRUE(bundle.get());
@@ -226,7 +229,6 @@ TEST_F(ConfigDirPolicyLoaderTest, Load3rdParty) {
harness_.WriteConfigFile(json_dict, "policy.json");
ConfigDirPolicyProviderDelegate loader(harness_.test_dir(),
- POLICY_LEVEL_MANDATORY,
POLICY_SCOPE_USER);
scoped_ptr<PolicyBundle> bundle(loader.Load());
ASSERT_TRUE(bundle.get());

Powered by Google App Engine
This is Rietveld 408576698