Enabling tests which should be fixed by r173829.
[chromium-blink-merge.git] / net / spdy / spdy_stream_test_util.cc
blobe2144aece022f25434066f75320daf0a17da9faf
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"
11 namespace net {
13 namespace test {
15 TestSpdyStreamDelegate::TestSpdyStreamDelegate(
16 SpdyStream* stream,
17 SpdyHeaderBlock* headers,
18 IOBufferWithSize* buf,
19 const CompletionCallback& callback)
20 : stream_(stream),
21 headers_(headers),
22 buf_(buf),
23 callback_(callback),
24 send_headers_completed_(false),
25 response_(new SpdyHeaderBlock),
26 headers_sent_(0),
27 data_sent_(0),
28 closed_(false) {
31 TestSpdyStreamDelegate::~TestSpdyStreamDelegate() {
34 bool TestSpdyStreamDelegate::OnSendHeadersComplete(int status) {
35 send_headers_completed_ = true;
36 return 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,
50 int status) {
51 EXPECT_TRUE(send_headers_completed_);
52 *response_ = response;
53 if (headers_.get()) {
54 EXPECT_EQ(ERR_IO_PENDING,
55 stream_->WriteHeaders(headers_.release()));
57 if (buf_) {
58 EXPECT_EQ(ERR_IO_PENDING,
59 stream_->WriteStreamData(buf_.get(), buf_->size(),
60 DATA_FLAG_NONE));
62 return status;
65 void TestSpdyStreamDelegate::OnHeadersSent() {
66 headers_sent_++;
69 int TestSpdyStreamDelegate::OnDataReceived(const char* buffer, int bytes) {
70 received_data_ += std::string(buffer, bytes);
71 return OK;
74 void TestSpdyStreamDelegate::OnDataSent(int length) {
75 data_sent_ += length;
78 void TestSpdyStreamDelegate::OnClose(int status) {
79 closed_ = true;
80 CompletionCallback callback = callback_;
81 callback_.Reset();
82 callback.Run(OK);
85 } // namespace test
87 } // namespace net