| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/bind.h" | 10 #include "base/bind.h" |
| (...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 613 EXPECT_EQ(kHandshakeResponseWithoutCookie, delegate.received_data()); | 613 EXPECT_EQ(kHandshakeResponseWithoutCookie, delegate.received_data()); |
| 614 EXPECT_EQ(WebSocketJob::OPEN, GetWebSocketJobState()); | 614 EXPECT_EQ(WebSocketJob::OPEN, GetWebSocketJobState()); |
| 615 CloseWebSocketJob(); | 615 CloseWebSocketJob(); |
| 616 } | 616 } |
| 617 | 617 |
| 618 INSTANTIATE_TEST_CASE_P( | 618 INSTANTIATE_TEST_CASE_P( |
| 619 NextProto, | 619 NextProto, |
| 620 WebSocketJobTest, | 620 WebSocketJobTest, |
| 621 testing::Values(kProtoSPDY2, kProtoSPDY3, kProtoSPDY31, kProtoSPDY4a2)); | 621 testing::Values(kProtoSPDY2, kProtoSPDY3, kProtoSPDY31, kProtoSPDY4a2)); |
| 622 | 622 |
| 623 // TODO(akalin): Don't early-exit in the tests below for values > | |
| 624 // kProtoSPDY3. | |
| 625 | |
| 626 TEST_P(WebSocketJobTest, DelayedCookies) { | 623 TEST_P(WebSocketJobTest, DelayedCookies) { |
| 627 WebSocketJob::set_websocket_over_spdy_enabled(true); | 624 WebSocketJob::set_websocket_over_spdy_enabled(true); |
| 628 GURL url("ws://example.com/demo"); | 625 GURL url("ws://example.com/demo"); |
| 629 GURL cookieUrl("http://example.com/demo"); | 626 GURL cookieUrl("http://example.com/demo"); |
| 630 CookieOptions cookie_options; | 627 CookieOptions cookie_options; |
| 631 scoped_refptr<DelayedCookieMonster> cookie_store = new DelayedCookieMonster(); | 628 scoped_refptr<DelayedCookieMonster> cookie_store = new DelayedCookieMonster(); |
| 632 context_->set_cookie_store(cookie_store.get()); | 629 context_->set_cookie_store(cookie_store.get()); |
| 633 cookie_store->SetCookieWithOptionsAsync(cookieUrl, | 630 cookie_store->SetCookieWithOptionsAsync(cookieUrl, |
| 634 "CR-test=1", | 631 "CR-test=1", |
| 635 cookie_options, | 632 cookie_options, |
| (...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1063 WebSocketJob::set_websocket_over_spdy_enabled(false); | 1060 WebSocketJob::set_websocket_over_spdy_enabled(false); |
| 1064 TestConnectByWebSocket(THROTTLING_OFF); | 1061 TestConnectByWebSocket(THROTTLING_OFF); |
| 1065 } | 1062 } |
| 1066 | 1063 |
| 1067 TEST_P(WebSocketJobTest, ConnectByWebSocketSpdyEnabled) { | 1064 TEST_P(WebSocketJobTest, ConnectByWebSocketSpdyEnabled) { |
| 1068 WebSocketJob::set_websocket_over_spdy_enabled(true); | 1065 WebSocketJob::set_websocket_over_spdy_enabled(true); |
| 1069 TestConnectByWebSocket(THROTTLING_OFF); | 1066 TestConnectByWebSocket(THROTTLING_OFF); |
| 1070 } | 1067 } |
| 1071 | 1068 |
| 1072 TEST_P(WebSocketJobTest, ConnectBySpdy) { | 1069 TEST_P(WebSocketJobTest, ConnectBySpdy) { |
| 1073 if (GetParam() > kProtoSPDY3) | |
| 1074 return; | |
| 1075 | |
| 1076 WebSocketJob::set_websocket_over_spdy_enabled(false); | 1070 WebSocketJob::set_websocket_over_spdy_enabled(false); |
| 1077 TestConnectBySpdy(SPDY_OFF, THROTTLING_OFF); | 1071 TestConnectBySpdy(SPDY_OFF, THROTTLING_OFF); |
| 1078 } | 1072 } |
| 1079 | 1073 |
| 1080 TEST_P(WebSocketJobTest, ConnectBySpdySpdyEnabled) { | 1074 TEST_P(WebSocketJobTest, ConnectBySpdySpdyEnabled) { |
| 1081 if (GetParam() > kProtoSPDY3) | |
| 1082 return; | |
| 1083 | |
| 1084 WebSocketJob::set_websocket_over_spdy_enabled(true); | 1075 WebSocketJob::set_websocket_over_spdy_enabled(true); |
| 1085 TestConnectBySpdy(SPDY_ON, THROTTLING_OFF); | 1076 TestConnectBySpdy(SPDY_ON, THROTTLING_OFF); |
| 1086 } | 1077 } |
| 1087 | 1078 |
| 1088 TEST_P(WebSocketJobTest, ThrottlingWebSocket) { | 1079 TEST_P(WebSocketJobTest, ThrottlingWebSocket) { |
| 1089 WebSocketJob::set_websocket_over_spdy_enabled(false); | 1080 WebSocketJob::set_websocket_over_spdy_enabled(false); |
| 1090 TestConnectByWebSocket(THROTTLING_ON); | 1081 TestConnectByWebSocket(THROTTLING_ON); |
| 1091 } | 1082 } |
| 1092 | 1083 |
| 1093 TEST_P(WebSocketJobTest, ThrottlingWebSocketSpdyEnabled) { | 1084 TEST_P(WebSocketJobTest, ThrottlingWebSocketSpdyEnabled) { |
| 1094 WebSocketJob::set_websocket_over_spdy_enabled(true); | 1085 WebSocketJob::set_websocket_over_spdy_enabled(true); |
| 1095 TestConnectByWebSocket(THROTTLING_ON); | 1086 TestConnectByWebSocket(THROTTLING_ON); |
| 1096 } | 1087 } |
| 1097 | 1088 |
| 1098 TEST_P(WebSocketJobTest, ThrottlingSpdy) { | 1089 TEST_P(WebSocketJobTest, ThrottlingSpdy) { |
| 1099 if (GetParam() > kProtoSPDY3) | |
| 1100 return; | |
| 1101 | |
| 1102 WebSocketJob::set_websocket_over_spdy_enabled(false); | 1090 WebSocketJob::set_websocket_over_spdy_enabled(false); |
| 1103 TestConnectBySpdy(SPDY_OFF, THROTTLING_ON); | 1091 TestConnectBySpdy(SPDY_OFF, THROTTLING_ON); |
| 1104 } | 1092 } |
| 1105 | 1093 |
| 1106 TEST_P(WebSocketJobTest, ThrottlingSpdySpdyEnabled) { | 1094 TEST_P(WebSocketJobTest, ThrottlingSpdySpdyEnabled) { |
| 1107 if (GetParam() > kProtoSPDY3) | |
| 1108 return; | |
| 1109 | |
| 1110 WebSocketJob::set_websocket_over_spdy_enabled(true); | 1095 WebSocketJob::set_websocket_over_spdy_enabled(true); |
| 1111 TestConnectBySpdy(SPDY_ON, THROTTLING_ON); | 1096 TestConnectBySpdy(SPDY_ON, THROTTLING_ON); |
| 1112 } | 1097 } |
| 1113 | 1098 |
| 1114 // TODO(toyoshim): Add tests to verify throttling, SPDY stream limitation. | 1099 // TODO(toyoshim): Add tests to verify throttling, SPDY stream limitation. |
| 1115 // TODO(toyoshim,yutak): Add tests to verify closing handshake. | 1100 // TODO(toyoshim,yutak): Add tests to verify closing handshake. |
| 1116 } // namespace net | 1101 } // namespace net |
| OLD | NEW |