OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 | 50 |
51 virtual void GetUsageAndQuota( | 51 virtual void GetUsageAndQuota( |
52 const GURL& origin, quota::StorageType type, | 52 const GURL& origin, quota::StorageType type, |
53 const GetUsageAndQuotaCallback& callback) OVERRIDE { | 53 const GetUsageAndQuotaCallback& callback) OVERRIDE { |
54 callback.Run(quota::kQuotaStatusOk, usage_, quota_); | 54 callback.Run(quota::kQuotaStatusOk, usage_, quota_); |
55 } | 55 } |
56 | 56 |
57 void set_usage(int64 usage) { usage_ = usage; } | 57 void set_usage(int64 usage) { usage_ = usage; } |
58 void set_quota(int64 quota) { quota_ = quota; } | 58 void set_quota(int64 quota) { quota_ = quota; } |
59 | 59 |
| 60 protected: |
| 61 virtual ~MockQuotaManager() {} |
| 62 |
60 private: | 63 private: |
61 int64 usage_; | 64 int64 usage_; |
62 int64 quota_; | 65 int64 quota_; |
63 }; | 66 }; |
64 | 67 |
65 } // namespace (anonymous) | 68 } // namespace |
66 | 69 |
67 class FileSystemOperationWriteTest | 70 class FileSystemOperationWriteTest |
68 : public testing::Test, | 71 : public testing::Test, |
69 public base::SupportsWeakPtr<FileSystemOperationWriteTest> { | 72 public base::SupportsWeakPtr<FileSystemOperationWriteTest> { |
70 public: | 73 public: |
71 FileSystemOperationWriteTest() | 74 FileSystemOperationWriteTest() |
72 : local_file_util_(new LocalFileUtil(QuotaFileUtil::CreateDefault())), | 75 : local_file_util_(new LocalFileUtil(QuotaFileUtil::CreateDefault())), |
73 loop_(MessageLoop::TYPE_IO), | 76 loop_(MessageLoop::TYPE_IO), |
74 status_(base::PLATFORM_FILE_OK), | 77 status_(base::PLATFORM_FILE_OK), |
75 cancel_status_(base::PLATFORM_FILE_ERROR_FAILED), | 78 cancel_status_(base::PLATFORM_FILE_ERROR_FAILED), |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 DISALLOW_COPY_AND_ASSIGN(FileSystemOperationWriteTest); | 147 DISALLOW_COPY_AND_ASSIGN(FileSystemOperationWriteTest); |
145 }; | 148 }; |
146 | 149 |
147 namespace { | 150 namespace { |
148 | 151 |
149 class TestURLRequestContext : public net::URLRequestContext { | 152 class TestURLRequestContext : public net::URLRequestContext { |
150 public: | 153 public: |
151 TestURLRequestContext() | 154 TestURLRequestContext() |
152 : blob_storage_controller_(new webkit_blob::BlobStorageController) {} | 155 : blob_storage_controller_(new webkit_blob::BlobStorageController) {} |
153 | 156 |
154 virtual ~TestURLRequestContext() {} | |
155 | |
156 webkit_blob::BlobStorageController* blob_storage_controller() const { | 157 webkit_blob::BlobStorageController* blob_storage_controller() const { |
157 return blob_storage_controller_.get(); | 158 return blob_storage_controller_.get(); |
158 } | 159 } |
159 | 160 |
| 161 protected: |
| 162 virtual ~TestURLRequestContext() {} |
| 163 |
160 private: | 164 private: |
161 scoped_ptr<webkit_blob::BlobStorageController> blob_storage_controller_; | 165 scoped_ptr<webkit_blob::BlobStorageController> blob_storage_controller_; |
162 }; | 166 }; |
163 | 167 |
164 static net::URLRequestJob* BlobURLRequestJobFactory(net::URLRequest* request, | 168 static net::URLRequestJob* BlobURLRequestJobFactory(net::URLRequest* request, |
165 const std::string& scheme) { | 169 const std::string& scheme) { |
166 webkit_blob::BlobStorageController* blob_storage_controller = | 170 webkit_blob::BlobStorageController* blob_storage_controller = |
167 static_cast<const TestURLRequestContext*>(request->context())-> | 171 static_cast<const TestURLRequestContext*>(request->context())-> |
168 blob_storage_controller(); | 172 blob_storage_controller(); |
169 return new webkit_blob::BlobURLRequestJob( | 173 return new webkit_blob::BlobURLRequestJob( |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 // so nothing should have happen. | 387 // so nothing should have happen. |
384 EXPECT_EQ(0, bytes_written()); | 388 EXPECT_EQ(0, bytes_written()); |
385 EXPECT_EQ(base::PLATFORM_FILE_ERROR_ABORT, status()); | 389 EXPECT_EQ(base::PLATFORM_FILE_ERROR_ABORT, status()); |
386 EXPECT_EQ(base::PLATFORM_FILE_OK, cancel_status()); | 390 EXPECT_EQ(base::PLATFORM_FILE_OK, cancel_status()); |
387 EXPECT_TRUE(complete()); | 391 EXPECT_TRUE(complete()); |
388 } | 392 } |
389 | 393 |
390 // TODO(ericu,dmikurube): Add more tests for Cancel. | 394 // TODO(ericu,dmikurube): Add more tests for Cancel. |
391 | 395 |
392 } // namespace fileapi | 396 } // namespace fileapi |
OLD | NEW |