| 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/files/file_util.h" | 8 #include "base/files/file_util.h" |
| 9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
| 12 #include "chrome/installer/util/create_dir_work_item.h" | 12 #include "chrome/installer/util/create_dir_work_item.h" |
| 13 #include "chrome/installer/util/work_item.h" | 13 #include "chrome/installer/util/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 void SetUp() override { ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); } |
| 20 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | |
| 21 } | |
| 22 | 20 |
| 23 base::ScopedTempDir temp_dir_; | 21 base::ScopedTempDir temp_dir_; |
| 24 }; | 22 }; |
| 25 }; | 23 }; |
| 26 | 24 |
| 27 TEST_F(CreateDirWorkItemTest, CreatePath) { | 25 TEST_F(CreateDirWorkItemTest, CreatePath) { |
| 28 base::FilePath parent_dir(temp_dir_.path()); | 26 base::FilePath parent_dir(temp_dir_.path()); |
| 29 parent_dir = parent_dir.AppendASCII("a"); | 27 parent_dir = parent_dir.AppendASCII("a"); |
| 30 base::CreateDirectory(parent_dir); | 28 base::CreateDirectory(parent_dir); |
| 31 ASSERT_TRUE(base::PathExists(parent_dir)); | 29 ASSERT_TRUE(base::PathExists(parent_dir)); |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 | 121 |
| 124 RemoveDirectory(dir_to_create_3.value().c_str()); | 122 RemoveDirectory(dir_to_create_3.value().c_str()); |
| 125 ASSERT_FALSE(base::PathExists(dir_to_create_3)); | 123 ASSERT_FALSE(base::PathExists(dir_to_create_3)); |
| 126 | 124 |
| 127 work_item->Rollback(); | 125 work_item->Rollback(); |
| 128 | 126 |
| 129 // dir_to_create_3 has already been deleted, Rollback should delete | 127 // dir_to_create_3 has already been deleted, Rollback should delete |
| 130 // the rest. | 128 // the rest. |
| 131 EXPECT_FALSE(base::PathExists(dir_to_create_1)); | 129 EXPECT_FALSE(base::PathExists(dir_to_create_1)); |
| 132 } | 130 } |
| OLD | NEW |