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

Side by Side Diff: net/spdy/spdy_http_stream_unittest.cc

Issue 1411383005: Initial implementation of RequestPriority-based HTTP/2 dependencies. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Final round of comments. Created 5 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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/spdy/spdy_http_stream.h" 5 #include "net/spdy/spdy_http_stream.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 16 matching lines...) Expand all
27 #include "net/spdy/spdy_http_utils.h" 27 #include "net/spdy/spdy_http_utils.h"
28 #include "net/spdy/spdy_session.h" 28 #include "net/spdy/spdy_session.h"
29 #include "net/spdy/spdy_test_util_common.h" 29 #include "net/spdy/spdy_test_util_common.h"
30 #include "net/ssl/default_channel_id_store.h" 30 #include "net/ssl/default_channel_id_store.h"
31 #include "testing/gtest/include/gtest/gtest.h" 31 #include "testing/gtest/include/gtest/gtest.h"
32 32
33 namespace net { 33 namespace net {
34 34
35 namespace { 35 namespace {
36 36
37 enum TestCase {
38 // Test using the SPDY/3.1 protocol.
39 kTestCaseSPDY31,
40
41 // Test using the HTTP/2 protocol, without specifying a stream
42 // dependency based on the RequestPriority.
43 kTestCaseHTTP2NoPriorityDependencies,
44
45 // Test using the HTTP/2 protocol, specifying a stream
46 // dependency based on the RequestPriority.
47 kTestCaseHTTP2PriorityDependencies
48 };
49
37 // Tests the load timing of a stream that's connected and is not the first 50 // Tests the load timing of a stream that's connected and is not the first
38 // request sent on a connection. 51 // request sent on a connection.
39 void TestLoadTimingReused(const HttpStream& stream) { 52 void TestLoadTimingReused(const HttpStream& stream) {
40 LoadTimingInfo load_timing_info; 53 LoadTimingInfo load_timing_info;
41 EXPECT_TRUE(stream.GetLoadTimingInfo(&load_timing_info)); 54 EXPECT_TRUE(stream.GetLoadTimingInfo(&load_timing_info));
42 55
43 EXPECT_TRUE(load_timing_info.socket_reused); 56 EXPECT_TRUE(load_timing_info.socket_reused);
44 EXPECT_NE(NetLog::Source::kInvalidId, load_timing_info.socket_log_id); 57 EXPECT_NE(NetLog::Source::kInvalidId, load_timing_info.socket_log_id);
45 58
46 ExpectConnectTimingHasNoTimes(load_timing_info.connect_timing); 59 ExpectConnectTimingHasNoTimes(load_timing_info.connect_timing);
(...skipping 10 matching lines...) Expand all
57 EXPECT_NE(NetLog::Source::kInvalidId, load_timing_info.socket_log_id); 70 EXPECT_NE(NetLog::Source::kInvalidId, load_timing_info.socket_log_id);
58 71
59 ExpectConnectTimingHasTimes(load_timing_info.connect_timing, 72 ExpectConnectTimingHasTimes(load_timing_info.connect_timing,
60 CONNECT_TIMING_HAS_DNS_TIMES); 73 CONNECT_TIMING_HAS_DNS_TIMES);
61 ExpectLoadTimingHasOnlyConnectionTimes(load_timing_info); 74 ExpectLoadTimingHasOnlyConnectionTimes(load_timing_info);
62 } 75 }
63 76
64 } // namespace 77 } // namespace
65 78
66 class SpdyHttpStreamTest : public testing::Test, 79 class SpdyHttpStreamTest : public testing::Test,
67 public testing::WithParamInterface<NextProto> { 80 public testing::WithParamInterface<TestCase> {
68 public: 81 public:
69 SpdyHttpStreamTest() 82 SpdyHttpStreamTest()
70 : spdy_util_(GetParam()), 83 : spdy_util_(GetProtocol(), GetDependenciesFromPriority()),
71 session_deps_(GetParam()) { 84 session_deps_(GetProtocol()) {
85 SpdySession::SetPriorityDependencyDefaultForTesting(
86 GetDependenciesFromPriority());
72 session_deps_.net_log = &net_log_; 87 session_deps_.net_log = &net_log_;
73 } 88 }
74 89
90 ~SpdyHttpStreamTest() {
91 SpdySession::SetPriorityDependencyDefaultForTesting(false);
92 }
93
75 protected: 94 protected:
95 NextProto GetProtocol() const {
96 return GetParam() == kTestCaseSPDY31 ? kProtoSPDY31 : kProtoHTTP2;
97 }
98
99 bool GetDependenciesFromPriority() const {
100 return GetParam() == kTestCaseHTTP2PriorityDependencies;
101 }
102
76 void TearDown() override { 103 void TearDown() override {
77 crypto::ECSignatureCreator::SetFactoryForTesting(NULL); 104 crypto::ECSignatureCreator::SetFactoryForTesting(NULL);
78 base::MessageLoop::current()->RunUntilIdle(); 105 base::MessageLoop::current()->RunUntilIdle();
79 EXPECT_TRUE(sequenced_data_->AllReadDataConsumed()); 106 EXPECT_TRUE(sequenced_data_->AllReadDataConsumed());
80 EXPECT_TRUE(sequenced_data_->AllWriteDataConsumed()); 107 EXPECT_TRUE(sequenced_data_->AllWriteDataConsumed());
81 } 108 }
82 109
83 // Initializes the session using SequencedSocketData. 110 // Initializes the session using SequencedSocketData.
84 void InitSession(MockRead* reads, 111 void InitSession(MockRead* reads,
85 size_t reads_count, 112 size_t reads_count,
(...skipping 17 matching lines...) Expand all
103 TestNetLog net_log_; 130 TestNetLog net_log_;
104 SpdySessionDependencies session_deps_; 131 SpdySessionDependencies session_deps_;
105 scoped_ptr<SequencedSocketData> sequenced_data_; 132 scoped_ptr<SequencedSocketData> sequenced_data_;
106 scoped_ptr<HttpNetworkSession> http_session_; 133 scoped_ptr<HttpNetworkSession> http_session_;
107 base::WeakPtr<SpdySession> session_; 134 base::WeakPtr<SpdySession> session_;
108 135
109 private: 136 private:
110 MockECSignatureCreatorFactory ec_signature_creator_factory_; 137 MockECSignatureCreatorFactory ec_signature_creator_factory_;
111 }; 138 };
112 139
113 INSTANTIATE_TEST_CASE_P(NextProto, 140 INSTANTIATE_TEST_CASE_P(ProtoPlusDepend,
114 SpdyHttpStreamTest, 141 SpdyHttpStreamTest,
115 testing::Values(kProtoSPDY31, 142 testing::Values(kTestCaseSPDY31,
116 kProtoHTTP2)); 143 kTestCaseHTTP2NoPriorityDependencies,
144 kTestCaseHTTP2PriorityDependencies));
117 145
118 // SpdyHttpStream::GetUploadProgress() should still work even before the 146 // SpdyHttpStream::GetUploadProgress() should still work even before the
119 // stream is initialized. 147 // stream is initialized.
120 TEST_P(SpdyHttpStreamTest, GetUploadProgressBeforeInitialization) { 148 TEST_P(SpdyHttpStreamTest, GetUploadProgressBeforeInitialization) {
121 MockRead reads[] = { 149 MockRead reads[] = {
122 MockRead(ASYNC, 0, 0) // EOF 150 MockRead(ASYNC, 0, 0) // EOF
123 }; 151 };
124 152
125 HostPortPair host_port_pair("www.example.org", 80); 153 HostPortPair host_port_pair("www.example.org", 80);
126 SpdySessionKey key(host_port_pair, ProxyServer::Direct(), 154 SpdySessionKey key(host_port_pair, ProxyServer::Direct(),
(...skipping 708 matching lines...) Expand 10 before | Expand all | Expand 10 after
835 EXPECT_EQ(kUploadData, std::string(buf1->data(), kUploadDataSize)); 863 EXPECT_EQ(kUploadData, std::string(buf1->data(), kUploadDataSize));
836 864
837 ASSERT_TRUE(response.headers.get()); 865 ASSERT_TRUE(response.headers.get());
838 ASSERT_EQ(200, response.headers->response_code()); 866 ASSERT_EQ(200, response.headers->response_code());
839 } 867 }
840 868
841 // TODO(willchan): Write a longer test for SpdyStream that exercises all 869 // TODO(willchan): Write a longer test for SpdyStream that exercises all
842 // methods. 870 // methods.
843 871
844 } // namespace net 872 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_proxy_client_socket_pool_unittest.cc ('k') | net/spdy/spdy_network_transaction_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698