Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(298)

Side by Side Diff: net/tools/quic/quic_spdy_server_stream_base_test.cc

Issue 2537773006: Extract a QuicSpdyServerStreamBase class for code sharing between QuicSimpleServerStream and GfeQui… (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2016 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.
4
5 #include "net/tools/quic/quic_spdy_server_stream_base.h"
6
7 #include "base/memory/ptr_util.h"
8 #include "net/quic/test_tools/quic_test_utils.h"
9 #include "testing/gmock/include/gmock/gmock.h"
10 #include "testing/gtest/include/gtest/gtest.h"
11
12 using testing::_;
13
14 namespace net {
15 namespace test {
16 namespace {
17
18 class TestQuicSpdyServerStream : public QuicSpdyServerStreamBase {
19 public:
20 TestQuicSpdyServerStream(QuicStreamId id, QuicSpdySession* session)
21 : QuicSpdyServerStreamBase(id, session) {}
22
23 void OnDataAvailable() override {}
24 };
25
26 class QuicSpdyServerStreamBaseTest : public ::testing::Test {
27 protected:
28 QuicSpdyServerStreamBaseTest()
29 : session_(new MockQuicConnection(&helper_,
30 &alarm_factory_,
31 Perspective::IS_SERVER)) {
32 stream_ = new TestQuicSpdyServerStream(kClientDataStreamId1, &session_);
33 session_.ActivateStream(base::WrapUnique(stream_));
34 }
35
36 QuicSpdyServerStreamBase* stream_ = nullptr;
37 MockQuicConnectionHelper helper_;
38 MockAlarmFactory alarm_factory_;
39 MockQuicSpdySession session_;
40 };
41
42 TEST_F(QuicSpdyServerStreamBaseTest,
43 SendQuicRstStreamNoErrorWithEarlyResponse) {
44 stream_->StopReading();
45 EXPECT_CALL(session_, SendRstStream(_, QUIC_STREAM_NO_ERROR, _)).Times(1);
46 stream_->set_fin_sent(true);
47 stream_->CloseWriteSide();
48 }
49
50 TEST_F(QuicSpdyServerStreamBaseTest,
51 DoNotSendQuicRstStreamNoErrorWithRstReceived) {
52 EXPECT_FALSE(stream_->reading_stopped());
53
54 EXPECT_CALL(session_, SendRstStream(_, QUIC_STREAM_NO_ERROR, _)).Times(0);
55 EXPECT_CALL(session_, SendRstStream(_, QUIC_RST_ACKNOWLEDGEMENT, _)).Times(1);
56 QuicRstStreamFrame rst_frame(stream_->id(), QUIC_STREAM_CANCELLED, 1234);
57 stream_->OnStreamReset(rst_frame);
58
59 EXPECT_TRUE(stream_->reading_stopped());
60 EXPECT_TRUE(stream_->write_side_closed());
61 }
62
63 } // namespace
64 } // namespace test
65 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698