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

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

Issue 915403003: Enable size_t to int truncation warnings in PPAPI (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ppapi_unittests win x64 Created 5 years, 10 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
« no previous file with comments | « ppapi/tests/test_url_loader.cc ('k') | ppapi/tests/test_websocket.cc » ('j') | 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) 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 // Tests PPB_URLRequestInfo interface. 5 // Tests PPB_URLRequestInfo interface.
6 6
7 #include "ppapi/tests/test_url_request.h" 7 #include "ppapi/tests/test_url_request.h"
8 8
9 #include <string.h> 9 #include <string.h>
10 #include <string> 10 #include <string>
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 70
71 void TestURLRequest::RunTests(const std::string& filter) { 71 void TestURLRequest::RunTests(const std::string& filter) {
72 RUN_TEST(CreateAndIsURLRequestInfo, filter); 72 RUN_TEST(CreateAndIsURLRequestInfo, filter);
73 RUN_TEST(SetProperty, filter); 73 RUN_TEST(SetProperty, filter);
74 RUN_TEST(AppendDataToBody, filter); 74 RUN_TEST(AppendDataToBody, filter);
75 RUN_TEST(AppendFileToBody, filter); 75 RUN_TEST(AppendFileToBody, filter);
76 RUN_TEST(Stress, filter); 76 RUN_TEST(Stress, filter);
77 } 77 }
78 78
79 PP_Var TestURLRequest::PP_MakeString(const char* s) { 79 PP_Var TestURLRequest::PP_MakeString(const char* s) {
80 return ppb_var_interface_->VarFromUtf8(s, strlen(s)); 80 return ppb_var_interface_->VarFromUtf8(s, static_cast<int32_t>(strlen(s)));
81 } 81 }
82 82
83 // Tests 83 // Tests
84 // PP_Resource Create(PP_Instance instance) 84 // PP_Resource Create(PP_Instance instance)
85 // PP_Bool IsURLRequestInfo(PP_Resource resource) 85 // PP_Bool IsURLRequestInfo(PP_Resource resource)
86 std::string TestURLRequest::TestCreateAndIsURLRequestInfo() { 86 std::string TestURLRequest::TestCreateAndIsURLRequestInfo() {
87 // Create: Invalid / non-existent instance -> invalid resource. 87 // Create: Invalid / non-existent instance -> invalid resource.
88 ASSERT_EQ(ppb_url_request_interface_->Create(kInvalidInstance), 88 ASSERT_EQ(ppb_url_request_interface_->Create(kInvalidInstance),
89 kInvalidResource); 89 kInvalidResource);
90 ASSERT_EQ(ppb_url_request_interface_->Create(kNotAnInstance), 90 ASSERT_EQ(ppb_url_request_interface_->Create(kNotAnInstance),
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 std::string postdata("sample postdata"); 350 std::string postdata("sample postdata");
351 PP_Var post_string_var = PP_MakeString("POST"); 351 PP_Var post_string_var = PP_MakeString("POST");
352 PP_Var echo_string_var = PP_MakeString("/echo"); 352 PP_Var echo_string_var = PP_MakeString("/echo");
353 353
354 // NULL pointer causes a crash. In general PPAPI implementation does not 354 // NULL pointer causes a crash. In general PPAPI implementation does not
355 // test for NULL because they are just a special case of bad pointers that 355 // test for NULL because they are just a special case of bad pointers that
356 // are not detectable if set to point to an object that does not exist. 356 // are not detectable if set to point to an object that does not exist.
357 357
358 // Invalid resource should fail. 358 // Invalid resource should fail.
359 ASSERT_EQ(PP_FALSE, ppb_url_request_interface_->AppendDataToBody( 359 ASSERT_EQ(PP_FALSE, ppb_url_request_interface_->AppendDataToBody(
360 kInvalidResource, postdata.data(), postdata.length())); 360 kInvalidResource, postdata.data(),
361 static_cast<uint32_t>(postdata.length())));
361 362
362 // Append data and POST to echoing web server. 363 // Append data and POST to echoing web server.
363 ASSERT_EQ(PP_TRUE, ppb_url_request_interface_->SetProperty( 364 ASSERT_EQ(PP_TRUE, ppb_url_request_interface_->SetProperty(
364 url_request, PP_URLREQUESTPROPERTY_METHOD, post_string_var)); 365 url_request, PP_URLREQUESTPROPERTY_METHOD, post_string_var));
365 ASSERT_EQ(PP_TRUE, ppb_url_request_interface_->SetProperty( 366 ASSERT_EQ(PP_TRUE, ppb_url_request_interface_->SetProperty(
366 url_request, PP_URLREQUESTPROPERTY_URL, echo_string_var)); 367 url_request, PP_URLREQUESTPROPERTY_URL, echo_string_var));
367 368
368 // Append data to body and verify the body is what we expect. 369 // Append data to body and verify the body is what we expect.
369 ASSERT_EQ(PP_TRUE, ppb_url_request_interface_->AppendDataToBody( 370 ASSERT_EQ(PP_TRUE, ppb_url_request_interface_->AppendDataToBody(
370 url_request, postdata.data(), postdata.length())); 371 url_request, postdata.data(),
372 static_cast<uint32_t>(postdata.length())));
371 std::string error = LoadAndCompareBody(url_request, postdata); 373 std::string error = LoadAndCompareBody(url_request, postdata);
372 374
373 ppb_var_interface_->Release(post_string_var); 375 ppb_var_interface_->Release(post_string_var);
374 ppb_var_interface_->Release(echo_string_var); 376 ppb_var_interface_->Release(echo_string_var);
375 ppb_core_interface_->ReleaseResource(url_request); 377 ppb_core_interface_->ReleaseResource(url_request);
376 return error; // == PASS() if empty. 378 return error; // == PASS() if empty.
377 } 379 }
378 380
379 std::string TestURLRequest::TestAppendFileToBody() { 381 std::string TestURLRequest::TestAppendFileToBody() {
380 PP_Resource url_request = ppb_url_request_interface_->Create( 382 PP_Resource url_request = ppb_url_request_interface_->Create(
(...skipping 11 matching lines...) Expand all
392 pp::FileIO io(instance_); 394 pp::FileIO io(instance_);
393 callback.WaitForResult(io.Open(ref, 395 callback.WaitForResult(io.Open(ref,
394 PP_FILEOPENFLAG_CREATE | PP_FILEOPENFLAG_WRITE, 396 PP_FILEOPENFLAG_CREATE | PP_FILEOPENFLAG_WRITE,
395 callback.GetCallback())); 397 callback.GetCallback()));
396 CHECK_CALLBACK_BEHAVIOR(callback); 398 CHECK_CALLBACK_BEHAVIOR(callback);
397 ASSERT_EQ(PP_OK, callback.result()); 399 ASSERT_EQ(PP_OK, callback.result());
398 400
399 std::string append_data = "hello\n"; 401 std::string append_data = "hello\n";
400 callback.WaitForResult(io.Write(0, 402 callback.WaitForResult(io.Write(0,
401 append_data.c_str(), 403 append_data.c_str(),
402 append_data.size(), 404 static_cast<int32_t>(append_data.size()),
403 callback.GetCallback())); 405 callback.GetCallback()));
404 CHECK_CALLBACK_BEHAVIOR(callback); 406 CHECK_CALLBACK_BEHAVIOR(callback);
405 ASSERT_EQ(static_cast<int32_t>(append_data.size()), callback.result()); 407 ASSERT_EQ(static_cast<int32_t>(append_data.size()), callback.result());
406 408
407 PP_Var post_string_var = PP_MakeString("POST"); 409 PP_Var post_string_var = PP_MakeString("POST");
408 PP_Var echo_string_var = PP_MakeString("/echo"); 410 PP_Var echo_string_var = PP_MakeString("/echo");
409 411
410 // NULL pointer causes a crash. In general PPAPI implementation does not 412 // NULL pointer causes a crash. In general PPAPI implementation does not
411 // test for NULL because they are just a special case of bad pointers that 413 // test for NULL because they are just a special case of bad pointers that
412 // are not detectable if set to point to an object that does not exist. 414 // are not detectable if set to point to an object that does not exist.
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 } 461 }
460 } 462 }
461 for (int i = 0; i < num_created; i++) { 463 for (int i = 0; i < num_created; i++) {
462 ppb_core_interface_->ReleaseResource(url_request_info[i]); 464 ppb_core_interface_->ReleaseResource(url_request_info[i]);
463 if (PP_TRUE == 465 if (PP_TRUE ==
464 ppb_url_request_interface_->IsURLRequestInfo(url_request_info[i])) 466 ppb_url_request_interface_->IsURLRequestInfo(url_request_info[i]))
465 error = "IsURLREquestInfo() succeeded after release"; 467 error = "IsURLREquestInfo() succeeded after release";
466 } 468 }
467 return error; // == PASS() if empty. 469 return error; // == PASS() if empty.
468 } 470 }
OLDNEW
« no previous file with comments | « ppapi/tests/test_url_loader.cc ('k') | ppapi/tests/test_websocket.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698