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

Side by Side Diff: chrome/browser/policy/cloud/user_cloud_policy_store_unittest.cc

Issue 100573002: Move directory creation functions to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/policy/cloud/user_cloud_policy_store.h" 5 #include "chrome/browser/policy/cloud/user_cloud_policy_store.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/files/scoped_temp_dir.h" 8 #include "base/files/scoped_temp_dir.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/message_loop/message_loop_proxy.h" 10 #include "base/message_loop/message_loop_proxy.h"
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 108
109 EXPECT_FALSE(store_->policy()); 109 EXPECT_FALSE(store_->policy());
110 EXPECT_TRUE(store_->policy_map().empty()); 110 EXPECT_TRUE(store_->policy_map().empty());
111 } 111 }
112 112
113 TEST_F(UserCloudPolicyStoreTest, LoadWithInvalidFile) { 113 TEST_F(UserCloudPolicyStoreTest, LoadWithInvalidFile) {
114 EXPECT_FALSE(store_->policy()); 114 EXPECT_FALSE(store_->policy());
115 EXPECT_TRUE(store_->policy_map().empty()); 115 EXPECT_TRUE(store_->policy_map().empty());
116 116
117 // Create a bogus file. 117 // Create a bogus file.
118 ASSERT_TRUE(file_util::CreateDirectory(policy_file().DirName())); 118 ASSERT_TRUE(base::CreateDirectory(policy_file().DirName()));
119 std::string bogus_data = "bogus_data"; 119 std::string bogus_data = "bogus_data";
120 int size = bogus_data.size(); 120 int size = bogus_data.size();
121 ASSERT_EQ(size, file_util::WriteFile(policy_file(), 121 ASSERT_EQ(size, file_util::WriteFile(policy_file(),
122 bogus_data.c_str(), 122 bogus_data.c_str(),
123 bogus_data.size())); 123 bogus_data.size()));
124 124
125 ExpectError(store_.get(), CloudPolicyStore::STATUS_LOAD_ERROR); 125 ExpectError(store_.get(), CloudPolicyStore::STATUS_LOAD_ERROR);
126 store_->Load(); 126 store_->Load();
127 RunUntilIdle(); 127 RunUntilIdle();
128 128
(...skipping 12 matching lines...) Expand all
141 141
142 EXPECT_FALSE(store_->policy()); 142 EXPECT_FALSE(store_->policy());
143 EXPECT_TRUE(store_->policy_map().empty()); 143 EXPECT_TRUE(store_->policy_map().empty());
144 } 144 }
145 145
146 TEST_F(UserCloudPolicyStoreTest, LoadImmediatelyWithInvalidFile) { 146 TEST_F(UserCloudPolicyStoreTest, LoadImmediatelyWithInvalidFile) {
147 EXPECT_FALSE(store_->policy()); 147 EXPECT_FALSE(store_->policy());
148 EXPECT_TRUE(store_->policy_map().empty()); 148 EXPECT_TRUE(store_->policy_map().empty());
149 149
150 // Create a bogus file. 150 // Create a bogus file.
151 ASSERT_TRUE(file_util::CreateDirectory(policy_file().DirName())); 151 ASSERT_TRUE(base::CreateDirectory(policy_file().DirName()));
152 std::string bogus_data = "bogus_data"; 152 std::string bogus_data = "bogus_data";
153 int size = bogus_data.size(); 153 int size = bogus_data.size();
154 ASSERT_EQ(size, file_util::WriteFile(policy_file(), 154 ASSERT_EQ(size, file_util::WriteFile(policy_file(),
155 bogus_data.c_str(), 155 bogus_data.c_str(),
156 bogus_data.size())); 156 bogus_data.size()));
157 157
158 ExpectError(store_.get(), CloudPolicyStore::STATUS_LOAD_ERROR); 158 ExpectError(store_.get(), CloudPolicyStore::STATUS_LOAD_ERROR);
159 store_->LoadImmediately(); // Should load without running the message loop. 159 store_->LoadImmediately(); // Should load without running the message loop.
160 160
161 EXPECT_FALSE(store_->policy()); 161 EXPECT_FALSE(store_->policy());
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 store4->Load(); 358 store4->Load();
359 RunUntilIdle(); 359 RunUntilIdle();
360 360
361 ASSERT_FALSE(store4->policy()); 361 ASSERT_FALSE(store4->policy());
362 store4->RemoveObserver(&observer_); 362 store4->RemoveObserver(&observer_);
363 } 363 }
364 364
365 } // namespace 365 } // namespace
366 366
367 } // namespace policy 367 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/policy/cloud/user_cloud_policy_store.cc ('k') | chrome/browser/policy/config_dir_policy_loader_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698