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

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

Issue 202002: Replaces the windows function CreateDirectory with the CreateDirectory method... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 11 years, 3 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) 2009 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 "base/base_paths.h" 7 #include "base/base_paths.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "base/scoped_ptr.h" 10 #include "base/scoped_ptr.h"
(...skipping 21 matching lines...) Expand all
32 } 32 }
33 33
34 // the path to temporary directory used to contain the test operations 34 // the path to temporary directory used to contain the test operations
35 FilePath test_dir_; 35 FilePath test_dir_;
36 }; 36 };
37 }; 37 };
38 38
39 TEST_F(CreateDirWorkItemTest, CreatePath) { 39 TEST_F(CreateDirWorkItemTest, CreatePath) {
40 FilePath parent_dir(test_dir_); 40 FilePath parent_dir(test_dir_);
41 parent_dir = parent_dir.AppendASCII("a"); 41 parent_dir = parent_dir.AppendASCII("a");
42 CreateDirectory(parent_dir.value().c_str(), NULL); 42 file_util::CreateDirectory(parent_dir);
43 ASSERT_TRUE(file_util::PathExists(parent_dir)); 43 ASSERT_TRUE(file_util::PathExists(parent_dir));
44 44
45 FilePath top_dir_to_create(parent_dir); 45 FilePath top_dir_to_create(parent_dir);
46 top_dir_to_create = top_dir_to_create.AppendASCII("b"); 46 top_dir_to_create = top_dir_to_create.AppendASCII("b");
47 47
48 FilePath dir_to_create(top_dir_to_create); 48 FilePath dir_to_create(top_dir_to_create);
49 dir_to_create = dir_to_create.AppendASCII("c"); 49 dir_to_create = dir_to_create.AppendASCII("c");
50 dir_to_create = dir_to_create.AppendASCII("d"); 50 dir_to_create = dir_to_create.AppendASCII("d");
51 51
52 scoped_ptr<CreateDirWorkItem> work_item( 52 scoped_ptr<CreateDirWorkItem> work_item(
53 WorkItem::CreateCreateDirWorkItem(dir_to_create)); 53 WorkItem::CreateCreateDirWorkItem(dir_to_create));
54 54
55 EXPECT_TRUE(work_item->Do()); 55 EXPECT_TRUE(work_item->Do());
56 56
57 EXPECT_TRUE(file_util::PathExists(dir_to_create)); 57 EXPECT_TRUE(file_util::PathExists(dir_to_create));
58 58
59 work_item->Rollback(); 59 work_item->Rollback();
60 60
61 // Rollback should delete all the paths up to top_dir_to_create. 61 // Rollback should delete all the paths up to top_dir_to_create.
62 EXPECT_FALSE(file_util::PathExists(top_dir_to_create)); 62 EXPECT_FALSE(file_util::PathExists(top_dir_to_create));
63 EXPECT_TRUE(file_util::PathExists(parent_dir)); 63 EXPECT_TRUE(file_util::PathExists(parent_dir));
64 } 64 }
65 65
66 TEST_F(CreateDirWorkItemTest, CreateExistingPath) { 66 TEST_F(CreateDirWorkItemTest, CreateExistingPath) {
67 FilePath dir_to_create(test_dir_); 67 FilePath dir_to_create(test_dir_);
68 dir_to_create = dir_to_create.AppendASCII("aa"); 68 dir_to_create = dir_to_create.AppendASCII("aa");
69 CreateDirectory(dir_to_create.value().c_str(), NULL); 69 file_util::CreateDirectory(dir_to_create);
70 ASSERT_TRUE(file_util::PathExists(dir_to_create)); 70 ASSERT_TRUE(file_util::PathExists(dir_to_create));
71 71
72 scoped_ptr<CreateDirWorkItem> work_item( 72 scoped_ptr<CreateDirWorkItem> work_item(
73 WorkItem::CreateCreateDirWorkItem(dir_to_create)); 73 WorkItem::CreateCreateDirWorkItem(dir_to_create));
74 74
75 EXPECT_TRUE(work_item->Do()); 75 EXPECT_TRUE(work_item->Do());
76 76
77 EXPECT_TRUE(file_util::PathExists(dir_to_create)); 77 EXPECT_TRUE(file_util::PathExists(dir_to_create));
78 78
79 work_item->Rollback(); 79 work_item->Rollback();
(...skipping 16 matching lines...) Expand all
96 scoped_ptr<CreateDirWorkItem> work_item( 96 scoped_ptr<CreateDirWorkItem> work_item(
97 WorkItem::CreateCreateDirWorkItem(dir_to_create_3)); 97 WorkItem::CreateCreateDirWorkItem(dir_to_create_3));
98 98
99 EXPECT_TRUE(work_item->Do()); 99 EXPECT_TRUE(work_item->Do());
100 100
101 EXPECT_TRUE(file_util::PathExists(dir_to_create_3)); 101 EXPECT_TRUE(file_util::PathExists(dir_to_create_3));
102 102
103 // Create another directory under dir_to_create_2 103 // Create another directory under dir_to_create_2
104 FilePath dir_to_create_4(dir_to_create_2); 104 FilePath dir_to_create_4(dir_to_create_2);
105 dir_to_create_4 = dir_to_create_4.AppendASCII("ddd"); 105 dir_to_create_4 = dir_to_create_4.AppendASCII("ddd");
106 CreateDirectory(dir_to_create_4.value().c_str(), NULL); 106 file_util::CreateDirectory(dir_to_create_4);
107 ASSERT_TRUE(file_util::PathExists(dir_to_create_4)); 107 ASSERT_TRUE(file_util::PathExists(dir_to_create_4));
108 108
109 work_item->Rollback(); 109 work_item->Rollback();
110 110
111 // Rollback should delete dir_to_create_3. 111 // Rollback should delete dir_to_create_3.
112 EXPECT_FALSE(file_util::PathExists(dir_to_create_3)); 112 EXPECT_FALSE(file_util::PathExists(dir_to_create_3));
113 113
114 // Rollback should not delete dir_to_create_2 as it is shared. 114 // Rollback should not delete dir_to_create_2 as it is shared.
115 EXPECT_TRUE(file_util::PathExists(dir_to_create_2)); 115 EXPECT_TRUE(file_util::PathExists(dir_to_create_2));
116 EXPECT_TRUE(file_util::PathExists(dir_to_create_4)); 116 EXPECT_TRUE(file_util::PathExists(dir_to_create_4));
(...skipping 18 matching lines...) Expand all
135 135
136 RemoveDirectory(dir_to_create_3.value().c_str()); 136 RemoveDirectory(dir_to_create_3.value().c_str());
137 ASSERT_FALSE(file_util::PathExists(dir_to_create_3)); 137 ASSERT_FALSE(file_util::PathExists(dir_to_create_3));
138 138
139 work_item->Rollback(); 139 work_item->Rollback();
140 140
141 // dir_to_create_3 has already been deleted, Rollback should delete 141 // dir_to_create_3 has already been deleted, Rollback should delete
142 // the rest. 142 // the rest.
143 EXPECT_FALSE(file_util::PathExists(dir_to_create_1)); 143 EXPECT_FALSE(file_util::PathExists(dir_to_create_1));
144 } 144 }
OLDNEW
« no previous file with comments | « chrome/installer/util/copy_tree_work_item_unittest.cc ('k') | chrome/installer/util/delete_tree_work_item_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698