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

Side by Side Diff: net/websockets/websocket_handshake_unittest.cc

Issue 3366011: base: Move SplitStringDontTrim functions from string_util.h to string_split.h (Closed) Base URL: git://git.chromium.org/chromium.git
Patch Set: remove dchecks Created 10 years, 3 months 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 <string> 5 #include <string>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/scoped_ptr.h" 8 #include "base/scoped_ptr.h"
9 #include "base/string_split.h"
9 #include "base/string_util.h" 10 #include "base/string_util.h"
10 #include "net/websockets/websocket_handshake.h" 11 #include "net/websockets/websocket_handshake.h"
11 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
12 #include "testing/gmock/include/gmock/gmock.h" 13 #include "testing/gmock/include/gmock/gmock.h"
13 #include "testing/platform_test.h" 14 #include "testing/platform_test.h"
14 15
15 namespace net { 16 namespace net {
16 17
17 class WebSocketHandshakeTest : public testing::Test { 18 class WebSocketHandshakeTest : public testing::Test {
18 public: 19 public:
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 134
134 const char kResponse[] = "HTTP/1.1 101 WebSocket Protocol Handshake\r\n" 135 const char kResponse[] = "HTTP/1.1 101 WebSocket Protocol Handshake\r\n"
135 "Upgrade: WebSocket\r\n" 136 "Upgrade: WebSocket\r\n"
136 "Connection: Upgrade\r\n" 137 "Connection: Upgrade\r\n"
137 "Sec-WebSocket-Origin: http://example.com\r\n" 138 "Sec-WebSocket-Origin: http://example.com\r\n"
138 "Sec-WebSocket-Location: ws://example.com/demo\r\n" 139 "Sec-WebSocket-Location: ws://example.com/demo\r\n"
139 "Sec-WebSocket-Protocol: sample\r\n" 140 "Sec-WebSocket-Protocol: sample\r\n"
140 "\r\n" 141 "\r\n"
141 "\x30\x73\x74\x33\x52\x6C\x26\x71\x2D\x32\x5A\x55\x5E\x77\x65\x75"; 142 "\x30\x73\x74\x33\x52\x6C\x26\x71\x2D\x32\x5A\x55\x5E\x77\x65\x75";
142 std::vector<std::string> response_lines; 143 std::vector<std::string> response_lines;
143 SplitStringDontTrim(kResponse, '\n', &response_lines); 144 base::SplitStringDontTrim(kResponse, '\n', &response_lines);
144 145
145 EXPECT_EQ(WebSocketHandshake::MODE_INCOMPLETE, handshake->mode()); 146 EXPECT_EQ(WebSocketHandshake::MODE_INCOMPLETE, handshake->mode());
146 // too short 147 // too short
147 EXPECT_EQ(-1, handshake->ReadServerHandshake(kResponse, 16)); 148 EXPECT_EQ(-1, handshake->ReadServerHandshake(kResponse, 16));
148 EXPECT_EQ(WebSocketHandshake::MODE_INCOMPLETE, handshake->mode()); 149 EXPECT_EQ(WebSocketHandshake::MODE_INCOMPLETE, handshake->mode());
149 150
150 // only status line 151 // only status line
151 std::string response = response_lines[0]; 152 std::string response = response_lines[0];
152 EXPECT_EQ(-1, handshake->ReadServerHandshake( 153 EXPECT_EQ(-1, handshake->ReadServerHandshake(
153 response.data(), response.size())); 154 response.data(), response.size()));
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 scoped_ptr<WebSocketHandshake> handshake( 320 scoped_ptr<WebSocketHandshake> handshake(
320 new WebSocketHandshake(GURL("wss://example.com:80/demo"), 321 new WebSocketHandshake(GURL("wss://example.com:80/demo"),
321 "http://example.com", 322 "http://example.com",
322 "wss://example.com/demo", 323 "wss://example.com/demo",
323 "sample")); 324 "sample"));
324 // :80 should be preserved as it's not the default port for wss://. 325 // :80 should be preserved as it's not the default port for wss://.
325 EXPECT_EQ("example.com:80", GetHostFieldValue(handshake.get())); 326 EXPECT_EQ("example.com:80", GetHostFieldValue(handshake.get()));
326 } 327 }
327 328
328 } // namespace net 329 } // namespace net
OLDNEW
« no previous file with comments | « chrome/service/cloud_print/cloud_print_proxy_backend.cc ('k') | net/websockets/websocket_net_log_params.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698