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_data_stream.h" | 5 #include "net/base/upload_data_stream.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 : content_length_(content_length), | 60 : content_length_(content_length), |
61 bytes_remaining_(content_length), | 61 bytes_remaining_(content_length), |
62 is_in_memory_(is_in_memory), | 62 is_in_memory_(is_in_memory), |
63 init_result_(OK), | 63 init_result_(OK), |
64 read_result_(OK) {} | 64 read_result_(OK) {} |
65 | 65 |
66 virtual ~MockUploadElementReader() {} | 66 virtual ~MockUploadElementReader() {} |
67 | 67 |
68 // UploadElementReader overrides. | 68 // UploadElementReader overrides. |
69 MOCK_METHOD1(Init, int(const CompletionCallback& callback)); | 69 MOCK_METHOD1(Init, int(const CompletionCallback& callback)); |
70 virtual uint64 GetContentLength() const OVERRIDE { return content_length_; } | 70 virtual uint64 GetContentLength() const override { return content_length_; } |
71 virtual uint64 BytesRemaining() const OVERRIDE { return bytes_remaining_; } | 71 virtual uint64 BytesRemaining() const override { return bytes_remaining_; } |
72 virtual bool IsInMemory() const OVERRIDE { return is_in_memory_; } | 72 virtual bool IsInMemory() const override { return is_in_memory_; } |
73 MOCK_METHOD3(Read, int(IOBuffer* buf, | 73 MOCK_METHOD3(Read, int(IOBuffer* buf, |
74 int buf_length, | 74 int buf_length, |
75 const CompletionCallback& callback)); | 75 const CompletionCallback& callback)); |
76 | 76 |
77 // Sets expectation to return the specified result from Init() asynchronously. | 77 // Sets expectation to return the specified result from Init() asynchronously. |
78 void SetAsyncInitExpectation(int result) { | 78 void SetAsyncInitExpectation(int result) { |
79 init_result_ = result; | 79 init_result_ = result; |
80 EXPECT_CALL(*this, Init(_)) | 80 EXPECT_CALL(*this, Init(_)) |
81 .WillOnce(DoAll(Invoke(this, &MockUploadElementReader::OnInit), | 81 .WillOnce(DoAll(Invoke(this, &MockUploadElementReader::OnInit), |
82 Return(ERR_IO_PENDING))); | 82 Return(ERR_IO_PENDING))); |
(...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
811 wrapped_buffer2.get(), buf2.size(), read_callback2.callback())); | 811 wrapped_buffer2.get(), buf2.size(), read_callback2.callback())); |
812 EXPECT_EQ(static_cast<int>(buf2.size()), read_callback2.WaitForResult()); | 812 EXPECT_EQ(static_cast<int>(buf2.size()), read_callback2.WaitForResult()); |
813 EXPECT_EQ(expected_data, buf2); | 813 EXPECT_EQ(expected_data, buf2); |
814 EXPECT_TRUE(stream.IsEOF()); | 814 EXPECT_TRUE(stream.IsEOF()); |
815 | 815 |
816 // Make sure callbacks are not called for cancelled operations. | 816 // Make sure callbacks are not called for cancelled operations. |
817 EXPECT_FALSE(read_callback1.have_result()); | 817 EXPECT_FALSE(read_callback1.have_result()); |
818 } | 818 } |
819 | 819 |
820 } // namespace net | 820 } // namespace net |
OLD | NEW |