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

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

Issue 690903002: Remove timing limitation of SetOption invocation for PPAPI sockets. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and fixed implementation. Created 6 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_udp_socket.h" 5 #include "ppapi/tests/test_udp_socket.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "ppapi/cpp/pass_ref.h" 9 #include "ppapi/cpp/pass_ref.h"
10 #include "ppapi/cpp/tcp_socket.h" 10 #include "ppapi/cpp/tcp_socket.h"
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 callback.WaitForResult(socket.SetOption( 265 callback.WaitForResult(socket.SetOption(
266 PP_UDPSOCKET_OPTION_ADDRESS_REUSE, pp::Var(1), callback.GetCallback())); 266 PP_UDPSOCKET_OPTION_ADDRESS_REUSE, pp::Var(1), callback.GetCallback()));
267 CHECK_CALLBACK_BEHAVIOR(callback); 267 CHECK_CALLBACK_BEHAVIOR(callback);
268 ASSERT_EQ(PP_ERROR_BADARGUMENT, callback.result()); 268 ASSERT_EQ(PP_ERROR_BADARGUMENT, callback.result());
269 269
270 callback.WaitForResult(socket.SetOption( 270 callback.WaitForResult(socket.SetOption(
271 PP_UDPSOCKET_OPTION_BROADCAST, pp::Var(false), callback.GetCallback())); 271 PP_UDPSOCKET_OPTION_BROADCAST, pp::Var(false), callback.GetCallback()));
272 CHECK_CALLBACK_BEHAVIOR(callback); 272 CHECK_CALLBACK_BEHAVIOR(callback);
273 ASSERT_EQ(PP_OK, callback.result()); 273 ASSERT_EQ(PP_OK, callback.result());
274 274
275 // SEND_BUFFER_SIZE and RECV_BUFFER_SIZE shouldn't be set before the socket is
276 // bound.
277 callback.WaitForResult(socket.SetOption( 275 callback.WaitForResult(socket.SetOption(
278 PP_UDPSOCKET_OPTION_SEND_BUFFER_SIZE, pp::Var(4096), 276 PP_UDPSOCKET_OPTION_SEND_BUFFER_SIZE, pp::Var(4096),
279 callback.GetCallback())); 277 callback.GetCallback()));
280 CHECK_CALLBACK_BEHAVIOR(callback); 278 CHECK_CALLBACK_BEHAVIOR(callback);
281 ASSERT_EQ(PP_ERROR_FAILED, callback.result()); 279 ASSERT_EQ(PP_OK, callback.result());
282 280
283 callback.WaitForResult(socket.SetOption( 281 callback.WaitForResult(socket.SetOption(
284 PP_UDPSOCKET_OPTION_RECV_BUFFER_SIZE, pp::Var(512), 282 PP_UDPSOCKET_OPTION_RECV_BUFFER_SIZE, pp::Var(512),
285 callback.GetCallback())); 283 callback.GetCallback()));
286 CHECK_CALLBACK_BEHAVIOR(callback); 284 CHECK_CALLBACK_BEHAVIOR(callback);
287 ASSERT_EQ(PP_ERROR_FAILED, callback.result()); 285 ASSERT_EQ(PP_OK, callback.result());
288 286
289 pp::NetAddress address; 287 pp::NetAddress address;
290 ASSERT_SUBTEST_SUCCESS(LookupPortAndBindUDPSocket(&socket, &address)); 288 ASSERT_SUBTEST_SUCCESS(LookupPortAndBindUDPSocket(&socket, &address));
291 289
292 // ADDRESS_REUSE and BROADCAST won't take effect after the socket is bound. 290 // ADDRESS_REUSE won't take effect after the socket is bound.
293 callback.WaitForResult(socket.SetOption( 291 callback.WaitForResult(socket.SetOption(
294 PP_UDPSOCKET_OPTION_ADDRESS_REUSE, pp::Var(true), 292 PP_UDPSOCKET_OPTION_ADDRESS_REUSE, pp::Var(true),
295 callback.GetCallback())); 293 callback.GetCallback()));
296 CHECK_CALLBACK_BEHAVIOR(callback); 294 CHECK_CALLBACK_BEHAVIOR(callback);
297 ASSERT_EQ(PP_ERROR_FAILED, callback.result()); 295 ASSERT_EQ(PP_ERROR_FAILED, callback.result());
298 296
297 // BROADCAST, SEND_BUFFER_SIZE and RECV_BUFFER_SIZE can be set after the
298 // socket is bound.
299 callback.WaitForResult(socket.SetOption( 299 callback.WaitForResult(socket.SetOption(
300 PP_UDPSOCKET_OPTION_BROADCAST, pp::Var(true), callback.GetCallback())); 300 PP_UDPSOCKET_OPTION_BROADCAST, pp::Var(true), callback.GetCallback()));
301 CHECK_CALLBACK_BEHAVIOR(callback); 301 CHECK_CALLBACK_BEHAVIOR(callback);
302 ASSERT_EQ(PP_ERROR_FAILED, callback.result()); 302 ASSERT_EQ(PP_OK, callback.result());
303 303
304 // SEND_BUFFER_SIZE and RECV_BUFFER_SIZE can be set after the socket is bound.
305 callback.WaitForResult(socket.SetOption( 304 callback.WaitForResult(socket.SetOption(
306 PP_UDPSOCKET_OPTION_SEND_BUFFER_SIZE, pp::Var(2048), 305 PP_UDPSOCKET_OPTION_SEND_BUFFER_SIZE, pp::Var(2048),
307 callback.GetCallback())); 306 callback.GetCallback()));
308 CHECK_CALLBACK_BEHAVIOR(callback); 307 CHECK_CALLBACK_BEHAVIOR(callback);
309 ASSERT_EQ(PP_OK, callback.result()); 308 ASSERT_EQ(PP_OK, callback.result());
310 309
311 callback.WaitForResult(socket.SetOption( 310 callback.WaitForResult(socket.SetOption(
312 PP_UDPSOCKET_OPTION_RECV_BUFFER_SIZE, pp::Var(1024), 311 PP_UDPSOCKET_OPTION_RECV_BUFFER_SIZE, pp::Var(1024),
313 callback.GetCallback())); 312 callback.GetCallback()));
314 CHECK_CALLBACK_BEHAVIOR(callback); 313 CHECK_CALLBACK_BEHAVIOR(callback);
315 ASSERT_EQ(PP_OK, callback.result()); 314 ASSERT_EQ(PP_OK, callback.result());
316 315
317 PASS(); 316 PASS();
318 } 317 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698