| 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 #include "base/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/bind.h" | 6 #include "base/bind.h" |
| 7 #include "base/bind_helpers.h" | 7 #include "base/bind_helpers.h" |
| 8 #include "base/files/file.h" | 8 #include "base/files/file.h" |
| 9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 663 } | 663 } |
| 664 EXPECT_EQ(net::ERR_INVALID_ARGUMENT, | 664 EXPECT_EQ(net::ERR_INVALID_ARGUMENT, |
| 665 ReadData(entry, kNumStreams, 0, buffer1.get(), kBufferSize)); | 665 ReadData(entry, kNumStreams, 0, buffer1.get(), kBufferSize)); |
| 666 entry->Close(); | 666 entry->Close(); |
| 667 | 667 |
| 668 // Open the entry and read it in chunks, including a read past the end. | 668 // Open the entry and read it in chunks, including a read past the end. |
| 669 ASSERT_EQ(net::OK, OpenEntry("the first key", &entry)); | 669 ASSERT_EQ(net::OK, OpenEntry("the first key", &entry)); |
| 670 ASSERT_TRUE(NULL != entry); | 670 ASSERT_TRUE(NULL != entry); |
| 671 const int kReadBufferSize = 600; | 671 const int kReadBufferSize = 600; |
| 672 const int kFinalReadSize = kBufferSize - kReadBufferSize; | 672 const int kFinalReadSize = kBufferSize - kReadBufferSize; |
| 673 COMPILE_ASSERT(kFinalReadSize < kReadBufferSize, should_be_exactly_two_reads); | 673 static_assert(kFinalReadSize < kReadBufferSize, |
| 674 "should be exactly two reads"); |
| 674 scoped_refptr<net::IOBuffer> buffer2(new net::IOBuffer(kReadBufferSize)); | 675 scoped_refptr<net::IOBuffer> buffer2(new net::IOBuffer(kReadBufferSize)); |
| 675 for (int i = 0; i < kNumStreams; i++) { | 676 for (int i = 0; i < kNumStreams; i++) { |
| 676 memset(buffer2->data(), 0, kReadBufferSize); | 677 memset(buffer2->data(), 0, kReadBufferSize); |
| 677 EXPECT_EQ(kReadBufferSize, | 678 EXPECT_EQ(kReadBufferSize, |
| 678 ReadData(entry, i, 0, buffer2.get(), kReadBufferSize)); | 679 ReadData(entry, i, 0, buffer2.get(), kReadBufferSize)); |
| 679 EXPECT_EQ( | 680 EXPECT_EQ( |
| 680 0, | 681 0, |
| 681 memcmp(reference_buffers[i]->data(), buffer2->data(), kReadBufferSize)); | 682 memcmp(reference_buffers[i]->data(), buffer2->data(), kReadBufferSize)); |
| 682 | 683 |
| 683 memset(buffer2->data(), 0, kReadBufferSize); | 684 memset(buffer2->data(), 0, kReadBufferSize); |
| (...skipping 3479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4163 | 4164 |
| 4164 ret = entry->ReadSparseData(kSize, buffer.get(), kSize, callback.callback()); | 4165 ret = entry->ReadSparseData(kSize, buffer.get(), kSize, callback.callback()); |
| 4165 EXPECT_EQ(kSize, callback.GetResult(ret)); | 4166 EXPECT_EQ(kSize, callback.GetResult(ret)); |
| 4166 | 4167 |
| 4167 // Make sure the first range was removed when the second was written. | 4168 // Make sure the first range was removed when the second was written. |
| 4168 ret = entry->ReadSparseData(0, buffer.get(), kSize, callback.callback()); | 4169 ret = entry->ReadSparseData(0, buffer.get(), kSize, callback.callback()); |
| 4169 EXPECT_EQ(0, callback.GetResult(ret)); | 4170 EXPECT_EQ(0, callback.GetResult(ret)); |
| 4170 | 4171 |
| 4171 entry->Close(); | 4172 entry->Close(); |
| 4172 } | 4173 } |
| OLD | NEW |