OLD | NEW |
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 "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/files/scoped_temp_dir.h" |
9 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
10 #include "base/path_service.h" | 11 #include "base/path_service.h" |
11 #include "base/scoped_temp_dir.h" | |
12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
13 #include "chrome/installer/util/create_dir_work_item.h" | 13 #include "chrome/installer/util/create_dir_work_item.h" |
14 #include "chrome/installer/util/work_item.h" | 14 #include "chrome/installer/util/work_item.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
16 | 16 |
17 namespace { | 17 namespace { |
18 class CreateDirWorkItemTest : public testing::Test { | 18 class CreateDirWorkItemTest : public testing::Test { |
19 protected: | 19 protected: |
20 virtual void SetUp() { | 20 virtual void SetUp() { |
21 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 21 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
22 } | 22 } |
23 | 23 |
24 ScopedTempDir temp_dir_; | 24 base::ScopedTempDir temp_dir_; |
25 }; | 25 }; |
26 }; | 26 }; |
27 | 27 |
28 TEST_F(CreateDirWorkItemTest, CreatePath) { | 28 TEST_F(CreateDirWorkItemTest, CreatePath) { |
29 FilePath parent_dir(temp_dir_.path()); | 29 FilePath parent_dir(temp_dir_.path()); |
30 parent_dir = parent_dir.AppendASCII("a"); | 30 parent_dir = parent_dir.AppendASCII("a"); |
31 file_util::CreateDirectory(parent_dir); | 31 file_util::CreateDirectory(parent_dir); |
32 ASSERT_TRUE(file_util::PathExists(parent_dir)); | 32 ASSERT_TRUE(file_util::PathExists(parent_dir)); |
33 | 33 |
34 FilePath top_dir_to_create(parent_dir); | 34 FilePath top_dir_to_create(parent_dir); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 | 124 |
125 RemoveDirectory(dir_to_create_3.value().c_str()); | 125 RemoveDirectory(dir_to_create_3.value().c_str()); |
126 ASSERT_FALSE(file_util::PathExists(dir_to_create_3)); | 126 ASSERT_FALSE(file_util::PathExists(dir_to_create_3)); |
127 | 127 |
128 work_item->Rollback(); | 128 work_item->Rollback(); |
129 | 129 |
130 // dir_to_create_3 has already been deleted, Rollback should delete | 130 // dir_to_create_3 has already been deleted, Rollback should delete |
131 // the rest. | 131 // the rest. |
132 EXPECT_FALSE(file_util::PathExists(dir_to_create_1)); | 132 EXPECT_FALSE(file_util::PathExists(dir_to_create_1)); |
133 } | 133 } |
OLD | NEW |