OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <stdint.h> |
| 6 |
| 7 #include <limits> |
5 #include <string> | 8 #include <string> |
6 #include <vector> | 9 #include <vector> |
7 | 10 |
8 #include "base/basictypes.h" | |
9 #include "base/bind.h" | 11 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
11 #include "base/files/scoped_temp_dir.h" | 13 #include "base/files/scoped_temp_dir.h" |
12 #include "base/location.h" | 14 #include "base/location.h" |
13 #include "base/run_loop.h" | 15 #include "base/run_loop.h" |
14 #include "base/single_thread_task_runner.h" | 16 #include "base/single_thread_task_runner.h" |
15 #include "base/thread_task_runner_handle.h" | 17 #include "base/thread_task_runner_handle.h" |
16 #include "content/public/test/async_file_test_helper.h" | 18 #include "content/public/test/async_file_test_helper.h" |
17 #include "content/public/test/test_file_system_context.h" | 19 #include "content/public/test/test_file_system_context.h" |
18 #include "net/base/io_buffer.h" | 20 #include "net/base/io_buffer.h" |
(...skipping 26 matching lines...) Expand all Loading... |
45 const int kDataSize = arraysize(kData) - 1; | 47 const int kDataSize = arraysize(kData) - 1; |
46 | 48 |
47 class Result { | 49 class Result { |
48 public: | 50 public: |
49 Result() | 51 Result() |
50 : status_(base::File::FILE_OK), | 52 : status_(base::File::FILE_OK), |
51 bytes_written_(0), | 53 bytes_written_(0), |
52 write_status_(FileWriterDelegate::SUCCESS_IO_PENDING) {} | 54 write_status_(FileWriterDelegate::SUCCESS_IO_PENDING) {} |
53 | 55 |
54 base::File::Error status() const { return status_; } | 56 base::File::Error status() const { return status_; } |
55 int64 bytes_written() const { return bytes_written_; } | 57 int64_t bytes_written() const { return bytes_written_; } |
56 FileWriterDelegate::WriteProgressStatus write_status() const { | 58 FileWriterDelegate::WriteProgressStatus write_status() const { |
57 return write_status_; | 59 return write_status_; |
58 } | 60 } |
59 | 61 |
60 void DidWrite(base::File::Error status, int64 bytes, | 62 void DidWrite(base::File::Error status, |
| 63 int64_t bytes, |
61 FileWriterDelegate::WriteProgressStatus write_status) { | 64 FileWriterDelegate::WriteProgressStatus write_status) { |
62 write_status_ = write_status; | 65 write_status_ = write_status; |
63 if (status == base::File::FILE_OK) { | 66 if (status == base::File::FILE_OK) { |
64 bytes_written_ += bytes; | 67 bytes_written_ += bytes; |
65 if (write_status_ != FileWriterDelegate::SUCCESS_IO_PENDING) | 68 if (write_status_ != FileWriterDelegate::SUCCESS_IO_PENDING) |
66 base::MessageLoop::current()->QuitWhenIdle(); | 69 base::MessageLoop::current()->QuitWhenIdle(); |
67 } else { | 70 } else { |
68 EXPECT_EQ(base::File::FILE_OK, status_); | 71 EXPECT_EQ(base::File::FILE_OK, status_); |
69 status_ = status; | 72 status_ = status; |
70 base::MessageLoop::current()->QuitWhenIdle(); | 73 base::MessageLoop::current()->QuitWhenIdle(); |
71 } | 74 } |
72 } | 75 } |
73 | 76 |
74 private: | 77 private: |
75 // For post-operation status. | 78 // For post-operation status. |
76 base::File::Error status_; | 79 base::File::Error status_; |
77 int64 bytes_written_; | 80 int64_t bytes_written_; |
78 FileWriterDelegate::WriteProgressStatus write_status_; | 81 FileWriterDelegate::WriteProgressStatus write_status_; |
79 }; | 82 }; |
80 | 83 |
81 class BlobURLRequestJobFactory; | 84 class BlobURLRequestJobFactory; |
82 | 85 |
83 } // namespace (anonymous) | 86 } // namespace (anonymous) |
84 | 87 |
85 class FileWriterDelegateTest : public PlatformTest { | 88 class FileWriterDelegateTest : public PlatformTest { |
86 public: | 89 public: |
87 FileWriterDelegateTest() {} | 90 FileWriterDelegateTest() {} |
88 | 91 |
89 protected: | 92 protected: |
90 void SetUp() override; | 93 void SetUp() override; |
91 void TearDown() override; | 94 void TearDown() override; |
92 | 95 |
93 int64 usage() { | 96 int64_t usage() { |
94 return file_system_context_->GetQuotaUtil(kFileSystemType) | 97 return file_system_context_->GetQuotaUtil(kFileSystemType) |
95 ->GetOriginUsageOnFileTaskRunner( | 98 ->GetOriginUsageOnFileTaskRunner( |
96 file_system_context_.get(), kOrigin, kFileSystemType); | 99 file_system_context_.get(), kOrigin, kFileSystemType); |
97 } | 100 } |
98 | 101 |
99 int64 GetFileSizeOnDisk(const char* test_file_path) { | 102 int64_t GetFileSizeOnDisk(const char* test_file_path) { |
100 // There might be in-flight flush/write. | 103 // There might be in-flight flush/write. |
101 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, | 104 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, |
102 base::Bind(&base::DoNothing)); | 105 base::Bind(&base::DoNothing)); |
103 base::RunLoop().RunUntilIdle(); | 106 base::RunLoop().RunUntilIdle(); |
104 | 107 |
105 FileSystemURL url = GetFileSystemURL(test_file_path); | 108 FileSystemURL url = GetFileSystemURL(test_file_path); |
106 base::File::Info file_info; | 109 base::File::Info file_info; |
107 EXPECT_EQ(base::File::FILE_OK, | 110 EXPECT_EQ(base::File::FILE_OK, |
108 AsyncFileTestHelper::GetMetadata( | 111 AsyncFileTestHelper::GetMetadata( |
109 file_system_context_.get(), url, &file_info)); | 112 file_system_context_.get(), url, &file_info)); |
110 return file_info.size; | 113 return file_info.size; |
111 } | 114 } |
112 | 115 |
113 FileSystemURL GetFileSystemURL(const char* file_name) const { | 116 FileSystemURL GetFileSystemURL(const char* file_name) const { |
114 return file_system_context_->CreateCrackedFileSystemURL( | 117 return file_system_context_->CreateCrackedFileSystemURL( |
115 kOrigin, kFileSystemType, base::FilePath().FromUTF8Unsafe(file_name)); | 118 kOrigin, kFileSystemType, base::FilePath().FromUTF8Unsafe(file_name)); |
116 } | 119 } |
117 | 120 |
118 FileWriterDelegate* CreateWriterDelegate( | 121 FileWriterDelegate* CreateWriterDelegate(const char* test_file_path, |
119 const char* test_file_path, | 122 int64_t offset, |
120 int64 offset, | 123 int64_t allowed_growth) { |
121 int64 allowed_growth) { | |
122 storage::SandboxFileStreamWriter* writer = | 124 storage::SandboxFileStreamWriter* writer = |
123 new storage::SandboxFileStreamWriter( | 125 new storage::SandboxFileStreamWriter( |
124 file_system_context_.get(), | 126 file_system_context_.get(), |
125 GetFileSystemURL(test_file_path), | 127 GetFileSystemURL(test_file_path), |
126 offset, | 128 offset, |
127 *file_system_context_->GetUpdateObservers(kFileSystemType)); | 129 *file_system_context_->GetUpdateObservers(kFileSystemType)); |
128 writer->set_default_quota(allowed_growth); | 130 writer->set_default_quota(allowed_growth); |
129 return new FileWriterDelegate(scoped_ptr<storage::FileStreamWriter>(writer), | 131 return new FileWriterDelegate(scoped_ptr<storage::FileStreamWriter>(writer), |
130 storage::FlushPolicy::FLUSH_ON_COMPLETION); | 132 storage::FlushPolicy::FLUSH_ON_COMPLETION); |
131 } | 133 } |
132 | 134 |
133 FileWriterDelegate::DelegateWriteCallback GetWriteCallback(Result* result) { | 135 FileWriterDelegate::DelegateWriteCallback GetWriteCallback(Result* result) { |
134 return base::Bind(&Result::DidWrite, base::Unretained(result)); | 136 return base::Bind(&Result::DidWrite, base::Unretained(result)); |
135 } | 137 } |
136 | 138 |
137 // Creates and sets up a FileWriterDelegate for writing the given |blob_url|, | 139 // Creates and sets up a FileWriterDelegate for writing the given |blob_url|, |
138 // and creates a new FileWriterDelegate for the file. | 140 // and creates a new FileWriterDelegate for the file. |
139 void PrepareForWrite(const char* test_file_path, | 141 void PrepareForWrite(const char* test_file_path, |
140 const GURL& blob_url, | 142 const GURL& blob_url, |
141 int64 offset, | 143 int64_t offset, |
142 int64 allowed_growth) { | 144 int64_t allowed_growth) { |
143 file_writer_delegate_.reset( | 145 file_writer_delegate_.reset( |
144 CreateWriterDelegate(test_file_path, offset, allowed_growth)); | 146 CreateWriterDelegate(test_file_path, offset, allowed_growth)); |
145 request_ = empty_context_.CreateRequest( | 147 request_ = empty_context_.CreateRequest( |
146 blob_url, net::DEFAULT_PRIORITY, file_writer_delegate_.get()); | 148 blob_url, net::DEFAULT_PRIORITY, file_writer_delegate_.get()); |
147 } | 149 } |
148 | 150 |
149 // This should be alive until the very end of this instance. | 151 // This should be alive until the very end of this instance. |
150 base::MessageLoopForIO loop_; | 152 base::MessageLoopForIO loop_; |
151 | 153 |
152 scoped_refptr<storage::FileSystemContext> file_system_context_; | 154 scoped_refptr<storage::FileSystemContext> file_system_context_; |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 | 269 |
268 void FileWriterDelegateTest::TearDown() { | 270 void FileWriterDelegateTest::TearDown() { |
269 file_system_context_ = NULL; | 271 file_system_context_ = NULL; |
270 base::RunLoop().RunUntilIdle(); | 272 base::RunLoop().RunUntilIdle(); |
271 } | 273 } |
272 | 274 |
273 TEST_F(FileWriterDelegateTest, WriteSuccessWithoutQuotaLimit) { | 275 TEST_F(FileWriterDelegateTest, WriteSuccessWithoutQuotaLimit) { |
274 const GURL kBlobURL("blob:nolimit"); | 276 const GURL kBlobURL("blob:nolimit"); |
275 content_ = kData; | 277 content_ = kData; |
276 | 278 |
277 PrepareForWrite("test", kBlobURL, 0, kint64max); | 279 PrepareForWrite("test", kBlobURL, 0, std::numeric_limits<int64_t>::max()); |
278 | 280 |
279 Result result; | 281 Result result; |
280 ASSERT_EQ(0, usage()); | 282 ASSERT_EQ(0, usage()); |
281 file_writer_delegate_->Start(request_.Pass(), GetWriteCallback(&result)); | 283 file_writer_delegate_->Start(request_.Pass(), GetWriteCallback(&result)); |
282 base::MessageLoop::current()->Run(); | 284 base::MessageLoop::current()->Run(); |
283 | 285 |
284 ASSERT_EQ(FileWriterDelegate::SUCCESS_COMPLETED, result.write_status()); | 286 ASSERT_EQ(FileWriterDelegate::SUCCESS_COMPLETED, result.write_status()); |
285 file_writer_delegate_.reset(); | 287 file_writer_delegate_.reset(); |
286 | 288 |
287 ASSERT_EQ(kDataSize, usage()); | 289 ASSERT_EQ(kDataSize, usage()); |
288 EXPECT_EQ(GetFileSizeOnDisk("test"), usage()); | 290 EXPECT_EQ(GetFileSizeOnDisk("test"), usage()); |
289 EXPECT_EQ(kDataSize, result.bytes_written()); | 291 EXPECT_EQ(kDataSize, result.bytes_written()); |
290 EXPECT_EQ(base::File::FILE_OK, result.status()); | 292 EXPECT_EQ(base::File::FILE_OK, result.status()); |
291 } | 293 } |
292 | 294 |
293 TEST_F(FileWriterDelegateTest, WriteSuccessWithJustQuota) { | 295 TEST_F(FileWriterDelegateTest, WriteSuccessWithJustQuota) { |
294 const GURL kBlobURL("blob:just"); | 296 const GURL kBlobURL("blob:just"); |
295 content_ = kData; | 297 content_ = kData; |
296 const int64 kAllowedGrowth = kDataSize; | 298 const int64_t kAllowedGrowth = kDataSize; |
297 PrepareForWrite("test", kBlobURL, 0, kAllowedGrowth); | 299 PrepareForWrite("test", kBlobURL, 0, kAllowedGrowth); |
298 | 300 |
299 Result result; | 301 Result result; |
300 ASSERT_EQ(0, usage()); | 302 ASSERT_EQ(0, usage()); |
301 file_writer_delegate_->Start(request_.Pass(), GetWriteCallback(&result)); | 303 file_writer_delegate_->Start(request_.Pass(), GetWriteCallback(&result)); |
302 base::MessageLoop::current()->Run(); | 304 base::MessageLoop::current()->Run(); |
303 ASSERT_EQ(FileWriterDelegate::SUCCESS_COMPLETED, result.write_status()); | 305 ASSERT_EQ(FileWriterDelegate::SUCCESS_COMPLETED, result.write_status()); |
304 file_writer_delegate_.reset(); | 306 file_writer_delegate_.reset(); |
305 | 307 |
306 ASSERT_EQ(kAllowedGrowth, usage()); | 308 ASSERT_EQ(kAllowedGrowth, usage()); |
307 EXPECT_EQ(GetFileSizeOnDisk("test"), usage()); | 309 EXPECT_EQ(GetFileSizeOnDisk("test"), usage()); |
308 | 310 |
309 EXPECT_EQ(kAllowedGrowth, result.bytes_written()); | 311 EXPECT_EQ(kAllowedGrowth, result.bytes_written()); |
310 EXPECT_EQ(base::File::FILE_OK, result.status()); | 312 EXPECT_EQ(base::File::FILE_OK, result.status()); |
311 } | 313 } |
312 | 314 |
313 TEST_F(FileWriterDelegateTest, DISABLED_WriteFailureByQuota) { | 315 TEST_F(FileWriterDelegateTest, DISABLED_WriteFailureByQuota) { |
314 const GURL kBlobURL("blob:failure"); | 316 const GURL kBlobURL("blob:failure"); |
315 content_ = kData; | 317 content_ = kData; |
316 const int64 kAllowedGrowth = kDataSize - 1; | 318 const int64_t kAllowedGrowth = kDataSize - 1; |
317 PrepareForWrite("test", kBlobURL, 0, kAllowedGrowth); | 319 PrepareForWrite("test", kBlobURL, 0, kAllowedGrowth); |
318 | 320 |
319 Result result; | 321 Result result; |
320 ASSERT_EQ(0, usage()); | 322 ASSERT_EQ(0, usage()); |
321 file_writer_delegate_->Start(request_.Pass(), GetWriteCallback(&result)); | 323 file_writer_delegate_->Start(request_.Pass(), GetWriteCallback(&result)); |
322 base::MessageLoop::current()->Run(); | 324 base::MessageLoop::current()->Run(); |
323 ASSERT_EQ(FileWriterDelegate::ERROR_WRITE_STARTED, result.write_status()); | 325 ASSERT_EQ(FileWriterDelegate::ERROR_WRITE_STARTED, result.write_status()); |
324 file_writer_delegate_.reset(); | 326 file_writer_delegate_.reset(); |
325 | 327 |
326 ASSERT_EQ(kAllowedGrowth, usage()); | 328 ASSERT_EQ(kAllowedGrowth, usage()); |
327 EXPECT_EQ(GetFileSizeOnDisk("test"), usage()); | 329 EXPECT_EQ(GetFileSizeOnDisk("test"), usage()); |
328 | 330 |
329 EXPECT_EQ(kAllowedGrowth, result.bytes_written()); | 331 EXPECT_EQ(kAllowedGrowth, result.bytes_written()); |
330 EXPECT_EQ(base::File::FILE_ERROR_NO_SPACE, result.status()); | 332 EXPECT_EQ(base::File::FILE_ERROR_NO_SPACE, result.status()); |
331 ASSERT_EQ(FileWriterDelegate::ERROR_WRITE_STARTED, result.write_status()); | 333 ASSERT_EQ(FileWriterDelegate::ERROR_WRITE_STARTED, result.write_status()); |
332 } | 334 } |
333 | 335 |
334 TEST_F(FileWriterDelegateTest, WriteZeroBytesSuccessfullyWithZeroQuota) { | 336 TEST_F(FileWriterDelegateTest, WriteZeroBytesSuccessfullyWithZeroQuota) { |
335 const GURL kBlobURL("blob:zero"); | 337 const GURL kBlobURL("blob:zero"); |
336 content_ = ""; | 338 content_ = ""; |
337 int64 kAllowedGrowth = 0; | 339 int64_t kAllowedGrowth = 0; |
338 PrepareForWrite("test", kBlobURL, 0, kAllowedGrowth); | 340 PrepareForWrite("test", kBlobURL, 0, kAllowedGrowth); |
339 | 341 |
340 Result result; | 342 Result result; |
341 ASSERT_EQ(0, usage()); | 343 ASSERT_EQ(0, usage()); |
342 file_writer_delegate_->Start(request_.Pass(), GetWriteCallback(&result)); | 344 file_writer_delegate_->Start(request_.Pass(), GetWriteCallback(&result)); |
343 base::MessageLoop::current()->Run(); | 345 base::MessageLoop::current()->Run(); |
344 ASSERT_EQ(FileWriterDelegate::SUCCESS_COMPLETED, result.write_status()); | 346 ASSERT_EQ(FileWriterDelegate::SUCCESS_COMPLETED, result.write_status()); |
345 file_writer_delegate_.reset(); | 347 file_writer_delegate_.reset(); |
346 | 348 |
347 ASSERT_EQ(kAllowedGrowth, usage()); | 349 ASSERT_EQ(kAllowedGrowth, usage()); |
348 EXPECT_EQ(GetFileSizeOnDisk("test"), usage()); | 350 EXPECT_EQ(GetFileSizeOnDisk("test"), usage()); |
349 | 351 |
350 EXPECT_EQ(kAllowedGrowth, result.bytes_written()); | 352 EXPECT_EQ(kAllowedGrowth, result.bytes_written()); |
351 EXPECT_EQ(base::File::FILE_OK, result.status()); | 353 EXPECT_EQ(base::File::FILE_OK, result.status()); |
352 ASSERT_EQ(FileWriterDelegate::SUCCESS_COMPLETED, result.write_status()); | 354 ASSERT_EQ(FileWriterDelegate::SUCCESS_COMPLETED, result.write_status()); |
353 } | 355 } |
354 | 356 |
355 TEST_F(FileWriterDelegateTest, WriteSuccessWithoutQuotaLimitConcurrent) { | 357 TEST_F(FileWriterDelegateTest, WriteSuccessWithoutQuotaLimitConcurrent) { |
356 scoped_ptr<FileWriterDelegate> file_writer_delegate2; | 358 scoped_ptr<FileWriterDelegate> file_writer_delegate2; |
357 scoped_ptr<net::URLRequest> request2; | 359 scoped_ptr<net::URLRequest> request2; |
358 | 360 |
359 ASSERT_EQ(base::File::FILE_OK, | 361 ASSERT_EQ(base::File::FILE_OK, |
360 AsyncFileTestHelper::CreateFile(file_system_context_.get(), | 362 AsyncFileTestHelper::CreateFile(file_system_context_.get(), |
361 GetFileSystemURL("test2"))); | 363 GetFileSystemURL("test2"))); |
362 | 364 |
363 const GURL kBlobURL("blob:nolimitconcurrent"); | 365 const GURL kBlobURL("blob:nolimitconcurrent"); |
364 const GURL kBlobURL2("blob:nolimitconcurrent2"); | 366 const GURL kBlobURL2("blob:nolimitconcurrent2"); |
365 content_ = kData; | 367 content_ = kData; |
366 | 368 |
367 PrepareForWrite("test", kBlobURL, 0, kint64max); | 369 PrepareForWrite("test", kBlobURL, 0, std::numeric_limits<int64_t>::max()); |
368 | 370 |
369 // Credate another FileWriterDelegate for concurrent write. | 371 // Credate another FileWriterDelegate for concurrent write. |
370 file_writer_delegate2.reset(CreateWriterDelegate("test2", 0, kint64max)); | 372 file_writer_delegate2.reset( |
| 373 CreateWriterDelegate("test2", 0, std::numeric_limits<int64_t>::max())); |
371 request2 = empty_context_.CreateRequest( | 374 request2 = empty_context_.CreateRequest( |
372 kBlobURL2, net::DEFAULT_PRIORITY, file_writer_delegate2.get()); | 375 kBlobURL2, net::DEFAULT_PRIORITY, file_writer_delegate2.get()); |
373 | 376 |
374 Result result, result2; | 377 Result result, result2; |
375 ASSERT_EQ(0, usage()); | 378 ASSERT_EQ(0, usage()); |
376 file_writer_delegate_->Start(request_.Pass(), GetWriteCallback(&result)); | 379 file_writer_delegate_->Start(request_.Pass(), GetWriteCallback(&result)); |
377 file_writer_delegate2->Start(request2.Pass(), GetWriteCallback(&result2)); | 380 file_writer_delegate2->Start(request2.Pass(), GetWriteCallback(&result2)); |
378 base::MessageLoop::current()->Run(); | 381 base::MessageLoop::current()->Run(); |
379 if (result.write_status() == FileWriterDelegate::SUCCESS_IO_PENDING || | 382 if (result.write_status() == FileWriterDelegate::SUCCESS_IO_PENDING || |
380 result2.write_status() == FileWriterDelegate::SUCCESS_IO_PENDING) | 383 result2.write_status() == FileWriterDelegate::SUCCESS_IO_PENDING) |
(...skipping 11 matching lines...) Expand all Loading... |
392 EXPECT_EQ(base::File::FILE_OK, result.status()); | 395 EXPECT_EQ(base::File::FILE_OK, result.status()); |
393 EXPECT_EQ(kDataSize, result2.bytes_written()); | 396 EXPECT_EQ(kDataSize, result2.bytes_written()); |
394 EXPECT_EQ(base::File::FILE_OK, result2.status()); | 397 EXPECT_EQ(base::File::FILE_OK, result2.status()); |
395 } | 398 } |
396 | 399 |
397 TEST_F(FileWriterDelegateTest, WritesWithQuotaAndOffset) { | 400 TEST_F(FileWriterDelegateTest, WritesWithQuotaAndOffset) { |
398 const GURL kBlobURL("blob:failure-with-updated-quota"); | 401 const GURL kBlobURL("blob:failure-with-updated-quota"); |
399 content_ = kData; | 402 content_ = kData; |
400 | 403 |
401 // Writing kDataSize (=45) bytes data while allowed_growth is 100. | 404 // Writing kDataSize (=45) bytes data while allowed_growth is 100. |
402 int64 offset = 0; | 405 int64_t offset = 0; |
403 int64 allowed_growth = 100; | 406 int64_t allowed_growth = 100; |
404 ASSERT_LT(kDataSize, allowed_growth); | 407 ASSERT_LT(kDataSize, allowed_growth); |
405 PrepareForWrite("test", kBlobURL, offset, allowed_growth); | 408 PrepareForWrite("test", kBlobURL, offset, allowed_growth); |
406 | 409 |
407 { | 410 { |
408 Result result; | 411 Result result; |
409 ASSERT_EQ(0, usage()); | 412 ASSERT_EQ(0, usage()); |
410 file_writer_delegate_->Start(request_.Pass(), GetWriteCallback(&result)); | 413 file_writer_delegate_->Start(request_.Pass(), GetWriteCallback(&result)); |
411 base::MessageLoop::current()->Run(); | 414 base::MessageLoop::current()->Run(); |
412 ASSERT_EQ(FileWriterDelegate::SUCCESS_COMPLETED, result.write_status()); | 415 ASSERT_EQ(FileWriterDelegate::SUCCESS_COMPLETED, result.write_status()); |
413 file_writer_delegate_.reset(); | 416 file_writer_delegate_.reset(); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 EXPECT_EQ(offset + kDataSize, usage()); | 453 EXPECT_EQ(offset + kDataSize, usage()); |
451 EXPECT_EQ(GetFileSizeOnDisk("test"), usage()); | 454 EXPECT_EQ(GetFileSizeOnDisk("test"), usage()); |
452 EXPECT_EQ(kDataSize, result.bytes_written()); | 455 EXPECT_EQ(kDataSize, result.bytes_written()); |
453 EXPECT_EQ(base::File::FILE_OK, result.status()); | 456 EXPECT_EQ(base::File::FILE_OK, result.status()); |
454 } | 457 } |
455 | 458 |
456 // Trying to overwrite 45 bytes data while allowed_growth is -20. | 459 // Trying to overwrite 45 bytes data while allowed_growth is -20. |
457 offset = 0; | 460 offset = 0; |
458 allowed_growth = -20; | 461 allowed_growth = -20; |
459 PrepareForWrite("test", kBlobURL, offset, allowed_growth); | 462 PrepareForWrite("test", kBlobURL, offset, allowed_growth); |
460 int64 pre_write_usage = GetFileSizeOnDisk("test"); | 463 int64_t pre_write_usage = GetFileSizeOnDisk("test"); |
461 | 464 |
462 { | 465 { |
463 Result result; | 466 Result result; |
464 file_writer_delegate_->Start(request_.Pass(), GetWriteCallback(&result)); | 467 file_writer_delegate_->Start(request_.Pass(), GetWriteCallback(&result)); |
465 base::MessageLoop::current()->Run(); | 468 base::MessageLoop::current()->Run(); |
466 ASSERT_EQ(FileWriterDelegate::SUCCESS_COMPLETED, result.write_status()); | 469 ASSERT_EQ(FileWriterDelegate::SUCCESS_COMPLETED, result.write_status()); |
467 file_writer_delegate_.reset(); | 470 file_writer_delegate_.reset(); |
468 | 471 |
469 EXPECT_EQ(pre_write_usage, usage()); | 472 EXPECT_EQ(pre_write_usage, usage()); |
470 EXPECT_EQ(GetFileSizeOnDisk("test"), usage()); | 473 EXPECT_EQ(GetFileSizeOnDisk("test"), usage()); |
(...skipping 16 matching lines...) Expand all Loading... |
487 file_writer_delegate_.reset(); | 490 file_writer_delegate_.reset(); |
488 | 491 |
489 EXPECT_EQ(pre_write_usage + allowed_growth, usage()); | 492 EXPECT_EQ(pre_write_usage + allowed_growth, usage()); |
490 EXPECT_EQ(GetFileSizeOnDisk("test"), usage()); | 493 EXPECT_EQ(GetFileSizeOnDisk("test"), usage()); |
491 EXPECT_EQ(kOverlap + allowed_growth, result.bytes_written()); | 494 EXPECT_EQ(kOverlap + allowed_growth, result.bytes_written()); |
492 EXPECT_EQ(base::File::FILE_ERROR_NO_SPACE, result.status()); | 495 EXPECT_EQ(base::File::FILE_ERROR_NO_SPACE, result.status()); |
493 } | 496 } |
494 } | 497 } |
495 | 498 |
496 } // namespace content | 499 } // namespace content |
OLD | NEW |