OLD | NEW |
1 // Copyright (c) 2011 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" |
11 #include "ppapi/c/dev/ppb_var_array_buffer_dev.h" | 11 #include "ppapi/c/dev/ppb_var_array_buffer_dev.h" |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 PP_Resource ws = websocket_interface_->Create(instance_->pp_instance()); | 121 PP_Resource ws = websocket_interface_->Create(instance_->pp_instance()); |
122 if (!ws) | 122 if (!ws) |
123 return 0; | 123 return 0; |
124 PP_Var url_var = CreateVarString(url); | 124 PP_Var url_var = CreateVarString(url); |
125 TestCompletionCallback callback(instance_->pp_instance(), force_async_); | 125 TestCompletionCallback callback(instance_->pp_instance(), force_async_); |
126 uint32_t protocol_count = 0U; | 126 uint32_t protocol_count = 0U; |
127 if (protocol) { | 127 if (protocol) { |
128 protocols[0] = CreateVarString(protocol); | 128 protocols[0] = CreateVarString(protocol); |
129 protocol_count = 1U; | 129 protocol_count = 1U; |
130 } | 130 } |
| 131 websocket_interface_->SetBinaryType( |
| 132 ws, PP_WEBSOCKETBINARYTYPE_ARRAYBUFFER_DEV); |
131 *result = websocket_interface_->Connect( | 133 *result = websocket_interface_->Connect( |
132 ws, url_var, protocols, protocol_count, | 134 ws, url_var, protocols, protocol_count, |
133 static_cast<pp::CompletionCallback>(callback).pp_completion_callback()); | 135 static_cast<pp::CompletionCallback>(callback).pp_completion_callback()); |
134 ReleaseVar(url_var); | 136 ReleaseVar(url_var); |
135 if (protocol) | 137 if (protocol) |
136 ReleaseVar(protocols[0]); | 138 ReleaseVar(protocols[0]); |
137 if (*result == PP_OK_COMPLETIONPENDING) | 139 if (*result == PP_OK_COMPLETIONPENDING) |
138 *result = callback.WaitForResult(); | 140 *result = callback.WaitForResult(); |
139 return ws; | 141 return ws; |
140 } | 142 } |
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
549 ASSERT_EQ(kCloseCodeNormalClosure, ws.GetCloseCode()); | 551 ASSERT_EQ(kCloseCodeNormalClosure, ws.GetCloseCode()); |
550 ASSERT_TRUE(AreEqualWithString(ws.GetCloseReason().pp_var(), reason.c_str())); | 552 ASSERT_TRUE(AreEqualWithString(ws.GetCloseReason().pp_var(), reason.c_str())); |
551 ASSERT_EQ(true, ws.GetCloseWasClean()); | 553 ASSERT_EQ(true, ws.GetCloseWasClean()); |
552 ASSERT_TRUE(AreEqualWithString(ws.GetExtensions().pp_var(), "")); | 554 ASSERT_TRUE(AreEqualWithString(ws.GetExtensions().pp_var(), "")); |
553 ASSERT_TRUE(AreEqualWithString(ws.GetProtocol().pp_var(), "")); | 555 ASSERT_TRUE(AreEqualWithString(ws.GetProtocol().pp_var(), "")); |
554 ASSERT_EQ(PP_WEBSOCKETREADYSTATE_CLOSED_DEV, ws.GetReadyState()); | 556 ASSERT_EQ(PP_WEBSOCKETREADYSTATE_CLOSED_DEV, ws.GetReadyState()); |
555 ASSERT_TRUE(AreEqualWithString(ws.GetURL().pp_var(), kCloseServerURL)); | 557 ASSERT_TRUE(AreEqualWithString(ws.GetURL().pp_var(), kCloseServerURL)); |
556 | 558 |
557 PASS(); | 559 PASS(); |
558 } | 560 } |
OLD | NEW |