| 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 "webkit/fileapi/file_system_operation.h" | 5 #include "webkit/fileapi/file_system_operation.h" |
| 6 | 6 |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 return FilePath().AppendASCII(str); | 147 return FilePath().AppendASCII(str); |
| 148 } | 148 } |
| 149 | 149 |
| 150 } // namespace (anonymous) | 150 } // namespace (anonymous) |
| 151 | 151 |
| 152 // Test class for FileSystemOperation. Note that this just tests low-level | 152 // Test class for FileSystemOperation. Note that this just tests low-level |
| 153 // operations but doesn't test OpenFileSystem. | 153 // operations but doesn't test OpenFileSystem. |
| 154 class FileSystemOperationTest : public testing::Test { | 154 class FileSystemOperationTest : public testing::Test { |
| 155 public: | 155 public: |
| 156 FileSystemOperationTest() | 156 FileSystemOperationTest() |
| 157 : status_(kFileOperationStatusNotSet) { | 157 : status_(kFileOperationStatusNotSet), |
| 158 local_file_util_( |
| 159 new LocalFileSystemFileUtil(QuotaFileUtil::GetInstance())) { |
| 158 EXPECT_TRUE(base_.CreateUniqueTempDir()); | 160 EXPECT_TRUE(base_.CreateUniqueTempDir()); |
| 159 } | 161 } |
| 160 | 162 |
| 161 FileSystemOperation* operation(); | 163 FileSystemOperation* operation(); |
| 162 | 164 |
| 163 void set_status(int status) { status_ = status; } | 165 void set_status(int status) { status_ = status; } |
| 164 int status() const { return status_; } | 166 int status() const { return status_; } |
| 165 void set_info(const base::PlatformFileInfo& info) { info_ = info; } | 167 void set_info(const base::PlatformFileInfo& info) { info_ = info; } |
| 166 const base::PlatformFileInfo& info() const { return info_; } | 168 const base::PlatformFileInfo& info() const { return info_; } |
| 167 void set_path(const FilePath& path) { path_ = path; } | 169 void set_path(const FilePath& path) { path_ = path; } |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 | 243 |
| 242 FileSystemTestOriginHelper test_helper_; | 244 FileSystemTestOriginHelper test_helper_; |
| 243 | 245 |
| 244 // For post-operation status. | 246 // For post-operation status. |
| 245 int status_; | 247 int status_; |
| 246 base::PlatformFileInfo info_; | 248 base::PlatformFileInfo info_; |
| 247 FilePath path_; | 249 FilePath path_; |
| 248 std::vector<base::FileUtilProxy::Entry> entries_; | 250 std::vector<base::FileUtilProxy::Entry> entries_; |
| 249 | 251 |
| 250 private: | 252 private: |
| 253 scoped_ptr<LocalFileSystemFileUtil> local_file_util_; |
| 251 scoped_refptr<QuotaManager> quota_manager_; | 254 scoped_refptr<QuotaManager> quota_manager_; |
| 252 scoped_refptr<QuotaManagerProxy> quota_manager_proxy_; | 255 scoped_refptr<QuotaManagerProxy> quota_manager_proxy_; |
| 253 DISALLOW_COPY_AND_ASSIGN(FileSystemOperationTest); | 256 DISALLOW_COPY_AND_ASSIGN(FileSystemOperationTest); |
| 254 }; | 257 }; |
| 255 | 258 |
| 256 namespace { | 259 namespace { |
| 257 | 260 |
| 258 class MockDispatcher : public FileSystemCallbackDispatcher { | 261 class MockDispatcher : public FileSystemCallbackDispatcher { |
| 259 public: | 262 public: |
| 260 explicit MockDispatcher(FileSystemOperationTest* test) : test_(test) { } | 263 explicit MockDispatcher(FileSystemOperationTest* test) : test_(test) { } |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 | 300 |
| 298 void FileSystemOperationTest::SetUp() { | 301 void FileSystemOperationTest::SetUp() { |
| 299 FilePath base_dir = base_.path().AppendASCII("filesystem"); | 302 FilePath base_dir = base_.path().AppendASCII("filesystem"); |
| 300 quota_manager_ = new MockQuotaManager( | 303 quota_manager_ = new MockQuotaManager( |
| 301 base_dir, test_helper_.origin(), test_helper_.storage_type()); | 304 base_dir, test_helper_.origin(), test_helper_.storage_type()); |
| 302 quota_manager_proxy_ = new MockQuotaManagerProxy(quota_manager_.get()); | 305 quota_manager_proxy_ = new MockQuotaManagerProxy(quota_manager_.get()); |
| 303 test_helper_.SetUp(base_dir, | 306 test_helper_.SetUp(base_dir, |
| 304 false /* incognito */, | 307 false /* incognito */, |
| 305 false /* unlimited quota */, | 308 false /* unlimited quota */, |
| 306 quota_manager_proxy_.get(), | 309 quota_manager_proxy_.get(), |
| 307 LocalFileSystemFileUtil::GetInstance()); | 310 local_file_util_.get()); |
| 308 } | 311 } |
| 309 | 312 |
| 310 void FileSystemOperationTest::TearDown() { | 313 void FileSystemOperationTest::TearDown() { |
| 311 // Let the client go away before dropping a ref of the quota manager proxy. | 314 // Let the client go away before dropping a ref of the quota manager proxy. |
| 312 quota_manager_proxy()->SimulateQuotaManagerDestroyed(); | 315 quota_manager_proxy()->SimulateQuotaManagerDestroyed(); |
| 313 quota_manager_ = NULL; | 316 quota_manager_ = NULL; |
| 314 quota_manager_proxy_ = NULL; | 317 quota_manager_proxy_ = NULL; |
| 315 test_helper_.TearDown(); | 318 test_helper_.TearDown(); |
| 316 } | 319 } |
| 317 | 320 |
| (...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 947 | 950 |
| 948 operation()->Truncate(URLForPath(file_path), 11); | 951 operation()->Truncate(URLForPath(file_path), 11); |
| 949 MessageLoop::current()->RunAllPending(); | 952 MessageLoop::current()->RunAllPending(); |
| 950 EXPECT_EQ(base::PLATFORM_FILE_ERROR_NO_SPACE, status()); | 953 EXPECT_EQ(base::PLATFORM_FILE_ERROR_NO_SPACE, status()); |
| 951 | 954 |
| 952 EXPECT_TRUE(file_util::GetFileInfo(PlatformPath(file_path), &info)); | 955 EXPECT_TRUE(file_util::GetFileInfo(PlatformPath(file_path), &info)); |
| 953 EXPECT_EQ(10, info.size); | 956 EXPECT_EQ(10, info.size); |
| 954 } | 957 } |
| 955 | 958 |
| 956 } // namespace fileapi | 959 } // namespace fileapi |
| OLD | NEW |