| 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 "net/base/upload_bytes_element_reader.h" | 5 #include "net/base/upload_bytes_element_reader.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "net/base/io_buffer.h" | 9 #include "net/base/io_buffer.h" |
| 10 #include "net/base/net_errors.h" | 10 #include "net/base/net_errors.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 #include "testing/platform_test.h" | 12 #include "testing/platform_test.h" |
| 13 | 13 |
| 14 namespace net { | 14 namespace net { |
| 15 | 15 |
| 16 class UploadBytesElementReaderTest : public PlatformTest { | 16 class UploadBytesElementReaderTest : public PlatformTest { |
| 17 protected: | 17 protected: |
| 18 virtual void SetUp() OVERRIDE { | 18 virtual void SetUp() override { |
| 19 const char kData[] = "123abc"; | 19 const char kData[] = "123abc"; |
| 20 bytes_.assign(kData, kData + arraysize(kData)); | 20 bytes_.assign(kData, kData + arraysize(kData)); |
| 21 reader_.reset(new UploadBytesElementReader(&bytes_[0], bytes_.size())); | 21 reader_.reset(new UploadBytesElementReader(&bytes_[0], bytes_.size())); |
| 22 ASSERT_EQ(OK, reader_->Init(CompletionCallback())); | 22 ASSERT_EQ(OK, reader_->Init(CompletionCallback())); |
| 23 EXPECT_EQ(bytes_.size(), reader_->GetContentLength()); | 23 EXPECT_EQ(bytes_.size(), reader_->GetContentLength()); |
| 24 EXPECT_EQ(bytes_.size(), reader_->BytesRemaining()); | 24 EXPECT_EQ(bytes_.size(), reader_->BytesRemaining()); |
| 25 EXPECT_TRUE(reader_->IsInMemory()); | 25 EXPECT_TRUE(reader_->IsInMemory()); |
| 26 } | 26 } |
| 27 | 27 |
| 28 std::vector<char> bytes_; | 28 std::vector<char> bytes_; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 | 84 |
| 85 // Read again. | 85 // Read again. |
| 86 EXPECT_EQ( | 86 EXPECT_EQ( |
| 87 static_cast<int>(buf.size()), | 87 static_cast<int>(buf.size()), |
| 88 reader_->Read(wrapped_buffer.get(), buf.size(), CompletionCallback())); | 88 reader_->Read(wrapped_buffer.get(), buf.size(), CompletionCallback())); |
| 89 EXPECT_EQ(0U, reader_->BytesRemaining()); | 89 EXPECT_EQ(0U, reader_->BytesRemaining()); |
| 90 EXPECT_EQ(bytes_, buf); | 90 EXPECT_EQ(bytes_, buf); |
| 91 } | 91 } |
| 92 | 92 |
| 93 } // namespace net | 93 } // namespace net |
| OLD | NEW |