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

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

Issue 3836005: Move pe_image and registry from base to base/win and use the namespace. It re... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 2 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) 2009 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 <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/registry.h"
10 #include "base/scoped_ptr.h" 9 #include "base/scoped_ptr.h"
11 #include "base/string_util.h" 10 #include "base/string_util.h"
11 #include "base/win/registry.h"
12 #include "chrome/installer/util/delete_after_reboot_helper.h" 12 #include "chrome/installer/util/delete_after_reboot_helper.h"
13 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
14 14
15 namespace { 15 namespace {
16 16
17 // These tests exercise the Delete-After-Reboot code which requires 17 // These tests exercise the Delete-After-Reboot code which requires
18 // modifications to HKLM. This will fail on Vista and above if the user 18 // modifications to HKLM. This will fail on Vista and above if the user
19 // is not an admin or if UAC is on. 19 // is not an admin or if UAC is on.
20 // I tried using RegOverridePredefKey to test, but MoveFileEx ignore this 20 // I tried using RegOverridePredefKey to test, but MoveFileEx ignore this
21 // even on 32 bit machines :-( As such, running this test may pollute 21 // even on 32 bit machines :-( As such, running this test may pollute
(...skipping 14 matching lines...) Expand all
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 file_util::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 RegKey session_manager_key(HKEY_LOCAL_MACHINE, kSessionManagerKey, 46 base::win::RegKey session_manager_key(
47 KEY_CREATE_SUB_KEY | KEY_SET_VALUE); 47 HKEY_LOCAL_MACHINE, kSessionManagerKey,
48 KEY_CREATE_SUB_KEY | KEY_SET_VALUE);
48 if (!session_manager_key.Handle()) { 49 if (!session_manager_key.Handle()) {
49 // Couldn't open / create the key. 50 // Couldn't open / create the key.
50 DLOG(ERROR) << "Failed to open session manager key for writing."; 51 DLOG(ERROR) << "Failed to open session manager key for writing.";
51 } 52 }
52 53
53 std::vector<char> buffer; 54 std::vector<char> buffer;
54 StringArrayToMultiSZBytes(original_pending_moves_, &buffer); 55 StringArrayToMultiSZBytes(original_pending_moves_, &buffer);
55 session_manager_key.WriteValue(kPendingFileRenameOps, &buffer[0], 56 session_manager_key.WriteValue(kPendingFileRenameOps, &buffer[0],
56 buffer.size(), REG_MULTI_SZ); 57 buffer.size(), REG_MULTI_SZ);
57 } 58 }
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 // Test that we can remove the pending deletes. 178 // Test that we can remove the pending deletes.
178 EXPECT_TRUE(RemoveFromMovesPendingReboot(temp_dir_.value().c_str())); 179 EXPECT_TRUE(RemoveFromMovesPendingReboot(temp_dir_.value().c_str()));
179 HRESULT hr = GetPendingMovesValue(&pending_moves); 180 HRESULT hr = GetPendingMovesValue(&pending_moves);
180 EXPECT_TRUE(hr == S_OK || hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND)); 181 EXPECT_TRUE(hr == S_OK || hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND));
181 182
182 std::vector<PendingMove>::const_iterator check_iter(pending_moves.begin()); 183 std::vector<PendingMove>::const_iterator check_iter(pending_moves.begin());
183 for (; check_iter != pending_moves.end(); ++check_iter) { 184 for (; check_iter != pending_moves.end(); ++check_iter) {
184 EXPECT_FALSE(MatchPendingDeletePath(short_temp_file, check_iter->first)); 185 EXPECT_FALSE(MatchPendingDeletePath(short_temp_file, check_iter->first));
185 } 186 }
186 } 187 }
OLDNEW
« no previous file with comments | « chrome/installer/util/delete_after_reboot_helper.cc ('k') | chrome/installer/util/delete_reg_value_work_item.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698