| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 // End-to-end tests for WebSocket. | 5 // End-to-end tests for WebSocket. |
| 6 // | 6 // |
| 7 // A python server is (re)started for each test, which is moderately | 7 // A python server is (re)started for each test, which is moderately |
| 8 // inefficient. However, it makes these tests a good fit for scenarios which | 8 // inefficient. However, it makes these tests a good fit for scenarios which |
| 9 // require special server configurations. | 9 // require special server configurations. |
| 10 | 10 |
| 11 #include <stdint.h> |
| 11 #include <string> | 12 #include <string> |
| 12 | 13 |
| 13 #include "base/bind.h" | 14 #include "base/bind.h" |
| 14 #include "base/bind_helpers.h" | 15 #include "base/bind_helpers.h" |
| 15 #include "base/callback.h" | 16 #include "base/callback.h" |
| 16 #include "base/location.h" | 17 #include "base/location.h" |
| 17 #include "base/memory/scoped_ptr.h" | 18 #include "base/memory/scoped_ptr.h" |
| 18 #include "base/run_loop.h" | 19 #include "base/run_loop.h" |
| 19 #include "base/single_thread_task_runner.h" | 20 #include "base/single_thread_task_runner.h" |
| 20 #include "base/strings/string_piece.h" | 21 #include "base/strings/string_piece.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 std::string extensions() const; | 62 std::string extensions() const; |
| 62 | 63 |
| 63 // Implementation of WebSocketEventInterface. | 64 // Implementation of WebSocketEventInterface. |
| 64 ChannelState OnAddChannelResponse(const std::string& selected_subprotocol, | 65 ChannelState OnAddChannelResponse(const std::string& selected_subprotocol, |
| 65 const std::string& extensions) override; | 66 const std::string& extensions) override; |
| 66 | 67 |
| 67 ChannelState OnDataFrame(bool fin, | 68 ChannelState OnDataFrame(bool fin, |
| 68 WebSocketMessageType type, | 69 WebSocketMessageType type, |
| 69 const std::vector<char>& data) override; | 70 const std::vector<char>& data) override; |
| 70 | 71 |
| 71 ChannelState OnFlowControl(int64 quota) override; | 72 ChannelState OnFlowControl(int64_t quota) override; |
| 72 | 73 |
| 73 ChannelState OnClosingHandshake() override; | 74 ChannelState OnClosingHandshake() override; |
| 74 | 75 |
| 75 ChannelState OnDropChannel(bool was_clean, | 76 ChannelState OnDropChannel(bool was_clean, |
| 76 uint16 code, | 77 uint16_t code, |
| 77 const std::string& reason) override; | 78 const std::string& reason) override; |
| 78 | 79 |
| 79 ChannelState OnFailChannel(const std::string& message) override; | 80 ChannelState OnFailChannel(const std::string& message) override; |
| 80 | 81 |
| 81 ChannelState OnStartOpeningHandshake( | 82 ChannelState OnStartOpeningHandshake( |
| 82 scoped_ptr<WebSocketHandshakeRequestInfo> request) override; | 83 scoped_ptr<WebSocketHandshakeRequestInfo> request) override; |
| 83 | 84 |
| 84 ChannelState OnFinishOpeningHandshake( | 85 ChannelState OnFinishOpeningHandshake( |
| 85 scoped_ptr<WebSocketHandshakeResponseInfo> response) override; | 86 scoped_ptr<WebSocketHandshakeResponseInfo> response) override; |
| 86 | 87 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 return CHANNEL_ALIVE; | 135 return CHANNEL_ALIVE; |
| 135 } | 136 } |
| 136 | 137 |
| 137 ChannelState ConnectTestingEventInterface::OnDataFrame( | 138 ChannelState ConnectTestingEventInterface::OnDataFrame( |
| 138 bool fin, | 139 bool fin, |
| 139 WebSocketMessageType type, | 140 WebSocketMessageType type, |
| 140 const std::vector<char>& data) { | 141 const std::vector<char>& data) { |
| 141 return CHANNEL_ALIVE; | 142 return CHANNEL_ALIVE; |
| 142 } | 143 } |
| 143 | 144 |
| 144 ChannelState ConnectTestingEventInterface::OnFlowControl(int64 quota) { | 145 ChannelState ConnectTestingEventInterface::OnFlowControl(int64_t quota) { |
| 145 return CHANNEL_ALIVE; | 146 return CHANNEL_ALIVE; |
| 146 } | 147 } |
| 147 | 148 |
| 148 ChannelState ConnectTestingEventInterface::OnClosingHandshake() { | 149 ChannelState ConnectTestingEventInterface::OnClosingHandshake() { |
| 149 return CHANNEL_ALIVE; | 150 return CHANNEL_ALIVE; |
| 150 } | 151 } |
| 151 | 152 |
| 152 ChannelState ConnectTestingEventInterface::OnDropChannel( | 153 ChannelState ConnectTestingEventInterface::OnDropChannel( |
| 153 bool was_clean, | 154 bool was_clean, |
| 154 uint16 code, | 155 uint16_t code, |
| 155 const std::string& reason) { | 156 const std::string& reason) { |
| 156 return CHANNEL_DELETED; | 157 return CHANNEL_DELETED; |
| 157 } | 158 } |
| 158 | 159 |
| 159 ChannelState ConnectTestingEventInterface::OnFailChannel( | 160 ChannelState ConnectTestingEventInterface::OnFailChannel( |
| 160 const std::string& message) { | 161 const std::string& message) { |
| 161 failed_ = true; | 162 failed_ = true; |
| 162 failure_message_ = message; | 163 failure_message_ = message; |
| 163 QuitNestedEventLoop(); | 164 QuitNestedEventLoop(); |
| 164 return CHANNEL_DELETED; | 165 return CHANNEL_DELETED; |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 GURL ws_url = ws_server.GetURL("header-continuation"); | 491 GURL ws_url = ws_server.GetURL("header-continuation"); |
| 491 | 492 |
| 492 EXPECT_TRUE(ConnectAndWait(ws_url)); | 493 EXPECT_TRUE(ConnectAndWait(ws_url)); |
| 493 EXPECT_EQ("permessage-deflate; server_max_window_bits=10", | 494 EXPECT_EQ("permessage-deflate; server_max_window_bits=10", |
| 494 event_interface_->extensions()); | 495 event_interface_->extensions()); |
| 495 } | 496 } |
| 496 | 497 |
| 497 } // namespace | 498 } // namespace |
| 498 | 499 |
| 499 } // namespace net | 500 } // namespace net |
| OLD | NEW |