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

Side by Side Diff: base/files/scoped_temp_dir_unittest.cc

Issue 16950028: Move file_util::Delete to the base namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 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
« no previous file with comments | « base/files/scoped_temp_dir.cc ('k') | base/json/json_value_serializer_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 FilePath test_path; 70 FilePath test_path;
71 { 71 {
72 ScopedTempDir dir; 72 ScopedTempDir dir;
73 EXPECT_TRUE(dir.CreateUniqueTempDirUnderPath(base_path)); 73 EXPECT_TRUE(dir.CreateUniqueTempDirUnderPath(base_path));
74 test_path = dir.path(); 74 test_path = dir.path();
75 EXPECT_TRUE(file_util::DirectoryExists(test_path)); 75 EXPECT_TRUE(file_util::DirectoryExists(test_path));
76 EXPECT_TRUE(base_path.IsParent(test_path)); 76 EXPECT_TRUE(base_path.IsParent(test_path));
77 EXPECT_TRUE(test_path.value().find(base_path.value()) != std::string::npos); 77 EXPECT_TRUE(test_path.value().find(base_path.value()) != std::string::npos);
78 } 78 }
79 EXPECT_FALSE(file_util::DirectoryExists(test_path)); 79 EXPECT_FALSE(file_util::DirectoryExists(test_path));
80 file_util::Delete(base_path, true); 80 base::Delete(base_path, true);
81 } 81 }
82 82
83 TEST(ScopedTempDir, MultipleInvocations) { 83 TEST(ScopedTempDir, MultipleInvocations) {
84 ScopedTempDir dir; 84 ScopedTempDir dir;
85 EXPECT_TRUE(dir.CreateUniqueTempDir()); 85 EXPECT_TRUE(dir.CreateUniqueTempDir());
86 EXPECT_FALSE(dir.CreateUniqueTempDir()); 86 EXPECT_FALSE(dir.CreateUniqueTempDir());
87 EXPECT_TRUE(dir.Delete()); 87 EXPECT_TRUE(dir.Delete());
88 EXPECT_TRUE(dir.CreateUniqueTempDir()); 88 EXPECT_TRUE(dir.CreateUniqueTempDir());
89 EXPECT_FALSE(dir.CreateUniqueTempDir()); 89 EXPECT_FALSE(dir.CreateUniqueTempDir());
90 ScopedTempDir other_dir; 90 ScopedTempDir other_dir;
(...skipping 17 matching lines...) Expand all
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
OLDNEW
« no previous file with comments | « base/files/scoped_temp_dir.cc ('k') | base/json/json_value_serializer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698