OLD | NEW |
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" |
11 #include "base/string_util.h" | 11 #include "base/string_util.h" |
12 #include "chrome/installer/util/work_item.h" | 12 #include "chrome/installer/util/work_item.h" |
13 #include "chrome/installer/util/create_dir_work_item.h" | 13 #include "chrome/installer/util/create_dir_work_item.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
15 | 15 |
16 namespace { | 16 namespace { |
17 class CreateDirWorkItemTest : public testing::Test { | 17 class CreateDirWorkItemTest : public testing::Test { |
18 protected: | 18 protected: |
19 virtual void SetUp() { | 19 virtual void SetUp() { |
20 // Name a subdirectory of the temp directory. | 20 // Name a subdirectory of the temp directory. |
21 ASSERT_TRUE(PathService::Get(base::DIR_TEMP, &test_dir_)); | 21 ASSERT_TRUE(PathService::Get(base::DIR_TEMP, &test_dir_)); |
22 test_dir_ = test_dir_.AppendASCII("CreateDirWorkItemTest"); | 22 test_dir_ = test_dir_.AppendASCII("CreateDirWorkItemTest"); |
23 | 23 |
24 // Create a fresh, empty copy of this directory. | 24 // Create a fresh, empty copy of this directory. |
25 file_util::Delete(test_dir_, true); | 25 file_util::Delete(test_dir_, true); |
26 file_util::CreateDirectoryW(test_dir_); | 26 file_util::CreateDirectoryW(test_dir_); |
27 } | 27 } |
28 virtual void TearDown() { | 28 virtual void TearDown() { |
29 // Clean up test directory | 29 // Clean up test directory |
30 ASSERT_TRUE(file_util::Delete(test_dir_, false)); | 30 ASSERT_TRUE(file_util::Delete(test_dir_, true)); |
31 ASSERT_FALSE(file_util::PathExists(test_dir_)); | 31 ASSERT_FALSE(file_util::PathExists(test_dir_)); |
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_); |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 } |
OLD | NEW |