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

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

Issue 1217003: Try to fix a compile error on ARM.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/ref_counted.h" 8 #include "base/ref_counted.h"
9 #include "googleurl/src/gurl.h" 9 #include "googleurl/src/gurl.h"
10 #include "net/base/cookie_policy.h" 10 #include "net/base/cookie_policy.h"
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 258
259 bool sent = websocket_->SendData(kHandshakeRequestMessage, 259 bool sent = websocket_->SendData(kHandshakeRequestMessage,
260 strlen(kHandshakeRequestMessage)); 260 strlen(kHandshakeRequestMessage));
261 EXPECT_EQ(true, sent); 261 EXPECT_EQ(true, sent);
262 MessageLoop::current()->RunAllPending(); 262 MessageLoop::current()->RunAllPending();
263 EXPECT_EQ(kHandshakeRequestMessage, socket_->sent_data()); 263 EXPECT_EQ(kHandshakeRequestMessage, socket_->sent_data());
264 EXPECT_EQ(WebSocketJob::CONNECTING, GetWebSocketJobState()); 264 EXPECT_EQ(WebSocketJob::CONNECTING, GetWebSocketJobState());
265 websocket_->OnSentData(socket_.get(), strlen(kHandshakeRequestMessage)); 265 websocket_->OnSentData(socket_.get(), strlen(kHandshakeRequestMessage));
266 EXPECT_EQ(strlen(kHandshakeRequestMessage), delegate.amount_sent()); 266 EXPECT_EQ(strlen(kHandshakeRequestMessage), delegate.amount_sent());
267 267
268 static const char* kHandshakeResponseMessage = 268 const char kHandshakeResponseMessage[] =
269 "HTTP/1.1 101 Web Socket Protocol Handshake\r\n" 269 "HTTP/1.1 101 Web Socket Protocol Handshake\r\n"
270 "Upgrade: WebSocket\r\n" 270 "Upgrade: WebSocket\r\n"
271 "Connection: Upgrade\r\n" 271 "Connection: Upgrade\r\n"
272 "WebSocket-Origin: http://example.com\r\n" 272 "WebSocket-Origin: http://example.com\r\n"
273 "WebSocket-Location: ws://example.com/demo\r\n" 273 "WebSocket-Location: ws://example.com/demo\r\n"
274 "WebSocket-Protocol: sample\r\n" 274 "WebSocket-Protocol: sample\r\n"
275 "\r\n"; 275 "\r\n";
276 276
277 websocket_->OnReceivedData(socket_.get(), 277 websocket_->OnReceivedData(socket_.get(),
278 kHandshakeResponseMessage, 278 kHandshakeResponseMessage,
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 for (size_t i = 0; i < lines.size() - 2; i++) { 316 for (size_t i = 0; i < lines.size() - 2; i++) {
317 std::string line = lines[i] + "\r\n"; 317 std::string line = lines[i] + "\r\n";
318 SCOPED_TRACE("Line: " + line); 318 SCOPED_TRACE("Line: " + line);
319 websocket_->OnSentData(socket_.get(), line.size()); 319 websocket_->OnSentData(socket_.get(), line.size());
320 EXPECT_EQ(0U, delegate.amount_sent()); 320 EXPECT_EQ(0U, delegate.amount_sent());
321 } 321 }
322 websocket_->OnSentData(socket_.get(), 2); // \r\n 322 websocket_->OnSentData(socket_.get(), 2); // \r\n
323 EXPECT_EQ(strlen(kHandshakeRequestMessage), delegate.amount_sent()); 323 EXPECT_EQ(strlen(kHandshakeRequestMessage), delegate.amount_sent());
324 EXPECT_EQ(WebSocketJob::CONNECTING, GetWebSocketJobState()); 324 EXPECT_EQ(WebSocketJob::CONNECTING, GetWebSocketJobState());
325 325
326 static const char* kHandshakeResponseMessage = 326 const char kHandshakeResponseMessage[] =
327 "HTTP/1.1 101 Web Socket Protocol Handshake\r\n" 327 "HTTP/1.1 101 Web Socket Protocol Handshake\r\n"
328 "Upgrade: WebSocket\r\n" 328 "Upgrade: WebSocket\r\n"
329 "Connection: Upgrade\r\n" 329 "Connection: Upgrade\r\n"
330 "WebSocket-Origin: http://example.com\r\n" 330 "WebSocket-Origin: http://example.com\r\n"
331 "WebSocket-Location: ws://example.com/demo\r\n" 331 "WebSocket-Location: ws://example.com/demo\r\n"
332 "WebSocket-Protocol: sample\r\n" 332 "WebSocket-Protocol: sample\r\n"
333 "\r\n"; 333 "\r\n";
334 334
335 lines.clear(); 335 lines.clear();
336 SplitString(kHandshakeResponseMessage, '\n', &lines); 336 SplitString(kHandshakeResponseMessage, '\n', &lines);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 386
387 bool sent = websocket_->SendData(kHandshakeRequestMessage, 387 bool sent = websocket_->SendData(kHandshakeRequestMessage,
388 strlen(kHandshakeRequestMessage)); 388 strlen(kHandshakeRequestMessage));
389 EXPECT_EQ(true, sent); 389 EXPECT_EQ(true, sent);
390 MessageLoop::current()->RunAllPending(); 390 MessageLoop::current()->RunAllPending();
391 EXPECT_EQ(kHandshakeRequestExpected, socket_->sent_data()); 391 EXPECT_EQ(kHandshakeRequestExpected, socket_->sent_data());
392 EXPECT_EQ(WebSocketJob::CONNECTING, GetWebSocketJobState()); 392 EXPECT_EQ(WebSocketJob::CONNECTING, GetWebSocketJobState());
393 websocket_->OnSentData(socket_, strlen(kHandshakeRequestExpected)); 393 websocket_->OnSentData(socket_, strlen(kHandshakeRequestExpected));
394 EXPECT_EQ(strlen(kHandshakeRequestMessage), delegate.amount_sent()); 394 EXPECT_EQ(strlen(kHandshakeRequestMessage), delegate.amount_sent());
395 395
396 static const char* kHandshakeResponseMessage = 396 const char kHandshakeResponseMessage[] =
397 "HTTP/1.1 101 Web Socket Protocol Handshake\r\n" 397 "HTTP/1.1 101 Web Socket Protocol Handshake\r\n"
398 "Upgrade: WebSocket\r\n" 398 "Upgrade: WebSocket\r\n"
399 "Connection: Upgrade\r\n" 399 "Connection: Upgrade\r\n"
400 "WebSocket-Origin: http://example.com\r\n" 400 "WebSocket-Origin: http://example.com\r\n"
401 "WebSocket-Location: ws://example.com/demo\r\n" 401 "WebSocket-Location: ws://example.com/demo\r\n"
402 "WebSocket-Protocol: sample\r\n" 402 "WebSocket-Protocol: sample\r\n"
403 "Set-Cookie: CR-set-test=1\r\n" 403 "Set-Cookie: CR-set-test=1\r\n"
404 "\r\n"; 404 "\r\n";
405 405
406 static const char* kHandshakeResponseExpected = 406 static const char* kHandshakeResponseExpected =
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 465
466 bool sent = websocket_->SendData(kHandshakeRequestMessage, 466 bool sent = websocket_->SendData(kHandshakeRequestMessage,
467 strlen(kHandshakeRequestMessage)); 467 strlen(kHandshakeRequestMessage));
468 EXPECT_EQ(true, sent); 468 EXPECT_EQ(true, sent);
469 MessageLoop::current()->RunAllPending(); 469 MessageLoop::current()->RunAllPending();
470 EXPECT_EQ(kHandshakeRequestExpected, socket_->sent_data()); 470 EXPECT_EQ(kHandshakeRequestExpected, socket_->sent_data());
471 EXPECT_EQ(WebSocketJob::CONNECTING, GetWebSocketJobState()); 471 EXPECT_EQ(WebSocketJob::CONNECTING, GetWebSocketJobState());
472 websocket_->OnSentData(socket_, strlen(kHandshakeRequestExpected)); 472 websocket_->OnSentData(socket_, strlen(kHandshakeRequestExpected));
473 EXPECT_EQ(strlen(kHandshakeRequestMessage), delegate.amount_sent()); 473 EXPECT_EQ(strlen(kHandshakeRequestMessage), delegate.amount_sent());
474 474
475 static const char* kHandshakeResponseMessage = 475 const char kHandshakeResponseMessage[] =
476 "HTTP/1.1 101 Web Socket Protocol Handshake\r\n" 476 "HTTP/1.1 101 Web Socket Protocol Handshake\r\n"
477 "Upgrade: WebSocket\r\n" 477 "Upgrade: WebSocket\r\n"
478 "Connection: Upgrade\r\n" 478 "Connection: Upgrade\r\n"
479 "WebSocket-Origin: http://example.com\r\n" 479 "WebSocket-Origin: http://example.com\r\n"
480 "WebSocket-Location: ws://example.com/demo\r\n" 480 "WebSocket-Location: ws://example.com/demo\r\n"
481 "WebSocket-Protocol: sample\r\n" 481 "WebSocket-Protocol: sample\r\n"
482 "Set-Cookie: CR-set-test=1\r\n" 482 "Set-Cookie: CR-set-test=1\r\n"
483 "\r\n"; 483 "\r\n";
484 484
485 static const char* kHandshakeResponseExpected = 485 static const char* kHandshakeResponseExpected =
(...skipping 15 matching lines...) Expand all
501 EXPECT_EQ(2U, cookie_store_->entries().size()); 501 EXPECT_EQ(2U, cookie_store_->entries().size());
502 EXPECT_EQ(cookieUrl, cookie_store_->entries()[0].url); 502 EXPECT_EQ(cookieUrl, cookie_store_->entries()[0].url);
503 EXPECT_EQ("CR-test=1", cookie_store_->entries()[0].cookie_line); 503 EXPECT_EQ("CR-test=1", cookie_store_->entries()[0].cookie_line);
504 EXPECT_EQ(cookieUrl, cookie_store_->entries()[1].url); 504 EXPECT_EQ(cookieUrl, cookie_store_->entries()[1].url);
505 EXPECT_EQ("CR-test-httponly=1", cookie_store_->entries()[1].cookie_line); 505 EXPECT_EQ("CR-test-httponly=1", cookie_store_->entries()[1].cookie_line);
506 506
507 CloseWebSocketJob(); 507 CloseWebSocketJob();
508 } 508 }
509 509
510 } // namespace net 510 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698