| 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 // NOTE: These tests are run as part of "unit_tests" (in chrome/test/unit) | 5 // NOTE: These tests are run as part of "unit_tests" (in chrome/test/unit) |
| 6 // rather than as part of test_shell_tests because they rely on being able | 6 // rather than as part of test_shell_tests because they rely on being able |
| 7 // to instantiate a MessageLoop of type TYPE_IO. test_shell_tests uses | 7 // to instantiate a MessageLoop of type TYPE_IO. test_shell_tests uses |
| 8 // TYPE_UI, which URLRequest doesn't allow. | 8 // TYPE_UI, which URLRequest doesn't allow. |
| 9 // | 9 // |
| 10 | 10 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #include "webkit/blob/blob_storage_controller.h" | 22 #include "webkit/blob/blob_storage_controller.h" |
| 23 #include "webkit/blob/blob_url_request_job.h" | 23 #include "webkit/blob/blob_url_request_job.h" |
| 24 #include "webkit/fileapi/file_system_callback_dispatcher.h" | 24 #include "webkit/fileapi/file_system_callback_dispatcher.h" |
| 25 #include "webkit/fileapi/file_system_context.h" | 25 #include "webkit/fileapi/file_system_context.h" |
| 26 #include "webkit/fileapi/file_system_file_util.h" | 26 #include "webkit/fileapi/file_system_file_util.h" |
| 27 #include "webkit/fileapi/file_system_operation.h" | 27 #include "webkit/fileapi/file_system_operation.h" |
| 28 #include "webkit/fileapi/file_system_path_manager.h" | 28 #include "webkit/fileapi/file_system_path_manager.h" |
| 29 #include "webkit/fileapi/file_system_test_helper.h" | 29 #include "webkit/fileapi/file_system_test_helper.h" |
| 30 #include "webkit/fileapi/file_system_util.h" | 30 #include "webkit/fileapi/file_system_util.h" |
| 31 #include "webkit/fileapi/local_file_system_file_util.h" | 31 #include "webkit/fileapi/local_file_system_file_util.h" |
| 32 #include "webkit/fileapi/quota_file_util.h" |
| 32 #include "webkit/quota/quota_manager.h" | 33 #include "webkit/quota/quota_manager.h" |
| 33 | 34 |
| 34 using quota::QuotaManager; | 35 using quota::QuotaManager; |
| 35 | 36 |
| 36 namespace fileapi { | 37 namespace fileapi { |
| 37 | 38 |
| 38 namespace { | 39 namespace { |
| 39 | 40 |
| 40 class MockQuotaManager : public QuotaManager { | 41 class MockQuotaManager : public QuotaManager { |
| 41 public: | 42 public: |
| (...skipping 17 matching lines...) Expand all Loading... |
| 59 private: | 60 private: |
| 60 int64 usage_; | 61 int64 usage_; |
| 61 int64 quota_; | 62 int64 quota_; |
| 62 }; | 63 }; |
| 63 | 64 |
| 64 } // namespace (anonymous) | 65 } // namespace (anonymous) |
| 65 | 66 |
| 66 class FileSystemOperationWriteTest : public testing::Test { | 67 class FileSystemOperationWriteTest : public testing::Test { |
| 67 public: | 68 public: |
| 68 FileSystemOperationWriteTest() | 69 FileSystemOperationWriteTest() |
| 69 : loop_(MessageLoop::TYPE_IO), | 70 : local_file_util_( |
| 71 new LocalFileSystemFileUtil(QuotaFileUtil::GetInstance())), |
| 72 loop_(MessageLoop::TYPE_IO), |
| 70 status_(base::PLATFORM_FILE_OK), | 73 status_(base::PLATFORM_FILE_OK), |
| 71 bytes_written_(0), | 74 bytes_written_(0), |
| 72 complete_(false) {} | 75 complete_(false) {} |
| 73 | 76 |
| 74 FileSystemOperation* operation(); | 77 FileSystemOperation* operation(); |
| 75 | 78 |
| 76 void set_failure_status(base::PlatformFileError status) { | 79 void set_failure_status(base::PlatformFileError status) { |
| 77 EXPECT_FALSE(complete_); | 80 EXPECT_FALSE(complete_); |
| 78 EXPECT_EQ(status_, base::PLATFORM_FILE_OK); | 81 EXPECT_EQ(status_, base::PLATFORM_FILE_OK); |
| 79 EXPECT_NE(status, base::PLATFORM_FILE_OK); | 82 EXPECT_NE(status, base::PLATFORM_FILE_OK); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 90 bool complete() const { return complete_; } | 93 bool complete() const { return complete_; } |
| 91 | 94 |
| 92 virtual void SetUp(); | 95 virtual void SetUp(); |
| 93 virtual void TearDown(); | 96 virtual void TearDown(); |
| 94 | 97 |
| 95 protected: | 98 protected: |
| 96 GURL URLForPath(const FilePath& path) const { | 99 GURL URLForPath(const FilePath& path) const { |
| 97 return test_helper_.GetURLForPath(path); | 100 return test_helper_.GetURLForPath(path); |
| 98 } | 101 } |
| 99 | 102 |
| 103 scoped_ptr<LocalFileSystemFileUtil> local_file_util_; |
| 100 scoped_refptr<MockQuotaManager> quota_manager_; | 104 scoped_refptr<MockQuotaManager> quota_manager_; |
| 101 FileSystemTestOriginHelper test_helper_; | 105 FileSystemTestOriginHelper test_helper_; |
| 102 | 106 |
| 103 MessageLoop loop_; | 107 MessageLoop loop_; |
| 104 | 108 |
| 105 ScopedTempDir dir_; | 109 ScopedTempDir dir_; |
| 106 FilePath filesystem_dir_; | 110 FilePath filesystem_dir_; |
| 107 FilePath file_; | 111 FilePath file_; |
| 108 FilePath virtual_path_; | 112 FilePath virtual_path_; |
| 109 | 113 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 | 185 |
| 182 void FileSystemOperationWriteTest::SetUp() { | 186 void FileSystemOperationWriteTest::SetUp() { |
| 183 ASSERT_TRUE(dir_.CreateUniqueTempDir()); | 187 ASSERT_TRUE(dir_.CreateUniqueTempDir()); |
| 184 FilePath base_dir = dir_.path().AppendASCII("filesystem"); | 188 FilePath base_dir = dir_.path().AppendASCII("filesystem"); |
| 185 | 189 |
| 186 quota_manager_ = new MockQuotaManager(base_dir, 1024); | 190 quota_manager_ = new MockQuotaManager(base_dir, 1024); |
| 187 test_helper_.SetUp(base_dir, | 191 test_helper_.SetUp(base_dir, |
| 188 false /* incognito */, | 192 false /* incognito */, |
| 189 false /* unlimited quota */, | 193 false /* unlimited quota */, |
| 190 quota_manager_->proxy(), | 194 quota_manager_->proxy(), |
| 191 LocalFileSystemFileUtil::GetInstance()); | 195 local_file_util_.get()); |
| 192 filesystem_dir_ = test_helper_.GetOriginRootPath(); | 196 filesystem_dir_ = test_helper_.GetOriginRootPath(); |
| 193 | 197 |
| 194 ASSERT_TRUE(file_util::CreateTemporaryFileInDir(filesystem_dir_, &file_)); | 198 ASSERT_TRUE(file_util::CreateTemporaryFileInDir(filesystem_dir_, &file_)); |
| 195 virtual_path_ = file_.BaseName(); | 199 virtual_path_ = file_.BaseName(); |
| 196 | 200 |
| 197 net::URLRequest::RegisterProtocolFactory("blob", &BlobURLRequestJobFactory); | 201 net::URLRequest::RegisterProtocolFactory("blob", &BlobURLRequestJobFactory); |
| 198 } | 202 } |
| 199 | 203 |
| 200 void FileSystemOperationWriteTest::TearDown() { | 204 void FileSystemOperationWriteTest::TearDown() { |
| 201 net::URLRequest::RegisterProtocolFactory("blob", NULL); | 205 net::URLRequest::RegisterProtocolFactory("blob", NULL); |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 url_request_context->blob_storage_controller()->UnregisterBlobUrl(blob_url); | 333 url_request_context->blob_storage_controller()->UnregisterBlobUrl(blob_url); |
| 330 | 334 |
| 331 EXPECT_EQ(10, bytes_written()); | 335 EXPECT_EQ(10, bytes_written()); |
| 332 EXPECT_EQ(base::PLATFORM_FILE_ERROR_NO_SPACE, status()); | 336 EXPECT_EQ(base::PLATFORM_FILE_ERROR_NO_SPACE, status()); |
| 333 EXPECT_TRUE(complete()); | 337 EXPECT_TRUE(complete()); |
| 334 } | 338 } |
| 335 | 339 |
| 336 // TODO(ericu,dmikurube): Add tests for Cancel. | 340 // TODO(ericu,dmikurube): Add tests for Cancel. |
| 337 | 341 |
| 338 } // namespace fileapi | 342 } // namespace fileapi |
| OLD | NEW |