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

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

Issue 9296001: WebSocket Pepper API: Remove binary type handling interfaces (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 11 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
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 <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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 PP_Resource ws = websocket_interface_->Create(instance_->pp_instance()); 128 PP_Resource ws = websocket_interface_->Create(instance_->pp_instance());
129 if (!ws) 129 if (!ws)
130 return 0; 130 return 0;
131 PP_Var url_var = CreateVarString(url); 131 PP_Var url_var = CreateVarString(url);
132 TestCompletionCallback callback(instance_->pp_instance(), force_async_); 132 TestCompletionCallback callback(instance_->pp_instance(), force_async_);
133 uint32_t protocol_count = 0U; 133 uint32_t protocol_count = 0U;
134 if (protocol) { 134 if (protocol) {
135 protocols[0] = CreateVarString(protocol); 135 protocols[0] = CreateVarString(protocol);
136 protocol_count = 1U; 136 protocol_count = 1U;
137 } 137 }
138 websocket_interface_->SetBinaryType(
139 ws, PP_WEBSOCKETBINARYTYPE_ARRAYBUFFER_DEV);
140 *result = websocket_interface_->Connect( 138 *result = websocket_interface_->Connect(
141 ws, url_var, protocols, protocol_count, 139 ws, url_var, protocols, protocol_count,
142 static_cast<pp::CompletionCallback>(callback).pp_completion_callback()); 140 static_cast<pp::CompletionCallback>(callback).pp_completion_callback());
143 ReleaseVar(url_var); 141 ReleaseVar(url_var);
144 if (protocol) 142 if (protocol)
145 ReleaseVar(protocols[0]); 143 ReleaseVar(protocols[0]);
146 if (*result == PP_OK_COMPLETIONPENDING) 144 if (*result == PP_OK_COMPLETIONPENDING)
147 *result = callback.WaitForResult(); 145 *result = callback.WaitForResult();
148 return ws; 146 return ws;
149 } 147 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 ReleaseVar(protocol); 190 ReleaseVar(protocol);
193 191
194 PP_WebSocketReadyState_Dev ready_state = 192 PP_WebSocketReadyState_Dev ready_state =
195 websocket_interface_->GetReadyState(ws); 193 websocket_interface_->GetReadyState(ws);
196 ASSERT_EQ(PP_WEBSOCKETREADYSTATE_INVALID_DEV, ready_state); 194 ASSERT_EQ(PP_WEBSOCKETREADYSTATE_INVALID_DEV, ready_state);
197 195
198 PP_Var url = websocket_interface_->GetURL(ws); 196 PP_Var url = websocket_interface_->GetURL(ws);
199 ASSERT_TRUE(AreEqualWithString(url, "")); 197 ASSERT_TRUE(AreEqualWithString(url, ""));
200 ReleaseVar(url); 198 ReleaseVar(url);
201 199
202 PP_WebSocketBinaryType_Dev binary_type =
203 websocket_interface_->GetBinaryType(ws);
204 ASSERT_EQ(PP_WEBSOCKETBINARYTYPE_BLOB_DEV, binary_type);
205
206 core_interface_->ReleaseResource(ws); 200 core_interface_->ReleaseResource(ws);
207 201
208 PASS(); 202 PASS();
209 } 203 }
210 204
211 std::string TestWebSocket::TestInvalidConnect() { 205 std::string TestWebSocket::TestInvalidConnect() {
212 PP_Var protocols[] = { PP_MakeUndefined() }; 206 PP_Var protocols[] = { PP_MakeUndefined() };
213 207
214 PP_Resource ws = websocket_interface_->Create(instance_->pp_instance()); 208 PP_Resource ws = websocket_interface_->Create(instance_->pp_instance());
215 ASSERT_TRUE(ws); 209 ASSERT_TRUE(ws);
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 ASSERT_EQ(0, ws.GetBufferedAmount()); 561 ASSERT_EQ(0, ws.GetBufferedAmount());
568 ASSERT_EQ(0, ws.GetCloseCode()); 562 ASSERT_EQ(0, ws.GetCloseCode());
569 ASSERT_TRUE(AreEqualWithString(ws.GetCloseReason().pp_var(), "")); 563 ASSERT_TRUE(AreEqualWithString(ws.GetCloseReason().pp_var(), ""));
570 ASSERT_EQ(false, ws.GetCloseWasClean()); 564 ASSERT_EQ(false, ws.GetCloseWasClean());
571 ASSERT_TRUE(AreEqualWithString(ws.GetExtensions().pp_var(), "")); 565 ASSERT_TRUE(AreEqualWithString(ws.GetExtensions().pp_var(), ""));
572 ASSERT_TRUE(AreEqualWithString(ws.GetProtocol().pp_var(), "")); 566 ASSERT_TRUE(AreEqualWithString(ws.GetProtocol().pp_var(), ""));
573 ASSERT_EQ(PP_WEBSOCKETREADYSTATE_INVALID_DEV, ws.GetReadyState()); 567 ASSERT_EQ(PP_WEBSOCKETREADYSTATE_INVALID_DEV, ws.GetReadyState());
574 ASSERT_TRUE(AreEqualWithString(ws.GetURL().pp_var(), "")); 568 ASSERT_TRUE(AreEqualWithString(ws.GetURL().pp_var(), ""));
575 569
576 // Check communication interfaces (connect, send, receive, and close). 570 // Check communication interfaces (connect, send, receive, and close).
577 ASSERT_TRUE(ws.SetBinaryType(PP_WEBSOCKETBINARYTYPE_ARRAYBUFFER_DEV));
578 TestCompletionCallback connect_callback(instance_->pp_instance()); 571 TestCompletionCallback connect_callback(instance_->pp_instance());
579 int32_t result = ws.Connect(pp::Var(std::string(kCloseServerURL)), NULL, 0U, 572 int32_t result = ws.Connect(pp::Var(std::string(kCloseServerURL)), NULL, 0U,
580 connect_callback); 573 connect_callback);
581 ASSERT_EQ(PP_OK_COMPLETIONPENDING, result); 574 ASSERT_EQ(PP_OK_COMPLETIONPENDING, result);
582 result = connect_callback.WaitForResult(); 575 result = connect_callback.WaitForResult();
583 ASSERT_EQ(PP_OK, result); 576 ASSERT_EQ(PP_OK, result);
584 577
585 std::string text_message("hello C++"); 578 std::string text_message("hello C++");
586 result = ws.SendMessage(pp::Var(text_message)); 579 result = ws.SendMessage(pp::Var(text_message));
587 ASSERT_EQ(PP_OK, result); 580 ASSERT_EQ(PP_OK, result);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 614
622 // Check initialized properties access. 615 // Check initialized properties access.
623 ASSERT_EQ(0, ws.GetBufferedAmount()); 616 ASSERT_EQ(0, ws.GetBufferedAmount());
624 ASSERT_EQ(kCloseCodeNormalClosure, ws.GetCloseCode()); 617 ASSERT_EQ(kCloseCodeNormalClosure, ws.GetCloseCode());
625 ASSERT_TRUE(AreEqualWithString(ws.GetCloseReason().pp_var(), reason.c_str())); 618 ASSERT_TRUE(AreEqualWithString(ws.GetCloseReason().pp_var(), reason.c_str()));
626 ASSERT_EQ(true, ws.GetCloseWasClean()); 619 ASSERT_EQ(true, ws.GetCloseWasClean());
627 ASSERT_TRUE(AreEqualWithString(ws.GetExtensions().pp_var(), "")); 620 ASSERT_TRUE(AreEqualWithString(ws.GetExtensions().pp_var(), ""));
628 ASSERT_TRUE(AreEqualWithString(ws.GetProtocol().pp_var(), "")); 621 ASSERT_TRUE(AreEqualWithString(ws.GetProtocol().pp_var(), ""));
629 ASSERT_EQ(PP_WEBSOCKETREADYSTATE_CLOSED_DEV, ws.GetReadyState()); 622 ASSERT_EQ(PP_WEBSOCKETREADYSTATE_CLOSED_DEV, ws.GetReadyState());
630 ASSERT_TRUE(AreEqualWithString(ws.GetURL().pp_var(), kCloseServerURL)); 623 ASSERT_TRUE(AreEqualWithString(ws.GetURL().pp_var(), kCloseServerURL));
631 ASSERT_EQ(PP_WEBSOCKETBINARYTYPE_ARRAYBUFFER_DEV, ws.GetBinaryType());
632 624
633 PASS(); 625 PASS();
634 } 626 }
OLDNEW
« no previous file with comments | « ppapi/native_client/src/shared/ppapi_proxy/untrusted/srpcgen/ppb_rpc.h ('k') | ppapi/thunk/interfaces_ppb_public_dev.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698