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

Side by Side Diff: third_party/WebKit/Source/modules/websockets/DOMWebSocketTest.cpp

Issue 2614663008: Migrate WTF::Vector::append() to ::push_back() [part 13 of N] (Closed)
Patch Set: Created 3 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "modules/websockets/DOMWebSocket.h" 5 #include "modules/websockets/DOMWebSocket.h"
6 6
7 #include "bindings/core/v8/ExceptionState.h" 7 #include "bindings/core/v8/ExceptionState.h"
8 #include "bindings/core/v8/V8Binding.h" 8 #include "bindings/core/v8/V8Binding.h"
9 #include "bindings/core/v8/V8BindingForTesting.h" 9 #include "bindings/core/v8/V8BindingForTesting.h"
10 #include "core/dom/DOMTypedArray.h" 10 #include "core/dom/DOMTypedArray.h"
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 EXPECT_EQ("The port 7 is not allowed.", scope.getExceptionState().message()); 182 EXPECT_EQ("The port 7 is not allowed.", scope.getExceptionState().message());
183 EXPECT_EQ(DOMWebSocket::kClosed, webSocketScope.socket().readyState()); 183 EXPECT_EQ(DOMWebSocket::kClosed, webSocketScope.socket().readyState());
184 } 184 }
185 185
186 // FIXME: Add a test for Content Security Policy. 186 // FIXME: Add a test for Content Security Policy.
187 187
188 TEST(DOMWebSocketTest, invalidSubprotocols) { 188 TEST(DOMWebSocketTest, invalidSubprotocols) {
189 V8TestingScope scope; 189 V8TestingScope scope;
190 DOMWebSocketTestScope webSocketScope(scope.getExecutionContext()); 190 DOMWebSocketTestScope webSocketScope(scope.getExecutionContext());
191 Vector<String> subprotocols; 191 Vector<String> subprotocols;
192 subprotocols.append("@subprotocol-|'\"x\x01\x02\x03x"); 192 subprotocols.push_back("@subprotocol-|'\"x\x01\x02\x03x");
193 193
194 webSocketScope.socket().connect("ws://example.com/", subprotocols, 194 webSocketScope.socket().connect("ws://example.com/", subprotocols,
195 scope.getExceptionState()); 195 scope.getExceptionState());
196 196
197 EXPECT_TRUE(scope.getExceptionState().hadException()); 197 EXPECT_TRUE(scope.getExceptionState().hadException());
198 EXPECT_EQ(SyntaxError, scope.getExceptionState().code()); 198 EXPECT_EQ(SyntaxError, scope.getExceptionState().code());
199 EXPECT_EQ( 199 EXPECT_EQ(
200 "The subprotocol '@subprotocol-|'\"x\\u0001\\u0002\\u0003x' is invalid.", 200 "The subprotocol '@subprotocol-|'\"x\\u0001\\u0002\\u0003x' is invalid.",
201 scope.getExceptionState().message()); 201 scope.getExceptionState().message());
202 EXPECT_EQ(DOMWebSocket::kClosed, webSocketScope.socket().readyState()); 202 EXPECT_EQ(DOMWebSocket::kClosed, webSocketScope.socket().readyState());
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 EXPECT_FALSE(scope.getExceptionState().hadException()); 239 EXPECT_FALSE(scope.getExceptionState().hadException());
240 EXPECT_EQ(DOMWebSocket::kConnecting, webSocketScope.socket().readyState()); 240 EXPECT_EQ(DOMWebSocket::kConnecting, webSocketScope.socket().readyState());
241 EXPECT_EQ(KURL(KURL(), "ws://example.com/endpoint"), 241 EXPECT_EQ(KURL(KURL(), "ws://example.com/endpoint"),
242 webSocketScope.socket().url()); 242 webSocketScope.socket().url());
243 } 243 }
244 244
245 TEST(DOMWebSocketTest, channelConnectSuccess) { 245 TEST(DOMWebSocketTest, channelConnectSuccess) {
246 V8TestingScope scope; 246 V8TestingScope scope;
247 DOMWebSocketTestScope webSocketScope(scope.getExecutionContext()); 247 DOMWebSocketTestScope webSocketScope(scope.getExecutionContext());
248 Vector<String> subprotocols; 248 Vector<String> subprotocols;
249 subprotocols.append("aa"); 249 subprotocols.push_back("aa");
250 subprotocols.append("bb"); 250 subprotocols.push_back("bb");
251 251
252 { 252 {
253 InSequence s; 253 InSequence s;
254 EXPECT_CALL( 254 EXPECT_CALL(
255 webSocketScope.channel(), 255 webSocketScope.channel(),
256 connect(KURL(KURL(), "ws://example.com/hoge"), String("aa, bb"))) 256 connect(KURL(KURL(), "ws://example.com/hoge"), String("aa, bb")))
257 .WillOnce(Return(true)); 257 .WillOnce(Return(true));
258 } 258 }
259 259
260 webSocketScope.socket().connect("ws://example.com/hoge", 260 webSocketScope.socket().connect("ws://example.com/hoge",
261 Vector<String>(subprotocols), 261 Vector<String>(subprotocols),
262 scope.getExceptionState()); 262 scope.getExceptionState());
263 263
264 EXPECT_FALSE(scope.getExceptionState().hadException()); 264 EXPECT_FALSE(scope.getExceptionState().hadException());
265 EXPECT_EQ(DOMWebSocket::kConnecting, webSocketScope.socket().readyState()); 265 EXPECT_EQ(DOMWebSocket::kConnecting, webSocketScope.socket().readyState());
266 EXPECT_EQ(KURL(KURL(), "ws://example.com/hoge"), 266 EXPECT_EQ(KURL(KURL(), "ws://example.com/hoge"),
267 webSocketScope.socket().url()); 267 webSocketScope.socket().url());
268 } 268 }
269 269
270 TEST(DOMWebSocketTest, channelConnectFail) { 270 TEST(DOMWebSocketTest, channelConnectFail) {
271 V8TestingScope scope; 271 V8TestingScope scope;
272 DOMWebSocketTestScope webSocketScope(scope.getExecutionContext()); 272 DOMWebSocketTestScope webSocketScope(scope.getExecutionContext());
273 Vector<String> subprotocols; 273 Vector<String> subprotocols;
274 subprotocols.append("aa"); 274 subprotocols.push_back("aa");
275 subprotocols.append("bb"); 275 subprotocols.push_back("bb");
276 276
277 { 277 {
278 InSequence s; 278 InSequence s;
279 EXPECT_CALL(webSocketScope.channel(), 279 EXPECT_CALL(webSocketScope.channel(),
280 connect(KURL(KURL(), "ws://example.com/"), String("aa, bb"))) 280 connect(KURL(KURL(), "ws://example.com/"), String("aa, bb")))
281 .WillOnce(Return(false)); 281 .WillOnce(Return(false));
282 EXPECT_CALL(webSocketScope.channel(), disconnect()); 282 EXPECT_CALL(webSocketScope.channel(), disconnect());
283 } 283 }
284 284
285 webSocketScope.socket().connect("ws://example.com/", 285 webSocketScope.socket().connect("ws://example.com/",
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 String s; 318 String s;
319 s.append(static_cast<UChar>(i)); 319 s.append(static_cast<UChar>(i));
320 EXPECT_FALSE(DOMWebSocket::isValidSubprotocolString(s)); 320 EXPECT_FALSE(DOMWebSocket::isValidSubprotocolString(s));
321 } 321 }
322 } 322 }
323 323
324 TEST(DOMWebSocketTest, connectSuccess) { 324 TEST(DOMWebSocketTest, connectSuccess) {
325 V8TestingScope scope; 325 V8TestingScope scope;
326 DOMWebSocketTestScope webSocketScope(scope.getExecutionContext()); 326 DOMWebSocketTestScope webSocketScope(scope.getExecutionContext());
327 Vector<String> subprotocols; 327 Vector<String> subprotocols;
328 subprotocols.append("aa"); 328 subprotocols.push_back("aa");
329 subprotocols.append("bb"); 329 subprotocols.push_back("bb");
330 { 330 {
331 InSequence s; 331 InSequence s;
332 EXPECT_CALL(webSocketScope.channel(), 332 EXPECT_CALL(webSocketScope.channel(),
333 connect(KURL(KURL(), "ws://example.com/"), String("aa, bb"))) 333 connect(KURL(KURL(), "ws://example.com/"), String("aa, bb")))
334 .WillOnce(Return(true)); 334 .WillOnce(Return(true));
335 } 335 }
336 webSocketScope.socket().connect("ws://example.com/", subprotocols, 336 webSocketScope.socket().connect("ws://example.com/", subprotocols,
337 scope.getExceptionState()); 337 scope.getExceptionState());
338 338
339 EXPECT_FALSE(scope.getExceptionState().hadException()); 339 EXPECT_FALSE(scope.getExceptionState().hadException());
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after
881 } 881 }
882 882
883 INSTANTIATE_TEST_CASE_P( 883 INSTANTIATE_TEST_CASE_P(
884 DOMWebSocketInvalidClosingCode, 884 DOMWebSocketInvalidClosingCode,
885 DOMWebSocketInvalidClosingCodeTest, 885 DOMWebSocketInvalidClosingCodeTest,
886 ::testing::Values(0, 1, 998, 999, 1001, 2999, 5000, 9999, 65535)); 886 ::testing::Values(0, 1, 998, 999, 1001, 2999, 5000, 9999, 65535));
887 887
888 } // namespace 888 } // namespace
889 889
890 } // namespace blink 890 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/websockets/DOMWebSocket.cpp ('k') | third_party/WebKit/Source/modules/webusb/USB.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698