OLD | NEW |
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_session.h" | 5 #include "net/spdy/spdy_session.h" |
6 | 6 |
7 #include "net/base/ip_endpoint.h" | 7 #include "net/base/ip_endpoint.h" |
8 #include "net/base/net_log_unittest.h" | 8 #include "net/base/net_log_unittest.h" |
9 #include "net/spdy/spdy_io_buffer.h" | 9 #include "net/spdy/spdy_io_buffer.h" |
10 #include "net/spdy/spdy_session_pool.h" | 10 #include "net/spdy/spdy_session_pool.h" |
11 #include "net/spdy/spdy_stream.h" | 11 #include "net/spdy/spdy_stream.h" |
12 #include "net/spdy/spdy_test_util.h" | 12 #include "net/spdy/spdy_test_util_spdy2.h" |
13 #include "testing/platform_test.h" | 13 #include "testing/platform_test.h" |
14 | 14 |
| 15 using namespace net::test_spdy2; |
| 16 |
15 namespace net { | 17 namespace net { |
16 | 18 |
17 // TODO(cbentzel): Expose compression setter/getter in public SpdySession | 19 // TODO(cbentzel): Expose compression setter/getter in public SpdySession |
18 // interface rather than going through all these contortions. | 20 // interface rather than going through all these contortions. |
19 class SpdySessionTest : public PlatformTest { | 21 class SpdySessionSpdy2Test : public PlatformTest { |
20 public: | 22 public: |
21 static void TurnOffCompression() { | 23 static void TurnOffCompression() { |
22 spdy::SpdyFramer::set_enable_compression_default(false); | 24 spdy::SpdyFramer::set_enable_compression_default(false); |
23 } | 25 } |
24 protected: | 26 protected: |
25 virtual void TearDown() { | 27 virtual void TearDown() { |
26 // Wanted to be 100% sure PING is disabled. | 28 // Wanted to be 100% sure PING is disabled. |
27 SpdySession::set_enable_ping_based_connection_checking(false); | 29 SpdySession::set_enable_ping_based_connection_checking(false); |
28 } | 30 } |
29 }; | 31 }; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 callback.Run(OK); | 64 callback.Run(OK); |
63 } | 65 } |
64 | 66 |
65 virtual void set_chunk_callback(net::ChunkCallback *) {} | 67 virtual void set_chunk_callback(net::ChunkCallback *) {} |
66 | 68 |
67 private: | 69 private: |
68 CompletionCallback callback_; | 70 CompletionCallback callback_; |
69 }; | 71 }; |
70 | 72 |
71 // Test the SpdyIOBuffer class. | 73 // Test the SpdyIOBuffer class. |
72 TEST_F(SpdySessionTest, SpdyIOBuffer) { | 74 TEST_F(SpdySessionSpdy2Test, SpdyIOBuffer) { |
73 std::priority_queue<SpdyIOBuffer> queue_; | 75 std::priority_queue<SpdyIOBuffer> queue_; |
74 const size_t kQueueSize = 100; | 76 const size_t kQueueSize = 100; |
75 | 77 |
76 // Insert 100 items; pri 100 to 1. | 78 // Insert 100 items; pri 100 to 1. |
77 for (size_t index = 0; index < kQueueSize; ++index) { | 79 for (size_t index = 0; index < kQueueSize; ++index) { |
78 SpdyIOBuffer buffer(new IOBuffer(), 0, kQueueSize - index, NULL); | 80 SpdyIOBuffer buffer(new IOBuffer(), 0, kQueueSize - index, NULL); |
79 queue_.push(buffer); | 81 queue_.push(buffer); |
80 } | 82 } |
81 | 83 |
82 // Insert several priority 0 items last. | 84 // Insert several priority 0 items last. |
(...skipping 15 matching lines...) Expand all Loading... |
98 } | 100 } |
99 | 101 |
100 int priority = 1; | 102 int priority = 1; |
101 while (queue_.size()) { | 103 while (queue_.size()) { |
102 SpdyIOBuffer buffer = queue_.top(); | 104 SpdyIOBuffer buffer = queue_.top(); |
103 EXPECT_EQ(priority++, buffer.priority()); | 105 EXPECT_EQ(priority++, buffer.priority()); |
104 queue_.pop(); | 106 queue_.pop(); |
105 } | 107 } |
106 } | 108 } |
107 | 109 |
108 TEST_F(SpdySessionTest, GoAway) { | 110 TEST_F(SpdySessionSpdy2Test, GoAway) { |
109 SpdySessionDependencies session_deps; | 111 SpdySessionDependencies session_deps; |
110 session_deps.host_resolver->set_synchronous_mode(true); | 112 session_deps.host_resolver->set_synchronous_mode(true); |
111 | 113 |
112 MockConnect connect_data(SYNCHRONOUS, OK); | 114 MockConnect connect_data(SYNCHRONOUS, OK); |
113 scoped_ptr<spdy::SpdyFrame> goaway(ConstructSpdyGoAway()); | 115 scoped_ptr<spdy::SpdyFrame> goaway(ConstructSpdyGoAway()); |
114 MockRead reads[] = { | 116 MockRead reads[] = { |
115 CreateMockRead(*goaway), | 117 CreateMockRead(*goaway), |
116 MockRead(SYNCHRONOUS, 0, 0) // EOF | 118 MockRead(SYNCHRONOUS, 0, 0) // EOF |
117 }; | 119 }; |
118 StaticSocketDataProvider data(reads, arraysize(reads), NULL, 0); | 120 StaticSocketDataProvider data(reads, arraysize(reads), NULL, 0); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 spdy_session_pool->Get(pair, BoundNetLog()); | 159 spdy_session_pool->Get(pair, BoundNetLog()); |
158 | 160 |
159 // Delete the first session. | 161 // Delete the first session. |
160 session = NULL; | 162 session = NULL; |
161 | 163 |
162 // Delete the second session. | 164 // Delete the second session. |
163 spdy_session_pool->Remove(session2); | 165 spdy_session_pool->Remove(session2); |
164 session2 = NULL; | 166 session2 = NULL; |
165 } | 167 } |
166 | 168 |
167 TEST_F(SpdySessionTest, Ping) { | 169 TEST_F(SpdySessionSpdy2Test, Ping) { |
168 SpdySessionDependencies session_deps; | 170 SpdySessionDependencies session_deps; |
169 session_deps.host_resolver->set_synchronous_mode(true); | 171 session_deps.host_resolver->set_synchronous_mode(true); |
170 | 172 |
171 MockConnect connect_data(SYNCHRONOUS, OK); | 173 MockConnect connect_data(SYNCHRONOUS, OK); |
172 scoped_ptr<spdy::SpdyFrame> read_ping(ConstructSpdyPing()); | 174 scoped_ptr<spdy::SpdyFrame> read_ping(ConstructSpdyPing()); |
173 MockRead reads[] = { | 175 MockRead reads[] = { |
174 CreateMockRead(*read_ping), | 176 CreateMockRead(*read_ping), |
175 CreateMockRead(*read_ping), | 177 CreateMockRead(*read_ping), |
176 MockRead(SYNCHRONOUS, 0, 0) // EOF | 178 MockRead(SYNCHRONOUS, 0, 0) // EOF |
177 }; | 179 }; |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 EXPECT_FALSE(session->trailing_ping_pending()); | 250 EXPECT_FALSE(session->trailing_ping_pending()); |
249 EXPECT_FALSE(session->check_ping_status_pending()); | 251 EXPECT_FALSE(session->check_ping_status_pending()); |
250 EXPECT_GE(session->received_data_time(), before_ping_time); | 252 EXPECT_GE(session->received_data_time(), before_ping_time); |
251 | 253 |
252 EXPECT_FALSE(spdy_session_pool->HasSession(pair)); | 254 EXPECT_FALSE(spdy_session_pool->HasSession(pair)); |
253 | 255 |
254 // Delete the first session. | 256 // Delete the first session. |
255 session = NULL; | 257 session = NULL; |
256 } | 258 } |
257 | 259 |
258 TEST_F(SpdySessionTest, FailedPing) { | 260 TEST_F(SpdySessionSpdy2Test, FailedPing) { |
259 SpdySessionDependencies session_deps; | 261 SpdySessionDependencies session_deps; |
260 session_deps.host_resolver->set_synchronous_mode(true); | 262 session_deps.host_resolver->set_synchronous_mode(true); |
261 | 263 |
262 MockConnect connect_data(SYNCHRONOUS, OK); | 264 MockConnect connect_data(SYNCHRONOUS, OK); |
263 scoped_ptr<spdy::SpdyFrame> read_ping(ConstructSpdyPing()); | 265 scoped_ptr<spdy::SpdyFrame> read_ping(ConstructSpdyPing()); |
264 MockRead reads[] = { | 266 MockRead reads[] = { |
265 CreateMockRead(*read_ping), | 267 CreateMockRead(*read_ping), |
266 MockRead(SYNCHRONOUS, 0, 0) // EOF | 268 MockRead(SYNCHRONOUS, 0, 0) // EOF |
267 }; | 269 }; |
268 scoped_ptr<spdy::SpdyFrame> write_ping(ConstructSpdyPing()); | 270 scoped_ptr<spdy::SpdyFrame> write_ping(ConstructSpdyPing()); |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 } | 380 } |
379 | 381 |
380 scoped_refptr<SpdySession> session_; | 382 scoped_refptr<SpdySession> session_; |
381 scoped_refptr<SpdyStream> first_stream_; | 383 scoped_refptr<SpdyStream> first_stream_; |
382 scoped_refptr<SpdyStream> stream_; | 384 scoped_refptr<SpdyStream> stream_; |
383 CompletionCallback callback_; | 385 CompletionCallback callback_; |
384 }; | 386 }; |
385 | 387 |
386 // TODO(kristianm): Could also test with more sessions where some are idle, | 388 // TODO(kristianm): Could also test with more sessions where some are idle, |
387 // and more than one session to a HostPortPair. | 389 // and more than one session to a HostPortPair. |
388 TEST_F(SpdySessionTest, CloseIdleSessions) { | 390 TEST_F(SpdySessionSpdy2Test, CloseIdleSessions) { |
389 SpdySessionDependencies session_deps; | 391 SpdySessionDependencies session_deps; |
390 scoped_refptr<HttpNetworkSession> http_session( | 392 scoped_refptr<HttpNetworkSession> http_session( |
391 SpdySessionDependencies::SpdyCreateSession(&session_deps)); | 393 SpdySessionDependencies::SpdyCreateSession(&session_deps)); |
392 SpdySessionPool* spdy_session_pool(http_session->spdy_session_pool()); | 394 SpdySessionPool* spdy_session_pool(http_session->spdy_session_pool()); |
393 | 395 |
394 // Set up session 1 | 396 // Set up session 1 |
395 const std::string kTestHost1("http://www.a.com"); | 397 const std::string kTestHost1("http://www.a.com"); |
396 HostPortPair test_host_port_pair1(kTestHost1, 80); | 398 HostPortPair test_host_port_pair1(kTestHost1, 80); |
397 HostPortProxyPair pair1(test_host_port_pair1, ProxyServer::Direct()); | 399 HostPortProxyPair pair1(test_host_port_pair1, ProxyServer::Direct()); |
398 scoped_refptr<SpdySession> session1 = | 400 scoped_refptr<SpdySession> session1 = |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 spdy_session_pool->CloseIdleSessions(); | 485 spdy_session_pool->CloseIdleSessions(); |
484 EXPECT_FALSE(session2->is_active()); | 486 EXPECT_FALSE(session2->is_active()); |
485 EXPECT_TRUE(session2->IsClosed()); | 487 EXPECT_TRUE(session2->IsClosed()); |
486 } | 488 } |
487 | 489 |
488 // Start with max concurrent streams set to 1. Request two streams. Receive a | 490 // Start with max concurrent streams set to 1. Request two streams. Receive a |
489 // settings frame setting max concurrent streams to 2. Have the callback | 491 // settings frame setting max concurrent streams to 2. Have the callback |
490 // release the stream, which releases its reference (the last) to the session. | 492 // release the stream, which releases its reference (the last) to the session. |
491 // Make sure nothing blows up. | 493 // Make sure nothing blows up. |
492 // http://crbug.com/57331 | 494 // http://crbug.com/57331 |
493 TEST_F(SpdySessionTest, OnSettings) { | 495 TEST_F(SpdySessionSpdy2Test, OnSettings) { |
494 SpdySessionDependencies session_deps; | 496 SpdySessionDependencies session_deps; |
495 session_deps.host_resolver->set_synchronous_mode(true); | 497 session_deps.host_resolver->set_synchronous_mode(true); |
496 | 498 |
497 spdy::SpdySettings new_settings; | 499 spdy::SpdySettings new_settings; |
498 spdy::SettingsFlagsAndId id(0); | 500 spdy::SettingsFlagsAndId id(0); |
499 id.set_id(spdy::SETTINGS_MAX_CONCURRENT_STREAMS); | 501 id.set_id(spdy::SETTINGS_MAX_CONCURRENT_STREAMS); |
500 const size_t max_concurrent_streams = 2; | 502 const size_t max_concurrent_streams = 2; |
501 new_settings.push_back(spdy::SpdySetting(id, max_concurrent_streams)); | 503 new_settings.push_back(spdy::SpdySetting(id, max_concurrent_streams)); |
502 | 504 |
503 // Set up the socket so we read a SETTINGS frame that raises max concurrent | 505 // Set up the socket so we read a SETTINGS frame that raises max concurrent |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
575 session = NULL; | 577 session = NULL; |
576 spdy_stream1 = NULL; | 578 spdy_stream1 = NULL; |
577 | 579 |
578 EXPECT_EQ(OK, stream_releaser.WaitForResult()); | 580 EXPECT_EQ(OK, stream_releaser.WaitForResult()); |
579 } | 581 } |
580 | 582 |
581 // Start with max concurrent streams set to 1. Request two streams. When the | 583 // Start with max concurrent streams set to 1. Request two streams. When the |
582 // first completes, have the callback close itself, which should trigger the | 584 // first completes, have the callback close itself, which should trigger the |
583 // second stream creation. Then cancel that one immediately. Don't crash. | 585 // second stream creation. Then cancel that one immediately. Don't crash. |
584 // http://crbug.com/63532 | 586 // http://crbug.com/63532 |
585 TEST_F(SpdySessionTest, CancelPendingCreateStream) { | 587 TEST_F(SpdySessionSpdy2Test, CancelPendingCreateStream) { |
586 SpdySessionDependencies session_deps; | 588 SpdySessionDependencies session_deps; |
587 session_deps.host_resolver->set_synchronous_mode(true); | 589 session_deps.host_resolver->set_synchronous_mode(true); |
588 | 590 |
589 MockRead reads[] = { | 591 MockRead reads[] = { |
590 MockRead(SYNCHRONOUS, ERR_IO_PENDING) // Stall forever. | 592 MockRead(SYNCHRONOUS, ERR_IO_PENDING) // Stall forever. |
591 }; | 593 }; |
592 | 594 |
593 StaticSocketDataProvider data(reads, arraysize(reads), NULL, 0); | 595 StaticSocketDataProvider data(reads, arraysize(reads), NULL, 0); |
594 MockConnect connect_data(SYNCHRONOUS, OK); | 596 MockConnect connect_data(SYNCHRONOUS, OK); |
595 | 597 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
661 spdy_stream1->Cancel(); | 663 spdy_stream1->Cancel(); |
662 spdy_stream1 = NULL; | 664 spdy_stream1 = NULL; |
663 | 665 |
664 session->CancelPendingCreateStreams(&spdy_stream2); | 666 session->CancelPendingCreateStreams(&spdy_stream2); |
665 callback.reset(); | 667 callback.reset(); |
666 | 668 |
667 // Should not crash when running the pending callback. | 669 // Should not crash when running the pending callback. |
668 MessageLoop::current()->RunAllPending(); | 670 MessageLoop::current()->RunAllPending(); |
669 } | 671 } |
670 | 672 |
671 TEST_F(SpdySessionTest, SendSettingsOnNewSession) { | 673 TEST_F(SpdySessionSpdy2Test, SendSettingsOnNewSession) { |
672 SpdySessionDependencies session_deps; | 674 SpdySessionDependencies session_deps; |
673 session_deps.host_resolver->set_synchronous_mode(true); | 675 session_deps.host_resolver->set_synchronous_mode(true); |
674 | 676 |
675 MockRead reads[] = { | 677 MockRead reads[] = { |
676 MockRead(SYNCHRONOUS, ERR_IO_PENDING) // Stall forever. | 678 MockRead(SYNCHRONOUS, ERR_IO_PENDING) // Stall forever. |
677 }; | 679 }; |
678 | 680 |
679 // Create the bogus setting that we want to verify is sent out. | 681 // Create the bogus setting that we want to verify is sent out. |
680 // Note that it will be marked as SETTINGS_FLAG_PERSISTED when sent out. But | 682 // Note that it will be marked as SETTINGS_FLAG_PERSISTED when sent out. But |
681 // to set it into the SpdySettingsStorage, we need to mark as | 683 // to set it into the SpdySettingsStorage, we need to mark as |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
729 scoped_ptr<ClientSocketHandle> connection(new ClientSocketHandle); | 731 scoped_ptr<ClientSocketHandle> connection(new ClientSocketHandle); |
730 EXPECT_EQ(OK, connection->Init(test_host_port_pair.ToString(), | 732 EXPECT_EQ(OK, connection->Init(test_host_port_pair.ToString(), |
731 transport_params, MEDIUM, CompletionCallback(), | 733 transport_params, MEDIUM, CompletionCallback(), |
732 http_session->GetTransportSocketPool(), | 734 http_session->GetTransportSocketPool(), |
733 BoundNetLog())); | 735 BoundNetLog())); |
734 EXPECT_EQ(OK, session->InitializeWithSocket(connection.release(), false, OK)); | 736 EXPECT_EQ(OK, session->InitializeWithSocket(connection.release(), false, OK)); |
735 MessageLoop::current()->RunAllPending(); | 737 MessageLoop::current()->RunAllPending(); |
736 EXPECT_TRUE(data.at_write_eof()); | 738 EXPECT_TRUE(data.at_write_eof()); |
737 } | 739 } |
738 | 740 |
| 741 namespace { |
739 // This test has two variants, one for each style of closing the connection. | 742 // This test has two variants, one for each style of closing the connection. |
740 // If |clean_via_close_current_sessions| is false, the sessions are closed | 743 // If |clean_via_close_current_sessions| is false, the sessions are closed |
741 // manually, calling SpdySessionPool::Remove() directly. If it is true, | 744 // manually, calling SpdySessionPool::Remove() directly. If it is true, |
742 // sessions are closed with SpdySessionPool::CloseCurrentSessions(). | 745 // sessions are closed with SpdySessionPool::CloseCurrentSessions(). |
743 void IPPoolingTest(bool clean_via_close_current_sessions) { | 746 void IPPoolingTest(bool clean_via_close_current_sessions) { |
744 const int kTestPort = 80; | 747 const int kTestPort = 80; |
745 struct TestHosts { | 748 struct TestHosts { |
746 std::string name; | 749 std::string name; |
747 std::string iplist; | 750 std::string iplist; |
748 HostPortProxyPair pair; | 751 HostPortProxyPair pair; |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
847 } else { | 850 } else { |
848 spdy_session_pool->CloseCurrentSessions(); | 851 spdy_session_pool->CloseCurrentSessions(); |
849 } | 852 } |
850 | 853 |
851 // Verify that the map is all cleaned up. | 854 // Verify that the map is all cleaned up. |
852 EXPECT_FALSE(spdy_session_pool->HasSession(test_hosts[0].pair)); | 855 EXPECT_FALSE(spdy_session_pool->HasSession(test_hosts[0].pair)); |
853 EXPECT_FALSE(spdy_session_pool->HasSession(test_hosts[1].pair)); | 856 EXPECT_FALSE(spdy_session_pool->HasSession(test_hosts[1].pair)); |
854 EXPECT_FALSE(spdy_session_pool->HasSession(test_hosts[2].pair)); | 857 EXPECT_FALSE(spdy_session_pool->HasSession(test_hosts[2].pair)); |
855 } | 858 } |
856 | 859 |
857 TEST_F(SpdySessionTest, IPPooling) { | 860 } // namespace |
| 861 |
| 862 TEST_F(SpdySessionSpdy2Test, IPPooling) { |
858 IPPoolingTest(false); | 863 IPPoolingTest(false); |
859 } | 864 } |
860 | 865 |
861 TEST_F(SpdySessionTest, IPPoolingCloseCurrentSessions) { | 866 TEST_F(SpdySessionSpdy2Test, IPPoolingCloseCurrentSessions) { |
862 IPPoolingTest(true); | 867 IPPoolingTest(true); |
863 } | 868 } |
864 | 869 |
865 TEST_F(SpdySessionTest, ClearSettingsStorage) { | 870 TEST_F(SpdySessionSpdy2Test, ClearSettingsStorage) { |
866 SpdySettingsStorage settings_storage; | 871 SpdySettingsStorage settings_storage; |
867 const std::string kTestHost("www.foo.com"); | 872 const std::string kTestHost("www.foo.com"); |
868 const int kTestPort = 80; | 873 const int kTestPort = 80; |
869 HostPortPair test_host_port_pair(kTestHost, kTestPort); | 874 HostPortPair test_host_port_pair(kTestHost, kTestPort); |
870 spdy::SpdySettings test_settings; | 875 spdy::SpdySettings test_settings; |
871 spdy::SettingsFlagsAndId id(0); | 876 spdy::SettingsFlagsAndId id(0); |
872 id.set_id(spdy::SETTINGS_MAX_CONCURRENT_STREAMS); | 877 id.set_id(spdy::SETTINGS_MAX_CONCURRENT_STREAMS); |
873 id.set_flags(spdy::SETTINGS_FLAG_PLEASE_PERSIST); | 878 id.set_flags(spdy::SETTINGS_FLAG_PLEASE_PERSIST); |
874 const size_t max_concurrent_streams = 2; | 879 const size_t max_concurrent_streams = 2; |
875 test_settings.push_back(spdy::SpdySetting(id, max_concurrent_streams)); | 880 test_settings.push_back(spdy::SpdySetting(id, max_concurrent_streams)); |
876 | 881 |
877 settings_storage.Set(test_host_port_pair, test_settings); | 882 settings_storage.Set(test_host_port_pair, test_settings); |
878 EXPECT_NE(0u, settings_storage.Get(test_host_port_pair).size()); | 883 EXPECT_NE(0u, settings_storage.Get(test_host_port_pair).size()); |
879 settings_storage.Clear(); | 884 settings_storage.Clear(); |
880 EXPECT_EQ(0u, settings_storage.Get(test_host_port_pair).size()); | 885 EXPECT_EQ(0u, settings_storage.Get(test_host_port_pair).size()); |
881 } | 886 } |
882 | 887 |
883 TEST_F(SpdySessionTest, ClearSettingsStorageOnIPAddressChanged) { | 888 TEST_F(SpdySessionSpdy2Test, ClearSettingsStorageOnIPAddressChanged) { |
884 const std::string kTestHost("www.foo.com"); | 889 const std::string kTestHost("www.foo.com"); |
885 const int kTestPort = 80; | 890 const int kTestPort = 80; |
886 HostPortPair test_host_port_pair(kTestHost, kTestPort); | 891 HostPortPair test_host_port_pair(kTestHost, kTestPort); |
887 | 892 |
888 SpdySessionDependencies session_deps; | 893 SpdySessionDependencies session_deps; |
889 scoped_refptr<HttpNetworkSession> http_session( | 894 scoped_refptr<HttpNetworkSession> http_session( |
890 SpdySessionDependencies::SpdyCreateSession(&session_deps)); | 895 SpdySessionDependencies::SpdyCreateSession(&session_deps)); |
891 SpdySessionPool* spdy_session_pool(http_session->spdy_session_pool()); | 896 SpdySessionPool* spdy_session_pool(http_session->spdy_session_pool()); |
892 | 897 |
893 HttpServerProperties* test_http_server_properties = | 898 HttpServerProperties* test_http_server_properties = |
894 spdy_session_pool->http_server_properties(); | 899 spdy_session_pool->http_server_properties(); |
895 spdy::SettingsFlagsAndId id(0); | 900 spdy::SettingsFlagsAndId id(0); |
896 id.set_id(spdy::SETTINGS_MAX_CONCURRENT_STREAMS); | 901 id.set_id(spdy::SETTINGS_MAX_CONCURRENT_STREAMS); |
897 id.set_flags(spdy::SETTINGS_FLAG_PLEASE_PERSIST); | 902 id.set_flags(spdy::SETTINGS_FLAG_PLEASE_PERSIST); |
898 const size_t max_concurrent_streams = 2; | 903 const size_t max_concurrent_streams = 2; |
899 spdy::SpdySettings test_settings; | 904 spdy::SpdySettings test_settings; |
900 test_settings.push_back(spdy::SpdySetting(id, max_concurrent_streams)); | 905 test_settings.push_back(spdy::SpdySetting(id, max_concurrent_streams)); |
901 | 906 |
902 test_http_server_properties->SetSpdySettings(test_host_port_pair, | 907 test_http_server_properties->SetSpdySettings(test_host_port_pair, |
903 test_settings); | 908 test_settings); |
904 EXPECT_NE(0u, test_http_server_properties->GetSpdySettings( | 909 EXPECT_NE(0u, test_http_server_properties->GetSpdySettings( |
905 test_host_port_pair).size()); | 910 test_host_port_pair).size()); |
906 spdy_session_pool->OnIPAddressChanged(); | 911 spdy_session_pool->OnIPAddressChanged(); |
907 EXPECT_EQ(0u, test_http_server_properties->GetSpdySettings( | 912 EXPECT_EQ(0u, test_http_server_properties->GetSpdySettings( |
908 test_host_port_pair).size()); | 913 test_host_port_pair).size()); |
909 } | 914 } |
910 | 915 |
911 TEST_F(SpdySessionTest, NeedsCredentials) { | 916 TEST_F(SpdySessionSpdy2Test, NeedsCredentials) { |
912 SpdySessionDependencies session_deps; | 917 SpdySessionDependencies session_deps; |
913 | 918 |
914 MockConnect connect_data(SYNCHRONOUS, OK); | 919 MockConnect connect_data(SYNCHRONOUS, OK); |
915 MockRead reads[] = { | 920 MockRead reads[] = { |
916 MockRead(SYNCHRONOUS, ERR_IO_PENDING) // Stall forever. | 921 MockRead(SYNCHRONOUS, ERR_IO_PENDING) // Stall forever. |
917 }; | 922 }; |
918 StaticSocketDataProvider data(reads, arraysize(reads), NULL, 0); | 923 StaticSocketDataProvider data(reads, arraysize(reads), NULL, 0); |
919 data.set_connect_data(connect_data); | 924 data.set_connect_data(connect_data); |
920 session_deps.socket_factory->AddSocketDataProvider(&data); | 925 session_deps.socket_factory->AddSocketDataProvider(&data); |
921 | 926 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
969 HostPortPair test_host_port_pair2(kTestHost2, kTestPort); | 974 HostPortPair test_host_port_pair2(kTestHost2, kTestPort); |
970 EXPECT_TRUE(session->NeedsCredentials(test_host_port_pair2)); | 975 EXPECT_TRUE(session->NeedsCredentials(test_host_port_pair2)); |
971 | 976 |
972 // Flush the SpdySession::OnReadComplete() task. | 977 // Flush the SpdySession::OnReadComplete() task. |
973 MessageLoop::current()->RunAllPending(); | 978 MessageLoop::current()->RunAllPending(); |
974 | 979 |
975 spdy_session_pool->Remove(session); | 980 spdy_session_pool->Remove(session); |
976 EXPECT_FALSE(spdy_session_pool->HasSession(pair)); | 981 EXPECT_FALSE(spdy_session_pool->HasSession(pair)); |
977 } | 982 } |
978 | 983 |
979 TEST_F(SpdySessionTest, SendCredentials) { | 984 TEST_F(SpdySessionSpdy2Test, SendCredentials) { |
980 SpdySessionDependencies session_deps; | 985 SpdySessionDependencies session_deps; |
981 | 986 |
982 MockConnect connect_data(SYNCHRONOUS, OK); | 987 MockConnect connect_data(SYNCHRONOUS, OK); |
983 MockRead reads[] = { | 988 MockRead reads[] = { |
984 MockRead(SYNCHRONOUS, ERR_IO_PENDING) // Stall forever. | 989 MockRead(SYNCHRONOUS, ERR_IO_PENDING) // Stall forever. |
985 }; | 990 }; |
986 spdy::SpdySettings settings; | 991 spdy::SpdySettings settings; |
987 scoped_ptr<spdy::SpdyFrame> settings_frame( | 992 scoped_ptr<spdy::SpdyFrame> settings_frame( |
988 ConstructSpdySettings(settings)); | 993 ConstructSpdySettings(settings)); |
989 MockWrite writes[] = { | 994 MockWrite writes[] = { |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1044 HostPortPair test_host_port_pair2(kTestHost2, kTestPort); | 1049 HostPortPair test_host_port_pair2(kTestHost2, kTestPort); |
1045 EXPECT_TRUE(session->NeedsCredentials(test_host_port_pair2)); | 1050 EXPECT_TRUE(session->NeedsCredentials(test_host_port_pair2)); |
1046 | 1051 |
1047 // Flush the SpdySession::OnReadComplete() task. | 1052 // Flush the SpdySession::OnReadComplete() task. |
1048 MessageLoop::current()->RunAllPending(); | 1053 MessageLoop::current()->RunAllPending(); |
1049 | 1054 |
1050 spdy_session_pool->Remove(session); | 1055 spdy_session_pool->Remove(session); |
1051 EXPECT_FALSE(spdy_session_pool->HasSession(pair)); | 1056 EXPECT_FALSE(spdy_session_pool->HasSession(pair)); |
1052 } | 1057 } |
1053 | 1058 |
1054 TEST_F(SpdySessionTest, CloseSessionOnError) { | 1059 TEST_F(SpdySessionSpdy2Test, CloseSessionOnError) { |
1055 SpdySessionDependencies session_deps; | 1060 SpdySessionDependencies session_deps; |
1056 session_deps.host_resolver->set_synchronous_mode(true); | 1061 session_deps.host_resolver->set_synchronous_mode(true); |
1057 | 1062 |
1058 MockConnect connect_data(SYNCHRONOUS, OK); | 1063 MockConnect connect_data(SYNCHRONOUS, OK); |
1059 scoped_ptr<spdy::SpdyFrame> goaway(ConstructSpdyGoAway()); | 1064 scoped_ptr<spdy::SpdyFrame> goaway(ConstructSpdyGoAway()); |
1060 MockRead reads[] = { | 1065 MockRead reads[] = { |
1061 CreateMockRead(*goaway), | 1066 CreateMockRead(*goaway), |
1062 MockRead(SYNCHRONOUS, 0, 0) // EOF | 1067 MockRead(SYNCHRONOUS, 0, 0) // EOF |
1063 }; | 1068 }; |
1064 | 1069 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1114 net::NetLog::PHASE_NONE); | 1119 net::NetLog::PHASE_NONE); |
1115 | 1120 |
1116 CapturingNetLog::Entry entry = entries[pos]; | 1121 CapturingNetLog::Entry entry = entries[pos]; |
1117 NetLogSpdySessionCloseParameter* request_params = | 1122 NetLogSpdySessionCloseParameter* request_params = |
1118 static_cast<NetLogSpdySessionCloseParameter*>( | 1123 static_cast<NetLogSpdySessionCloseParameter*>( |
1119 entry.extra_parameters.get()); | 1124 entry.extra_parameters.get()); |
1120 EXPECT_EQ(ERR_CONNECTION_CLOSED, request_params->status()); | 1125 EXPECT_EQ(ERR_CONNECTION_CLOSED, request_params->status()); |
1121 } | 1126 } |
1122 | 1127 |
1123 } // namespace net | 1128 } // namespace net |
OLD | NEW |