OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/chromeos/file_system_provider/fileapi/provider_async_fi
le_util.h" | 5 #include "chrome/browser/chromeos/file_system_provider/fileapi/provider_async_fi
le_util.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
| 9 #include <memory> |
9 #include <string> | 10 #include <string> |
10 #include <vector> | 11 #include <vector> |
11 | 12 |
12 #include "base/files/file.h" | 13 #include "base/files/file.h" |
13 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
14 #include "base/files/scoped_temp_dir.h" | 15 #include "base/files/scoped_temp_dir.h" |
15 #include "base/macros.h" | 16 #include "base/macros.h" |
16 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/ptr_util.h" |
17 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
18 #include "base/run_loop.h" | 19 #include "base/run_loop.h" |
19 #include "chrome/browser/chromeos/file_system_provider/fake_provided_file_system
.h" | 20 #include "chrome/browser/chromeos/file_system_provider/fake_provided_file_system
.h" |
20 #include "chrome/browser/chromeos/file_system_provider/service.h" | 21 #include "chrome/browser/chromeos/file_system_provider/service.h" |
21 #include "chrome/browser/chromeos/file_system_provider/service_factory.h" | 22 #include "chrome/browser/chromeos/file_system_provider/service_factory.h" |
22 #include "chrome/test/base/testing_browser_process.h" | 23 #include "chrome/test/base/testing_browser_process.h" |
23 #include "chrome/test/base/testing_profile.h" | 24 #include "chrome/test/base/testing_profile.h" |
24 #include "chrome/test/base/testing_profile_manager.h" | 25 #include "chrome/test/base/testing_profile_manager.h" |
25 #include "content/public/test/test_browser_thread_bundle.h" | 26 #include "content/public/test/test_browser_thread_bundle.h" |
26 #include "content/public/test/test_file_system_context.h" | 27 #include "content/public/test/test_file_system_context.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 const base::FilePath& platform_path, | 81 const base::FilePath& platform_path, |
81 const scoped_refptr<storage::ShareableFileReference>& file_ref) { | 82 const scoped_refptr<storage::ShareableFileReference>& file_ref) { |
82 result_.reset(new base::File::Error(error)); | 83 result_.reset(new base::File::Error(error)); |
83 } | 84 } |
84 | 85 |
85 void OnCopyFileProgress(int64_t size) {} | 86 void OnCopyFileProgress(int64_t size) {} |
86 | 87 |
87 base::File::Error* result() { return result_.get(); } | 88 base::File::Error* result() { return result_.get(); } |
88 | 89 |
89 private: | 90 private: |
90 scoped_ptr<base::File::Error> result_; | 91 std::unique_ptr<base::File::Error> result_; |
91 DISALLOW_COPY_AND_ASSIGN(EventLogger); | 92 DISALLOW_COPY_AND_ASSIGN(EventLogger); |
92 }; | 93 }; |
93 | 94 |
94 // Creates a cracked FileSystemURL for tests. | 95 // Creates a cracked FileSystemURL for tests. |
95 storage::FileSystemURL CreateFileSystemURL(const std::string& mount_point_name, | 96 storage::FileSystemURL CreateFileSystemURL(const std::string& mount_point_name, |
96 const base::FilePath& file_path) { | 97 const base::FilePath& file_path) { |
97 const std::string origin = std::string("chrome-extension://") + kExtensionId; | 98 const std::string origin = std::string("chrome-extension://") + kExtensionId; |
98 const storage::ExternalMountPoints* const mount_points = | 99 const storage::ExternalMountPoints* const mount_points = |
99 storage::ExternalMountPoints::GetSystemInstance(); | 100 storage::ExternalMountPoints::GetSystemInstance(); |
100 return mount_points->CreateCrackedFileSystemURL( | 101 return mount_points->CreateCrackedFileSystemURL( |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 mount_point_name, | 144 mount_point_name, |
144 base::FilePath(kFakeFilePath + 1 /* No leading slash. */)); | 145 base::FilePath(kFakeFilePath + 1 /* No leading slash. */)); |
145 ASSERT_TRUE(file_url_.is_valid()); | 146 ASSERT_TRUE(file_url_.is_valid()); |
146 directory_url_ = CreateFileSystemURL( | 147 directory_url_ = CreateFileSystemURL( |
147 mount_point_name, base::FilePath(FILE_PATH_LITERAL("hello"))); | 148 mount_point_name, base::FilePath(FILE_PATH_LITERAL("hello"))); |
148 ASSERT_TRUE(directory_url_.is_valid()); | 149 ASSERT_TRUE(directory_url_.is_valid()); |
149 root_url_ = CreateFileSystemURL(mount_point_name, base::FilePath()); | 150 root_url_ = CreateFileSystemURL(mount_point_name, base::FilePath()); |
150 ASSERT_TRUE(root_url_.is_valid()); | 151 ASSERT_TRUE(root_url_.is_valid()); |
151 } | 152 } |
152 | 153 |
153 scoped_ptr<storage::FileSystemOperationContext> CreateOperationContext() { | 154 std::unique_ptr<storage::FileSystemOperationContext> |
154 return make_scoped_ptr( | 155 CreateOperationContext() { |
| 156 return base::WrapUnique( |
155 new storage::FileSystemOperationContext(file_system_context_.get())); | 157 new storage::FileSystemOperationContext(file_system_context_.get())); |
156 } | 158 } |
157 | 159 |
158 content::TestBrowserThreadBundle thread_bundle_; | 160 content::TestBrowserThreadBundle thread_bundle_; |
159 base::ScopedTempDir data_dir_; | 161 base::ScopedTempDir data_dir_; |
160 scoped_ptr<TestingProfileManager> profile_manager_; | 162 std::unique_ptr<TestingProfileManager> profile_manager_; |
161 TestingProfile* profile_; // Owned by TestingProfileManager. | 163 TestingProfile* profile_; // Owned by TestingProfileManager. |
162 scoped_ptr<storage::AsyncFileUtil> async_file_util_; | 164 std::unique_ptr<storage::AsyncFileUtil> async_file_util_; |
163 scoped_refptr<storage::FileSystemContext> file_system_context_; | 165 scoped_refptr<storage::FileSystemContext> file_system_context_; |
164 storage::FileSystemURL file_url_; | 166 storage::FileSystemURL file_url_; |
165 storage::FileSystemURL directory_url_; | 167 storage::FileSystemURL directory_url_; |
166 storage::FileSystemURL root_url_; | 168 storage::FileSystemURL root_url_; |
167 }; | 169 }; |
168 | 170 |
169 TEST_F(FileSystemProviderProviderAsyncFileUtilTest, CreateOrOpen_Create) { | 171 TEST_F(FileSystemProviderProviderAsyncFileUtilTest, CreateOrOpen_Create) { |
170 EventLogger logger; | 172 EventLogger logger; |
171 | 173 |
172 async_file_util_->CreateOrOpen( | 174 async_file_util_->CreateOrOpen( |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 file_url_, | 409 file_url_, |
408 base::Bind(&EventLogger::OnCreateSnapshotFile, | 410 base::Bind(&EventLogger::OnCreateSnapshotFile, |
409 base::Unretained(&logger))); | 411 base::Unretained(&logger))); |
410 | 412 |
411 ASSERT_TRUE(logger.result()); | 413 ASSERT_TRUE(logger.result()); |
412 EXPECT_EQ(base::File::FILE_ERROR_INVALID_OPERATION, *logger.result()); | 414 EXPECT_EQ(base::File::FILE_ERROR_INVALID_OPERATION, *logger.result()); |
413 } | 415 } |
414 | 416 |
415 } // namespace file_system_provider | 417 } // namespace file_system_provider |
416 } // namespace chromeos | 418 } // namespace chromeos |
OLD | NEW |