OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/websockets/websocket_job.h" | 5 #include "net/websockets/websocket_job.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
615 EXPECT_TRUE(delegate.received_data().empty()); | 615 EXPECT_TRUE(delegate.received_data().empty()); |
616 EXPECT_EQ(WebSocketJob::CONNECTING, GetWebSocketJobState()); | 616 EXPECT_EQ(WebSocketJob::CONNECTING, GetWebSocketJobState()); |
617 websocket_->OnReceivedData(socket_.get(), "8jKS'y:G*Co,Wxa-", 16); | 617 websocket_->OnReceivedData(socket_.get(), "8jKS'y:G*Co,Wxa-", 16); |
618 EXPECT_EQ(kHandshakeResponseWithoutCookie, delegate.received_data()); | 618 EXPECT_EQ(kHandshakeResponseWithoutCookie, delegate.received_data()); |
619 EXPECT_EQ(WebSocketJob::OPEN, GetWebSocketJobState()); | 619 EXPECT_EQ(WebSocketJob::OPEN, GetWebSocketJobState()); |
620 CloseWebSocketJob(); | 620 CloseWebSocketJob(); |
621 } | 621 } |
622 | 622 |
623 TEST_F(WebSocketJobTest, DelayedCookies) { | 623 TEST_F(WebSocketJobTest, DelayedCookies) { |
624 WebSocketJob::set_websocket_over_spdy_enabled(true); | 624 WebSocketJob::set_websocket_over_spdy_enabled(true); |
| 625 // Disable sending PING. |
| 626 SpdySession::set_enable_ping_based_connection_checking(false); |
625 GURL url("ws://example.com/demo"); | 627 GURL url("ws://example.com/demo"); |
626 GURL cookieUrl("http://example.com/demo"); | 628 GURL cookieUrl("http://example.com/demo"); |
627 CookieOptions cookie_options; | 629 CookieOptions cookie_options; |
628 scoped_refptr<DelayedCookieMonster> cookie_store = new DelayedCookieMonster(); | 630 scoped_refptr<DelayedCookieMonster> cookie_store = new DelayedCookieMonster(); |
629 context_->set_cookie_store(cookie_store); | 631 context_->set_cookie_store(cookie_store); |
630 cookie_store->SetCookieWithOptionsAsync( | 632 cookie_store->SetCookieWithOptionsAsync( |
631 cookieUrl, "CR-test=1", cookie_options, | 633 cookieUrl, "CR-test=1", cookie_options, |
632 net::CookieMonster::SetCookiesCallback()); | 634 net::CookieMonster::SetCookiesCallback()); |
633 cookie_options.set_include_httponly(); | 635 cookie_options.set_include_httponly(); |
634 cookie_store->SetCookieWithOptionsAsync( | 636 cookie_store->SetCookieWithOptionsAsync( |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
859 } | 861 } |
860 | 862 |
861 EXPECT_EQ(OK, WaitForResult()); | 863 EXPECT_EQ(OK, WaitForResult()); |
862 EXPECT_TRUE(data_->at_read_eof()); | 864 EXPECT_TRUE(data_->at_read_eof()); |
863 EXPECT_TRUE(data_->at_write_eof()); | 865 EXPECT_TRUE(data_->at_write_eof()); |
864 EXPECT_EQ(WebSocketJob::CLOSED, GetWebSocketJobState()); | 866 EXPECT_EQ(WebSocketJob::CLOSED, GetWebSocketJobState()); |
865 } | 867 } |
866 | 868 |
867 void WebSocketJobTest::TestConnectBySpdy( | 869 void WebSocketJobTest::TestConnectBySpdy( |
868 SpdyOption spdy, ThrottlingOption throttling) { | 870 SpdyOption spdy, ThrottlingOption throttling) { |
| 871 // Disable sending PING. |
| 872 SpdySession::set_enable_ping_based_connection_checking(false); |
869 // This is a test for verifying cooperation between WebSocketJob and | 873 // This is a test for verifying cooperation between WebSocketJob and |
870 // SocketStream in the situation we have SPDY session to the server. If | 874 // SocketStream in the situation we have SPDY session to the server. If |
871 // |throttling| was |THROTTLING_ON|, throttling limits the latter connection. | 875 // |throttling| was |THROTTLING_ON|, throttling limits the latter connection. |
872 // If you enabled spdy, you should specify |spdy| as |SPDY_ON|. Expected | 876 // If you enabled spdy, you should specify |spdy| as |SPDY_ON|. Expected |
873 // results depend on its configuration. | 877 // results depend on its configuration. |
874 MockWrite writes_websocket[] = { | 878 MockWrite writes_websocket[] = { |
875 MockWrite(true, | 879 MockWrite(true, |
876 kHandshakeRequestWithoutCookie, | 880 kHandshakeRequestWithoutCookie, |
877 kHandshakeRequestWithoutCookieLength, | 881 kHandshakeRequestWithoutCookieLength, |
878 1), | 882 1), |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1077 | 1081 |
1078 TEST_F(WebSocketJobTest, ThrottlingSpdySpdyEnabled) { | 1082 TEST_F(WebSocketJobTest, ThrottlingSpdySpdyEnabled) { |
1079 WebSocketJob::set_websocket_over_spdy_enabled(true); | 1083 WebSocketJob::set_websocket_over_spdy_enabled(true); |
1080 TestConnectBySpdy(SPDY_ON, THROTTLING_ON); | 1084 TestConnectBySpdy(SPDY_ON, THROTTLING_ON); |
1081 } | 1085 } |
1082 | 1086 |
1083 // TODO(toyoshim): Add tests to verify throttling, SPDY stream limitation. | 1087 // TODO(toyoshim): Add tests to verify throttling, SPDY stream limitation. |
1084 // TODO(toyoshim,yutak): Add tests to verify closing handshake. | 1088 // TODO(toyoshim,yutak): Add tests to verify closing handshake. |
1085 | 1089 |
1086 } // namespace net | 1090 } // namespace net |
OLD | NEW |