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

Side by Side Diff: chrome/browser/policy/config_dir_policy_provider_unittest.cc

Issue 3117017: Remove deprecated wstring Get(As)String() methods from Value, etc. (Closed)
Patch Set: fix win Created 10 years, 4 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/file_util.h" 5 #include "base/file_util.h"
6 #include "base/path_service.h" 6 #include "base/path_service.h"
7 #include "base/string_number_conversions.h" 7 #include "base/string_number_conversions.h"
8 #include "chrome/browser/policy/config_dir_policy_provider.h" 8 #include "chrome/browser/policy/config_dir_policy_provider.h"
9 #include "chrome/browser/policy/mock_configuration_policy_store.h" 9 #include "chrome/browser/policy/mock_configuration_policy_store.h"
10 #include "chrome/common/json_value_serializer.h" 10 #include "chrome/common/json_value_serializer.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 TEST_F(ConfigDirPolicyProviderTest, ReadPrefsNonExistentDirectory) { 60 TEST_F(ConfigDirPolicyProviderTest, ReadPrefsNonExistentDirectory) {
61 FilePath non_existent_dir(test_dir_.Append(FILE_PATH_LITERAL("not_there"))); 61 FilePath non_existent_dir(test_dir_.Append(FILE_PATH_LITERAL("not_there")));
62 ConfigDirPolicyProvider provider(non_existent_dir); 62 ConfigDirPolicyProvider provider(non_existent_dir);
63 EXPECT_TRUE(provider.Provide(policy_store_.get())); 63 EXPECT_TRUE(provider.Provide(policy_store_.get()));
64 EXPECT_TRUE(policy_store_->policy_map().empty()); 64 EXPECT_TRUE(policy_store_->policy_map().empty());
65 } 65 }
66 66
67 // Test reading back a single preference value. 67 // Test reading back a single preference value.
68 TEST_F(ConfigDirPolicyProviderTest, ReadPrefsSinglePref) { 68 TEST_F(ConfigDirPolicyProviderTest, ReadPrefsSinglePref) {
69 DictionaryValue test_dict; 69 DictionaryValue test_dict;
70 test_dict.SetString(L"HomepageLocation", L"http://www.google.com"); 70 test_dict.SetString("HomepageLocation", "http://www.google.com");
71 WriteConfigFile(test_dict, "config_file"); 71 WriteConfigFile(test_dict, "config_file");
72 ConfigDirPolicyProvider provider(test_dir_); 72 ConfigDirPolicyProvider provider(test_dir_);
73 73
74 EXPECT_TRUE(provider.Provide(policy_store_.get())); 74 EXPECT_TRUE(provider.Provide(policy_store_.get()));
75 const MockConfigurationPolicyStore::PolicyMap& policy_map( 75 const MockConfigurationPolicyStore::PolicyMap& policy_map(
76 policy_store_->policy_map()); 76 policy_store_->policy_map());
77 EXPECT_EQ(1U, policy_map.size()); 77 EXPECT_EQ(1U, policy_map.size());
78 MockConfigurationPolicyStore::PolicyMap::const_iterator entry = 78 MockConfigurationPolicyStore::PolicyMap::const_iterator entry =
79 policy_map.find(ConfigurationPolicyStore::kPolicyHomePage); 79 policy_map.find(ConfigurationPolicyStore::kPolicyHomePage);
80 ASSERT_TRUE(entry != policy_map.end()); 80 ASSERT_TRUE(entry != policy_map.end());
81 81
82 std::wstring str_value; 82 std::string str_value;
83 EXPECT_TRUE(entry->second->GetAsString(&str_value)); 83 EXPECT_TRUE(entry->second->GetAsString(&str_value));
84 EXPECT_EQ(L"http://www.google.com", str_value); 84 EXPECT_EQ("http://www.google.com", str_value);
85 } 85 }
86 86
87 // Test merging values from different files. 87 // Test merging values from different files.
88 TEST_F(ConfigDirPolicyProviderTest, ReadPrefsMergePrefs) { 88 TEST_F(ConfigDirPolicyProviderTest, ReadPrefsMergePrefs) {
89 // Write a bunch of data files in order to increase the chance to detect the 89 // Write a bunch of data files in order to increase the chance to detect the
90 // provider not respecting lexicographic ordering when reading them. Since the 90 // provider not respecting lexicographic ordering when reading them. Since the
91 // filesystem may return files in arbitrary order, there is no way to be sure, 91 // filesystem may return files in arbitrary order, there is no way to be sure,
92 // but this is better than nothing. 92 // but this is better than nothing.
93 DictionaryValue test_dict_bar; 93 DictionaryValue test_dict_bar;
94 test_dict_bar.SetString(L"HomepageLocation", L"http://bar.com"); 94 test_dict_bar.SetString("HomepageLocation", "http://bar.com");
95 for (unsigned int i = 1; i <= 4; ++i) 95 for (unsigned int i = 1; i <= 4; ++i)
96 WriteConfigFile(test_dict_bar, base::IntToString(i)); 96 WriteConfigFile(test_dict_bar, base::IntToString(i));
97 DictionaryValue test_dict_foo; 97 DictionaryValue test_dict_foo;
98 test_dict_foo.SetString(L"HomepageLocation", L"http://foo.com"); 98 test_dict_foo.SetString("HomepageLocation", "http://foo.com");
99 WriteConfigFile(test_dict_foo, "9"); 99 WriteConfigFile(test_dict_foo, "9");
100 for (unsigned int i = 5; i <= 8; ++i) 100 for (unsigned int i = 5; i <= 8; ++i)
101 WriteConfigFile(test_dict_bar, base::IntToString(i)); 101 WriteConfigFile(test_dict_bar, base::IntToString(i));
102 ConfigDirPolicyProvider provider(test_dir_); 102 ConfigDirPolicyProvider provider(test_dir_);
103 103
104 EXPECT_TRUE(provider.Provide(policy_store_.get())); 104 EXPECT_TRUE(provider.Provide(policy_store_.get()));
105 const MockConfigurationPolicyStore::PolicyMap& policy_map( 105 const MockConfigurationPolicyStore::PolicyMap& policy_map(
106 policy_store_->policy_map()); 106 policy_store_->policy_map());
107 EXPECT_EQ(1U, policy_map.size()); 107 EXPECT_EQ(1U, policy_map.size());
108 MockConfigurationPolicyStore::PolicyMap::const_iterator entry = 108 MockConfigurationPolicyStore::PolicyMap::const_iterator entry =
109 policy_map.find(ConfigurationPolicyStore::kPolicyHomePage); 109 policy_map.find(ConfigurationPolicyStore::kPolicyHomePage);
110 ASSERT_TRUE(entry != policy_map.end()); 110 ASSERT_TRUE(entry != policy_map.end());
111 111
112 std::wstring str_value; 112 std::string str_value;
113 EXPECT_TRUE(entry->second->GetAsString(&str_value)); 113 EXPECT_TRUE(entry->second->GetAsString(&str_value));
114 EXPECT_EQ(L"http://foo.com", str_value); 114 EXPECT_EQ("http://foo.com", str_value);
115 } 115 }
OLDNEW
« no previous file with comments | « chrome/browser/notifications/notifications_prefs_cache.cc ('k') | chrome/browser/pref_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698