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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
9 #include "base/platform_file.h" | 9 #include "base/platform_file.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 TEST(ScopedTempDir, TempDir) { | 48 TEST(ScopedTempDir, TempDir) { |
49 // In this case, just verify that a directory was created and that it's a | 49 // In this case, just verify that a directory was created and that it's a |
50 // child of TempDir. | 50 // child of TempDir. |
51 FilePath test_path; | 51 FilePath test_path; |
52 { | 52 { |
53 ScopedTempDir dir; | 53 ScopedTempDir dir; |
54 EXPECT_TRUE(dir.CreateUniqueTempDir()); | 54 EXPECT_TRUE(dir.CreateUniqueTempDir()); |
55 test_path = dir.path(); | 55 test_path = dir.path(); |
56 EXPECT_TRUE(DirectoryExists(test_path)); | 56 EXPECT_TRUE(DirectoryExists(test_path)); |
57 FilePath tmp_dir; | 57 FilePath tmp_dir; |
58 EXPECT_TRUE(file_util::GetTempDir(&tmp_dir)); | 58 EXPECT_TRUE(base::GetTempDir(&tmp_dir)); |
59 EXPECT_TRUE(test_path.value().find(tmp_dir.value()) != std::string::npos); | 59 EXPECT_TRUE(test_path.value().find(tmp_dir.value()) != std::string::npos); |
60 } | 60 } |
61 EXPECT_FALSE(DirectoryExists(test_path)); | 61 EXPECT_FALSE(DirectoryExists(test_path)); |
62 } | 62 } |
63 | 63 |
64 TEST(ScopedTempDir, UniqueTempDirUnderPath) { | 64 TEST(ScopedTempDir, UniqueTempDirUnderPath) { |
65 // Create a path which will contain a unique temp path. | 65 // Create a path which will contain a unique temp path. |
66 FilePath base_path; | 66 FilePath base_path; |
67 ASSERT_TRUE(file_util::CreateNewTempDirectory(FILE_PATH_LITERAL("base_dir"), | 67 ASSERT_TRUE(file_util::CreateNewTempDirectory(FILE_PATH_LITERAL("base_dir"), |
68 &base_path)); | 68 &base_path)); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 EXPECT_EQ(base::PLATFORM_FILE_OK, error_code); | 108 EXPECT_EQ(base::PLATFORM_FILE_OK, error_code); |
109 EXPECT_FALSE(dir.Delete()); // We should not be able to delete. | 109 EXPECT_FALSE(dir.Delete()); // We should not be able to delete. |
110 EXPECT_FALSE(dir.path().empty()); // We should still have a valid path. | 110 EXPECT_FALSE(dir.path().empty()); // We should still have a valid path. |
111 EXPECT_TRUE(base::ClosePlatformFile(file)); | 111 EXPECT_TRUE(base::ClosePlatformFile(file)); |
112 // Now, we should be able to delete. | 112 // Now, we should be able to delete. |
113 EXPECT_TRUE(dir.Delete()); | 113 EXPECT_TRUE(dir.Delete()); |
114 } | 114 } |
115 #endif // defined(OS_WIN) | 115 #endif // defined(OS_WIN) |
116 | 116 |
117 } // namespace base | 117 } // namespace base |
OLD | NEW |