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
3 // found in the LICENSE file.
5 #include "net/spdy/spdy_stream_test_util.h"
7 #include "net/base/completion_callback.h"
8 #include "net/spdy/spdy_stream.h"
9 #include "testing/gtest/include/gtest/gtest.h"
15 TestSpdyStreamDelegate::TestSpdyStreamDelegate(
17 SpdyHeaderBlock
* headers
,
18 IOBufferWithSize
* buf
,
19 const CompletionCallback
& callback
)
24 send_headers_completed_(false),
25 response_(new SpdyHeaderBlock
),
31 TestSpdyStreamDelegate::~TestSpdyStreamDelegate() {
34 bool TestSpdyStreamDelegate::OnSendHeadersComplete(int status
) {
35 send_headers_completed_
= true;
39 int TestSpdyStreamDelegate::OnSendBody() {
40 ADD_FAILURE() << "OnSendBody should not be called";
41 return ERR_UNEXPECTED
;
43 int TestSpdyStreamDelegate::OnSendBodyComplete(int /*status*/, bool* /*eof*/) {
44 ADD_FAILURE() << "OnSendBodyComplete should not be called";
45 return ERR_UNEXPECTED
;
48 int TestSpdyStreamDelegate::OnResponseReceived(const SpdyHeaderBlock
& response
,
49 base::Time response_time
,
51 EXPECT_TRUE(send_headers_completed_
);
52 *response_
= response
;
54 EXPECT_EQ(ERR_IO_PENDING
,
55 stream_
->WriteHeaders(headers_
.release()));
58 EXPECT_EQ(ERR_IO_PENDING
,
59 stream_
->WriteStreamData(buf_
.get(), buf_
->size(),
65 void TestSpdyStreamDelegate::OnHeadersSent() {
69 int TestSpdyStreamDelegate::OnDataReceived(const char* buffer
, int bytes
) {
70 received_data_
+= std::string(buffer
, bytes
);
74 void TestSpdyStreamDelegate::OnDataSent(int length
) {
78 void TestSpdyStreamDelegate::OnClose(int status
) {
80 CompletionCallback callback
= callback_
;