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

Side by Side Diff: net/http/http_pipelined_host_forced_unittest.cc

Issue 275953002: Remove HTTP pipelining support. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge Created 6 years, 7 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 | Annotate | Revision Log
OLDNEW
(Empty)
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.
4
5 #include "net/http/http_pipelined_host_forced.h"
6
7 #include "base/memory/scoped_ptr.h"
8 #include "net/http/http_pipelined_host_test_util.h"
9 #include "net/proxy/proxy_info.h"
10 #include "net/socket/client_socket_handle.h"
11 #include "net/ssl/ssl_config_service.h"
12 #include "testing/gmock/include/gmock/gmock.h"
13 #include "testing/gtest/include/gtest/gtest.h"
14
15 using testing::NiceMock;
16 using testing::Ref;
17 using testing::Return;
18
19 namespace net {
20
21 namespace {
22
23 HttpPipelinedStream* kDummyStream =
24 reinterpret_cast<HttpPipelinedStream*>(24);
25
26 class HttpPipelinedHostForcedTest : public testing::Test {
27 public:
28 HttpPipelinedHostForcedTest()
29 : key_(HostPortPair("host", 123)),
30 factory_(new MockPipelineFactory), // Owned by |host_|.
31 host_(new HttpPipelinedHostForced(&delegate_, key_, factory_)) {
32 }
33
34 MockPipeline* AddTestPipeline() {
35 MockPipeline* pipeline = new MockPipeline(0, true, true);
36 EXPECT_CALL(*factory_, CreateNewPipeline(&connection_, host_.get(),
37 MatchesOrigin(key_.origin()),
38 Ref(ssl_config_), Ref(proxy_info_),
39 Ref(net_log_), true,
40 kProtoSPDY3))
41 .Times(1)
42 .WillOnce(Return(pipeline));
43 EXPECT_CALL(*pipeline, CreateNewStream())
44 .Times(1)
45 .WillOnce(Return(kDummyStream));
46 EXPECT_EQ(kDummyStream, host_->CreateStreamOnNewPipeline(
47 &connection_, ssl_config_, proxy_info_, net_log_, true,
48 kProtoSPDY3));
49 return pipeline;
50 }
51
52 ClientSocketHandle connection_;
53 NiceMock<MockHostDelegate> delegate_;
54 HttpPipelinedHost::Key key_;
55 MockPipelineFactory* factory_;
56 scoped_ptr<HttpPipelinedHostForced> host_;
57
58 SSLConfig ssl_config_;
59 ProxyInfo proxy_info_;
60 BoundNetLog net_log_;
61 };
62
63 TEST_F(HttpPipelinedHostForcedTest, Delegate) {
64 EXPECT_TRUE(key_.origin().Equals(host_->GetKey().origin()));
65 }
66
67 TEST_F(HttpPipelinedHostForcedTest, SingleUser) {
68 EXPECT_FALSE(host_->IsExistingPipelineAvailable());
69
70 MockPipeline* pipeline = AddTestPipeline();
71 EXPECT_TRUE(host_->IsExistingPipelineAvailable());
72
73 EXPECT_CALL(delegate_, OnHostHasAdditionalCapacity(host_.get()))
74 .Times(1);
75 EXPECT_CALL(delegate_, OnHostIdle(host_.get()))
76 .Times(1);
77 host_->OnPipelineHasCapacity(pipeline);
78 }
79
80 TEST_F(HttpPipelinedHostForcedTest, ReuseExisting) {
81 EXPECT_EQ(NULL, host_->CreateStreamOnExistingPipeline());
82
83 MockPipeline* pipeline = AddTestPipeline();
84 EXPECT_CALL(*pipeline, CreateNewStream())
85 .Times(1)
86 .WillOnce(Return(kDummyStream));
87 EXPECT_EQ(kDummyStream, host_->CreateStreamOnExistingPipeline());
88
89 pipeline->SetState(1, true, true);
90 EXPECT_CALL(delegate_, OnHostHasAdditionalCapacity(host_.get()))
91 .Times(1);
92 EXPECT_CALL(delegate_, OnHostIdle(host_.get()))
93 .Times(0);
94 host_->OnPipelineHasCapacity(pipeline);
95
96 pipeline->SetState(0, true, true);
97 EXPECT_CALL(delegate_, OnHostHasAdditionalCapacity(host_.get()))
98 .Times(1);
99 EXPECT_CALL(delegate_, OnHostIdle(host_.get()))
100 .Times(1);
101 host_->OnPipelineHasCapacity(pipeline);
102 }
103
104 } // anonymous namespace
105
106 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698