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

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

Issue 99923002: Move temp file 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) 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"
11 #include "base/win/registry.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
22 // your PendingFileRenameOperations value. 22 // your PendingFileRenameOperations value.
23 class DeleteAfterRebootHelperTest : public testing::Test { 23 class DeleteAfterRebootHelperTest : public testing::Test {
24 protected: 24 protected:
25 virtual void SetUp() { 25 virtual void SetUp() {
26 // Create a temporary directory for testing and fill it with some files. 26 // Create a temporary directory for testing and fill it with some files.
27 std::wstring no_prefix; 27 base::CreateNewTempDirectory(base::FilePath::StringType(), &temp_dir_);
28 file_util::CreateNewTempDirectory(no_prefix, &temp_dir_); 28 base::CreateTemporaryFileInDir(temp_dir_, &temp_file_);
29 file_util::CreateTemporaryFileInDir(temp_dir_, &temp_file_);
30 29
31 temp_subdir_ = temp_dir_.Append(L"subdir"); 30 temp_subdir_ = temp_dir_.Append(L"subdir");
32 file_util::CreateDirectory(temp_subdir_); 31 file_util::CreateDirectory(temp_subdir_);
33 file_util::CreateTemporaryFileInDir(temp_subdir_, &temp_subdir_file_); 32 base::CreateTemporaryFileInDir(temp_subdir_, &temp_subdir_file_);
34 33
35 // Copy the current pending moves and then clear it if we can: 34 // Copy the current pending moves and then clear it if we can:
36 if (IsUserAnAdmin()) { 35 if (IsUserAnAdmin()) {
37 GetPendingMovesValue(&original_pending_moves_); 36 GetPendingMovesValue(&original_pending_moves_);
38 } 37 }
39 } 38 }
40 virtual void TearDown() { 39 virtual void TearDown() {
41 // Delete the temporary directory if it's still there. 40 // Delete the temporary directory if it's still there.
42 base::DeleteFile(temp_dir_, true); 41 base::DeleteFile(temp_dir_, true);
43 42
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 240
242 EXPECT_EQ(initial_pending_moves_size, pending_moves.size()); 241 EXPECT_EQ(initial_pending_moves_size, pending_moves.size());
243 242
244 std::vector<PendingMove>::const_iterator check_iter(pending_moves.begin()); 243 std::vector<PendingMove>::const_iterator check_iter(pending_moves.begin());
245 for (; check_iter != pending_moves.end(); ++check_iter) { 244 for (; check_iter != pending_moves.end(); ++check_iter) {
246 base::FilePath move_path(check_iter->first); 245 base::FilePath move_path(check_iter->first);
247 EXPECT_FALSE(MatchPendingDeletePath(short_temp_file, move_path)); 246 EXPECT_FALSE(MatchPendingDeletePath(short_temp_file, move_path));
248 } 247 }
249 } 248 }
250 249
OLDNEW
« no previous file with comments | « chrome/installer/test/upgrade_test.cc ('k') | chrome/installer/util/installer_state_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698