| OLD | NEW |
| 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 <string.h> | 7 #include <string.h> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "ppapi/c/dev/ppb_testing_dev.h" | 10 #include "ppapi/c/dev/ppb_testing_dev.h" |
| (...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 577 | 577 |
| 578 std::string text_message("hello C++"); | 578 std::string text_message("hello C++"); |
| 579 result = ws.SendMessage(pp::Var(text_message)); | 579 result = ws.SendMessage(pp::Var(text_message)); |
| 580 ASSERT_EQ(PP_OK, result); | 580 ASSERT_EQ(PP_OK, result); |
| 581 | 581 |
| 582 uint32_t binary_length = 256; | 582 uint32_t binary_length = 256; |
| 583 uint8_t binary_message[256]; | 583 uint8_t binary_message[256]; |
| 584 for (uint32_t i = 0; i < binary_length; ++i) | 584 for (uint32_t i = 0; i < binary_length; ++i) |
| 585 binary_message[i] = i; | 585 binary_message[i] = i; |
| 586 result = ws.SendMessage(pp::Var( | 586 result = ws.SendMessage(pp::Var( |
| 587 pp::Var::PassRef(), CreateVarBinary(binary_message, binary_length))); | 587 pp::PASS_REF, CreateVarBinary(binary_message, binary_length))); |
| 588 ASSERT_EQ(PP_OK, result); | 588 ASSERT_EQ(PP_OK, result); |
| 589 | 589 |
| 590 pp::Var text_receive_var; | 590 pp::Var text_receive_var; |
| 591 TestCompletionCallback text_receive_callback(instance_->pp_instance()); | 591 TestCompletionCallback text_receive_callback(instance_->pp_instance()); |
| 592 result = ws.ReceiveMessage(&text_receive_var, text_receive_callback); | 592 result = ws.ReceiveMessage(&text_receive_var, text_receive_callback); |
| 593 if (result == PP_OK_COMPLETIONPENDING) | 593 if (result == PP_OK_COMPLETIONPENDING) |
| 594 result = text_receive_callback.WaitForResult(); | 594 result = text_receive_callback.WaitForResult(); |
| 595 ASSERT_EQ(PP_OK, result); | 595 ASSERT_EQ(PP_OK, result); |
| 596 ASSERT_TRUE( | 596 ASSERT_TRUE( |
| 597 AreEqualWithString(text_receive_var.pp_var(), text_message.c_str())); | 597 AreEqualWithString(text_receive_var.pp_var(), text_message.c_str())); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 617 ASSERT_EQ(kCloseCodeNormalClosure, ws.GetCloseCode()); | 617 ASSERT_EQ(kCloseCodeNormalClosure, ws.GetCloseCode()); |
| 618 ASSERT_TRUE(AreEqualWithString(ws.GetCloseReason().pp_var(), reason.c_str())); | 618 ASSERT_TRUE(AreEqualWithString(ws.GetCloseReason().pp_var(), reason.c_str())); |
| 619 ASSERT_EQ(true, ws.GetCloseWasClean()); | 619 ASSERT_EQ(true, ws.GetCloseWasClean()); |
| 620 ASSERT_TRUE(AreEqualWithString(ws.GetExtensions().pp_var(), "")); | 620 ASSERT_TRUE(AreEqualWithString(ws.GetExtensions().pp_var(), "")); |
| 621 ASSERT_TRUE(AreEqualWithString(ws.GetProtocol().pp_var(), "")); | 621 ASSERT_TRUE(AreEqualWithString(ws.GetProtocol().pp_var(), "")); |
| 622 ASSERT_EQ(PP_WEBSOCKETREADYSTATE_CLOSED, ws.GetReadyState()); | 622 ASSERT_EQ(PP_WEBSOCKETREADYSTATE_CLOSED, ws.GetReadyState()); |
| 623 ASSERT_TRUE(AreEqualWithString(ws.GetURL().pp_var(), kCloseServerURL)); | 623 ASSERT_TRUE(AreEqualWithString(ws.GetURL().pp_var(), kCloseServerURL)); |
| 624 | 624 |
| 625 PASS(); | 625 PASS(); |
| 626 } | 626 } |
| OLD | NEW |