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

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

Issue 2458793002: Server push cancellation: add PushPromiseHelper which reflects information on the push promise. (Closed)
Patch Set: sync and fix tests Created 4 years, 1 month 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/core/quic_client_promised_info.cc ('k') | net/quic/core/quic_client_session_base.h » ('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/core/quic_client_promised_info.h" 5 #include "net/quic/core/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 "net/quic/core/spdy_utils.h" 10 #include "net/quic/core/spdy_utils.h"
11 #include "net/quic/test_tools/crypto_test_utils.h" 11 #include "net/quic/test_tools/crypto_test_utils.h"
12 #include "net/quic/test_tools/quic_client_promised_info_peer.h" 12 #include "net/quic/test_tools/quic_client_promised_info_peer.h"
13 #include "net/test/gtest_util.h" 13 #include "net/test/gtest_util.h"
14 #include "net/tools/quic/quic_client_session.h" 14 #include "net/tools/quic/quic_client_session.h"
15 #include "net/tools/quic/test_tools/push_promise_delegate.h"
15 16
16 using std::string; 17 using std::string;
17 using testing::StrictMock; 18 using testing::StrictMock;
18 19
19 namespace net { 20 namespace net {
20 namespace test { 21 namespace test {
21 namespace { 22 namespace {
22 23
23 class MockQuicClientSession : public QuicClientSession { 24 class MockQuicClientSession : public QuicClientSession {
24 public: 25 public:
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 79
79 client_request_ = push_promise_.Clone(); 80 client_request_ = push_promise_.Clone();
80 } 81 }
81 82
82 class StreamVisitor : public QuicSpdyClientStream::Visitor { 83 class StreamVisitor : public QuicSpdyClientStream::Visitor {
83 void OnClose(QuicSpdyStream* stream) override { 84 void OnClose(QuicSpdyStream* stream) override {
84 DVLOG(1) << "stream " << stream->id(); 85 DVLOG(1) << "stream " << stream->id();
85 } 86 }
86 }; 87 };
87 88
88 class PushPromiseDelegate : public QuicClientPushPromiseIndex::Delegate {
89 public:
90 explicit PushPromiseDelegate(bool match)
91 : match_(match),
92 rendezvous_fired_(false),
93 rendezvous_stream_(nullptr) {}
94
95 bool CheckVary(const SpdyHeaderBlock& client_request,
96 const SpdyHeaderBlock& promise_request,
97 const SpdyHeaderBlock& promise_response) override {
98 DVLOG(1) << "match " << match_;
99 return match_;
100 }
101
102 void OnRendezvousResult(QuicSpdyStream* stream) override {
103 rendezvous_fired_ = true;
104 rendezvous_stream_ = stream;
105 }
106
107 QuicSpdyStream* rendezvous_stream() { return rendezvous_stream_; }
108 bool rendezvous_fired() { return rendezvous_fired_; }
109
110 private:
111 bool match_;
112 bool rendezvous_fired_;
113 QuicSpdyStream* rendezvous_stream_;
114 };
115
116 void ReceivePromise(QuicStreamId id) { 89 void ReceivePromise(QuicStreamId id) {
117 auto headers = AsHeaderList(push_promise_); 90 auto headers = AsHeaderList(push_promise_);
118 stream_->OnPromiseHeaderList(id, headers.uncompressed_header_bytes(), 91 stream_->OnPromiseHeaderList(id, headers.uncompressed_header_bytes(),
119 headers); 92 headers);
120 } 93 }
121 94
122 MockQuicConnectionHelper helper_; 95 MockQuicConnectionHelper helper_;
123 MockAlarmFactory alarm_factory_; 96 MockAlarmFactory alarm_factory_;
124 StrictMock<MockQuicConnection>* connection_; 97 StrictMock<MockQuicConnection>* connection_;
125 QuicClientPushPromiseIndex push_promise_index_; 98 QuicClientPushPromiseIndex push_promise_index_;
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 EXPECT_FALSE(delegate.rendezvous_fired()); 306 EXPECT_FALSE(delegate.rendezvous_fired());
334 EXPECT_EQ(delegate.rendezvous_stream(), nullptr); 307 EXPECT_EQ(delegate.rendezvous_stream(), nullptr);
335 308
336 // Promise is gone 309 // Promise is gone
337 EXPECT_EQ(session_.GetPromisedById(promise_id_), nullptr); 310 EXPECT_EQ(session_.GetPromisedById(promise_id_), nullptr);
338 } 311 }
339 312
340 } // namespace 313 } // namespace
341 } // namespace test 314 } // namespace test
342 } // namespace net 315 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/core/quic_client_promised_info.cc ('k') | net/quic/core/quic_client_session_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698