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

Side by Side Diff: chrome/browser/google_apis/gdata_wapi_operations_unittest.cc

Issue 13145003: Rewrite std::string("") to std::string(), Linux edition. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Ugh Created 7 years, 8 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 <algorithm> 5 #include <algorithm>
6 #include <map> 6 #include <map>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 } // namespace 318 } // namespace
319 319
320 TEST_F(GDataWapiOperationsTest, GetResourceListOperation_DefaultFeed) { 320 TEST_F(GDataWapiOperationsTest, GetResourceListOperation_DefaultFeed) {
321 GDataErrorCode result_code = GDATA_OTHER_ERROR; 321 GDataErrorCode result_code = GDATA_OTHER_ERROR;
322 scoped_ptr<ResourceList> result_data; 322 scoped_ptr<ResourceList> result_data;
323 323
324 GetResourceListOperation* operation = new GetResourceListOperation( 324 GetResourceListOperation* operation = new GetResourceListOperation(
325 &operation_registry_, 325 &operation_registry_,
326 request_context_getter_.get(), 326 request_context_getter_.get(),
327 *url_generator_, 327 *url_generator_,
328 GURL(), // Pass an empty URL to use the default feed 328 GURL(), // Pass an empty URL to use the default feed
329 0, // start changestamp 329 0, // start changestamp
330 "", // search string 330 std::string(), // search string
331 "", // directory resource ID 331 std::string(), // directory resource ID
332 CreateComposedCallback( 332 CreateComposedCallback(
333 base::Bind(&test_util::RunAndQuit), 333 base::Bind(&test_util::RunAndQuit),
334 test_util::CreateCopyResultCallback(&result_code, &result_data))); 334 test_util::CreateCopyResultCallback(&result_code, &result_data)));
335 operation->Start(kTestGDataAuthToken, kTestUserAgent, 335 operation->Start(kTestGDataAuthToken, kTestUserAgent,
336 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); 336 base::Bind(&test_util::DoNothingForReAuthenticateCallback));
337 MessageLoop::current()->Run(); 337 MessageLoop::current()->Run();
338 338
339 EXPECT_EQ(HTTP_SUCCESS, result_code); 339 EXPECT_EQ(HTTP_SUCCESS, result_code);
340 EXPECT_EQ(test_server::METHOD_GET, http_request_.method); 340 EXPECT_EQ(test_server::METHOD_GET, http_request_.method);
341 EXPECT_EQ("/feeds/default/private/full?v=3&alt=json&showroot=true&" 341 EXPECT_EQ("/feeds/default/private/full?v=3&alt=json&showroot=true&"
(...skipping 11 matching lines...) Expand all
353 353
354 TEST_F(GDataWapiOperationsTest, GetResourceListOperation_ValidFeed) { 354 TEST_F(GDataWapiOperationsTest, GetResourceListOperation_ValidFeed) {
355 GDataErrorCode result_code = GDATA_OTHER_ERROR; 355 GDataErrorCode result_code = GDATA_OTHER_ERROR;
356 scoped_ptr<ResourceList> result_data; 356 scoped_ptr<ResourceList> result_data;
357 357
358 GetResourceListOperation* operation = new GetResourceListOperation( 358 GetResourceListOperation* operation = new GetResourceListOperation(
359 &operation_registry_, 359 &operation_registry_,
360 request_context_getter_.get(), 360 request_context_getter_.get(),
361 *url_generator_, 361 *url_generator_,
362 test_server_.GetURL("/files/chromeos/gdata/root_feed.json"), 362 test_server_.GetURL("/files/chromeos/gdata/root_feed.json"),
363 0, // start changestamp 363 0, // start changestamp
364 "", // search string 364 std::string(), // search string
365 "", // directory resource ID 365 std::string(), // directory resource ID
366 CreateComposedCallback( 366 CreateComposedCallback(
367 base::Bind(&test_util::RunAndQuit), 367 base::Bind(&test_util::RunAndQuit),
368 test_util::CreateCopyResultCallback(&result_code, &result_data))); 368 test_util::CreateCopyResultCallback(&result_code, &result_data)));
369 operation->Start(kTestGDataAuthToken, kTestUserAgent, 369 operation->Start(kTestGDataAuthToken, kTestUserAgent,
370 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); 370 base::Bind(&test_util::DoNothingForReAuthenticateCallback));
371 MessageLoop::current()->Run(); 371 MessageLoop::current()->Run();
372 372
373 EXPECT_EQ(HTTP_SUCCESS, result_code); 373 EXPECT_EQ(HTTP_SUCCESS, result_code);
374 EXPECT_EQ(test_server::METHOD_GET, http_request_.method); 374 EXPECT_EQ(test_server::METHOD_GET, http_request_.method);
375 EXPECT_EQ("/files/chromeos/gdata/root_feed.json?v=3&alt=json&showroot=true&" 375 EXPECT_EQ("/files/chromeos/gdata/root_feed.json?v=3&alt=json&showroot=true&"
(...skipping 12 matching lines...) Expand all
388 // testfile.txt exists but the response is not JSON, so it should 388 // testfile.txt exists but the response is not JSON, so it should
389 // emit a parse error instead. 389 // emit a parse error instead.
390 GDataErrorCode result_code = GDATA_OTHER_ERROR; 390 GDataErrorCode result_code = GDATA_OTHER_ERROR;
391 scoped_ptr<ResourceList> result_data; 391 scoped_ptr<ResourceList> result_data;
392 392
393 GetResourceListOperation* operation = new GetResourceListOperation( 393 GetResourceListOperation* operation = new GetResourceListOperation(
394 &operation_registry_, 394 &operation_registry_,
395 request_context_getter_.get(), 395 request_context_getter_.get(),
396 *url_generator_, 396 *url_generator_,
397 test_server_.GetURL("/files/chromeos/gdata/testfile.txt"), 397 test_server_.GetURL("/files/chromeos/gdata/testfile.txt"),
398 0, // start changestamp 398 0, // start changestamp
399 "", // search string 399 std::string(), // search string
400 "", // directory resource ID 400 std::string(), // directory resource ID
401 CreateComposedCallback( 401 CreateComposedCallback(
402 base::Bind(&test_util::RunAndQuit), 402 base::Bind(&test_util::RunAndQuit),
403 test_util::CreateCopyResultCallback(&result_code, &result_data))); 403 test_util::CreateCopyResultCallback(&result_code, &result_data)));
404 operation->Start(kTestGDataAuthToken, kTestUserAgent, 404 operation->Start(kTestGDataAuthToken, kTestUserAgent,
405 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); 405 base::Bind(&test_util::DoNothingForReAuthenticateCallback));
406 MessageLoop::current()->Run(); 406 MessageLoop::current()->Run();
407 407
408 EXPECT_EQ(GDATA_PARSE_ERROR, result_code); 408 EXPECT_EQ(GDATA_PARSE_ERROR, result_code);
409 EXPECT_EQ(test_server::METHOD_GET, http_request_.method); 409 EXPECT_EQ(test_server::METHOD_GET, http_request_.method);
410 EXPECT_EQ("/files/chromeos/gdata/testfile.txt?v=3&alt=json&showroot=true&" 410 EXPECT_EQ("/files/chromeos/gdata/testfile.txt?v=3&alt=json&showroot=true&"
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 EXPECT_EQ(0U, result_data->installed_apps().size()); 541 EXPECT_EQ(0U, result_data->installed_apps().size());
542 } 542 }
543 543
544 TEST_F(GDataWapiOperationsTest, DeleteResourceOperation) { 544 TEST_F(GDataWapiOperationsTest, DeleteResourceOperation) {
545 GDataErrorCode result_code = GDATA_OTHER_ERROR; 545 GDataErrorCode result_code = GDATA_OTHER_ERROR;
546 546
547 DeleteResourceOperation* operation = new DeleteResourceOperation( 547 DeleteResourceOperation* operation = new DeleteResourceOperation(
548 &operation_registry_, 548 &operation_registry_,
549 request_context_getter_.get(), 549 request_context_getter_.get(),
550 *url_generator_, 550 *url_generator_,
551 CreateComposedCallback( 551 CreateComposedCallback(base::Bind(&test_util::RunAndQuit),
552 base::Bind(&test_util::RunAndQuit), 552 test_util::CreateCopyResultCallback(&result_code)),
553 test_util::CreateCopyResultCallback(&result_code)),
554 "file:2_file_resource_id", 553 "file:2_file_resource_id",
555 ""); 554 std::string());
556 555
557 operation->Start(kTestGDataAuthToken, kTestUserAgent, 556 operation->Start(kTestGDataAuthToken, kTestUserAgent,
558 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); 557 base::Bind(&test_util::DoNothingForReAuthenticateCallback));
559 MessageLoop::current()->Run(); 558 MessageLoop::current()->Run();
560 559
561 EXPECT_EQ(HTTP_SUCCESS, result_code); 560 EXPECT_EQ(HTTP_SUCCESS, result_code);
562 EXPECT_EQ(test_server::METHOD_DELETE, http_request_.method); 561 EXPECT_EQ(test_server::METHOD_DELETE, http_request_.method);
563 EXPECT_EQ( 562 EXPECT_EQ(
564 "/feeds/default/private/full/file%3A2_file_resource_id?v=3&alt=json" 563 "/feeds/default/private/full/file%3A2_file_resource_id?v=3&alt=json"
565 "&showroot=true", 564 "&showroot=true",
(...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after
1128 1127
1129 EXPECT_EQ(kUploadContent.size(), num_bytes_consumed); 1128 EXPECT_EQ(kUploadContent.size(), num_bytes_consumed);
1130 } 1129 }
1131 1130
1132 // This test exercises InitiateUploadNewFileOperation and ResumeUploadOperation 1131 // This test exercises InitiateUploadNewFileOperation and ResumeUploadOperation
1133 // for a scenario of uploading a new *empty* file. 1132 // for a scenario of uploading a new *empty* file.
1134 // 1133 //
1135 // The test is almost identical to UploadNewFile. The only difference is the 1134 // The test is almost identical to UploadNewFile. The only difference is the
1136 // expectation for the Content-Range header. 1135 // expectation for the Content-Range header.
1137 TEST_F(GDataWapiOperationsTest, UploadNewEmptyFile) { 1136 TEST_F(GDataWapiOperationsTest, UploadNewEmptyFile) {
1138 const std::string kUploadContent = ""; 1137 const std::string kUploadContent;
1139 GDataErrorCode result_code = GDATA_OTHER_ERROR; 1138 GDataErrorCode result_code = GDATA_OTHER_ERROR;
1140 GURL upload_url; 1139 GURL upload_url;
1141 1140
1142 // 1) Get the upload URL for uploading a new file. 1141 // 1) Get the upload URL for uploading a new file.
1143 InitiateUploadNewFileOperation* initiate_operation = 1142 InitiateUploadNewFileOperation* initiate_operation =
1144 new InitiateUploadNewFileOperation( 1143 new InitiateUploadNewFileOperation(
1145 &operation_registry_, 1144 &operation_registry_,
1146 request_context_getter_.get(), 1145 request_context_getter_.get(),
1147 *url_generator_, 1146 *url_generator_,
1148 CreateComposedCallback( 1147 CreateComposedCallback(
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
1237 &operation_registry_, 1236 &operation_registry_,
1238 request_context_getter_.get(), 1237 request_context_getter_.get(),
1239 *url_generator_, 1238 *url_generator_,
1240 CreateComposedCallback( 1239 CreateComposedCallback(
1241 base::Bind(&test_util::RunAndQuit), 1240 base::Bind(&test_util::RunAndQuit),
1242 test_util::CreateCopyResultCallback(&result_code, &upload_url)), 1241 test_util::CreateCopyResultCallback(&result_code, &upload_url)),
1243 base::FilePath::FromUTF8Unsafe("drive/existingfile.txt"), 1242 base::FilePath::FromUTF8Unsafe("drive/existingfile.txt"),
1244 "text/plain", 1243 "text/plain",
1245 kUploadContent.size(), 1244 kUploadContent.size(),
1246 "file:foo", 1245 "file:foo",
1247 "" /* etag */); 1246 std::string() /* etag */);
1248 1247
1249 initiate_operation->Start( 1248 initiate_operation->Start(
1250 kTestGDataAuthToken, kTestUserAgent, 1249 kTestGDataAuthToken, kTestUserAgent,
1251 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); 1250 base::Bind(&test_util::DoNothingForReAuthenticateCallback));
1252 MessageLoop::current()->Run(); 1251 MessageLoop::current()->Run();
1253 1252
1254 EXPECT_EQ(HTTP_SUCCESS, result_code); 1253 EXPECT_EQ(HTTP_SUCCESS, result_code);
1255 EXPECT_EQ(test_server_.GetURL("/upload_existing_file"), upload_url); 1254 EXPECT_EQ(test_server_.GetURL("/upload_existing_file"), upload_url);
1256 // For updating an existing file, METHOD_PUT should be used. 1255 // For updating an existing file, METHOD_PUT should be used.
1257 EXPECT_EQ(test_server::METHOD_PUT, http_request_.method); 1256 EXPECT_EQ(test_server::METHOD_PUT, http_request_.method);
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
1451 EXPECT_EQ(base::Int64ToString(kUploadContent.size()), 1450 EXPECT_EQ(base::Int64ToString(kUploadContent.size()),
1452 http_request_.headers["X-Upload-Content-Length"]); 1451 http_request_.headers["X-Upload-Content-Length"]);
1453 // For updating an existing file, an empty body should be attached (PUT 1452 // For updating an existing file, an empty body should be attached (PUT
1454 // requires a body) 1453 // requires a body)
1455 EXPECT_TRUE(http_request_.has_content); 1454 EXPECT_TRUE(http_request_.has_content);
1456 EXPECT_EQ("", http_request_.content); 1455 EXPECT_EQ("", http_request_.content);
1457 EXPECT_EQ(kWrongETag, http_request_.headers["If-Match"]); 1456 EXPECT_EQ(kWrongETag, http_request_.headers["If-Match"]);
1458 } 1457 }
1459 1458
1460 } // namespace google_apis 1459 } // namespace google_apis
OLDNEW
« no previous file with comments | « chrome/browser/google_apis/fake_drive_service_unittest.cc ('k') | chrome/browser/google_apis/gdata_wapi_parser_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698