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

Side by Side Diff: net/quic/quic_client_promised_info_test.cc

Issue 1905843003: Split out QuicAlarm creation from QuicConnectionHelper to new QuicAlarmFactory. No behavior change,… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@119753783
Patch Set: Rebase Created 4 years, 8 months 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
« no previous file with comments | « net/quic/quic_client_promised_info.cc ('k') | net/quic/quic_client_push_promise_index_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/quic/quic_client_promised_info.h" 5 #include "net/quic/quic_client_promised_info.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/scoped_ptr.h" 10 #include "base/scoped_ptr.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 bool authorized_; 65 bool authorized_;
66 66
67 DISALLOW_COPY_AND_ASSIGN(MockQuicClientSession); 67 DISALLOW_COPY_AND_ASSIGN(MockQuicClientSession);
68 }; 68 };
69 69
70 class QuicClientPromisedInfoTest : public ::testing::Test { 70 class QuicClientPromisedInfoTest : public ::testing::Test {
71 public: 71 public:
72 class StreamVisitor; 72 class StreamVisitor;
73 73
74 QuicClientPromisedInfoTest() 74 QuicClientPromisedInfoTest()
75 : connection_( 75 : connection_(new StrictMock<MockConnection>(&helper_,
76 new StrictMock<MockConnection>(&helper_, Perspective::IS_CLIENT)), 76 &alarm_factory_,
77 Perspective::IS_CLIENT)),
77 session_(connection_, &push_promise_index_), 78 session_(connection_, &push_promise_index_),
78 body_("hello world"), 79 body_("hello world"),
79 promise_id_(gfe_quic::test::kServerDataStreamId1) { 80 promise_id_(gfe_quic::test::kServerDataStreamId1) {
80 FLAGS_quic_supports_push_promise = true; 81 FLAGS_quic_supports_push_promise = true;
81 82
82 session_.Initialize(); 83 session_.Initialize();
83 84
84 headers_.SetResponseFirstline("HTTP/1.1", 200, "Ok"); 85 headers_.SetResponseFirstline("HTTP/1.1", 200, "Ok");
85 headers_.ReplaceOrAppendHeader("content-length", "11"); 86 headers_.ReplaceOrAppendHeader("content-length", "11");
86 headers_string_ = SpdyBalsaUtils::SerializeResponseHeaders(headers_); 87 headers_string_ = SpdyBalsaUtils::SerializeResponseHeaders(headers_);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 QuicSpdyClientStream* rendezvous_stream_; 138 QuicSpdyClientStream* rendezvous_stream_;
138 }; 139 };
139 140
140 void ReceivePromise(QuicStreamId id) { 141 void ReceivePromise(QuicStreamId id) {
141 stream_->OnStreamHeaders(serialized_push_promise_); 142 stream_->OnStreamHeaders(serialized_push_promise_);
142 143
143 stream_->OnPromiseHeadersComplete(id, serialized_push_promise_.size()); 144 stream_->OnPromiseHeadersComplete(id, serialized_push_promise_.size());
144 } 145 }
145 146
146 MockConnectionHelper helper_; 147 MockConnectionHelper helper_;
148 MockAlarmFactory alarm_factory_;
147 StrictMock<MockConnection>* connection_; 149 StrictMock<MockConnection>* connection_;
148 QuicClientPushPromiseIndex push_promise_index_; 150 QuicClientPushPromiseIndex push_promise_index_;
149 151
150 MockQuicClientSession session_; 152 MockQuicClientSession session_;
151 std::unique_ptr<QuicSpdyClientStream> stream_; 153 std::unique_ptr<QuicSpdyClientStream> stream_;
152 std::unique_ptr<StreamVisitor> stream_visitor_; 154 std::unique_ptr<StreamVisitor> stream_visitor_;
153 std::unique_ptr<QuicSpdyClientStream> promised_stream_; 155 std::unique_ptr<QuicSpdyClientStream> promised_stream_;
154 BalsaHeaders headers_; 156 BalsaHeaders headers_;
155 string headers_string_; 157 string headers_string_;
156 string body_; 158 string body_;
(...skipping 14 matching lines...) Expand all
171 TEST_F(QuicClientPromisedInfoTest, PushPromiseCleanupAlarm) { 173 TEST_F(QuicClientPromisedInfoTest, PushPromiseCleanupAlarm) {
172 ReceivePromise(promise_id_); 174 ReceivePromise(promise_id_);
173 175
174 // Verify that the promise is in the unclaimed streams map. 176 // Verify that the promise is in the unclaimed streams map.
175 QuicClientPromisedInfo* promised = session_.GetPromisedById(promise_id_); 177 QuicClientPromisedInfo* promised = session_.GetPromisedById(promise_id_);
176 ASSERT_NE(promised, nullptr); 178 ASSERT_NE(promised, nullptr);
177 179
178 // Fire the alarm that will cancel the promised stream. 180 // Fire the alarm that will cancel the promised stream.
179 EXPECT_CALL(*connection_, 181 EXPECT_CALL(*connection_,
180 SendRstStream(promise_id_, QUIC_STREAM_CANCELLED, 0)); 182 SendRstStream(promise_id_, QUIC_STREAM_CANCELLED, 0));
181 helper_.FireAlarm(QuicClientPromisedInfoPeer::GetAlarm(promised)); 183 alarm_factory_.FireAlarm(QuicClientPromisedInfoPeer::GetAlarm(promised));
182 184
183 // Verify that the promise is gone after the alarm fires. 185 // Verify that the promise is gone after the alarm fires.
184 EXPECT_EQ(session_.GetPromisedById(promise_id_), nullptr); 186 EXPECT_EQ(session_.GetPromisedById(promise_id_), nullptr);
185 EXPECT_EQ(session_.GetPromisedByUrl(promise_url_), nullptr); 187 EXPECT_EQ(session_.GetPromisedByUrl(promise_url_), nullptr);
186 } 188 }
187 189
188 TEST_F(QuicClientPromisedInfoTest, PushPromiseInvalidMethod) { 190 TEST_F(QuicClientPromisedInfoTest, PushPromiseInvalidMethod) {
189 // Promise with an unsafe method 191 // Promise with an unsafe method
190 push_promise_[":method"] = "PUT"; 192 push_promise_[":method"] = "PUT";
191 serialized_push_promise_ = 193 serialized_push_promise_ =
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 EXPECT_FALSE(delegate.rendezvous_fired()); 371 EXPECT_FALSE(delegate.rendezvous_fired());
370 EXPECT_EQ(delegate.rendezvous_stream(), nullptr); 372 EXPECT_EQ(delegate.rendezvous_stream(), nullptr);
371 373
372 // Promise is gone 374 // Promise is gone
373 EXPECT_EQ(session_.GetPromisedById(promise_id_), nullptr); 375 EXPECT_EQ(session_.GetPromisedById(promise_id_), nullptr);
374 } 376 }
375 377
376 } // namespace 378 } // namespace
377 } // namespace test 379 } // namespace test
378 } // namespace net 380 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_client_promised_info.cc ('k') | net/quic/quic_client_push_promise_index_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698