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

Side by Side Diff: chrome/installer/util/delete_after_reboot_helper_unittest.cc

Issue 16950028: Move file_util::Delete to the base namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <windows.h> 5 #include <windows.h>
6 #include <shlobj.h> 6 #include <shlobj.h>
7 7
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 21 matching lines...) Expand all
32 file_util::CreateDirectory(temp_subdir_); 32 file_util::CreateDirectory(temp_subdir_);
33 file_util::CreateTemporaryFileInDir(temp_subdir_, &temp_subdir_file_); 33 file_util::CreateTemporaryFileInDir(temp_subdir_, &temp_subdir_file_);
34 34
35 // Copy the current pending moves and then clear it if we can: 35 // Copy the current pending moves and then clear it if we can:
36 if (IsUserAnAdmin()) { 36 if (IsUserAnAdmin()) {
37 GetPendingMovesValue(&original_pending_moves_); 37 GetPendingMovesValue(&original_pending_moves_);
38 } 38 }
39 } 39 }
40 virtual void TearDown() { 40 virtual void TearDown() {
41 // Delete the temporary directory if it's still there. 41 // Delete the temporary directory if it's still there.
42 file_util::Delete(temp_dir_, true); 42 base::Delete(temp_dir_, true);
43 43
44 // Try and restore the pending moves value, if we have one. 44 // Try and restore the pending moves value, if we have one.
45 if (IsUserAnAdmin() && original_pending_moves_.size() > 1) { 45 if (IsUserAnAdmin() && original_pending_moves_.size() > 1) {
46 base::win::RegKey session_manager_key( 46 base::win::RegKey session_manager_key(
47 HKEY_LOCAL_MACHINE, kSessionManagerKey, 47 HKEY_LOCAL_MACHINE, kSessionManagerKey,
48 KEY_CREATE_SUB_KEY | KEY_SET_VALUE); 48 KEY_CREATE_SUB_KEY | KEY_SET_VALUE);
49 if (!session_manager_key.Handle()) { 49 if (!session_manager_key.Handle()) {
50 // Couldn't open / create the key. 50 // Couldn't open / create the key.
51 DLOG(ERROR) << "Failed to open session manager key for writing."; 51 DLOG(ERROR) << "Failed to open session manager key for writing.";
52 } 52 }
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 EXPECT_FALSE(iter == pending_moves.end()); 221 EXPECT_FALSE(iter == pending_moves.end());
222 if (iter != pending_moves.end()) { 222 if (iter != pending_moves.end()) {
223 std::wstring short_path_name( 223 std::wstring short_path_name(
224 GetShortPathName(expected_paths[i].value().c_str())); 224 GetShortPathName(expected_paths[i].value().c_str()));
225 EXPECT_TRUE(MatchPendingDeletePath(short_path_name, iter->first)); 225 EXPECT_TRUE(MatchPendingDeletePath(short_path_name, iter->first));
226 ++iter; 226 ++iter;
227 } 227 }
228 } 228 }
229 229
230 // Delete the temporary directory. 230 // Delete the temporary directory.
231 file_util::Delete(temp_dir_, true); 231 base::Delete(temp_dir_, true);
232 232
233 // Test that we can remove the pending deletes. 233 // Test that we can remove the pending deletes.
234 EXPECT_TRUE(RemoveFromMovesPendingReboot(temp_dir_.value().c_str())); 234 EXPECT_TRUE(RemoveFromMovesPendingReboot(temp_dir_.value().c_str()));
235 HRESULT hr = GetPendingMovesValue(&pending_moves); 235 HRESULT hr = GetPendingMovesValue(&pending_moves);
236 EXPECT_TRUE(hr == S_OK || hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND)); 236 EXPECT_TRUE(hr == S_OK || hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND));
237 237
238 EXPECT_EQ(initial_pending_moves_size, pending_moves.size()); 238 EXPECT_EQ(initial_pending_moves_size, pending_moves.size());
239 239
240 std::vector<PendingMove>::const_iterator check_iter(pending_moves.begin()); 240 std::vector<PendingMove>::const_iterator check_iter(pending_moves.begin());
241 for (; check_iter != pending_moves.end(); ++check_iter) { 241 for (; check_iter != pending_moves.end(); ++check_iter) {
242 EXPECT_FALSE(MatchPendingDeletePath(short_temp_file, check_iter->first)); 242 EXPECT_FALSE(MatchPendingDeletePath(short_temp_file, check_iter->first));
243 } 243 }
244 } 244 }
245 245
OLDNEW
« no previous file with comments | « chrome/installer/util/copy_tree_work_item_unittest.cc ('k') | chrome/installer/util/delete_tree_work_item.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698