OLD | NEW |
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/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 } // namespace | 336 } // namespace |
337 | 337 |
338 TEST_F(GDataWapiRequestsTest, GetResourceListRequest_DefaultFeed) { | 338 TEST_F(GDataWapiRequestsTest, GetResourceListRequest_DefaultFeed) { |
339 GDataErrorCode result_code = GDATA_OTHER_ERROR; | 339 GDataErrorCode result_code = GDATA_OTHER_ERROR; |
340 scoped_ptr<ResourceList> result_data; | 340 scoped_ptr<ResourceList> result_data; |
341 | 341 |
342 { | 342 { |
343 base::RunLoop run_loop; | 343 base::RunLoop run_loop; |
344 GetResourceListRequest* request = new GetResourceListRequest( | 344 GetResourceListRequest* request = new GetResourceListRequest( |
345 request_sender_.get(), | 345 request_sender_.get(), |
346 request_context_getter_.get(), | |
347 *url_generator_, | 346 *url_generator_, |
348 GURL(), // Pass an empty URL to use the default feed | 347 GURL(), // Pass an empty URL to use the default feed |
349 0, // start changestamp | 348 0, // start changestamp |
350 std::string(), // search string | 349 std::string(), // search string |
351 std::string(), // directory resource ID | 350 std::string(), // directory resource ID |
352 test_util::CreateQuitCallback( | 351 test_util::CreateQuitCallback( |
353 &run_loop, | 352 &run_loop, |
354 test_util::CreateCopyResultCallback(&result_code, &result_data))); | 353 test_util::CreateCopyResultCallback(&result_code, &result_data))); |
355 request_sender_->StartRequestWithRetry(request); | 354 request_sender_->StartRequestWithRetry(request); |
356 run_loop.Run(); | 355 run_loop.Run(); |
(...skipping 14 matching lines...) Expand all Loading... |
371 } | 370 } |
372 | 371 |
373 TEST_F(GDataWapiRequestsTest, GetResourceListRequest_ValidFeed) { | 372 TEST_F(GDataWapiRequestsTest, GetResourceListRequest_ValidFeed) { |
374 GDataErrorCode result_code = GDATA_OTHER_ERROR; | 373 GDataErrorCode result_code = GDATA_OTHER_ERROR; |
375 scoped_ptr<ResourceList> result_data; | 374 scoped_ptr<ResourceList> result_data; |
376 | 375 |
377 { | 376 { |
378 base::RunLoop run_loop; | 377 base::RunLoop run_loop; |
379 GetResourceListRequest* request = new GetResourceListRequest( | 378 GetResourceListRequest* request = new GetResourceListRequest( |
380 request_sender_.get(), | 379 request_sender_.get(), |
381 request_context_getter_.get(), | |
382 *url_generator_, | 380 *url_generator_, |
383 test_server_.GetURL("/files/chromeos/gdata/root_feed.json"), | 381 test_server_.GetURL("/files/chromeos/gdata/root_feed.json"), |
384 0, // start changestamp | 382 0, // start changestamp |
385 std::string(), // search string | 383 std::string(), // search string |
386 std::string(), // directory resource ID | 384 std::string(), // directory resource ID |
387 test_util::CreateQuitCallback( | 385 test_util::CreateQuitCallback( |
388 &run_loop, | 386 &run_loop, |
389 test_util::CreateCopyResultCallback(&result_code, &result_data))); | 387 test_util::CreateCopyResultCallback(&result_code, &result_data))); |
390 request_sender_->StartRequestWithRetry(request); | 388 request_sender_->StartRequestWithRetry(request); |
391 run_loop.Run(); | 389 run_loop.Run(); |
(...skipping 15 matching lines...) Expand all Loading... |
407 TEST_F(GDataWapiRequestsTest, GetResourceListRequest_InvalidFeed) { | 405 TEST_F(GDataWapiRequestsTest, GetResourceListRequest_InvalidFeed) { |
408 // testfile.txt exists but the response is not JSON, so it should | 406 // testfile.txt exists but the response is not JSON, so it should |
409 // emit a parse error instead. | 407 // emit a parse error instead. |
410 GDataErrorCode result_code = GDATA_OTHER_ERROR; | 408 GDataErrorCode result_code = GDATA_OTHER_ERROR; |
411 scoped_ptr<ResourceList> result_data; | 409 scoped_ptr<ResourceList> result_data; |
412 | 410 |
413 { | 411 { |
414 base::RunLoop run_loop; | 412 base::RunLoop run_loop; |
415 GetResourceListRequest* request = new GetResourceListRequest( | 413 GetResourceListRequest* request = new GetResourceListRequest( |
416 request_sender_.get(), | 414 request_sender_.get(), |
417 request_context_getter_.get(), | |
418 *url_generator_, | 415 *url_generator_, |
419 test_server_.GetURL("/files/chromeos/gdata/testfile.txt"), | 416 test_server_.GetURL("/files/chromeos/gdata/testfile.txt"), |
420 0, // start changestamp | 417 0, // start changestamp |
421 std::string(), // search string | 418 std::string(), // search string |
422 std::string(), // directory resource ID | 419 std::string(), // directory resource ID |
423 test_util::CreateQuitCallback( | 420 test_util::CreateQuitCallback( |
424 &run_loop, | 421 &run_loop, |
425 test_util::CreateCopyResultCallback(&result_code, &result_data))); | 422 test_util::CreateCopyResultCallback(&result_code, &result_data))); |
426 request_sender_->StartRequestWithRetry(request); | 423 request_sender_->StartRequestWithRetry(request); |
427 run_loop.Run(); | 424 run_loop.Run(); |
428 } | 425 } |
429 | 426 |
430 EXPECT_EQ(GDATA_PARSE_ERROR, result_code); | 427 EXPECT_EQ(GDATA_PARSE_ERROR, result_code); |
431 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); | 428 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); |
432 EXPECT_EQ("/files/chromeos/gdata/testfile.txt?v=3&alt=json&showroot=true&" | 429 EXPECT_EQ("/files/chromeos/gdata/testfile.txt?v=3&alt=json&showroot=true&" |
433 "showfolders=true&include-shared=true&max-results=500", | 430 "showfolders=true&include-shared=true&max-results=500", |
434 http_request_.relative_url); | 431 http_request_.relative_url); |
435 EXPECT_FALSE(result_data); | 432 EXPECT_FALSE(result_data); |
436 } | 433 } |
437 | 434 |
438 TEST_F(GDataWapiRequestsTest, SearchByTitleRequest) { | 435 TEST_F(GDataWapiRequestsTest, SearchByTitleRequest) { |
439 GDataErrorCode result_code = GDATA_OTHER_ERROR; | 436 GDataErrorCode result_code = GDATA_OTHER_ERROR; |
440 scoped_ptr<ResourceList> result_data; | 437 scoped_ptr<ResourceList> result_data; |
441 | 438 |
442 { | 439 { |
443 base::RunLoop run_loop; | 440 base::RunLoop run_loop; |
444 SearchByTitleRequest* request = new SearchByTitleRequest( | 441 SearchByTitleRequest* request = new SearchByTitleRequest( |
445 request_sender_.get(), | 442 request_sender_.get(), |
446 request_context_getter_.get(), | |
447 *url_generator_, | 443 *url_generator_, |
448 "search-title", | 444 "search-title", |
449 std::string(), // directory resource id | 445 std::string(), // directory resource id |
450 test_util::CreateQuitCallback( | 446 test_util::CreateQuitCallback( |
451 &run_loop, | 447 &run_loop, |
452 test_util::CreateCopyResultCallback(&result_code, &result_data))); | 448 test_util::CreateCopyResultCallback(&result_code, &result_data))); |
453 request_sender_->StartRequestWithRetry(request); | 449 request_sender_->StartRequestWithRetry(request); |
454 run_loop.Run(); | 450 run_loop.Run(); |
455 } | 451 } |
456 | 452 |
457 EXPECT_EQ(HTTP_SUCCESS, result_code); | 453 EXPECT_EQ(HTTP_SUCCESS, result_code); |
458 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); | 454 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); |
459 EXPECT_EQ("/feeds/default/private/full?v=3&alt=json&showroot=true&" | 455 EXPECT_EQ("/feeds/default/private/full?v=3&alt=json&showroot=true&" |
460 "showfolders=true&include-shared=true&max-results=500" | 456 "showfolders=true&include-shared=true&max-results=500" |
461 "&title=search-title&title-exact=true", | 457 "&title=search-title&title-exact=true", |
462 http_request_.relative_url); | 458 http_request_.relative_url); |
463 EXPECT_TRUE(result_data); | 459 EXPECT_TRUE(result_data); |
464 } | 460 } |
465 | 461 |
466 TEST_F(GDataWapiRequestsTest, GetResourceEntryRequest_ValidResourceId) { | 462 TEST_F(GDataWapiRequestsTest, GetResourceEntryRequest_ValidResourceId) { |
467 GDataErrorCode result_code = GDATA_OTHER_ERROR; | 463 GDataErrorCode result_code = GDATA_OTHER_ERROR; |
468 scoped_ptr<base::Value> result_data; | 464 scoped_ptr<base::Value> result_data; |
469 | 465 |
470 { | 466 { |
471 base::RunLoop run_loop; | 467 base::RunLoop run_loop; |
472 GetResourceEntryRequest* request = new GetResourceEntryRequest( | 468 GetResourceEntryRequest* request = new GetResourceEntryRequest( |
473 request_sender_.get(), | 469 request_sender_.get(), |
474 request_context_getter_.get(), | |
475 *url_generator_, | 470 *url_generator_, |
476 "file:2_file_resource_id", // resource ID | 471 "file:2_file_resource_id", // resource ID |
477 test_util::CreateQuitCallback( | 472 test_util::CreateQuitCallback( |
478 &run_loop, | 473 &run_loop, |
479 test_util::CreateCopyResultCallback(&result_code, &result_data))); | 474 test_util::CreateCopyResultCallback(&result_code, &result_data))); |
480 request_sender_->StartRequestWithRetry(request); | 475 request_sender_->StartRequestWithRetry(request); |
481 run_loop.Run(); | 476 run_loop.Run(); |
482 } | 477 } |
483 | 478 |
484 EXPECT_EQ(HTTP_SUCCESS, result_code); | 479 EXPECT_EQ(HTTP_SUCCESS, result_code); |
485 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); | 480 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); |
486 EXPECT_EQ("/feeds/default/private/full/file%3A2_file_resource_id" | 481 EXPECT_EQ("/feeds/default/private/full/file%3A2_file_resource_id" |
487 "?v=3&alt=json&showroot=true", | 482 "?v=3&alt=json&showroot=true", |
488 http_request_.relative_url); | 483 http_request_.relative_url); |
489 EXPECT_TRUE(test_util::VerifyJsonData( | 484 EXPECT_TRUE(test_util::VerifyJsonData( |
490 test_util::GetTestFilePath("chromeos/gdata/file_entry.json"), | 485 test_util::GetTestFilePath("chromeos/gdata/file_entry.json"), |
491 result_data.get())); | 486 result_data.get())); |
492 } | 487 } |
493 | 488 |
494 TEST_F(GDataWapiRequestsTest, GetResourceEntryRequest_InvalidResourceId) { | 489 TEST_F(GDataWapiRequestsTest, GetResourceEntryRequest_InvalidResourceId) { |
495 GDataErrorCode result_code = GDATA_OTHER_ERROR; | 490 GDataErrorCode result_code = GDATA_OTHER_ERROR; |
496 scoped_ptr<base::Value> result_data; | 491 scoped_ptr<base::Value> result_data; |
497 | 492 |
498 { | 493 { |
499 base::RunLoop run_loop; | 494 base::RunLoop run_loop; |
500 GetResourceEntryRequest* request = new GetResourceEntryRequest( | 495 GetResourceEntryRequest* request = new GetResourceEntryRequest( |
501 request_sender_.get(), | 496 request_sender_.get(), |
502 request_context_getter_.get(), | |
503 *url_generator_, | 497 *url_generator_, |
504 "<invalid>", // resource ID | 498 "<invalid>", // resource ID |
505 test_util::CreateQuitCallback( | 499 test_util::CreateQuitCallback( |
506 &run_loop, | 500 &run_loop, |
507 test_util::CreateCopyResultCallback(&result_code, &result_data))); | 501 test_util::CreateCopyResultCallback(&result_code, &result_data))); |
508 request_sender_->StartRequestWithRetry(request); | 502 request_sender_->StartRequestWithRetry(request); |
509 run_loop.Run(); | 503 run_loop.Run(); |
510 } | 504 } |
511 | 505 |
512 EXPECT_EQ(HTTP_NOT_FOUND, result_code); | 506 EXPECT_EQ(HTTP_NOT_FOUND, result_code); |
513 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); | 507 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); |
514 EXPECT_EQ("/feeds/default/private/full/%3Cinvalid%3E?v=3&alt=json" | 508 EXPECT_EQ("/feeds/default/private/full/%3Cinvalid%3E?v=3&alt=json" |
515 "&showroot=true", | 509 "&showroot=true", |
516 http_request_.relative_url); | 510 http_request_.relative_url); |
517 ASSERT_FALSE(result_data); | 511 ASSERT_FALSE(result_data); |
518 } | 512 } |
519 | 513 |
520 TEST_F(GDataWapiRequestsTest, GetAccountMetadataRequest) { | 514 TEST_F(GDataWapiRequestsTest, GetAccountMetadataRequest) { |
521 GDataErrorCode result_code = GDATA_OTHER_ERROR; | 515 GDataErrorCode result_code = GDATA_OTHER_ERROR; |
522 scoped_ptr<AccountMetadata> result_data; | 516 scoped_ptr<AccountMetadata> result_data; |
523 | 517 |
524 { | 518 { |
525 base::RunLoop run_loop; | 519 base::RunLoop run_loop; |
526 GetAccountMetadataRequest* request = new GetAccountMetadataRequest( | 520 GetAccountMetadataRequest* request = new GetAccountMetadataRequest( |
527 request_sender_.get(), | 521 request_sender_.get(), |
528 request_context_getter_.get(), | |
529 *url_generator_, | 522 *url_generator_, |
530 test_util::CreateQuitCallback( | 523 test_util::CreateQuitCallback( |
531 &run_loop, | 524 &run_loop, |
532 test_util::CreateCopyResultCallback(&result_code, &result_data)), | 525 test_util::CreateCopyResultCallback(&result_code, &result_data)), |
533 true); // Include installed apps. | 526 true); // Include installed apps. |
534 request_sender_->StartRequestWithRetry(request); | 527 request_sender_->StartRequestWithRetry(request); |
535 run_loop.Run(); | 528 run_loop.Run(); |
536 } | 529 } |
537 | 530 |
538 EXPECT_EQ(HTTP_SUCCESS, result_code); | 531 EXPECT_EQ(HTTP_SUCCESS, result_code); |
(...skipping 21 matching lines...) Expand all Loading... |
560 | 553 |
561 TEST_F(GDataWapiRequestsTest, | 554 TEST_F(GDataWapiRequestsTest, |
562 GetAccountMetadataRequestWithoutInstalledApps) { | 555 GetAccountMetadataRequestWithoutInstalledApps) { |
563 GDataErrorCode result_code = GDATA_OTHER_ERROR; | 556 GDataErrorCode result_code = GDATA_OTHER_ERROR; |
564 scoped_ptr<AccountMetadata> result_data; | 557 scoped_ptr<AccountMetadata> result_data; |
565 | 558 |
566 { | 559 { |
567 base::RunLoop run_loop; | 560 base::RunLoop run_loop; |
568 GetAccountMetadataRequest* request = new GetAccountMetadataRequest( | 561 GetAccountMetadataRequest* request = new GetAccountMetadataRequest( |
569 request_sender_.get(), | 562 request_sender_.get(), |
570 request_context_getter_.get(), | |
571 *url_generator_, | 563 *url_generator_, |
572 test_util::CreateQuitCallback( | 564 test_util::CreateQuitCallback( |
573 &run_loop, | 565 &run_loop, |
574 test_util::CreateCopyResultCallback(&result_code, &result_data)), | 566 test_util::CreateCopyResultCallback(&result_code, &result_data)), |
575 false); // Exclude installed apps. | 567 false); // Exclude installed apps. |
576 request_sender_->StartRequestWithRetry(request); | 568 request_sender_->StartRequestWithRetry(request); |
577 run_loop.Run(); | 569 run_loop.Run(); |
578 } | 570 } |
579 | 571 |
580 EXPECT_EQ(HTTP_SUCCESS, result_code); | 572 EXPECT_EQ(HTTP_SUCCESS, result_code); |
(...skipping 17 matching lines...) Expand all Loading... |
598 EXPECT_EQ(0U, result_data->installed_apps().size()); | 590 EXPECT_EQ(0U, result_data->installed_apps().size()); |
599 } | 591 } |
600 | 592 |
601 TEST_F(GDataWapiRequestsTest, DeleteResourceRequest) { | 593 TEST_F(GDataWapiRequestsTest, DeleteResourceRequest) { |
602 GDataErrorCode result_code = GDATA_OTHER_ERROR; | 594 GDataErrorCode result_code = GDATA_OTHER_ERROR; |
603 | 595 |
604 { | 596 { |
605 base::RunLoop run_loop; | 597 base::RunLoop run_loop; |
606 DeleteResourceRequest* request = new DeleteResourceRequest( | 598 DeleteResourceRequest* request = new DeleteResourceRequest( |
607 request_sender_.get(), | 599 request_sender_.get(), |
608 request_context_getter_.get(), | |
609 *url_generator_, | 600 *url_generator_, |
610 test_util::CreateQuitCallback( | 601 test_util::CreateQuitCallback( |
611 &run_loop, | 602 &run_loop, |
612 test_util::CreateCopyResultCallback(&result_code)), | 603 test_util::CreateCopyResultCallback(&result_code)), |
613 "file:2_file_resource_id", | 604 "file:2_file_resource_id", |
614 std::string()); | 605 std::string()); |
615 | 606 |
616 request_sender_->StartRequestWithRetry(request); | 607 request_sender_->StartRequestWithRetry(request); |
617 run_loop.Run(); | 608 run_loop.Run(); |
618 } | 609 } |
619 | 610 |
620 EXPECT_EQ(HTTP_SUCCESS, result_code); | 611 EXPECT_EQ(HTTP_SUCCESS, result_code); |
621 EXPECT_EQ(net::test_server::METHOD_DELETE, http_request_.method); | 612 EXPECT_EQ(net::test_server::METHOD_DELETE, http_request_.method); |
622 EXPECT_EQ( | 613 EXPECT_EQ( |
623 "/feeds/default/private/full/file%3A2_file_resource_id?v=3&alt=json" | 614 "/feeds/default/private/full/file%3A2_file_resource_id?v=3&alt=json" |
624 "&showroot=true", | 615 "&showroot=true", |
625 http_request_.relative_url); | 616 http_request_.relative_url); |
626 EXPECT_EQ("*", http_request_.headers["If-Match"]); | 617 EXPECT_EQ("*", http_request_.headers["If-Match"]); |
627 } | 618 } |
628 | 619 |
629 TEST_F(GDataWapiRequestsTest, DeleteResourceRequestWithETag) { | 620 TEST_F(GDataWapiRequestsTest, DeleteResourceRequestWithETag) { |
630 GDataErrorCode result_code = GDATA_OTHER_ERROR; | 621 GDataErrorCode result_code = GDATA_OTHER_ERROR; |
631 | 622 |
632 { | 623 { |
633 base::RunLoop run_loop; | 624 base::RunLoop run_loop; |
634 DeleteResourceRequest* request = new DeleteResourceRequest( | 625 DeleteResourceRequest* request = new DeleteResourceRequest( |
635 request_sender_.get(), | 626 request_sender_.get(), |
636 request_context_getter_.get(), | |
637 *url_generator_, | 627 *url_generator_, |
638 test_util::CreateQuitCallback( | 628 test_util::CreateQuitCallback( |
639 &run_loop, | 629 &run_loop, |
640 test_util::CreateCopyResultCallback(&result_code)), | 630 test_util::CreateCopyResultCallback(&result_code)), |
641 "file:2_file_resource_id", | 631 "file:2_file_resource_id", |
642 "etag"); | 632 "etag"); |
643 | 633 |
644 request_sender_->StartRequestWithRetry(request); | 634 request_sender_->StartRequestWithRetry(request); |
645 run_loop.Run(); | 635 run_loop.Run(); |
646 } | 636 } |
647 | 637 |
648 EXPECT_EQ(HTTP_SUCCESS, result_code); | 638 EXPECT_EQ(HTTP_SUCCESS, result_code); |
649 EXPECT_EQ(net::test_server::METHOD_DELETE, http_request_.method); | 639 EXPECT_EQ(net::test_server::METHOD_DELETE, http_request_.method); |
650 EXPECT_EQ( | 640 EXPECT_EQ( |
651 "/feeds/default/private/full/file%3A2_file_resource_id?v=3&alt=json" | 641 "/feeds/default/private/full/file%3A2_file_resource_id?v=3&alt=json" |
652 "&showroot=true", | 642 "&showroot=true", |
653 http_request_.relative_url); | 643 http_request_.relative_url); |
654 EXPECT_EQ("etag", http_request_.headers["If-Match"]); | 644 EXPECT_EQ("etag", http_request_.headers["If-Match"]); |
655 } | 645 } |
656 | 646 |
657 TEST_F(GDataWapiRequestsTest, CreateDirectoryRequest) { | 647 TEST_F(GDataWapiRequestsTest, CreateDirectoryRequest) { |
658 GDataErrorCode result_code = GDATA_OTHER_ERROR; | 648 GDataErrorCode result_code = GDATA_OTHER_ERROR; |
659 scoped_ptr<base::Value> result_data; | 649 scoped_ptr<base::Value> result_data; |
660 | 650 |
661 // Create "new directory" in the root directory. | 651 // Create "new directory" in the root directory. |
662 { | 652 { |
663 base::RunLoop run_loop; | 653 base::RunLoop run_loop; |
664 CreateDirectoryRequest* request = new CreateDirectoryRequest( | 654 CreateDirectoryRequest* request = new CreateDirectoryRequest( |
665 request_sender_.get(), | 655 request_sender_.get(), |
666 request_context_getter_.get(), | |
667 *url_generator_, | 656 *url_generator_, |
668 test_util::CreateQuitCallback( | 657 test_util::CreateQuitCallback( |
669 &run_loop, | 658 &run_loop, |
670 test_util::CreateCopyResultCallback(&result_code, &result_data)), | 659 test_util::CreateCopyResultCallback(&result_code, &result_data)), |
671 "folder:root", | 660 "folder:root", |
672 "new directory"); | 661 "new directory"); |
673 | 662 |
674 request_sender_->StartRequestWithRetry(request); | 663 request_sender_->StartRequestWithRetry(request); |
675 run_loop.Run(); | 664 run_loop.Run(); |
676 } | 665 } |
(...skipping 17 matching lines...) Expand all Loading... |
694 | 683 |
695 TEST_F(GDataWapiRequestsTest, CopyHostedDocumentRequest) { | 684 TEST_F(GDataWapiRequestsTest, CopyHostedDocumentRequest) { |
696 GDataErrorCode result_code = GDATA_OTHER_ERROR; | 685 GDataErrorCode result_code = GDATA_OTHER_ERROR; |
697 scoped_ptr<base::Value> result_data; | 686 scoped_ptr<base::Value> result_data; |
698 | 687 |
699 // Copy a document with a new name "New Document". | 688 // Copy a document with a new name "New Document". |
700 { | 689 { |
701 base::RunLoop run_loop; | 690 base::RunLoop run_loop; |
702 CopyHostedDocumentRequest* request = new CopyHostedDocumentRequest( | 691 CopyHostedDocumentRequest* request = new CopyHostedDocumentRequest( |
703 request_sender_.get(), | 692 request_sender_.get(), |
704 request_context_getter_.get(), | |
705 *url_generator_, | 693 *url_generator_, |
706 test_util::CreateQuitCallback( | 694 test_util::CreateQuitCallback( |
707 &run_loop, | 695 &run_loop, |
708 test_util::CreateCopyResultCallback(&result_code, &result_data)), | 696 test_util::CreateCopyResultCallback(&result_code, &result_data)), |
709 "document:5_document_resource_id", // source resource ID | 697 "document:5_document_resource_id", // source resource ID |
710 "New Document"); | 698 "New Document"); |
711 | 699 |
712 request_sender_->StartRequestWithRetry(request); | 700 request_sender_->StartRequestWithRetry(request); |
713 run_loop.Run(); | 701 run_loop.Run(); |
714 } | 702 } |
(...skipping 14 matching lines...) Expand all Loading... |
729 } | 717 } |
730 | 718 |
731 TEST_F(GDataWapiRequestsTest, RenameResourceRequest) { | 719 TEST_F(GDataWapiRequestsTest, RenameResourceRequest) { |
732 GDataErrorCode result_code = GDATA_OTHER_ERROR; | 720 GDataErrorCode result_code = GDATA_OTHER_ERROR; |
733 | 721 |
734 // Rename a file with a new name "New File". | 722 // Rename a file with a new name "New File". |
735 { | 723 { |
736 base::RunLoop run_loop; | 724 base::RunLoop run_loop; |
737 RenameResourceRequest* request = new RenameResourceRequest( | 725 RenameResourceRequest* request = new RenameResourceRequest( |
738 request_sender_.get(), | 726 request_sender_.get(), |
739 request_context_getter_.get(), | |
740 *url_generator_, | 727 *url_generator_, |
741 test_util::CreateQuitCallback( | 728 test_util::CreateQuitCallback( |
742 &run_loop, | 729 &run_loop, |
743 test_util::CreateCopyResultCallback(&result_code)), | 730 test_util::CreateCopyResultCallback(&result_code)), |
744 "file:2_file_resource_id", | 731 "file:2_file_resource_id", |
745 "New File"); | 732 "New File"); |
746 | 733 |
747 request_sender_->StartRequestWithRetry(request); | 734 request_sender_->StartRequestWithRetry(request); |
748 run_loop.Run(); | 735 run_loop.Run(); |
749 } | 736 } |
(...skipping 17 matching lines...) Expand all Loading... |
767 | 754 |
768 TEST_F(GDataWapiRequestsTest, AuthorizeAppRequest_ValidFeed) { | 755 TEST_F(GDataWapiRequestsTest, AuthorizeAppRequest_ValidFeed) { |
769 GDataErrorCode result_code = GDATA_OTHER_ERROR; | 756 GDataErrorCode result_code = GDATA_OTHER_ERROR; |
770 GURL result_data; | 757 GURL result_data; |
771 | 758 |
772 // Authorize an app with APP_ID to access to a document. | 759 // Authorize an app with APP_ID to access to a document. |
773 { | 760 { |
774 base::RunLoop run_loop; | 761 base::RunLoop run_loop; |
775 AuthorizeAppRequest* request = new AuthorizeAppRequest( | 762 AuthorizeAppRequest* request = new AuthorizeAppRequest( |
776 request_sender_.get(), | 763 request_sender_.get(), |
777 request_context_getter_.get(), | |
778 *url_generator_, | 764 *url_generator_, |
779 test_util::CreateQuitCallback( | 765 test_util::CreateQuitCallback( |
780 &run_loop, | 766 &run_loop, |
781 test_util::CreateCopyResultCallback(&result_code, &result_data)), | 767 test_util::CreateCopyResultCallback(&result_code, &result_data)), |
782 "file:2_file_resource_id", | 768 "file:2_file_resource_id", |
783 "the_app_id"); | 769 "the_app_id"); |
784 | 770 |
785 request_sender_->StartRequestWithRetry(request); | 771 request_sender_->StartRequestWithRetry(request); |
786 run_loop.Run(); | 772 run_loop.Run(); |
787 } | 773 } |
(...skipping 19 matching lines...) Expand all Loading... |
807 | 793 |
808 TEST_F(GDataWapiRequestsTest, AuthorizeAppRequest_NotFound) { | 794 TEST_F(GDataWapiRequestsTest, AuthorizeAppRequest_NotFound) { |
809 GDataErrorCode result_code = GDATA_OTHER_ERROR; | 795 GDataErrorCode result_code = GDATA_OTHER_ERROR; |
810 GURL result_data; | 796 GURL result_data; |
811 | 797 |
812 // Authorize an app with APP_ID to access to a document. | 798 // Authorize an app with APP_ID to access to a document. |
813 { | 799 { |
814 base::RunLoop run_loop; | 800 base::RunLoop run_loop; |
815 AuthorizeAppRequest* request = new AuthorizeAppRequest( | 801 AuthorizeAppRequest* request = new AuthorizeAppRequest( |
816 request_sender_.get(), | 802 request_sender_.get(), |
817 request_context_getter_.get(), | |
818 *url_generator_, | 803 *url_generator_, |
819 test_util::CreateQuitCallback( | 804 test_util::CreateQuitCallback( |
820 &run_loop, | 805 &run_loop, |
821 test_util::CreateCopyResultCallback(&result_code, &result_data)), | 806 test_util::CreateCopyResultCallback(&result_code, &result_data)), |
822 "file:2_file_resource_id", | 807 "file:2_file_resource_id", |
823 "unauthorized_app_id"); | 808 "unauthorized_app_id"); |
824 | 809 |
825 request_sender_->StartRequestWithRetry(request); | 810 request_sender_->StartRequestWithRetry(request); |
826 run_loop.Run(); | 811 run_loop.Run(); |
827 } | 812 } |
(...skipping 17 matching lines...) Expand all Loading... |
845 | 830 |
846 TEST_F(GDataWapiRequestsTest, AuthorizeAppRequest_InvalidFeed) { | 831 TEST_F(GDataWapiRequestsTest, AuthorizeAppRequest_InvalidFeed) { |
847 GDataErrorCode result_code = GDATA_OTHER_ERROR; | 832 GDataErrorCode result_code = GDATA_OTHER_ERROR; |
848 GURL result_data; | 833 GURL result_data; |
849 | 834 |
850 // Authorize an app with APP_ID to access to a document but an invalid feed. | 835 // Authorize an app with APP_ID to access to a document but an invalid feed. |
851 { | 836 { |
852 base::RunLoop run_loop; | 837 base::RunLoop run_loop; |
853 AuthorizeAppRequest* request = new AuthorizeAppRequest( | 838 AuthorizeAppRequest* request = new AuthorizeAppRequest( |
854 request_sender_.get(), | 839 request_sender_.get(), |
855 request_context_getter_.get(), | |
856 *url_generator_, | 840 *url_generator_, |
857 test_util::CreateQuitCallback( | 841 test_util::CreateQuitCallback( |
858 &run_loop, | 842 &run_loop, |
859 test_util::CreateCopyResultCallback(&result_code, &result_data)), | 843 test_util::CreateCopyResultCallback(&result_code, &result_data)), |
860 "invalid_resource_id", | 844 "invalid_resource_id", |
861 "APP_ID"); | 845 "APP_ID"); |
862 | 846 |
863 request_sender_->StartRequestWithRetry(request); | 847 request_sender_->StartRequestWithRetry(request); |
864 run_loop.Run(); | 848 run_loop.Run(); |
865 } | 849 } |
(...skipping 17 matching lines...) Expand all Loading... |
883 | 867 |
884 TEST_F(GDataWapiRequestsTest, AddResourceToDirectoryRequest) { | 868 TEST_F(GDataWapiRequestsTest, AddResourceToDirectoryRequest) { |
885 GDataErrorCode result_code = GDATA_OTHER_ERROR; | 869 GDataErrorCode result_code = GDATA_OTHER_ERROR; |
886 | 870 |
887 // Add a file to the root directory. | 871 // Add a file to the root directory. |
888 { | 872 { |
889 base::RunLoop run_loop; | 873 base::RunLoop run_loop; |
890 AddResourceToDirectoryRequest* request = | 874 AddResourceToDirectoryRequest* request = |
891 new AddResourceToDirectoryRequest( | 875 new AddResourceToDirectoryRequest( |
892 request_sender_.get(), | 876 request_sender_.get(), |
893 request_context_getter_.get(), | |
894 *url_generator_, | 877 *url_generator_, |
895 test_util::CreateQuitCallback( | 878 test_util::CreateQuitCallback( |
896 &run_loop, | 879 &run_loop, |
897 test_util::CreateCopyResultCallback(&result_code)), | 880 test_util::CreateCopyResultCallback(&result_code)), |
898 "folder:root", | 881 "folder:root", |
899 "file:2_file_resource_id"); | 882 "file:2_file_resource_id"); |
900 | 883 |
901 request_sender_->StartRequestWithRetry(request); | 884 request_sender_->StartRequestWithRetry(request); |
902 run_loop.Run(); | 885 run_loop.Run(); |
903 } | 886 } |
(...skipping 17 matching lines...) Expand all Loading... |
921 | 904 |
922 TEST_F(GDataWapiRequestsTest, RemoveResourceFromDirectoryRequest) { | 905 TEST_F(GDataWapiRequestsTest, RemoveResourceFromDirectoryRequest) { |
923 GDataErrorCode result_code = GDATA_OTHER_ERROR; | 906 GDataErrorCode result_code = GDATA_OTHER_ERROR; |
924 | 907 |
925 // Remove a file from the root directory. | 908 // Remove a file from the root directory. |
926 { | 909 { |
927 base::RunLoop run_loop; | 910 base::RunLoop run_loop; |
928 RemoveResourceFromDirectoryRequest* request = | 911 RemoveResourceFromDirectoryRequest* request = |
929 new RemoveResourceFromDirectoryRequest( | 912 new RemoveResourceFromDirectoryRequest( |
930 request_sender_.get(), | 913 request_sender_.get(), |
931 request_context_getter_.get(), | |
932 *url_generator_, | 914 *url_generator_, |
933 test_util::CreateQuitCallback( | 915 test_util::CreateQuitCallback( |
934 &run_loop, | 916 &run_loop, |
935 test_util::CreateCopyResultCallback(&result_code)), | 917 test_util::CreateCopyResultCallback(&result_code)), |
936 "folder:root", | 918 "folder:root", |
937 "file:2_file_resource_id"); | 919 "file:2_file_resource_id"); |
938 | 920 |
939 request_sender_->StartRequestWithRetry(request); | 921 request_sender_->StartRequestWithRetry(request); |
940 run_loop.Run(); | 922 run_loop.Run(); |
941 } | 923 } |
(...skipping 18 matching lines...) Expand all Loading... |
960 | 942 |
961 GDataErrorCode result_code = GDATA_OTHER_ERROR; | 943 GDataErrorCode result_code = GDATA_OTHER_ERROR; |
962 GURL upload_url; | 944 GURL upload_url; |
963 | 945 |
964 // 1) Get the upload URL for uploading a new file. | 946 // 1) Get the upload URL for uploading a new file. |
965 { | 947 { |
966 base::RunLoop run_loop; | 948 base::RunLoop run_loop; |
967 InitiateUploadNewFileRequest* initiate_request = | 949 InitiateUploadNewFileRequest* initiate_request = |
968 new InitiateUploadNewFileRequest( | 950 new InitiateUploadNewFileRequest( |
969 request_sender_.get(), | 951 request_sender_.get(), |
970 request_context_getter_.get(), | |
971 *url_generator_, | 952 *url_generator_, |
972 test_util::CreateQuitCallback( | 953 test_util::CreateQuitCallback( |
973 &run_loop, | 954 &run_loop, |
974 test_util::CreateCopyResultCallback(&result_code, &upload_url)), | 955 test_util::CreateCopyResultCallback(&result_code, &upload_url)), |
975 "text/plain", | 956 "text/plain", |
976 kUploadContent.size(), | 957 kUploadContent.size(), |
977 "folder:id", | 958 "folder:id", |
978 "New file"); | 959 "New file"); |
979 request_sender_->StartRequestWithRetry(initiate_request); | 960 request_sender_->StartRequestWithRetry(initiate_request); |
980 run_loop.Run(); | 961 run_loop.Run(); |
(...skipping 21 matching lines...) Expand all Loading... |
1002 http_request_.content); | 983 http_request_.content); |
1003 | 984 |
1004 // 2) Upload the content to the upload URL. | 985 // 2) Upload the content to the upload URL. |
1005 UploadRangeResponse response; | 986 UploadRangeResponse response; |
1006 scoped_ptr<ResourceEntry> new_entry; | 987 scoped_ptr<ResourceEntry> new_entry; |
1007 | 988 |
1008 { | 989 { |
1009 base::RunLoop run_loop; | 990 base::RunLoop run_loop; |
1010 ResumeUploadRequest* resume_request = new ResumeUploadRequest( | 991 ResumeUploadRequest* resume_request = new ResumeUploadRequest( |
1011 request_sender_.get(), | 992 request_sender_.get(), |
1012 request_context_getter_.get(), | |
1013 test_util::CreateQuitCallback( | 993 test_util::CreateQuitCallback( |
1014 &run_loop, | 994 &run_loop, |
1015 test_util::CreateCopyResultCallback(&response, &new_entry)), | 995 test_util::CreateCopyResultCallback(&response, &new_entry)), |
1016 ProgressCallback(), | 996 ProgressCallback(), |
1017 upload_url, | 997 upload_url, |
1018 0, // start_position | 998 0, // start_position |
1019 kUploadContent.size(), // end_position (exclusive) | 999 kUploadContent.size(), // end_position (exclusive) |
1020 kUploadContent.size(), // content_length, | 1000 kUploadContent.size(), // content_length, |
1021 "text/plain", // content_type | 1001 "text/plain", // content_type |
1022 kTestFilePath); | 1002 kTestFilePath); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1062 | 1042 |
1063 GDataErrorCode result_code = GDATA_OTHER_ERROR; | 1043 GDataErrorCode result_code = GDATA_OTHER_ERROR; |
1064 GURL upload_url; | 1044 GURL upload_url; |
1065 | 1045 |
1066 // 1) Get the upload URL for uploading a new file. | 1046 // 1) Get the upload URL for uploading a new file. |
1067 { | 1047 { |
1068 base::RunLoop run_loop; | 1048 base::RunLoop run_loop; |
1069 InitiateUploadNewFileRequest* initiate_request = | 1049 InitiateUploadNewFileRequest* initiate_request = |
1070 new InitiateUploadNewFileRequest( | 1050 new InitiateUploadNewFileRequest( |
1071 request_sender_.get(), | 1051 request_sender_.get(), |
1072 request_context_getter_.get(), | |
1073 *url_generator_, | 1052 *url_generator_, |
1074 test_util::CreateQuitCallback( | 1053 test_util::CreateQuitCallback( |
1075 &run_loop, | 1054 &run_loop, |
1076 test_util::CreateCopyResultCallback(&result_code, &upload_url)), | 1055 test_util::CreateCopyResultCallback(&result_code, &upload_url)), |
1077 "text/plain", | 1056 "text/plain", |
1078 kUploadContent.size(), | 1057 kUploadContent.size(), |
1079 "folder:id", | 1058 "folder:id", |
1080 "New file"); | 1059 "New file"); |
1081 request_sender_->StartRequestWithRetry(initiate_request); | 1060 request_sender_->StartRequestWithRetry(initiate_request); |
1082 run_loop.Run(); | 1061 run_loop.Run(); |
(...skipping 26 matching lines...) Expand all Loading... |
1109 { | 1088 { |
1110 UploadRangeResponse response; | 1089 UploadRangeResponse response; |
1111 scoped_ptr<ResourceEntry> new_entry; | 1090 scoped_ptr<ResourceEntry> new_entry; |
1112 | 1091 |
1113 // Check the response by GetUploadStatusRequest. | 1092 // Check the response by GetUploadStatusRequest. |
1114 { | 1093 { |
1115 base::RunLoop run_loop; | 1094 base::RunLoop run_loop; |
1116 GetUploadStatusRequest* get_upload_status_request = | 1095 GetUploadStatusRequest* get_upload_status_request = |
1117 new GetUploadStatusRequest( | 1096 new GetUploadStatusRequest( |
1118 request_sender_.get(), | 1097 request_sender_.get(), |
1119 request_context_getter_.get(), | |
1120 test_util::CreateQuitCallback( | 1098 test_util::CreateQuitCallback( |
1121 &run_loop, | 1099 &run_loop, |
1122 test_util::CreateCopyResultCallback(&response, &new_entry)), | 1100 test_util::CreateCopyResultCallback(&response, &new_entry)), |
1123 upload_url, | 1101 upload_url, |
1124 kUploadContent.size()); | 1102 kUploadContent.size()); |
1125 request_sender_->StartRequestWithRetry(get_upload_status_request); | 1103 request_sender_->StartRequestWithRetry(get_upload_status_request); |
1126 run_loop.Run(); | 1104 run_loop.Run(); |
1127 } | 1105 } |
1128 | 1106 |
1129 // METHOD_PUT should be used to upload data. | 1107 // METHOD_PUT should be used to upload data. |
(...skipping 26 matching lines...) Expand all Loading... |
1156 // The end position is exclusive. | 1134 // The end position is exclusive. |
1157 const size_t end_position = start_position + payload.size(); | 1135 const size_t end_position = start_position + payload.size(); |
1158 | 1136 |
1159 UploadRangeResponse response; | 1137 UploadRangeResponse response; |
1160 scoped_ptr<ResourceEntry> new_entry; | 1138 scoped_ptr<ResourceEntry> new_entry; |
1161 | 1139 |
1162 { | 1140 { |
1163 base::RunLoop run_loop; | 1141 base::RunLoop run_loop; |
1164 ResumeUploadRequest* resume_request = new ResumeUploadRequest( | 1142 ResumeUploadRequest* resume_request = new ResumeUploadRequest( |
1165 request_sender_.get(), | 1143 request_sender_.get(), |
1166 request_context_getter_.get(), | |
1167 test_util::CreateQuitCallback( | 1144 test_util::CreateQuitCallback( |
1168 &run_loop, | 1145 &run_loop, |
1169 test_util::CreateCopyResultCallback(&response, &new_entry)), | 1146 test_util::CreateCopyResultCallback(&response, &new_entry)), |
1170 ProgressCallback(), | 1147 ProgressCallback(), |
1171 upload_url, | 1148 upload_url, |
1172 start_position, | 1149 start_position, |
1173 end_position, | 1150 end_position, |
1174 kUploadContent.size(), // content_length, | 1151 kUploadContent.size(), // content_length, |
1175 "text/plain", // content_type | 1152 "text/plain", // content_type |
1176 kTestFilePath); | 1153 kTestFilePath); |
(...skipping 30 matching lines...) Expand all Loading... |
1207 EXPECT_EQ(0, response.start_position_received); | 1184 EXPECT_EQ(0, response.start_position_received); |
1208 EXPECT_EQ(static_cast<int64>(end_position), | 1185 EXPECT_EQ(static_cast<int64>(end_position), |
1209 response.end_position_received); | 1186 response.end_position_received); |
1210 | 1187 |
1211 // Check the response by GetUploadStatusRequest. | 1188 // Check the response by GetUploadStatusRequest. |
1212 { | 1189 { |
1213 base::RunLoop run_loop; | 1190 base::RunLoop run_loop; |
1214 GetUploadStatusRequest* get_upload_status_request = | 1191 GetUploadStatusRequest* get_upload_status_request = |
1215 new GetUploadStatusRequest( | 1192 new GetUploadStatusRequest( |
1216 request_sender_.get(), | 1193 request_sender_.get(), |
1217 request_context_getter_.get(), | |
1218 test_util::CreateQuitCallback( | 1194 test_util::CreateQuitCallback( |
1219 &run_loop, | 1195 &run_loop, |
1220 test_util::CreateCopyResultCallback(&response, &new_entry)), | 1196 test_util::CreateCopyResultCallback(&response, &new_entry)), |
1221 upload_url, | 1197 upload_url, |
1222 kUploadContent.size()); | 1198 kUploadContent.size()); |
1223 request_sender_->StartRequestWithRetry(get_upload_status_request); | 1199 request_sender_->StartRequestWithRetry(get_upload_status_request); |
1224 run_loop.Run(); | 1200 run_loop.Run(); |
1225 } | 1201 } |
1226 | 1202 |
1227 // METHOD_PUT should be used to upload data. | 1203 // METHOD_PUT should be used to upload data. |
(...skipping 29 matching lines...) Expand all Loading... |
1257 | 1233 |
1258 GDataErrorCode result_code = GDATA_OTHER_ERROR; | 1234 GDataErrorCode result_code = GDATA_OTHER_ERROR; |
1259 GURL upload_url; | 1235 GURL upload_url; |
1260 | 1236 |
1261 // 1) Get the upload URL for uploading a new file. | 1237 // 1) Get the upload URL for uploading a new file. |
1262 { | 1238 { |
1263 base::RunLoop run_loop; | 1239 base::RunLoop run_loop; |
1264 InitiateUploadNewFileRequest* initiate_request = | 1240 InitiateUploadNewFileRequest* initiate_request = |
1265 new InitiateUploadNewFileRequest( | 1241 new InitiateUploadNewFileRequest( |
1266 request_sender_.get(), | 1242 request_sender_.get(), |
1267 request_context_getter_.get(), | |
1268 *url_generator_, | 1243 *url_generator_, |
1269 test_util::CreateQuitCallback( | 1244 test_util::CreateQuitCallback( |
1270 &run_loop, | 1245 &run_loop, |
1271 test_util::CreateCopyResultCallback(&result_code, &upload_url)), | 1246 test_util::CreateCopyResultCallback(&result_code, &upload_url)), |
1272 "text/plain", | 1247 "text/plain", |
1273 kUploadContent.size(), | 1248 kUploadContent.size(), |
1274 "folder:id", | 1249 "folder:id", |
1275 "New file"); | 1250 "New file"); |
1276 request_sender_->StartRequestWithRetry(initiate_request); | 1251 request_sender_->StartRequestWithRetry(initiate_request); |
1277 run_loop.Run(); | 1252 run_loop.Run(); |
(...skipping 21 matching lines...) Expand all Loading... |
1299 http_request_.content); | 1274 http_request_.content); |
1300 | 1275 |
1301 // 2) Upload the content to the upload URL. | 1276 // 2) Upload the content to the upload URL. |
1302 UploadRangeResponse response; | 1277 UploadRangeResponse response; |
1303 scoped_ptr<ResourceEntry> new_entry; | 1278 scoped_ptr<ResourceEntry> new_entry; |
1304 | 1279 |
1305 { | 1280 { |
1306 base::RunLoop run_loop; | 1281 base::RunLoop run_loop; |
1307 ResumeUploadRequest* resume_request = new ResumeUploadRequest( | 1282 ResumeUploadRequest* resume_request = new ResumeUploadRequest( |
1308 request_sender_.get(), | 1283 request_sender_.get(), |
1309 request_context_getter_.get(), | |
1310 test_util::CreateQuitCallback( | 1284 test_util::CreateQuitCallback( |
1311 &run_loop, | 1285 &run_loop, |
1312 test_util::CreateCopyResultCallback(&response, &new_entry)), | 1286 test_util::CreateCopyResultCallback(&response, &new_entry)), |
1313 ProgressCallback(), | 1287 ProgressCallback(), |
1314 upload_url, | 1288 upload_url, |
1315 0, // start_position | 1289 0, // start_position |
1316 kUploadContent.size(), // end_position (exclusive) | 1290 kUploadContent.size(), // end_position (exclusive) |
1317 kUploadContent.size(), // content_length, | 1291 kUploadContent.size(), // content_length, |
1318 "text/plain", // content_type | 1292 "text/plain", // content_type |
1319 kTestFilePath); | 1293 kTestFilePath); |
(...skipping 29 matching lines...) Expand all Loading... |
1349 | 1323 |
1350 GDataErrorCode result_code = GDATA_OTHER_ERROR; | 1324 GDataErrorCode result_code = GDATA_OTHER_ERROR; |
1351 GURL upload_url; | 1325 GURL upload_url; |
1352 | 1326 |
1353 // 1) Get the upload URL for uploading an existing file. | 1327 // 1) Get the upload URL for uploading an existing file. |
1354 { | 1328 { |
1355 base::RunLoop run_loop; | 1329 base::RunLoop run_loop; |
1356 InitiateUploadExistingFileRequest* initiate_request = | 1330 InitiateUploadExistingFileRequest* initiate_request = |
1357 new InitiateUploadExistingFileRequest( | 1331 new InitiateUploadExistingFileRequest( |
1358 request_sender_.get(), | 1332 request_sender_.get(), |
1359 request_context_getter_.get(), | |
1360 *url_generator_, | 1333 *url_generator_, |
1361 test_util::CreateQuitCallback( | 1334 test_util::CreateQuitCallback( |
1362 &run_loop, | 1335 &run_loop, |
1363 test_util::CreateCopyResultCallback(&result_code, &upload_url)), | 1336 test_util::CreateCopyResultCallback(&result_code, &upload_url)), |
1364 "text/plain", | 1337 "text/plain", |
1365 kUploadContent.size(), | 1338 kUploadContent.size(), |
1366 "file:foo", | 1339 "file:foo", |
1367 std::string() /* etag */); | 1340 std::string() /* etag */); |
1368 request_sender_->StartRequestWithRetry(initiate_request); | 1341 request_sender_->StartRequestWithRetry(initiate_request); |
1369 run_loop.Run(); | 1342 run_loop.Run(); |
(...skipping 20 matching lines...) Expand all Loading... |
1390 EXPECT_EQ("*", http_request_.headers["If-Match"]); | 1363 EXPECT_EQ("*", http_request_.headers["If-Match"]); |
1391 | 1364 |
1392 // 2) Upload the content to the upload URL. | 1365 // 2) Upload the content to the upload URL. |
1393 UploadRangeResponse response; | 1366 UploadRangeResponse response; |
1394 scoped_ptr<ResourceEntry> new_entry; | 1367 scoped_ptr<ResourceEntry> new_entry; |
1395 | 1368 |
1396 { | 1369 { |
1397 base::RunLoop run_loop; | 1370 base::RunLoop run_loop; |
1398 ResumeUploadRequest* resume_request = new ResumeUploadRequest( | 1371 ResumeUploadRequest* resume_request = new ResumeUploadRequest( |
1399 request_sender_.get(), | 1372 request_sender_.get(), |
1400 request_context_getter_.get(), | |
1401 test_util::CreateQuitCallback( | 1373 test_util::CreateQuitCallback( |
1402 &run_loop, | 1374 &run_loop, |
1403 test_util::CreateCopyResultCallback(&response, &new_entry)), | 1375 test_util::CreateCopyResultCallback(&response, &new_entry)), |
1404 ProgressCallback(), | 1376 ProgressCallback(), |
1405 upload_url, | 1377 upload_url, |
1406 0, // start_position | 1378 0, // start_position |
1407 kUploadContent.size(), // end_position (exclusive) | 1379 kUploadContent.size(), // end_position (exclusive) |
1408 kUploadContent.size(), // content_length, | 1380 kUploadContent.size(), // content_length, |
1409 "text/plain", // content_type | 1381 "text/plain", // content_type |
1410 kTestFilePath); | 1382 kTestFilePath); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1443 | 1415 |
1444 GDataErrorCode result_code = GDATA_OTHER_ERROR; | 1416 GDataErrorCode result_code = GDATA_OTHER_ERROR; |
1445 GURL upload_url; | 1417 GURL upload_url; |
1446 | 1418 |
1447 // 1) Get the upload URL for uploading an existing file. | 1419 // 1) Get the upload URL for uploading an existing file. |
1448 { | 1420 { |
1449 base::RunLoop run_loop; | 1421 base::RunLoop run_loop; |
1450 InitiateUploadExistingFileRequest* initiate_request = | 1422 InitiateUploadExistingFileRequest* initiate_request = |
1451 new InitiateUploadExistingFileRequest( | 1423 new InitiateUploadExistingFileRequest( |
1452 request_sender_.get(), | 1424 request_sender_.get(), |
1453 request_context_getter_.get(), | |
1454 *url_generator_, | 1425 *url_generator_, |
1455 test_util::CreateQuitCallback( | 1426 test_util::CreateQuitCallback( |
1456 &run_loop, | 1427 &run_loop, |
1457 test_util::CreateCopyResultCallback(&result_code, &upload_url)), | 1428 test_util::CreateCopyResultCallback(&result_code, &upload_url)), |
1458 "text/plain", | 1429 "text/plain", |
1459 kUploadContent.size(), | 1430 kUploadContent.size(), |
1460 "file:foo", | 1431 "file:foo", |
1461 kTestETag); | 1432 kTestETag); |
1462 request_sender_->StartRequestWithRetry(initiate_request); | 1433 request_sender_->StartRequestWithRetry(initiate_request); |
1463 run_loop.Run(); | 1434 run_loop.Run(); |
(...skipping 20 matching lines...) Expand all Loading... |
1484 EXPECT_EQ(kTestETag, http_request_.headers["If-Match"]); | 1455 EXPECT_EQ(kTestETag, http_request_.headers["If-Match"]); |
1485 | 1456 |
1486 // 2) Upload the content to the upload URL. | 1457 // 2) Upload the content to the upload URL. |
1487 UploadRangeResponse response; | 1458 UploadRangeResponse response; |
1488 scoped_ptr<ResourceEntry> new_entry; | 1459 scoped_ptr<ResourceEntry> new_entry; |
1489 | 1460 |
1490 { | 1461 { |
1491 base::RunLoop run_loop; | 1462 base::RunLoop run_loop; |
1492 ResumeUploadRequest* resume_request = new ResumeUploadRequest( | 1463 ResumeUploadRequest* resume_request = new ResumeUploadRequest( |
1493 request_sender_.get(), | 1464 request_sender_.get(), |
1494 request_context_getter_.get(), | |
1495 test_util::CreateQuitCallback( | 1465 test_util::CreateQuitCallback( |
1496 &run_loop, | 1466 &run_loop, |
1497 test_util::CreateCopyResultCallback(&response, &new_entry)), | 1467 test_util::CreateCopyResultCallback(&response, &new_entry)), |
1498 ProgressCallback(), | 1468 ProgressCallback(), |
1499 upload_url, | 1469 upload_url, |
1500 0, // start_position | 1470 0, // start_position |
1501 kUploadContent.size(), // end_position (exclusive) | 1471 kUploadContent.size(), // end_position (exclusive) |
1502 kUploadContent.size(), // content_length, | 1472 kUploadContent.size(), // content_length, |
1503 "text/plain", // content_type | 1473 "text/plain", // content_type |
1504 kTestFilePath); | 1474 kTestFilePath); |
(...skipping 27 matching lines...) Expand all Loading... |
1532 const std::string kUploadContent = "hello"; | 1502 const std::string kUploadContent = "hello"; |
1533 const std::string kWrongETag = "wrong_etag"; | 1503 const std::string kWrongETag = "wrong_etag"; |
1534 GDataErrorCode result_code = GDATA_OTHER_ERROR; | 1504 GDataErrorCode result_code = GDATA_OTHER_ERROR; |
1535 GURL upload_url; | 1505 GURL upload_url; |
1536 | 1506 |
1537 { | 1507 { |
1538 base::RunLoop run_loop; | 1508 base::RunLoop run_loop; |
1539 InitiateUploadExistingFileRequest* initiate_request = | 1509 InitiateUploadExistingFileRequest* initiate_request = |
1540 new InitiateUploadExistingFileRequest( | 1510 new InitiateUploadExistingFileRequest( |
1541 request_sender_.get(), | 1511 request_sender_.get(), |
1542 request_context_getter_.get(), | |
1543 *url_generator_, | 1512 *url_generator_, |
1544 test_util::CreateQuitCallback( | 1513 test_util::CreateQuitCallback( |
1545 &run_loop, | 1514 &run_loop, |
1546 test_util::CreateCopyResultCallback(&result_code, &upload_url)), | 1515 test_util::CreateCopyResultCallback(&result_code, &upload_url)), |
1547 "text/plain", | 1516 "text/plain", |
1548 kUploadContent.size(), | 1517 kUploadContent.size(), |
1549 "file:foo", | 1518 "file:foo", |
1550 kWrongETag); | 1519 kWrongETag); |
1551 request_sender_->StartRequestWithRetry(initiate_request); | 1520 request_sender_->StartRequestWithRetry(initiate_request); |
1552 run_loop.Run(); | 1521 run_loop.Run(); |
(...skipping 13 matching lines...) Expand all Loading... |
1566 EXPECT_EQ(base::Int64ToString(kUploadContent.size()), | 1535 EXPECT_EQ(base::Int64ToString(kUploadContent.size()), |
1567 http_request_.headers["X-Upload-Content-Length"]); | 1536 http_request_.headers["X-Upload-Content-Length"]); |
1568 // For updating an existing file, an empty body should be attached (PUT | 1537 // For updating an existing file, an empty body should be attached (PUT |
1569 // requires a body) | 1538 // requires a body) |
1570 EXPECT_TRUE(http_request_.has_content); | 1539 EXPECT_TRUE(http_request_.has_content); |
1571 EXPECT_EQ("", http_request_.content); | 1540 EXPECT_EQ("", http_request_.content); |
1572 EXPECT_EQ(kWrongETag, http_request_.headers["If-Match"]); | 1541 EXPECT_EQ(kWrongETag, http_request_.headers["If-Match"]); |
1573 } | 1542 } |
1574 | 1543 |
1575 } // namespace google_apis | 1544 } // namespace google_apis |
OLD | NEW |