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

Side by Side Diff: content/browser/fileapi/transient_file_util_unittest.cc

Issue 145303002: Convert Media Galleries to use base::File (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 10 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/file_util.h" 6 #include "base/file_util.h"
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/files/scoped_temp_dir.h" 8 #include "base/files/scoped_temp_dir.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/platform_file.h" 10 #include "base/platform_file.h"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 76
77 DISALLOW_COPY_AND_ASSIGN(TransientFileUtilTest); 77 DISALLOW_COPY_AND_ASSIGN(TransientFileUtilTest);
78 }; 78 };
79 79
80 TEST_F(TransientFileUtilTest, TransientFile) { 80 TEST_F(TransientFileUtilTest, TransientFile) {
81 FileSystemURL temp_url; 81 FileSystemURL temp_url;
82 base::FilePath temp_path; 82 base::FilePath temp_path;
83 83
84 CreateAndRegisterTemporaryFile(&temp_url, &temp_path); 84 CreateAndRegisterTemporaryFile(&temp_url, &temp_path);
85 85
86 base::PlatformFileError error; 86 base::File::Error error;
87 base::PlatformFileInfo file_info; 87 base::File::Info file_info;
88 base::FilePath path; 88 base::FilePath path;
89 89
90 // Make sure the file is there. 90 // Make sure the file is there.
91 ASSERT_TRUE(temp_url.is_valid()); 91 ASSERT_TRUE(temp_url.is_valid());
92 ASSERT_TRUE(base::PathExists(temp_path)); 92 ASSERT_TRUE(base::PathExists(temp_path));
93 ASSERT_FALSE(base::DirectoryExists(temp_path)); 93 ASSERT_FALSE(base::DirectoryExists(temp_path));
94 94
95 // Create a snapshot file. 95 // Create a snapshot file.
96 { 96 {
97 webkit_blob::ScopedFile scoped_file = 97 webkit_blob::ScopedFile scoped_file =
98 file_util()->CreateSnapshotFile(NewOperationContext().get(), 98 file_util()->CreateSnapshotFile(NewOperationContext().get(),
99 temp_url, 99 temp_url,
100 &error, 100 &error,
101 &file_info, 101 &file_info,
102 &path); 102 &path);
103 ASSERT_EQ(base::PLATFORM_FILE_OK, error); 103 ASSERT_EQ(base::File::FILE_OK, error);
104 ASSERT_EQ(temp_path, path); 104 ASSERT_EQ(temp_path, path);
105 ASSERT_FALSE(file_info.is_directory); 105 ASSERT_FALSE(file_info.is_directory);
106 106
107 // The file should be still there. 107 // The file should be still there.
108 ASSERT_TRUE(base::PathExists(temp_path)); 108 ASSERT_TRUE(base::PathExists(temp_path));
109 ASSERT_EQ(base::PLATFORM_FILE_OK, 109 ASSERT_EQ(base::File::FILE_OK,
110 file_util()->GetFileInfo(NewOperationContext().get(), 110 file_util()->GetFileInfo(NewOperationContext().get(),
111 temp_url, &file_info, &path)); 111 temp_url, &file_info, &path));
112 ASSERT_EQ(temp_path, path); 112 ASSERT_EQ(temp_path, path);
113 ASSERT_FALSE(file_info.is_directory); 113 ASSERT_FALSE(file_info.is_directory);
114 } 114 }
115 115
116 // The file's now scoped out. 116 // The file's now scoped out.
117 base::RunLoop().RunUntilIdle(); 117 base::RunLoop().RunUntilIdle();
118 118
119 // Now the temporary file and the transient filesystem must be gone too. 119 // Now the temporary file and the transient filesystem must be gone too.
120 ASSERT_FALSE(base::PathExists(temp_path)); 120 ASSERT_FALSE(base::PathExists(temp_path));
121 ASSERT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND, 121 ASSERT_EQ(base::File::FILE_ERROR_NOT_FOUND,
122 file_util()->GetFileInfo(NewOperationContext().get(), 122 file_util()->GetFileInfo(NewOperationContext().get(),
123 temp_url, &file_info, &path)); 123 temp_url, &file_info, &path));
124 } 124 }
125 125
126 } // namespace content 126 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698