| 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 |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/memory/weak_ptr.h" | |
| 15 #include "base/message_loop.h" | 14 #include "base/message_loop.h" |
| 16 #include "base/message_loop.h" | 15 #include "base/message_loop.h" |
| 17 #include "base/message_loop_proxy.h" | 16 #include "base/message_loop_proxy.h" |
| 18 #include "base/scoped_temp_dir.h" | 17 #include "base/scoped_temp_dir.h" |
| 19 #include "googleurl/src/gurl.h" | 18 #include "googleurl/src/gurl.h" |
| 20 #include "net/url_request/url_request.h" | 19 #include "net/url_request/url_request.h" |
| 21 #include "net/url_request/url_request_context.h" | 20 #include "net/url_request/url_request_context.h" |
| 22 #include "net/url_request/url_request_job.h" | 21 #include "net/url_request/url_request_job.h" |
| 23 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
| 24 #include "webkit/blob/blob_data.h" | 23 #include "webkit/blob/blob_data.h" |
| 25 #include "webkit/blob/blob_storage_controller.h" | 24 #include "webkit/blob/blob_storage_controller.h" |
| 26 #include "webkit/blob/blob_url_request_job.h" | 25 #include "webkit/blob/blob_url_request_job.h" |
| 26 #include "webkit/fileapi/file_system_callback_dispatcher.h" |
| 27 #include "webkit/fileapi/file_system_context.h" | 27 #include "webkit/fileapi/file_system_context.h" |
| 28 #include "webkit/fileapi/file_system_file_util.h" | 28 #include "webkit/fileapi/file_system_file_util.h" |
| 29 #include "webkit/fileapi/file_system_operation.h" | 29 #include "webkit/fileapi/file_system_operation.h" |
| 30 #include "webkit/fileapi/file_system_test_helper.h" | 30 #include "webkit/fileapi/file_system_test_helper.h" |
| 31 #include "webkit/fileapi/file_system_util.h" | 31 #include "webkit/fileapi/file_system_util.h" |
| 32 #include "webkit/fileapi/local_file_util.h" | 32 #include "webkit/fileapi/local_file_util.h" |
| 33 #include "webkit/fileapi/quota_file_util.h" | 33 #include "webkit/fileapi/quota_file_util.h" |
| 34 #include "webkit/quota/quota_manager.h" | 34 #include "webkit/quota/quota_manager.h" |
| 35 | 35 |
| 36 using quota::QuotaManager; | 36 using quota::QuotaManager; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 58 void set_usage(int64 usage) { usage_ = usage; } | 58 void set_usage(int64 usage) { usage_ = usage; } |
| 59 void set_quota(int64 quota) { quota_ = quota; } | 59 void set_quota(int64 quota) { quota_ = quota; } |
| 60 | 60 |
| 61 private: | 61 private: |
| 62 int64 usage_; | 62 int64 usage_; |
| 63 int64 quota_; | 63 int64 quota_; |
| 64 }; | 64 }; |
| 65 | 65 |
| 66 } // namespace (anonymous) | 66 } // namespace (anonymous) |
| 67 | 67 |
| 68 class FileSystemOperationWriteTest | 68 class FileSystemOperationWriteTest : public testing::Test { |
| 69 : public testing::Test, | |
| 70 public base::SupportsWeakPtr<FileSystemOperationWriteTest> { | |
| 71 public: | 69 public: |
| 72 FileSystemOperationWriteTest() | 70 FileSystemOperationWriteTest() |
| 73 : local_file_util_(new LocalFileUtil(QuotaFileUtil::CreateDefault())), | 71 : local_file_util_(new LocalFileUtil(QuotaFileUtil::CreateDefault())), |
| 74 loop_(MessageLoop::TYPE_IO), | 72 loop_(MessageLoop::TYPE_IO), |
| 75 status_(base::PLATFORM_FILE_OK), | 73 status_(base::PLATFORM_FILE_OK), |
| 76 bytes_written_(0), | 74 bytes_written_(0), |
| 77 complete_(false) {} | 75 complete_(false) {} |
| 78 | 76 |
| 79 FileSystemOperation* operation(); | 77 FileSystemOperation* operation(); |
| 80 | 78 |
| 79 void set_failure_status(base::PlatformFileError status) { |
| 80 EXPECT_FALSE(complete_); |
| 81 EXPECT_EQ(status_, base::PLATFORM_FILE_OK); |
| 82 EXPECT_NE(status, base::PLATFORM_FILE_OK); |
| 83 complete_ = true; |
| 84 status_ = status; |
| 85 } |
| 81 base::PlatformFileError status() const { return status_; } | 86 base::PlatformFileError status() const { return status_; } |
| 82 void add_bytes_written(int64 bytes, bool complete) { | 87 void add_bytes_written(int64 bytes, bool complete) { |
| 83 bytes_written_ += bytes; | 88 bytes_written_ += bytes; |
| 84 EXPECT_FALSE(complete_); | 89 EXPECT_FALSE(complete_); |
| 85 complete_ = complete; | 90 complete_ = complete; |
| 86 } | 91 } |
| 87 int64 bytes_written() const { return bytes_written_; } | 92 int64 bytes_written() const { return bytes_written_; } |
| 88 bool complete() const { return complete_; } | 93 bool complete() const { return complete_; } |
| 89 | 94 |
| 90 virtual void SetUp(); | 95 virtual void SetUp(); |
| 91 virtual void TearDown(); | 96 virtual void TearDown(); |
| 92 | 97 |
| 93 protected: | 98 protected: |
| 94 GURL URLForPath(const FilePath& path) const { | 99 GURL URLForPath(const FilePath& path) const { |
| 95 return test_helper_.GetURLForPath(path); | 100 return test_helper_.GetURLForPath(path); |
| 96 } | 101 } |
| 97 | 102 |
| 98 // Callback function for recording test results. | |
| 99 FileSystemOperationInterface::WriteCallback RecordWriteCallback() { | |
| 100 return base::Bind(&FileSystemOperationWriteTest::DidWrite, AsWeakPtr()); | |
| 101 } | |
| 102 | |
| 103 void DidWrite(base::PlatformFileError status, int64 bytes, bool complete) { | |
| 104 if (status == base::PLATFORM_FILE_OK) { | |
| 105 add_bytes_written(bytes, complete); | |
| 106 if (complete) | |
| 107 MessageLoop::current()->Quit(); | |
| 108 } else { | |
| 109 EXPECT_FALSE(complete_); | |
| 110 EXPECT_EQ(status_, base::PLATFORM_FILE_OK); | |
| 111 complete_ = true; | |
| 112 status_ = status; | |
| 113 MessageLoop::current()->Quit(); | |
| 114 } | |
| 115 } | |
| 116 | |
| 117 scoped_ptr<LocalFileUtil> local_file_util_; | 103 scoped_ptr<LocalFileUtil> local_file_util_; |
| 118 scoped_refptr<MockQuotaManager> quota_manager_; | 104 scoped_refptr<MockQuotaManager> quota_manager_; |
| 119 FileSystemTestOriginHelper test_helper_; | 105 FileSystemTestOriginHelper test_helper_; |
| 120 | 106 |
| 121 MessageLoop loop_; | 107 MessageLoop loop_; |
| 122 | 108 |
| 123 ScopedTempDir dir_; | 109 ScopedTempDir dir_; |
| 124 FilePath filesystem_dir_; | 110 FilePath filesystem_dir_; |
| 125 FilePath file_; | 111 FilePath file_; |
| 126 FilePath virtual_path_; | 112 FilePath virtual_path_; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 154 const std::string& scheme) { | 140 const std::string& scheme) { |
| 155 webkit_blob::BlobStorageController* blob_storage_controller = | 141 webkit_blob::BlobStorageController* blob_storage_controller = |
| 156 static_cast<const TestURLRequestContext*>(request->context())-> | 142 static_cast<const TestURLRequestContext*>(request->context())-> |
| 157 blob_storage_controller(); | 143 blob_storage_controller(); |
| 158 return new webkit_blob::BlobURLRequestJob( | 144 return new webkit_blob::BlobURLRequestJob( |
| 159 request, | 145 request, |
| 160 blob_storage_controller->GetBlobDataFromUrl(request->url()), | 146 blob_storage_controller->GetBlobDataFromUrl(request->url()), |
| 161 base::MessageLoopProxy::current()); | 147 base::MessageLoopProxy::current()); |
| 162 } | 148 } |
| 163 | 149 |
| 150 class MockDispatcher : public FileSystemCallbackDispatcher { |
| 151 public: |
| 152 MockDispatcher(FileSystemOperationWriteTest* test) : test_(test) { } |
| 153 |
| 154 virtual void DidFail(base::PlatformFileError status) { |
| 155 test_->set_failure_status(status); |
| 156 MessageLoop::current()->Quit(); |
| 157 } |
| 158 |
| 159 virtual void DidSucceed() { |
| 160 ADD_FAILURE(); |
| 161 } |
| 162 |
| 163 virtual void DidReadMetadata( |
| 164 const base::PlatformFileInfo& info, |
| 165 const FilePath& platform_path) { |
| 166 ADD_FAILURE(); |
| 167 } |
| 168 |
| 169 virtual void DidReadDirectory( |
| 170 const std::vector<base::FileUtilProxy::Entry>& entries, |
| 171 bool /* has_more */) { |
| 172 ADD_FAILURE(); |
| 173 } |
| 174 |
| 175 virtual void DidOpenFileSystem(const std::string&, const GURL&) { |
| 176 ADD_FAILURE(); |
| 177 } |
| 178 |
| 179 virtual void DidWrite(int64 bytes, bool complete) { |
| 180 test_->add_bytes_written(bytes, complete); |
| 181 if (complete) |
| 182 MessageLoop::current()->Quit(); |
| 183 } |
| 184 |
| 185 private: |
| 186 FileSystemOperationWriteTest* test_; |
| 187 }; |
| 188 |
| 164 } // namespace (anonymous) | 189 } // namespace (anonymous) |
| 165 | 190 |
| 166 void FileSystemOperationWriteTest::SetUp() { | 191 void FileSystemOperationWriteTest::SetUp() { |
| 167 ASSERT_TRUE(dir_.CreateUniqueTempDir()); | 192 ASSERT_TRUE(dir_.CreateUniqueTempDir()); |
| 168 FilePath base_dir = dir_.path().AppendASCII("filesystem"); | 193 FilePath base_dir = dir_.path().AppendASCII("filesystem"); |
| 169 | 194 |
| 170 quota_manager_ = new MockQuotaManager(base_dir, 1024); | 195 quota_manager_ = new MockQuotaManager(base_dir, 1024); |
| 171 test_helper_.SetUp(base_dir, | 196 test_helper_.SetUp(base_dir, |
| 172 false /* unlimited quota */, | 197 false /* unlimited quota */, |
| 173 quota_manager_->proxy(), | 198 quota_manager_->proxy(), |
| 174 local_file_util_.get()); | 199 local_file_util_.get()); |
| 175 filesystem_dir_ = test_helper_.GetOriginRootPath(); | 200 filesystem_dir_ = test_helper_.GetOriginRootPath(); |
| 176 | 201 |
| 177 ASSERT_TRUE(file_util::CreateTemporaryFileInDir(filesystem_dir_, &file_)); | 202 ASSERT_TRUE(file_util::CreateTemporaryFileInDir(filesystem_dir_, &file_)); |
| 178 virtual_path_ = file_.BaseName(); | 203 virtual_path_ = file_.BaseName(); |
| 179 | 204 |
| 180 net::URLRequest::Deprecated::RegisterProtocolFactory( | 205 net::URLRequest::Deprecated::RegisterProtocolFactory( |
| 181 "blob", &BlobURLRequestJobFactory); | 206 "blob", &BlobURLRequestJobFactory); |
| 182 } | 207 } |
| 183 | 208 |
| 184 void FileSystemOperationWriteTest::TearDown() { | 209 void FileSystemOperationWriteTest::TearDown() { |
| 185 net::URLRequest::Deprecated::RegisterProtocolFactory("blob", NULL); | 210 net::URLRequest::Deprecated::RegisterProtocolFactory("blob", NULL); |
| 186 quota_manager_ = NULL; | 211 quota_manager_ = NULL; |
| 187 test_helper_.TearDown(); | 212 test_helper_.TearDown(); |
| 188 } | 213 } |
| 189 | 214 |
| 190 FileSystemOperation* FileSystemOperationWriteTest::operation() { | 215 FileSystemOperation* FileSystemOperationWriteTest::operation() { |
| 191 return test_helper_.NewOperation(); | 216 return test_helper_.NewOperation(new MockDispatcher(this)); |
| 192 } | 217 } |
| 193 | 218 |
| 194 TEST_F(FileSystemOperationWriteTest, TestWriteSuccess) { | 219 TEST_F(FileSystemOperationWriteTest, TestWriteSuccess) { |
| 195 GURL blob_url("blob:success"); | 220 GURL blob_url("blob:success"); |
| 196 scoped_refptr<webkit_blob::BlobData> blob_data(new webkit_blob::BlobData()); | 221 scoped_refptr<webkit_blob::BlobData> blob_data(new webkit_blob::BlobData()); |
| 197 blob_data->AppendData("Hello, world!\n"); | 222 blob_data->AppendData("Hello, world!\n"); |
| 198 | 223 |
| 199 scoped_refptr<TestURLRequestContext> url_request_context( | 224 scoped_refptr<TestURLRequestContext> url_request_context( |
| 200 new TestURLRequestContext()); | 225 new TestURLRequestContext()); |
| 201 url_request_context->blob_storage_controller()->AddFinishedBlob( | 226 url_request_context->blob_storage_controller()->AddFinishedBlob( |
| 202 blob_url, blob_data); | 227 blob_url, blob_data); |
| 203 | 228 |
| 204 operation()->Write(url_request_context, URLForPath(virtual_path_), blob_url, | 229 operation()->Write(url_request_context, URLForPath(virtual_path_), blob_url, |
| 205 0, RecordWriteCallback()); | 230 0); |
| 206 MessageLoop::current()->Run(); | 231 MessageLoop::current()->Run(); |
| 207 | 232 |
| 208 url_request_context->blob_storage_controller()->RemoveBlob(blob_url); | 233 url_request_context->blob_storage_controller()->RemoveBlob(blob_url); |
| 209 | 234 |
| 210 EXPECT_EQ(14, bytes_written()); | 235 EXPECT_EQ(14, bytes_written()); |
| 211 EXPECT_EQ(base::PLATFORM_FILE_OK, status()); | 236 EXPECT_EQ(base::PLATFORM_FILE_OK, status()); |
| 212 EXPECT_TRUE(complete()); | 237 EXPECT_TRUE(complete()); |
| 213 } | 238 } |
| 214 | 239 |
| 215 TEST_F(FileSystemOperationWriteTest, TestWriteZero) { | 240 TEST_F(FileSystemOperationWriteTest, TestWriteZero) { |
| 216 GURL blob_url("blob:zero"); | 241 GURL blob_url("blob:zero"); |
| 217 scoped_refptr<webkit_blob::BlobData> blob_data(new webkit_blob::BlobData()); | 242 scoped_refptr<webkit_blob::BlobData> blob_data(new webkit_blob::BlobData()); |
| 218 blob_data->AppendData(""); | 243 blob_data->AppendData(""); |
| 219 | 244 |
| 220 scoped_refptr<TestURLRequestContext> url_request_context( | 245 scoped_refptr<TestURLRequestContext> url_request_context( |
| 221 new TestURLRequestContext()); | 246 new TestURLRequestContext()); |
| 222 url_request_context->blob_storage_controller()->AddFinishedBlob( | 247 url_request_context->blob_storage_controller()->AddFinishedBlob( |
| 223 blob_url, blob_data); | 248 blob_url, blob_data); |
| 224 | 249 |
| 225 operation()->Write(url_request_context, URLForPath(virtual_path_), | 250 operation()->Write(url_request_context, URLForPath(virtual_path_), |
| 226 blob_url, 0, RecordWriteCallback()); | 251 blob_url, 0); |
| 227 MessageLoop::current()->Run(); | 252 MessageLoop::current()->Run(); |
| 228 | 253 |
| 229 url_request_context->blob_storage_controller()->RemoveBlob(blob_url); | 254 url_request_context->blob_storage_controller()->RemoveBlob(blob_url); |
| 230 | 255 |
| 231 EXPECT_EQ(0, bytes_written()); | 256 EXPECT_EQ(0, bytes_written()); |
| 232 EXPECT_EQ(base::PLATFORM_FILE_OK, status()); | 257 EXPECT_EQ(base::PLATFORM_FILE_OK, status()); |
| 233 EXPECT_TRUE(complete()); | 258 EXPECT_TRUE(complete()); |
| 234 } | 259 } |
| 235 | 260 |
| 236 TEST_F(FileSystemOperationWriteTest, TestWriteInvalidBlobUrl) { | 261 TEST_F(FileSystemOperationWriteTest, TestWriteInvalidBlobUrl) { |
| 237 scoped_refptr<TestURLRequestContext> url_request_context( | 262 scoped_refptr<TestURLRequestContext> url_request_context( |
| 238 new TestURLRequestContext()); | 263 new TestURLRequestContext()); |
| 239 | 264 |
| 240 operation()->Write(url_request_context, URLForPath(virtual_path_), | 265 operation()->Write(url_request_context, URLForPath(virtual_path_), |
| 241 GURL("blob:invalid"), 0, RecordWriteCallback()); | 266 GURL("blob:invalid"), 0); |
| 242 MessageLoop::current()->Run(); | 267 MessageLoop::current()->Run(); |
| 243 | 268 |
| 244 EXPECT_EQ(0, bytes_written()); | 269 EXPECT_EQ(0, bytes_written()); |
| 245 EXPECT_EQ(base::PLATFORM_FILE_ERROR_FAILED, status()); | 270 EXPECT_EQ(base::PLATFORM_FILE_ERROR_FAILED, status()); |
| 246 EXPECT_TRUE(complete()); | 271 EXPECT_TRUE(complete()); |
| 247 } | 272 } |
| 248 | 273 |
| 249 TEST_F(FileSystemOperationWriteTest, TestWriteInvalidFile) { | 274 TEST_F(FileSystemOperationWriteTest, TestWriteInvalidFile) { |
| 250 GURL blob_url("blob:writeinvalidfile"); | 275 GURL blob_url("blob:writeinvalidfile"); |
| 251 scoped_refptr<webkit_blob::BlobData> blob_data(new webkit_blob::BlobData()); | 276 scoped_refptr<webkit_blob::BlobData> blob_data(new webkit_blob::BlobData()); |
| 252 blob_data->AppendData("It\'ll not be written."); | 277 blob_data->AppendData("It\'ll not be written."); |
| 253 | 278 |
| 254 scoped_refptr<TestURLRequestContext> url_request_context( | 279 scoped_refptr<TestURLRequestContext> url_request_context( |
| 255 new TestURLRequestContext()); | 280 new TestURLRequestContext()); |
| 256 url_request_context->blob_storage_controller()->AddFinishedBlob( | 281 url_request_context->blob_storage_controller()->AddFinishedBlob( |
| 257 blob_url, blob_data); | 282 blob_url, blob_data); |
| 258 | 283 |
| 259 operation()->Write(url_request_context, | 284 operation()->Write(url_request_context, |
| 260 URLForPath(FilePath(FILE_PATH_LITERAL("nonexist"))), | 285 URLForPath(FilePath(FILE_PATH_LITERAL("nonexist"))), |
| 261 blob_url, 0, RecordWriteCallback()); | 286 blob_url, 0); |
| 262 MessageLoop::current()->Run(); | 287 MessageLoop::current()->Run(); |
| 263 | 288 |
| 264 url_request_context->blob_storage_controller()->RemoveBlob(blob_url); | 289 url_request_context->blob_storage_controller()->RemoveBlob(blob_url); |
| 265 | 290 |
| 266 EXPECT_EQ(0, bytes_written()); | 291 EXPECT_EQ(0, bytes_written()); |
| 267 EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND, status()); | 292 EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND, status()); |
| 268 EXPECT_TRUE(complete()); | 293 EXPECT_TRUE(complete()); |
| 269 } | 294 } |
| 270 | 295 |
| 271 TEST_F(FileSystemOperationWriteTest, TestWriteDir) { | 296 TEST_F(FileSystemOperationWriteTest, TestWriteDir) { |
| 272 FilePath subdir; | 297 FilePath subdir; |
| 273 ASSERT_TRUE(file_util::CreateTemporaryDirInDir(filesystem_dir_, | 298 ASSERT_TRUE(file_util::CreateTemporaryDirInDir(filesystem_dir_, |
| 274 FILE_PATH_LITERAL("d"), | 299 FILE_PATH_LITERAL("d"), |
| 275 &subdir)); | 300 &subdir)); |
| 276 FilePath virtual_subdir_path = subdir.BaseName(); | 301 FilePath virtual_subdir_path = subdir.BaseName(); |
| 277 | 302 |
| 278 GURL blob_url("blob:writedir"); | 303 GURL blob_url("blob:writedir"); |
| 279 scoped_refptr<webkit_blob::BlobData> blob_data(new webkit_blob::BlobData()); | 304 scoped_refptr<webkit_blob::BlobData> blob_data(new webkit_blob::BlobData()); |
| 280 blob_data->AppendData("It\'ll not be written, too."); | 305 blob_data->AppendData("It\'ll not be written, too."); |
| 281 | 306 |
| 282 scoped_refptr<TestURLRequestContext> url_request_context( | 307 scoped_refptr<TestURLRequestContext> url_request_context( |
| 283 new TestURLRequestContext()); | 308 new TestURLRequestContext()); |
| 284 url_request_context->blob_storage_controller()->AddFinishedBlob( | 309 url_request_context->blob_storage_controller()->AddFinishedBlob( |
| 285 blob_url, blob_data); | 310 blob_url, blob_data); |
| 286 | 311 |
| 287 operation()->Write(url_request_context, URLForPath(virtual_subdir_path), | 312 operation()->Write(url_request_context, URLForPath(virtual_subdir_path), |
| 288 blob_url, 0, RecordWriteCallback()); | 313 blob_url, 0); |
| 289 MessageLoop::current()->Run(); | 314 MessageLoop::current()->Run(); |
| 290 | 315 |
| 291 url_request_context->blob_storage_controller()->RemoveBlob(blob_url); | 316 url_request_context->blob_storage_controller()->RemoveBlob(blob_url); |
| 292 | 317 |
| 293 EXPECT_EQ(0, bytes_written()); | 318 EXPECT_EQ(0, bytes_written()); |
| 294 EXPECT_EQ(base::PLATFORM_FILE_ERROR_ACCESS_DENIED, status()); | 319 EXPECT_EQ(base::PLATFORM_FILE_ERROR_ACCESS_DENIED, status()); |
| 295 EXPECT_TRUE(complete()); | 320 EXPECT_TRUE(complete()); |
| 296 } | 321 } |
| 297 | 322 |
| 298 TEST_F(FileSystemOperationWriteTest, TestWriteFailureByQuota) { | 323 TEST_F(FileSystemOperationWriteTest, TestWriteFailureByQuota) { |
| 299 GURL blob_url("blob:success"); | 324 GURL blob_url("blob:success"); |
| 300 scoped_refptr<webkit_blob::BlobData> blob_data(new webkit_blob::BlobData()); | 325 scoped_refptr<webkit_blob::BlobData> blob_data(new webkit_blob::BlobData()); |
| 301 blob_data->AppendData("Hello, world!\n"); | 326 blob_data->AppendData("Hello, world!\n"); |
| 302 | 327 |
| 303 scoped_refptr<TestURLRequestContext> url_request_context( | 328 scoped_refptr<TestURLRequestContext> url_request_context( |
| 304 new TestURLRequestContext()); | 329 new TestURLRequestContext()); |
| 305 url_request_context->blob_storage_controller()->AddFinishedBlob( | 330 url_request_context->blob_storage_controller()->AddFinishedBlob( |
| 306 blob_url, blob_data); | 331 blob_url, blob_data); |
| 307 | 332 |
| 308 quota_manager_->set_quota(10); | 333 quota_manager_->set_quota(10); |
| 309 operation()->Write(url_request_context, URLForPath(virtual_path_), blob_url, | 334 operation()->Write(url_request_context, URLForPath(virtual_path_), blob_url, |
| 310 0, RecordWriteCallback()); | 335 0); |
| 311 MessageLoop::current()->Run(); | 336 MessageLoop::current()->Run(); |
| 312 | 337 |
| 313 url_request_context->blob_storage_controller()->RemoveBlob(blob_url); | 338 url_request_context->blob_storage_controller()->RemoveBlob(blob_url); |
| 314 | 339 |
| 315 EXPECT_EQ(10, bytes_written()); | 340 EXPECT_EQ(10, bytes_written()); |
| 316 EXPECT_EQ(base::PLATFORM_FILE_ERROR_NO_SPACE, status()); | 341 EXPECT_EQ(base::PLATFORM_FILE_ERROR_NO_SPACE, status()); |
| 317 EXPECT_TRUE(complete()); | 342 EXPECT_TRUE(complete()); |
| 318 } | 343 } |
| 319 | 344 |
| 320 // TODO(ericu,dmikurube): Add tests for Cancel. | 345 // TODO(ericu,dmikurube): Add tests for Cancel. |
| 321 | 346 |
| 322 } // namespace fileapi | 347 } // namespace fileapi |
| OLD | NEW |