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

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

Issue 3056029: Move the number conversions from string_util to a new file.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' 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 | Annotate | Revision Log
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_util.h" 7 #include "base/string_number_conversions.h"
8 #include "chrome/browser/config_dir_policy_provider.h" 8 #include "chrome/browser/config_dir_policy_provider.h"
9 #include "chrome/browser/mock_configuration_policy_store.h" 9 #include "chrome/browser/mock_configuration_policy_store.h"
10 #include "chrome/common/json_value_serializer.h" 10 #include "chrome/common/json_value_serializer.h"
11 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
12 12
13 class ConfigDirPolicyProviderTest : public testing::Test { 13 class ConfigDirPolicyProviderTest : public testing::Test {
14 protected: 14 protected:
15 virtual void SetUp() { 15 virtual void SetUp() {
16 // Determine the directory to use for testing. 16 // Determine the directory to use for testing.
17 ASSERT_TRUE(PathService::Get(base::DIR_TEMP, &test_dir_)); 17 ASSERT_TRUE(PathService::Get(base::DIR_TEMP, &test_dir_));
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(L"HomepageLocation", L"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, 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(L"HomepageLocation", L"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, 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::wstring 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(L"http://foo.com", str_value);
115 } 115 }
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/page_info_window_mac_unittest.mm ('k') | chrome/browser/debugger/debugger_remote_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698