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

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

Issue 8931026: Reverting because I reverted the CL this depends on... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years 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_websocket.h ('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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 8
9 #include "ppapi/c/dev/ppb_testing_dev.h"
10 #include "ppapi/c/dev/ppb_websocket_dev.h" 9 #include "ppapi/c/dev/ppb_websocket_dev.h"
11 #include "ppapi/c/pp_errors.h" 10 #include "ppapi/c/pp_errors.h"
12 #include "ppapi/c/pp_var.h" 11 #include "ppapi/c/pp_var.h"
13 #include "ppapi/c/pp_completion_callback.h" 12 #include "ppapi/c/pp_completion_callback.h"
14 #include "ppapi/c/ppb_core.h" 13 #include "ppapi/c/ppb_core.h"
15 #include "ppapi/c/ppb_var.h" 14 #include "ppapi/c/ppb_var.h"
16 #include "ppapi/cpp/instance.h" 15 #include "ppapi/cpp/instance.h"
17 #include "ppapi/cpp/module.h" 16 #include "ppapi/cpp/module.h"
18 #include "ppapi/tests/test_utils.h" 17 #include "ppapi/tests/test_utils.h"
19 #include "ppapi/tests/testing_instance.h" 18 #include "ppapi/tests/testing_instance.h"
(...skipping 21 matching lines...) Expand all
41 bool TestWebSocket::Init() { 40 bool TestWebSocket::Init() {
42 websocket_interface_ = static_cast<const PPB_WebSocket_Dev*>( 41 websocket_interface_ = static_cast<const PPB_WebSocket_Dev*>(
43 pp::Module::Get()->GetBrowserInterface(PPB_WEBSOCKET_DEV_INTERFACE)); 42 pp::Module::Get()->GetBrowserInterface(PPB_WEBSOCKET_DEV_INTERFACE));
44 var_interface_ = static_cast<const PPB_Var*>( 43 var_interface_ = static_cast<const PPB_Var*>(
45 pp::Module::Get()->GetBrowserInterface(PPB_VAR_INTERFACE)); 44 pp::Module::Get()->GetBrowserInterface(PPB_VAR_INTERFACE));
46 core_interface_ = static_cast<const PPB_Core*>( 45 core_interface_ = static_cast<const PPB_Core*>(
47 pp::Module::Get()->GetBrowserInterface(PPB_CORE_INTERFACE)); 46 pp::Module::Get()->GetBrowserInterface(PPB_CORE_INTERFACE));
48 if (!websocket_interface_ || !var_interface_ || !core_interface_) 47 if (!websocket_interface_ || !var_interface_ || !core_interface_)
49 return false; 48 return false;
50 49
51 return InitTestingInterface(); 50 return true;
52 } 51 }
53 52
54 void TestWebSocket::RunTests(const std::string& filter) { 53 void TestWebSocket::RunTests(const std::string& filter) {
55 RUN_TEST_WITH_REFERENCE_CHECK(IsWebSocket, filter); 54 RUN_TEST(IsWebSocket, filter);
56 RUN_TEST_WITH_REFERENCE_CHECK(UninitializedPropertiesAccess, filter); 55 RUN_TEST(UninitializedPropertiesAccess, filter);
57 RUN_TEST_WITH_REFERENCE_CHECK(InvalidConnect, filter); 56 RUN_TEST(InvalidConnect, filter);
58 RUN_TEST_WITH_REFERENCE_CHECK(Protocols, filter); 57 RUN_TEST(Protocols, filter);
59 RUN_TEST_WITH_REFERENCE_CHECK(GetURL, filter); 58 RUN_TEST(GetURL, filter);
60 RUN_TEST_WITH_REFERENCE_CHECK(ValidConnect, filter); 59 RUN_TEST(ValidConnect, filter);
61 RUN_TEST_WITH_REFERENCE_CHECK(InvalidClose, filter); 60 RUN_TEST(InvalidClose, filter);
62 RUN_TEST_WITH_REFERENCE_CHECK(ValidClose, filter); 61 RUN_TEST(ValidClose, filter);
63 RUN_TEST_WITH_REFERENCE_CHECK(GetProtocol, filter); 62 RUN_TEST(GetProtocol, filter);
64 RUN_TEST_WITH_REFERENCE_CHECK(TextSendReceive, filter); 63 RUN_TEST(TextSendReceive, filter);
65 } 64 }
66 65
67 PP_Var TestWebSocket::CreateVar(const char* string) { 66 PP_Var TestWebSocket::CreateVar(const char* string) {
68 return var_interface_->VarFromUtf8(string, strlen(string)); 67 return var_interface_->VarFromUtf8(string, strlen(string));
69 } 68 }
70 69
71 void TestWebSocket::ReleaseVar(const PP_Var& var) { 70 void TestWebSocket::ReleaseVar(const PP_Var& var) {
72 var_interface_->Release(var); 71 var_interface_->Release(var);
73 } 72 }
74 73
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 ASSERT_TRUE(ws); 131 ASSERT_TRUE(ws);
133 132
134 uint64_t bufferedAmount = websocket_interface_->GetBufferedAmount(ws); 133 uint64_t bufferedAmount = websocket_interface_->GetBufferedAmount(ws);
135 ASSERT_EQ(0U, bufferedAmount); 134 ASSERT_EQ(0U, bufferedAmount);
136 135
137 uint16_t close_code = websocket_interface_->GetCloseCode(ws); 136 uint16_t close_code = websocket_interface_->GetCloseCode(ws);
138 ASSERT_EQ(0U, close_code); 137 ASSERT_EQ(0U, close_code);
139 138
140 PP_Var close_reason = websocket_interface_->GetCloseReason(ws); 139 PP_Var close_reason = websocket_interface_->GetCloseReason(ws);
141 ASSERT_TRUE(AreEqual(close_reason, "")); 140 ASSERT_TRUE(AreEqual(close_reason, ""));
142 ReleaseVar(close_reason);
143 141
144 PP_Bool close_was_clean = websocket_interface_->GetCloseWasClean(ws); 142 PP_Bool close_was_clean = websocket_interface_->GetCloseWasClean(ws);
145 ASSERT_EQ(PP_FALSE, close_was_clean); 143 ASSERT_EQ(PP_FALSE, close_was_clean);
146 144
147 PP_Var extensions = websocket_interface_->GetExtensions(ws); 145 PP_Var extensions = websocket_interface_->GetExtensions(ws);
148 ASSERT_TRUE(AreEqual(extensions, "")); 146 ASSERT_TRUE(AreEqual(extensions, ""));
149 ReleaseVar(extensions);
150 147
151 PP_Var protocol = websocket_interface_->GetProtocol(ws); 148 PP_Var protocol = websocket_interface_->GetProtocol(ws);
152 ASSERT_TRUE(AreEqual(protocol, "")); 149 ASSERT_TRUE(AreEqual(protocol, ""));
153 ReleaseVar(protocol);
154 150
155 PP_WebSocketReadyState_Dev ready_state = 151 PP_WebSocketReadyState_Dev ready_state =
156 websocket_interface_->GetReadyState(ws); 152 websocket_interface_->GetReadyState(ws);
157 ASSERT_EQ(PP_WEBSOCKETREADYSTATE_INVALID_DEV, ready_state); 153 ASSERT_EQ(PP_WEBSOCKETREADYSTATE_INVALID_DEV, ready_state);
158 154
159 PP_Var url = websocket_interface_->GetURL(ws); 155 PP_Var url = websocket_interface_->GetURL(ws);
160 ASSERT_TRUE(AreEqual(url, "")); 156 ASSERT_TRUE(AreEqual(url, ""));
161 ReleaseVar(url);
162
163 core_interface_->ReleaseResource(ws);
164 157
165 PASS(); 158 PASS();
166 } 159 }
167 160
168 std::string TestWebSocket::TestInvalidConnect() { 161 std::string TestWebSocket::TestInvalidConnect() {
169 PP_Var protocols[] = { PP_MakeUndefined() }; 162 PP_Var protocols[] = { PP_MakeUndefined() };
170 163
171 PP_Resource ws = websocket_interface_->Create(instance_->pp_instance()); 164 PP_Resource ws = websocket_interface_->Create(instance_->pp_instance());
172 ASSERT_TRUE(ws); 165 ASSERT_TRUE(ws);
173 166
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 PASS(); 400 PASS();
408 } 401 }
409 402
410 // TODO(toyoshim): Add tests for GetBufferedAmount(). 403 // TODO(toyoshim): Add tests for GetBufferedAmount().
411 // For now, the function doesn't work fine because update callback in WebKit is 404 // For now, the function doesn't work fine because update callback in WebKit is
412 // not landed yet. 405 // not landed yet.
413 406
414 // TODO(toyoshim): Add tests for didReceiveMessageError(). 407 // TODO(toyoshim): Add tests for didReceiveMessageError().
415 408
416 // TODO(toyoshim): Add other function tests. 409 // TODO(toyoshim): Add other function tests.
OLDNEW
« no previous file with comments | « ppapi/tests/test_websocket.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698