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

Side by Side Diff: ppapi/tests/test_websocket.cc

Issue 9937001: PPAPI: Refactor ppapi test callbacks to ease testing blocking callbacks. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync Created 8 years, 8 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 | « ppapi/tests/test_utils.cc ('k') | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ppapi/tests/test_websocket.h" 5 #include "ppapi/tests/test_websocket.h"
6 6
7 #include <stdio.h> 7 #include <stdio.h>
8 #include <string.h> 8 #include <string.h>
9 #include <algorithm> 9 #include <algorithm>
10 #include <string> 10 #include <string>
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 return 0; 275 return 0;
276 PP_Var url_var = CreateVarString(url); 276 PP_Var url_var = CreateVarString(url);
277 TestCompletionCallback callback(instance_->pp_instance(), force_async_); 277 TestCompletionCallback callback(instance_->pp_instance(), force_async_);
278 uint32_t protocol_count = 0U; 278 uint32_t protocol_count = 0U;
279 if (protocol.size()) { 279 if (protocol.size()) {
280 protocols[0] = CreateVarString(protocol); 280 protocols[0] = CreateVarString(protocol);
281 protocol_count = 1U; 281 protocol_count = 1U;
282 } 282 }
283 *result = websocket_interface_->Connect( 283 *result = websocket_interface_->Connect(
284 ws, url_var, protocols, protocol_count, 284 ws, url_var, protocols, protocol_count,
285 static_cast<pp::CompletionCallback>(callback).pp_completion_callback()); 285 callback.GetCallback().pp_completion_callback());
286 ReleaseVar(url_var); 286 ReleaseVar(url_var);
287 if (protocol.size()) 287 if (protocol.size())
288 ReleaseVar(protocols[0]); 288 ReleaseVar(protocols[0]);
289 if (*result == PP_OK_COMPLETIONPENDING) 289 if (*result == PP_OK_COMPLETIONPENDING)
290 *result = callback.WaitForResult(); 290 *result = callback.WaitForResult();
291 return ws; 291 return ws;
292 } 292 }
293 293
294 std::string TestWebSocket::TestIsWebSocket() { 294 std::string TestWebSocket::TestIsWebSocket() {
295 // Test that a NULL resource isn't a websocket. 295 // Test that a NULL resource isn't a websocket.
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 349
350 std::string TestWebSocket::TestInvalidConnect() { 350 std::string TestWebSocket::TestInvalidConnect() {
351 PP_Var protocols[] = { PP_MakeUndefined() }; 351 PP_Var protocols[] = { PP_MakeUndefined() };
352 352
353 PP_Resource ws = websocket_interface_->Create(instance_->pp_instance()); 353 PP_Resource ws = websocket_interface_->Create(instance_->pp_instance());
354 ASSERT_TRUE(ws); 354 ASSERT_TRUE(ws);
355 355
356 TestCompletionCallback callback(instance_->pp_instance(), force_async_); 356 TestCompletionCallback callback(instance_->pp_instance(), force_async_);
357 int32_t result = websocket_interface_->Connect( 357 int32_t result = websocket_interface_->Connect(
358 ws, PP_MakeUndefined(), protocols, 1U, 358 ws, PP_MakeUndefined(), protocols, 1U,
359 static_cast<pp::CompletionCallback>(callback).pp_completion_callback()); 359 callback.GetCallback().pp_completion_callback());
360 ASSERT_EQ(PP_ERROR_BADARGUMENT, result); 360 ASSERT_EQ(PP_ERROR_BADARGUMENT, result);
361 361
362 result = websocket_interface_->Connect( 362 result = websocket_interface_->Connect(
363 ws, PP_MakeUndefined(), protocols, 1U, 363 ws, PP_MakeUndefined(), protocols, 1U,
364 static_cast<pp::CompletionCallback>(callback).pp_completion_callback()); 364 callback.GetCallback().pp_completion_callback());
365 ASSERT_EQ(PP_ERROR_INPROGRESS, result); 365 ASSERT_EQ(PP_ERROR_INPROGRESS, result);
366 366
367 core_interface_->ReleaseResource(ws); 367 core_interface_->ReleaseResource(ws);
368 368
369 for (int i = 0; kInvalidURLs[i]; ++i) { 369 for (int i = 0; kInvalidURLs[i]; ++i) {
370 ws = Connect(kInvalidURLs[i], &result, ""); 370 ws = Connect(kInvalidURLs[i], &result, "");
371 ASSERT_TRUE(ws); 371 ASSERT_TRUE(ws);
372 ASSERT_EQ(PP_ERROR_BADARGUMENT, result); 372 ASSERT_EQ(PP_ERROR_BADARGUMENT, result);
373 373
374 core_interface_->ReleaseResource(ws); 374 core_interface_->ReleaseResource(ws);
(...skipping 11 matching lines...) Expand all
386 PP_Var good_protocols[] = { 386 PP_Var good_protocols[] = {
387 CreateVarString("x-test"), 387 CreateVarString("x-test"),
388 CreateVarString("x-yatest") 388 CreateVarString("x-yatest")
389 }; 389 };
390 390
391 PP_Resource ws = websocket_interface_->Create(instance_->pp_instance()); 391 PP_Resource ws = websocket_interface_->Create(instance_->pp_instance());
392 ASSERT_TRUE(ws); 392 ASSERT_TRUE(ws);
393 TestCompletionCallback callback(instance_->pp_instance(), force_async_); 393 TestCompletionCallback callback(instance_->pp_instance(), force_async_);
394 int32_t result = websocket_interface_->Connect( 394 int32_t result = websocket_interface_->Connect(
395 ws, url, bad_protocols, 2U, 395 ws, url, bad_protocols, 2U,
396 static_cast<pp::CompletionCallback>(callback).pp_completion_callback()); 396 callback.GetCallback().pp_completion_callback());
397 if (result == PP_OK_COMPLETIONPENDING) 397 if (result == PP_OK_COMPLETIONPENDING)
398 result = callback.WaitForResult(); 398 result = callback.WaitForResult();
399 ASSERT_EQ(PP_ERROR_BADARGUMENT, result); 399 ASSERT_EQ(PP_ERROR_BADARGUMENT, result);
400 core_interface_->ReleaseResource(ws); 400 core_interface_->ReleaseResource(ws);
401 401
402 ws = websocket_interface_->Create(instance_->pp_instance()); 402 ws = websocket_interface_->Create(instance_->pp_instance());
403 ASSERT_TRUE(ws); 403 ASSERT_TRUE(ws);
404 result = websocket_interface_->Connect( 404 result = websocket_interface_->Connect(
405 ws, url, good_protocols, 2U, PP_BlockUntilComplete()); 405 ws, url, good_protocols, 2U, PP_BlockUntilComplete());
406 ASSERT_EQ(PP_ERROR_BLOCKS_MAIN_THREAD, result); 406 ASSERT_EQ(PP_ERROR_BLOCKS_MAIN_THREAD, result);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 } 445 }
446 446
447 std::string TestWebSocket::TestInvalidClose() { 447 std::string TestWebSocket::TestInvalidClose() {
448 PP_Var reason = CreateVarString("close for test"); 448 PP_Var reason = CreateVarString("close for test");
449 TestCompletionCallback callback(instance_->pp_instance()); 449 TestCompletionCallback callback(instance_->pp_instance());
450 450
451 // Close before connect. 451 // Close before connect.
452 PP_Resource ws = websocket_interface_->Create(instance_->pp_instance()); 452 PP_Resource ws = websocket_interface_->Create(instance_->pp_instance());
453 int32_t result = websocket_interface_->Close( 453 int32_t result = websocket_interface_->Close(
454 ws, PP_WEBSOCKETSTATUSCODE_NORMAL_CLOSURE, reason, 454 ws, PP_WEBSOCKETSTATUSCODE_NORMAL_CLOSURE, reason,
455 static_cast<pp::CompletionCallback>(callback).pp_completion_callback()); 455 callback.GetCallback().pp_completion_callback());
456 ASSERT_EQ(PP_ERROR_FAILED, result); 456 ASSERT_EQ(PP_ERROR_FAILED, result);
457 core_interface_->ReleaseResource(ws); 457 core_interface_->ReleaseResource(ws);
458 458
459 // Close with bad arguments. 459 // Close with bad arguments.
460 ws = Connect(GetFullURL(kEchoServerURL), &result, ""); 460 ws = Connect(GetFullURL(kEchoServerURL), &result, "");
461 ASSERT_TRUE(ws); 461 ASSERT_TRUE(ws);
462 ASSERT_EQ(PP_OK, result); 462 ASSERT_EQ(PP_OK, result);
463 result = websocket_interface_->Close(ws, 1U, reason, 463 result = websocket_interface_->Close(ws, 1U, reason,
464 static_cast<pp::CompletionCallback>(callback).pp_completion_callback()); 464 callback.GetCallback().pp_completion_callback());
465 ASSERT_EQ(PP_ERROR_NOACCESS, result); 465 ASSERT_EQ(PP_ERROR_NOACCESS, result);
466 core_interface_->ReleaseResource(ws); 466 core_interface_->ReleaseResource(ws);
467 467
468 ReleaseVar(reason); 468 ReleaseVar(reason);
469 469
470 PASS(); 470 PASS();
471 } 471 }
472 472
473 std::string TestWebSocket::TestValidClose() { 473 std::string TestWebSocket::TestValidClose() {
474 PP_Var reason = CreateVarString("close for test"); 474 PP_Var reason = CreateVarString("close for test");
475 PP_Var url = CreateVarString(GetFullURL(kEchoServerURL).c_str()); 475 PP_Var url = CreateVarString(GetFullURL(kEchoServerURL).c_str());
476 PP_Var protocols[] = { PP_MakeUndefined() }; 476 PP_Var protocols[] = { PP_MakeUndefined() };
477 TestCompletionCallback callback(instance_->pp_instance()); 477 TestCompletionCallback callback(instance_->pp_instance());
478 TestCompletionCallback another_callback(instance_->pp_instance()); 478 TestCompletionCallback another_callback(instance_->pp_instance());
479 479
480 // Close. 480 // Close.
481 int32_t result; 481 int32_t result;
482 PP_Resource ws = Connect(GetFullURL(kEchoServerURL), &result, ""); 482 PP_Resource ws = Connect(GetFullURL(kEchoServerURL), &result, "");
483 ASSERT_TRUE(ws); 483 ASSERT_TRUE(ws);
484 ASSERT_EQ(PP_OK, result); 484 ASSERT_EQ(PP_OK, result);
485 result = websocket_interface_->Close(ws, 485 result = websocket_interface_->Close(ws,
486 PP_WEBSOCKETSTATUSCODE_NORMAL_CLOSURE, reason, 486 PP_WEBSOCKETSTATUSCODE_NORMAL_CLOSURE, reason,
487 static_cast<pp::CompletionCallback>(callback).pp_completion_callback()); 487 callback.GetCallback().pp_completion_callback());
488 ASSERT_EQ(PP_OK_COMPLETIONPENDING, result); 488 ASSERT_EQ(PP_OK_COMPLETIONPENDING, result);
489 result = callback.WaitForResult(); 489 result = callback.WaitForResult();
490 ASSERT_EQ(PP_OK, result); 490 ASSERT_EQ(PP_OK, result);
491 core_interface_->ReleaseResource(ws); 491 core_interface_->ReleaseResource(ws);
492 492
493 // Close in connecting. 493 // Close in connecting.
494 // The ongoing connect failed with PP_ERROR_ABORTED, then the close is done 494 // The ongoing connect failed with PP_ERROR_ABORTED, then the close is done
495 // successfully. 495 // successfully.
496 ws = websocket_interface_->Create(instance_->pp_instance()); 496 ws = websocket_interface_->Create(instance_->pp_instance());
497 result = websocket_interface_->Connect(ws, url, protocols, 0U, 497 result = websocket_interface_->Connect(ws, url, protocols, 0U,
498 static_cast<pp::CompletionCallback>(callback).pp_completion_callback()); 498 callback.GetCallback().pp_completion_callback());
499 ASSERT_EQ(PP_OK_COMPLETIONPENDING, result); 499 ASSERT_EQ(PP_OK_COMPLETIONPENDING, result);
500 result = websocket_interface_->Close(ws, 500 result = websocket_interface_->Close(ws,
501 PP_WEBSOCKETSTATUSCODE_NORMAL_CLOSURE, reason, 501 PP_WEBSOCKETSTATUSCODE_NORMAL_CLOSURE, reason,
502 static_cast<pp::CompletionCallback>( 502 another_callback.GetCallback().pp_completion_callback());
503 another_callback).pp_completion_callback());
504 ASSERT_EQ(PP_OK_COMPLETIONPENDING, result); 503 ASSERT_EQ(PP_OK_COMPLETIONPENDING, result);
505 result = callback.WaitForResult(); 504 result = callback.WaitForResult();
506 ASSERT_EQ(PP_ERROR_ABORTED, result); 505 ASSERT_EQ(PP_ERROR_ABORTED, result);
507 result = another_callback.WaitForResult(); 506 result = another_callback.WaitForResult();
508 ASSERT_EQ(PP_OK, result); 507 ASSERT_EQ(PP_OK, result);
509 core_interface_->ReleaseResource(ws); 508 core_interface_->ReleaseResource(ws);
510 509
511 // Close in closing. 510 // Close in closing.
512 // The first close will be done successfully, then the second one failed with 511 // The first close will be done successfully, then the second one failed with
513 // with PP_ERROR_INPROGRESS immediately. 512 // with PP_ERROR_INPROGRESS immediately.
514 ws = Connect(GetFullURL(kEchoServerURL), &result, ""); 513 ws = Connect(GetFullURL(kEchoServerURL), &result, "");
515 ASSERT_TRUE(ws); 514 ASSERT_TRUE(ws);
516 ASSERT_EQ(PP_OK, result); 515 ASSERT_EQ(PP_OK, result);
517 result = websocket_interface_->Close(ws, 516 result = websocket_interface_->Close(ws,
518 PP_WEBSOCKETSTATUSCODE_NORMAL_CLOSURE, reason, 517 PP_WEBSOCKETSTATUSCODE_NORMAL_CLOSURE, reason,
519 static_cast<pp::CompletionCallback>(callback).pp_completion_callback()); 518 callback.GetCallback().pp_completion_callback());
520 ASSERT_EQ(PP_OK_COMPLETIONPENDING, result); 519 ASSERT_EQ(PP_OK_COMPLETIONPENDING, result);
521 result = websocket_interface_->Close(ws, 520 result = websocket_interface_->Close(ws,
522 PP_WEBSOCKETSTATUSCODE_NORMAL_CLOSURE, reason, 521 PP_WEBSOCKETSTATUSCODE_NORMAL_CLOSURE, reason,
523 static_cast<pp::CompletionCallback>( 522 another_callback.GetCallback().pp_completion_callback());
524 another_callback).pp_completion_callback());
525 ASSERT_EQ(PP_ERROR_INPROGRESS, result); 523 ASSERT_EQ(PP_ERROR_INPROGRESS, result);
526 result = callback.WaitForResult(); 524 result = callback.WaitForResult();
527 ASSERT_EQ(PP_OK, result); 525 ASSERT_EQ(PP_OK, result);
528 core_interface_->ReleaseResource(ws); 526 core_interface_->ReleaseResource(ws);
529 527
530 // Close with ongoing receive message. 528 // Close with ongoing receive message.
531 ws = Connect(GetFullURL(kEchoServerURL), &result, ""); 529 ws = Connect(GetFullURL(kEchoServerURL), &result, "");
532 ASSERT_TRUE(ws); 530 ASSERT_TRUE(ws);
533 ASSERT_EQ(PP_OK, result); 531 ASSERT_EQ(PP_OK, result);
534 PP_Var receive_message_var; 532 PP_Var receive_message_var;
535 result = websocket_interface_->ReceiveMessage(ws, &receive_message_var, 533 result = websocket_interface_->ReceiveMessage(ws, &receive_message_var,
536 static_cast<pp::CompletionCallback>(callback).pp_completion_callback()); 534 callback.GetCallback().pp_completion_callback());
537 ASSERT_EQ(PP_OK_COMPLETIONPENDING, result); 535 ASSERT_EQ(PP_OK_COMPLETIONPENDING, result);
538 result = websocket_interface_->Close(ws, 536 result = websocket_interface_->Close(ws,
539 PP_WEBSOCKETSTATUSCODE_NORMAL_CLOSURE, reason, 537 PP_WEBSOCKETSTATUSCODE_NORMAL_CLOSURE, reason,
540 static_cast<pp::CompletionCallback>( 538 another_callback.GetCallback().pp_completion_callback());
541 another_callback).pp_completion_callback());
542 ASSERT_EQ(PP_OK_COMPLETIONPENDING, result); 539 ASSERT_EQ(PP_OK_COMPLETIONPENDING, result);
543 result = callback.WaitForResult(); 540 result = callback.WaitForResult();
544 ASSERT_EQ(PP_ERROR_ABORTED, result); 541 ASSERT_EQ(PP_ERROR_ABORTED, result);
545 result = another_callback.WaitForResult(); 542 result = another_callback.WaitForResult();
546 ASSERT_EQ(PP_OK, result); 543 ASSERT_EQ(PP_OK, result);
547 core_interface_->ReleaseResource(ws); 544 core_interface_->ReleaseResource(ws);
548 545
549 ReleaseVar(reason); 546 ReleaseVar(reason);
550 ReleaseVar(url); 547 ReleaseVar(url);
551 548
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 const char* message = "hello pepper"; 584 const char* message = "hello pepper";
588 PP_Var message_var = CreateVarString(message); 585 PP_Var message_var = CreateVarString(message);
589 int32_t result = websocket_interface_->SendMessage(ws, message_var); 586 int32_t result = websocket_interface_->SendMessage(ws, message_var);
590 ReleaseVar(message_var); 587 ReleaseVar(message_var);
591 ASSERT_EQ(PP_OK, result); 588 ASSERT_EQ(PP_OK, result);
592 589
593 // Receive echoed 'hello pepper'. 590 // Receive echoed 'hello pepper'.
594 TestCompletionCallback callback(instance_->pp_instance(), force_async_); 591 TestCompletionCallback callback(instance_->pp_instance(), force_async_);
595 PP_Var received_message; 592 PP_Var received_message;
596 result = websocket_interface_->ReceiveMessage(ws, &received_message, 593 result = websocket_interface_->ReceiveMessage(ws, &received_message,
597 static_cast<pp::CompletionCallback>(callback).pp_completion_callback()); 594 callback.GetCallback().pp_completion_callback());
598 ASSERT_FALSE(result != PP_OK && result != PP_OK_COMPLETIONPENDING); 595 ASSERT_FALSE(result != PP_OK && result != PP_OK_COMPLETIONPENDING);
599 if (result == PP_OK_COMPLETIONPENDING) 596 if (result == PP_OK_COMPLETIONPENDING)
600 result = callback.WaitForResult(); 597 result = callback.WaitForResult();
601 ASSERT_EQ(PP_OK, result); 598 ASSERT_EQ(PP_OK, result);
602 ASSERT_TRUE(AreEqualWithString(received_message, message)); 599 ASSERT_TRUE(AreEqualWithString(received_message, message));
603 ReleaseVar(received_message); 600 ReleaseVar(received_message);
604 core_interface_->ReleaseResource(ws); 601 core_interface_->ReleaseResource(ws);
605 602
606 PASS(); 603 PASS();
607 } 604 }
(...skipping 11 matching lines...) Expand all
619 binary[i] = i; 616 binary[i] = i;
620 PP_Var message_var = CreateVarBinary(binary); 617 PP_Var message_var = CreateVarBinary(binary);
621 int32_t result = websocket_interface_->SendMessage(ws, message_var); 618 int32_t result = websocket_interface_->SendMessage(ws, message_var);
622 ReleaseVar(message_var); 619 ReleaseVar(message_var);
623 ASSERT_EQ(PP_OK, result); 620 ASSERT_EQ(PP_OK, result);
624 621
625 // Receive echoed binary. 622 // Receive echoed binary.
626 TestCompletionCallback callback(instance_->pp_instance(), force_async_); 623 TestCompletionCallback callback(instance_->pp_instance(), force_async_);
627 PP_Var received_message; 624 PP_Var received_message;
628 result = websocket_interface_->ReceiveMessage(ws, &received_message, 625 result = websocket_interface_->ReceiveMessage(ws, &received_message,
629 static_cast<pp::CompletionCallback>(callback).pp_completion_callback()); 626 callback.GetCallback().pp_completion_callback());
630 ASSERT_TRUE(result == PP_OK || result == PP_OK_COMPLETIONPENDING); 627 ASSERT_TRUE(result == PP_OK || result == PP_OK_COMPLETIONPENDING);
631 if (result == PP_OK_COMPLETIONPENDING) 628 if (result == PP_OK_COMPLETIONPENDING)
632 result = callback.WaitForResult(); 629 result = callback.WaitForResult();
633 ASSERT_EQ(PP_OK, result); 630 ASSERT_EQ(PP_OK, result);
634 ASSERT_TRUE(AreEqualWithBinary(received_message, binary)); 631 ASSERT_TRUE(AreEqualWithBinary(received_message, binary));
635 ReleaseVar(received_message); 632 ReleaseVar(received_message);
636 core_interface_->ReleaseResource(ws); 633 core_interface_->ReleaseResource(ws);
637 634
638 PASS(); 635 PASS();
639 } 636 }
(...skipping 21 matching lines...) Expand all
661 ASSERT_EQ(PP_OK, result); 658 ASSERT_EQ(PP_OK, result);
662 } 659 }
663 ReleaseVar(text_var); 660 ReleaseVar(text_var);
664 ReleaseVar(binary_var); 661 ReleaseVar(binary_var);
665 662
666 // Receive echoed data. 663 // Receive echoed data.
667 for (int i = 0; i < 512; ++i) { 664 for (int i = 0; i < 512; ++i) {
668 TestCompletionCallback callback(instance_->pp_instance(), force_async_); 665 TestCompletionCallback callback(instance_->pp_instance(), force_async_);
669 PP_Var received_message; 666 PP_Var received_message;
670 int32_t result = websocket_interface_->ReceiveMessage( 667 int32_t result = websocket_interface_->ReceiveMessage(
671 ws, &received_message, static_cast<pp::CompletionCallback>( 668 ws, &received_message, callback.GetCallback().pp_completion_callback());
672 callback).pp_completion_callback());
673 ASSERT_TRUE(result == PP_OK || result == PP_OK_COMPLETIONPENDING); 669 ASSERT_TRUE(result == PP_OK || result == PP_OK_COMPLETIONPENDING);
674 if (result == PP_OK_COMPLETIONPENDING) 670 if (result == PP_OK_COMPLETIONPENDING)
675 result = callback.WaitForResult(); 671 result = callback.WaitForResult();
676 ASSERT_EQ(PP_OK, result); 672 ASSERT_EQ(PP_OK, result);
677 if (i & 1) { 673 if (i & 1) {
678 ASSERT_TRUE(AreEqualWithBinary(received_message, binary)); 674 ASSERT_TRUE(AreEqualWithBinary(received_message, binary));
679 } else { 675 } else {
680 ASSERT_TRUE(AreEqualWithString(received_message, text)); 676 ASSERT_TRUE(AreEqualWithString(received_message, text));
681 } 677 }
682 ReleaseVar(received_message); 678 ReleaseVar(received_message);
(...skipping 25 matching lines...) Expand all
708 if (buffered_amount > 262144) 704 if (buffered_amount > 262144)
709 break; 705 break;
710 } 706 }
711 707
712 // Close connection. 708 // Close connection.
713 std::string reason_str = "close while busy"; 709 std::string reason_str = "close while busy";
714 PP_Var reason = CreateVarString(reason_str.c_str()); 710 PP_Var reason = CreateVarString(reason_str.c_str());
715 TestCompletionCallback callback(instance_->pp_instance()); 711 TestCompletionCallback callback(instance_->pp_instance());
716 result = websocket_interface_->Close(ws, 712 result = websocket_interface_->Close(ws,
717 PP_WEBSOCKETSTATUSCODE_NORMAL_CLOSURE, reason, 713 PP_WEBSOCKETSTATUSCODE_NORMAL_CLOSURE, reason,
718 static_cast<pp::CompletionCallback>(callback).pp_completion_callback()); 714 callback.GetCallback().pp_completion_callback());
719 ASSERT_EQ(PP_OK_COMPLETIONPENDING, result); 715 ASSERT_EQ(PP_OK_COMPLETIONPENDING, result);
720 ASSERT_EQ(PP_WEBSOCKETREADYSTATE_CLOSING, 716 ASSERT_EQ(PP_WEBSOCKETREADYSTATE_CLOSING,
721 websocket_interface_->GetReadyState(ws)); 717 websocket_interface_->GetReadyState(ws));
722 718
723 result = callback.WaitForResult(); 719 result = callback.WaitForResult();
724 ASSERT_EQ(PP_OK, result); 720 ASSERT_EQ(PP_OK, result);
725 ASSERT_EQ(PP_WEBSOCKETREADYSTATE_CLOSED, 721 ASSERT_EQ(PP_WEBSOCKETREADYSTATE_CLOSED,
726 websocket_interface_->GetReadyState(ws)); 722 websocket_interface_->GetReadyState(ws));
727 723
728 uint64_t base_buffered_amount = websocket_interface_->GetBufferedAmount(ws); 724 uint64_t base_buffered_amount = websocket_interface_->GetBufferedAmount(ws);
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after
1149 size_t last_event = events_on_closed - 1; 1145 size_t last_event = events_on_closed - 1;
1150 for (uint32_t i = 1; i < last_event; ++i) { 1146 for (uint32_t i = 1; i < last_event; ++i) {
1151 ASSERT_EQ(WebSocketEvent::EVENT_MESSAGE, events[i].event_type); 1147 ASSERT_EQ(WebSocketEvent::EVENT_MESSAGE, events[i].event_type);
1152 ASSERT_TRUE(AreEqualWithString(events[i].var.pp_var(), message)); 1148 ASSERT_TRUE(AreEqualWithString(events[i].var.pp_var(), message));
1153 } 1149 }
1154 ASSERT_EQ(WebSocketEvent::EVENT_CLOSE, events[last_event].event_type); 1150 ASSERT_EQ(WebSocketEvent::EVENT_CLOSE, events[last_event].event_type);
1155 ASSERT_TRUE(events[last_event].was_clean); 1151 ASSERT_TRUE(events[last_event].was_clean);
1156 1152
1157 PASS(); 1153 PASS();
1158 } 1154 }
OLDNEW
« no previous file with comments | « ppapi/tests/test_utils.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698