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

Side by Side Diff: chrome/installer/util/delete_tree_work_item_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) 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 6
7 #include <fstream> 7 #include <fstream>
8 8
9 #include "base/base_paths.h" 9 #include "base/base_paths.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 29 matching lines...) Expand all
40 40
41 wchar_t text_content_1[] = L"delete me"; 41 wchar_t text_content_1[] = L"delete me";
42 wchar_t text_content_2[] = L"delete me as well"; 42 wchar_t text_content_2[] = L"delete me as well";
43 }; 43 };
44 44
45 // Delete a tree without key path. Everything should be deleted. 45 // Delete a tree without key path. Everything should be deleted.
46 TEST_F(DeleteTreeWorkItemTest, DeleteTreeNoKeyPath) { 46 TEST_F(DeleteTreeWorkItemTest, DeleteTreeNoKeyPath) {
47 // Create tree to be deleted. 47 // Create tree to be deleted.
48 base::FilePath dir_name_delete(temp_dir_.path()); 48 base::FilePath dir_name_delete(temp_dir_.path());
49 dir_name_delete = dir_name_delete.AppendASCII("to_be_delete"); 49 dir_name_delete = dir_name_delete.AppendASCII("to_be_delete");
50 file_util::CreateDirectory(dir_name_delete); 50 base::CreateDirectory(dir_name_delete);
51 ASSERT_TRUE(base::PathExists(dir_name_delete)); 51 ASSERT_TRUE(base::PathExists(dir_name_delete));
52 52
53 base::FilePath dir_name_delete_1(dir_name_delete); 53 base::FilePath dir_name_delete_1(dir_name_delete);
54 dir_name_delete_1 = dir_name_delete_1.AppendASCII("1"); 54 dir_name_delete_1 = dir_name_delete_1.AppendASCII("1");
55 file_util::CreateDirectory(dir_name_delete_1); 55 base::CreateDirectory(dir_name_delete_1);
56 ASSERT_TRUE(base::PathExists(dir_name_delete_1)); 56 ASSERT_TRUE(base::PathExists(dir_name_delete_1));
57 57
58 base::FilePath dir_name_delete_2(dir_name_delete); 58 base::FilePath dir_name_delete_2(dir_name_delete);
59 dir_name_delete_2 = dir_name_delete_2.AppendASCII("2"); 59 dir_name_delete_2 = dir_name_delete_2.AppendASCII("2");
60 file_util::CreateDirectory(dir_name_delete_2); 60 base::CreateDirectory(dir_name_delete_2);
61 ASSERT_TRUE(base::PathExists(dir_name_delete_2)); 61 ASSERT_TRUE(base::PathExists(dir_name_delete_2));
62 62
63 base::FilePath file_name_delete_1(dir_name_delete_1); 63 base::FilePath file_name_delete_1(dir_name_delete_1);
64 file_name_delete_1 = file_name_delete_1.AppendASCII("File_1.txt"); 64 file_name_delete_1 = file_name_delete_1.AppendASCII("File_1.txt");
65 CreateTextFile(file_name_delete_1.value(), text_content_1); 65 CreateTextFile(file_name_delete_1.value(), text_content_1);
66 ASSERT_TRUE(base::PathExists(file_name_delete_1)); 66 ASSERT_TRUE(base::PathExists(file_name_delete_1));
67 67
68 base::FilePath file_name_delete_2(dir_name_delete_2); 68 base::FilePath file_name_delete_2(dir_name_delete_2);
69 file_name_delete_2 = file_name_delete_2.AppendASCII("File_2.txt"); 69 file_name_delete_2 = file_name_delete_2.AppendASCII("File_2.txt");
70 CreateTextFile(file_name_delete_2.value(), text_content_1); 70 CreateTextFile(file_name_delete_2.value(), text_content_1);
(...skipping 21 matching lines...) Expand all
92 EXPECT_TRUE(base::PathExists(dir_name_delete)); 92 EXPECT_TRUE(base::PathExists(dir_name_delete));
93 } 93 }
94 94
95 95
96 // Delete a tree with keypath but not in use. Everything should be gone. 96 // Delete a tree with keypath but not in use. Everything should be gone.
97 // Rollback should bring back everything 97 // Rollback should bring back everything
98 TEST_F(DeleteTreeWorkItemTest, DeleteTree) { 98 TEST_F(DeleteTreeWorkItemTest, DeleteTree) {
99 // Create tree to be deleted 99 // Create tree to be deleted
100 base::FilePath dir_name_delete(temp_dir_.path()); 100 base::FilePath dir_name_delete(temp_dir_.path());
101 dir_name_delete = dir_name_delete.AppendASCII("to_be_delete"); 101 dir_name_delete = dir_name_delete.AppendASCII("to_be_delete");
102 file_util::CreateDirectory(dir_name_delete); 102 base::CreateDirectory(dir_name_delete);
103 ASSERT_TRUE(base::PathExists(dir_name_delete)); 103 ASSERT_TRUE(base::PathExists(dir_name_delete));
104 104
105 base::FilePath dir_name_delete_1(dir_name_delete); 105 base::FilePath dir_name_delete_1(dir_name_delete);
106 dir_name_delete_1 = dir_name_delete_1.AppendASCII("1"); 106 dir_name_delete_1 = dir_name_delete_1.AppendASCII("1");
107 file_util::CreateDirectory(dir_name_delete_1); 107 base::CreateDirectory(dir_name_delete_1);
108 ASSERT_TRUE(base::PathExists(dir_name_delete_1)); 108 ASSERT_TRUE(base::PathExists(dir_name_delete_1));
109 109
110 base::FilePath dir_name_delete_2(dir_name_delete); 110 base::FilePath dir_name_delete_2(dir_name_delete);
111 dir_name_delete_2 = dir_name_delete_2.AppendASCII("2"); 111 dir_name_delete_2 = dir_name_delete_2.AppendASCII("2");
112 file_util::CreateDirectory(dir_name_delete_2); 112 base::CreateDirectory(dir_name_delete_2);
113 ASSERT_TRUE(base::PathExists(dir_name_delete_2)); 113 ASSERT_TRUE(base::PathExists(dir_name_delete_2));
114 114
115 base::FilePath file_name_delete_1(dir_name_delete_1); 115 base::FilePath file_name_delete_1(dir_name_delete_1);
116 file_name_delete_1 = file_name_delete_1.AppendASCII("File_1.txt"); 116 file_name_delete_1 = file_name_delete_1.AppendASCII("File_1.txt");
117 CreateTextFile(file_name_delete_1.value(), text_content_1); 117 CreateTextFile(file_name_delete_1.value(), text_content_1);
118 ASSERT_TRUE(base::PathExists(file_name_delete_1)); 118 ASSERT_TRUE(base::PathExists(file_name_delete_1));
119 119
120 base::FilePath file_name_delete_2(dir_name_delete_2); 120 base::FilePath file_name_delete_2(dir_name_delete_2);
121 file_name_delete_2 = file_name_delete_2.AppendASCII("File_2.txt"); 121 file_name_delete_2 = file_name_delete_2.AppendASCII("File_2.txt");
122 CreateTextFile(file_name_delete_2.value(), text_content_1); 122 CreateTextFile(file_name_delete_2.value(), text_content_1);
(...skipping 19 matching lines...) Expand all
142 EXPECT_TRUE(base::PathExists(file_name_delete_1)); 142 EXPECT_TRUE(base::PathExists(file_name_delete_1));
143 EXPECT_TRUE(base::PathExists(file_name_delete_2)); 143 EXPECT_TRUE(base::PathExists(file_name_delete_2));
144 EXPECT_TRUE(base::PathExists(dir_name_delete)); 144 EXPECT_TRUE(base::PathExists(dir_name_delete));
145 } 145 }
146 146
147 // Delete a tree with key_path in use. Everything should still be there. 147 // Delete a tree with key_path in use. Everything should still be there.
148 TEST_F(DeleteTreeWorkItemTest, DeleteTreeInUse) { 148 TEST_F(DeleteTreeWorkItemTest, DeleteTreeInUse) {
149 // Create tree to be deleted 149 // Create tree to be deleted
150 base::FilePath dir_name_delete(temp_dir_.path()); 150 base::FilePath dir_name_delete(temp_dir_.path());
151 dir_name_delete = dir_name_delete.AppendASCII("to_be_delete"); 151 dir_name_delete = dir_name_delete.AppendASCII("to_be_delete");
152 file_util::CreateDirectory(dir_name_delete); 152 base::CreateDirectory(dir_name_delete);
153 ASSERT_TRUE(base::PathExists(dir_name_delete)); 153 ASSERT_TRUE(base::PathExists(dir_name_delete));
154 154
155 base::FilePath dir_name_delete_1(dir_name_delete); 155 base::FilePath dir_name_delete_1(dir_name_delete);
156 dir_name_delete_1 = dir_name_delete_1.AppendASCII("1"); 156 dir_name_delete_1 = dir_name_delete_1.AppendASCII("1");
157 file_util::CreateDirectory(dir_name_delete_1); 157 base::CreateDirectory(dir_name_delete_1);
158 ASSERT_TRUE(base::PathExists(dir_name_delete_1)); 158 ASSERT_TRUE(base::PathExists(dir_name_delete_1));
159 159
160 base::FilePath dir_name_delete_2(dir_name_delete); 160 base::FilePath dir_name_delete_2(dir_name_delete);
161 dir_name_delete_2 = dir_name_delete_2.AppendASCII("2"); 161 dir_name_delete_2 = dir_name_delete_2.AppendASCII("2");
162 file_util::CreateDirectory(dir_name_delete_2); 162 base::CreateDirectory(dir_name_delete_2);
163 ASSERT_TRUE(base::PathExists(dir_name_delete_2)); 163 ASSERT_TRUE(base::PathExists(dir_name_delete_2));
164 164
165 base::FilePath file_name_delete_1(dir_name_delete_1); 165 base::FilePath file_name_delete_1(dir_name_delete_1);
166 file_name_delete_1 = file_name_delete_1.AppendASCII("File_1.txt"); 166 file_name_delete_1 = file_name_delete_1.AppendASCII("File_1.txt");
167 CreateTextFile(file_name_delete_1.value(), text_content_1); 167 CreateTextFile(file_name_delete_1.value(), text_content_1);
168 ASSERT_TRUE(base::PathExists(file_name_delete_1)); 168 ASSERT_TRUE(base::PathExists(file_name_delete_1));
169 169
170 base::FilePath file_name_delete_2(dir_name_delete_2); 170 base::FilePath file_name_delete_2(dir_name_delete_2);
171 file_name_delete_2 = file_name_delete_2.AppendASCII("File_2.txt"); 171 file_name_delete_2 = file_name_delete_2.AppendASCII("File_2.txt");
172 CreateTextFile(file_name_delete_2.value(), text_content_1); 172 CreateTextFile(file_name_delete_2.value(), text_content_1);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 210
211 // verify everything is still there. 211 // verify everything is still there.
212 EXPECT_TRUE(base::PathExists(key_path)); 212 EXPECT_TRUE(base::PathExists(key_path));
213 EXPECT_TRUE(base::PathExists(file_name_delete_1)); 213 EXPECT_TRUE(base::PathExists(file_name_delete_1));
214 EXPECT_TRUE(base::PathExists(file_name_delete_2)); 214 EXPECT_TRUE(base::PathExists(file_name_delete_2));
215 215
216 TerminateProcess(pi.hProcess, 0); 216 TerminateProcess(pi.hProcess, 0);
217 // make sure the handle is closed. 217 // make sure the handle is closed.
218 WaitForSingleObject(pi.hProcess, INFINITE); 218 WaitForSingleObject(pi.hProcess, INFINITE);
219 } 219 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698