OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/files/file_path.h" | 6 #include "base/files/file_path.h" |
7 #include "base/files/scoped_temp_dir.h" | 7 #include "base/files/scoped_temp_dir.h" |
8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 expected_data_file_path_ = test_util::GetTestFilePath( | 314 expected_data_file_path_ = test_util::GetTestFilePath( |
315 "chromeos/drive/about.json"); | 315 "chromeos/drive/about.json"); |
316 | 316 |
317 GDataErrorCode error = GDATA_OTHER_ERROR; | 317 GDataErrorCode error = GDATA_OTHER_ERROR; |
318 scoped_ptr<AboutResource> about_resource; | 318 scoped_ptr<AboutResource> about_resource; |
319 | 319 |
320 { | 320 { |
321 base::RunLoop run_loop; | 321 base::RunLoop run_loop; |
322 GetAboutRequest* request = new GetAboutRequest( | 322 GetAboutRequest* request = new GetAboutRequest( |
323 request_sender_.get(), | 323 request_sender_.get(), |
324 request_context_getter_.get(), | |
325 *url_generator_, | 324 *url_generator_, |
326 test_util::CreateQuitCallback( | 325 test_util::CreateQuitCallback( |
327 &run_loop, | 326 &run_loop, |
328 test_util::CreateCopyResultCallback(&error, &about_resource))); | 327 test_util::CreateCopyResultCallback(&error, &about_resource))); |
329 request_sender_->StartRequestWithRetry(request); | 328 request_sender_->StartRequestWithRetry(request); |
330 run_loop.Run(); | 329 run_loop.Run(); |
331 } | 330 } |
332 | 331 |
333 EXPECT_EQ(HTTP_SUCCESS, error); | 332 EXPECT_EQ(HTTP_SUCCESS, error); |
334 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); | 333 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); |
(...skipping 14 matching lines...) Expand all Loading... |
349 expected_data_file_path_ = test_util::GetTestFilePath( | 348 expected_data_file_path_ = test_util::GetTestFilePath( |
350 "chromeos/gdata/testfile.txt"); | 349 "chromeos/gdata/testfile.txt"); |
351 | 350 |
352 GDataErrorCode error = GDATA_OTHER_ERROR; | 351 GDataErrorCode error = GDATA_OTHER_ERROR; |
353 scoped_ptr<AboutResource> about_resource; | 352 scoped_ptr<AboutResource> about_resource; |
354 | 353 |
355 { | 354 { |
356 base::RunLoop run_loop; | 355 base::RunLoop run_loop; |
357 GetAboutRequest* request = new GetAboutRequest( | 356 GetAboutRequest* request = new GetAboutRequest( |
358 request_sender_.get(), | 357 request_sender_.get(), |
359 request_context_getter_.get(), | |
360 *url_generator_, | 358 *url_generator_, |
361 test_util::CreateQuitCallback( | 359 test_util::CreateQuitCallback( |
362 &run_loop, | 360 &run_loop, |
363 test_util::CreateCopyResultCallback(&error, &about_resource))); | 361 test_util::CreateCopyResultCallback(&error, &about_resource))); |
364 request_sender_->StartRequestWithRetry(request); | 362 request_sender_->StartRequestWithRetry(request); |
365 run_loop.Run(); | 363 run_loop.Run(); |
366 } | 364 } |
367 | 365 |
368 // "parse error" should be returned, and the about resource should be NULL. | 366 // "parse error" should be returned, and the about resource should be NULL. |
369 EXPECT_EQ(GDATA_PARSE_ERROR, error); | 367 EXPECT_EQ(GDATA_PARSE_ERROR, error); |
370 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); | 368 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); |
371 EXPECT_EQ("/drive/v2/about", http_request_.relative_url); | 369 EXPECT_EQ("/drive/v2/about", http_request_.relative_url); |
372 EXPECT_FALSE(about_resource.get()); | 370 EXPECT_FALSE(about_resource.get()); |
373 } | 371 } |
374 | 372 |
375 TEST_F(DriveApiRequestsTest, GetApplistRequest) { | 373 TEST_F(DriveApiRequestsTest, GetApplistRequest) { |
376 // Set an expected data file containing valid result. | 374 // Set an expected data file containing valid result. |
377 expected_data_file_path_ = test_util::GetTestFilePath( | 375 expected_data_file_path_ = test_util::GetTestFilePath( |
378 "chromeos/drive/applist.json"); | 376 "chromeos/drive/applist.json"); |
379 | 377 |
380 GDataErrorCode error = GDATA_OTHER_ERROR; | 378 GDataErrorCode error = GDATA_OTHER_ERROR; |
381 scoped_ptr<base::Value> result; | 379 scoped_ptr<base::Value> result; |
382 | 380 |
383 { | 381 { |
384 base::RunLoop run_loop; | 382 base::RunLoop run_loop; |
385 GetApplistRequest* request = new GetApplistRequest( | 383 GetApplistRequest* request = new GetApplistRequest( |
386 request_sender_.get(), | 384 request_sender_.get(), |
387 request_context_getter_.get(), | |
388 *url_generator_, | 385 *url_generator_, |
389 test_util::CreateQuitCallback( | 386 test_util::CreateQuitCallback( |
390 &run_loop, | 387 &run_loop, |
391 test_util::CreateCopyResultCallback(&error, &result))); | 388 test_util::CreateCopyResultCallback(&error, &result))); |
392 request_sender_->StartRequestWithRetry(request); | 389 request_sender_->StartRequestWithRetry(request); |
393 run_loop.Run(); | 390 run_loop.Run(); |
394 } | 391 } |
395 | 392 |
396 EXPECT_EQ(HTTP_SUCCESS, error); | 393 EXPECT_EQ(HTTP_SUCCESS, error); |
397 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); | 394 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); |
398 EXPECT_EQ("/drive/v2/apps", http_request_.relative_url); | 395 EXPECT_EQ("/drive/v2/apps", http_request_.relative_url); |
399 EXPECT_TRUE(result); | 396 EXPECT_TRUE(result); |
400 } | 397 } |
401 | 398 |
402 TEST_F(DriveApiRequestsTest, GetChangelistRequest) { | 399 TEST_F(DriveApiRequestsTest, GetChangelistRequest) { |
403 // Set an expected data file containing valid result. | 400 // Set an expected data file containing valid result. |
404 expected_data_file_path_ = test_util::GetTestFilePath( | 401 expected_data_file_path_ = test_util::GetTestFilePath( |
405 "chromeos/drive/changelist.json"); | 402 "chromeos/drive/changelist.json"); |
406 | 403 |
407 GDataErrorCode error = GDATA_OTHER_ERROR; | 404 GDataErrorCode error = GDATA_OTHER_ERROR; |
408 scoped_ptr<base::Value> result; | 405 scoped_ptr<base::Value> result; |
409 | 406 |
410 { | 407 { |
411 base::RunLoop run_loop; | 408 base::RunLoop run_loop; |
412 GetChangelistRequest* request = new GetChangelistRequest( | 409 GetChangelistRequest* request = new GetChangelistRequest( |
413 request_sender_.get(), | 410 request_sender_.get(), |
414 request_context_getter_.get(), | |
415 *url_generator_, | 411 *url_generator_, |
416 true, // include deleted | 412 true, // include deleted |
417 100, // start changestamp | 413 100, // start changestamp |
418 500, // max results | 414 500, // max results |
419 test_util::CreateQuitCallback( | 415 test_util::CreateQuitCallback( |
420 &run_loop, | 416 &run_loop, |
421 test_util::CreateCopyResultCallback(&error, &result))); | 417 test_util::CreateCopyResultCallback(&error, &result))); |
422 request_sender_->StartRequestWithRetry(request); | 418 request_sender_->StartRequestWithRetry(request); |
423 run_loop.Run(); | 419 run_loop.Run(); |
424 } | 420 } |
(...skipping 10 matching lines...) Expand all Loading... |
435 expected_data_file_path_ = test_util::GetTestFilePath( | 431 expected_data_file_path_ = test_util::GetTestFilePath( |
436 "chromeos/drive/filelist.json"); | 432 "chromeos/drive/filelist.json"); |
437 | 433 |
438 GDataErrorCode error = GDATA_OTHER_ERROR; | 434 GDataErrorCode error = GDATA_OTHER_ERROR; |
439 scoped_ptr<base::Value> result; | 435 scoped_ptr<base::Value> result; |
440 | 436 |
441 { | 437 { |
442 base::RunLoop run_loop; | 438 base::RunLoop run_loop; |
443 GetFilelistRequest* request = new GetFilelistRequest( | 439 GetFilelistRequest* request = new GetFilelistRequest( |
444 request_sender_.get(), | 440 request_sender_.get(), |
445 request_context_getter_.get(), | |
446 *url_generator_, | 441 *url_generator_, |
447 "\"abcde\" in parents", | 442 "\"abcde\" in parents", |
448 50, // max results | 443 50, // max results |
449 test_util::CreateQuitCallback( | 444 test_util::CreateQuitCallback( |
450 &run_loop, | 445 &run_loop, |
451 test_util::CreateCopyResultCallback(&error, &result))); | 446 test_util::CreateCopyResultCallback(&error, &result))); |
452 request_sender_->StartRequestWithRetry(request); | 447 request_sender_->StartRequestWithRetry(request); |
453 run_loop.Run(); | 448 run_loop.Run(); |
454 } | 449 } |
455 | 450 |
(...skipping 10 matching lines...) Expand all Loading... |
466 "chromeos/drive/filelist.json"); | 461 "chromeos/drive/filelist.json"); |
467 | 462 |
468 GDataErrorCode error = GDATA_OTHER_ERROR; | 463 GDataErrorCode error = GDATA_OTHER_ERROR; |
469 scoped_ptr<base::Value> result; | 464 scoped_ptr<base::Value> result; |
470 | 465 |
471 { | 466 { |
472 base::RunLoop run_loop; | 467 base::RunLoop run_loop; |
473 drive::ContinueGetFileListRequest* request = | 468 drive::ContinueGetFileListRequest* request = |
474 new drive::ContinueGetFileListRequest( | 469 new drive::ContinueGetFileListRequest( |
475 request_sender_.get(), | 470 request_sender_.get(), |
476 request_context_getter_.get(), | |
477 test_server_.GetURL("/continue/get/file/list"), | 471 test_server_.GetURL("/continue/get/file/list"), |
478 test_util::CreateQuitCallback( | 472 test_util::CreateQuitCallback( |
479 &run_loop, | 473 &run_loop, |
480 test_util::CreateCopyResultCallback(&error, &result))); | 474 test_util::CreateCopyResultCallback(&error, &result))); |
481 request_sender_->StartRequestWithRetry(request); | 475 request_sender_->StartRequestWithRetry(request); |
482 run_loop.Run(); | 476 run_loop.Run(); |
483 } | 477 } |
484 | 478 |
485 EXPECT_EQ(HTTP_SUCCESS, error); | 479 EXPECT_EQ(HTTP_SUCCESS, error); |
486 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); | 480 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); |
487 EXPECT_EQ("/continue/get/file/list", http_request_.relative_url); | 481 EXPECT_EQ("/continue/get/file/list", http_request_.relative_url); |
488 EXPECT_TRUE(result); | 482 EXPECT_TRUE(result); |
489 } | 483 } |
490 | 484 |
491 TEST_F(DriveApiRequestsTest, CreateDirectoryRequest) { | 485 TEST_F(DriveApiRequestsTest, CreateDirectoryRequest) { |
492 // Set an expected data file containing the directory's entry data. | 486 // Set an expected data file containing the directory's entry data. |
493 expected_data_file_path_ = | 487 expected_data_file_path_ = |
494 test_util::GetTestFilePath("chromeos/drive/directory_entry.json"); | 488 test_util::GetTestFilePath("chromeos/drive/directory_entry.json"); |
495 | 489 |
496 GDataErrorCode error = GDATA_OTHER_ERROR; | 490 GDataErrorCode error = GDATA_OTHER_ERROR; |
497 scoped_ptr<FileResource> file_resource; | 491 scoped_ptr<FileResource> file_resource; |
498 | 492 |
499 // Create "new directory" in the root directory. | 493 // Create "new directory" in the root directory. |
500 { | 494 { |
501 base::RunLoop run_loop; | 495 base::RunLoop run_loop; |
502 drive::CreateDirectoryRequest* request = | 496 drive::CreateDirectoryRequest* request = |
503 new drive::CreateDirectoryRequest( | 497 new drive::CreateDirectoryRequest( |
504 request_sender_.get(), | 498 request_sender_.get(), |
505 request_context_getter_.get(), | |
506 *url_generator_, | 499 *url_generator_, |
507 "root", | 500 "root", |
508 "new directory", | 501 "new directory", |
509 test_util::CreateQuitCallback( | 502 test_util::CreateQuitCallback( |
510 &run_loop, | 503 &run_loop, |
511 test_util::CreateCopyResultCallback(&error, &file_resource))); | 504 test_util::CreateCopyResultCallback(&error, &file_resource))); |
512 request_sender_->StartRequestWithRetry(request); | 505 request_sender_->StartRequestWithRetry(request); |
513 run_loop.Run(); | 506 run_loop.Run(); |
514 } | 507 } |
515 | 508 |
(...skipping 24 matching lines...) Expand all Loading... |
540 test_util::GetTestFilePath("chromeos/drive/directory_entry.json"); | 533 test_util::GetTestFilePath("chromeos/drive/directory_entry.json"); |
541 | 534 |
542 GDataErrorCode error = GDATA_OTHER_ERROR; | 535 GDataErrorCode error = GDATA_OTHER_ERROR; |
543 | 536 |
544 // Create "new directory" in the root directory. | 537 // Create "new directory" in the root directory. |
545 { | 538 { |
546 base::RunLoop run_loop; | 539 base::RunLoop run_loop; |
547 drive::RenameResourceRequest* request = | 540 drive::RenameResourceRequest* request = |
548 new drive::RenameResourceRequest( | 541 new drive::RenameResourceRequest( |
549 request_sender_.get(), | 542 request_sender_.get(), |
550 request_context_getter_.get(), | |
551 *url_generator_, | 543 *url_generator_, |
552 "resource_id", | 544 "resource_id", |
553 "new name", | 545 "new name", |
554 test_util::CreateQuitCallback( | 546 test_util::CreateQuitCallback( |
555 &run_loop, | 547 &run_loop, |
556 test_util::CreateCopyResultCallback(&error))); | 548 test_util::CreateCopyResultCallback(&error))); |
557 request_sender_->StartRequestWithRetry(request); | 549 request_sender_->StartRequestWithRetry(request); |
558 run_loop.Run(); | 550 run_loop.Run(); |
559 } | 551 } |
560 | 552 |
(...skipping 16 matching lines...) Expand all Loading... |
577 scoped_ptr<FileResource> file_resource; | 569 scoped_ptr<FileResource> file_resource; |
578 const base::Time::Exploded kModifiedDate = {2012, 7, 0, 19, 15, 59, 13, 123}; | 570 const base::Time::Exploded kModifiedDate = {2012, 7, 0, 19, 15, 59, 13, 123}; |
579 const base::Time::Exploded kLastViewedByMeDate = | 571 const base::Time::Exploded kLastViewedByMeDate = |
580 {2013, 7, 0, 19, 15, 59, 13, 123}; | 572 {2013, 7, 0, 19, 15, 59, 13, 123}; |
581 | 573 |
582 // Touch a file with |resource_id|. | 574 // Touch a file with |resource_id|. |
583 { | 575 { |
584 base::RunLoop run_loop; | 576 base::RunLoop run_loop; |
585 drive::TouchResourceRequest* request = new drive::TouchResourceRequest( | 577 drive::TouchResourceRequest* request = new drive::TouchResourceRequest( |
586 request_sender_.get(), | 578 request_sender_.get(), |
587 request_context_getter_.get(), | |
588 *url_generator_, | 579 *url_generator_, |
589 "resource_id", | 580 "resource_id", |
590 base::Time::FromUTCExploded(kModifiedDate), | 581 base::Time::FromUTCExploded(kModifiedDate), |
591 base::Time::FromUTCExploded(kLastViewedByMeDate), | 582 base::Time::FromUTCExploded(kLastViewedByMeDate), |
592 test_util::CreateQuitCallback( | 583 test_util::CreateQuitCallback( |
593 &run_loop, | 584 &run_loop, |
594 test_util::CreateCopyResultCallback(&error, &file_resource))); | 585 test_util::CreateCopyResultCallback(&error, &file_resource))); |
595 request_sender_->StartRequestWithRetry(request); | 586 request_sender_->StartRequestWithRetry(request); |
596 run_loop.Run(); | 587 run_loop.Run(); |
597 } | 588 } |
(...skipping 19 matching lines...) Expand all Loading... |
617 | 608 |
618 GDataErrorCode error = GDATA_OTHER_ERROR; | 609 GDataErrorCode error = GDATA_OTHER_ERROR; |
619 scoped_ptr<FileResource> file_resource; | 610 scoped_ptr<FileResource> file_resource; |
620 | 611 |
621 // Copy the file to a new file named "new name". | 612 // Copy the file to a new file named "new name". |
622 { | 613 { |
623 base::RunLoop run_loop; | 614 base::RunLoop run_loop; |
624 drive::CopyResourceRequest* request = | 615 drive::CopyResourceRequest* request = |
625 new drive::CopyResourceRequest( | 616 new drive::CopyResourceRequest( |
626 request_sender_.get(), | 617 request_sender_.get(), |
627 request_context_getter_.get(), | |
628 *url_generator_, | 618 *url_generator_, |
629 "resource_id", | 619 "resource_id", |
630 "parent_resource_id", | 620 "parent_resource_id", |
631 "new name", | 621 "new name", |
632 test_util::CreateQuitCallback( | 622 test_util::CreateQuitCallback( |
633 &run_loop, | 623 &run_loop, |
634 test_util::CreateCopyResultCallback(&error, &file_resource))); | 624 test_util::CreateCopyResultCallback(&error, &file_resource))); |
635 request_sender_->StartRequestWithRetry(request); | 625 request_sender_->StartRequestWithRetry(request); |
636 run_loop.Run(); | 626 run_loop.Run(); |
637 } | 627 } |
(...skipping 18 matching lines...) Expand all Loading... |
656 | 646 |
657 GDataErrorCode error = GDATA_OTHER_ERROR; | 647 GDataErrorCode error = GDATA_OTHER_ERROR; |
658 scoped_ptr<FileResource> file_resource; | 648 scoped_ptr<FileResource> file_resource; |
659 | 649 |
660 // Copy the file to a new file named "new name". | 650 // Copy the file to a new file named "new name". |
661 { | 651 { |
662 base::RunLoop run_loop; | 652 base::RunLoop run_loop; |
663 drive::CopyResourceRequest* request = | 653 drive::CopyResourceRequest* request = |
664 new drive::CopyResourceRequest( | 654 new drive::CopyResourceRequest( |
665 request_sender_.get(), | 655 request_sender_.get(), |
666 request_context_getter_.get(), | |
667 *url_generator_, | 656 *url_generator_, |
668 "resource_id", | 657 "resource_id", |
669 std::string(), // parent resource id. | 658 std::string(), // parent resource id. |
670 "new name", | 659 "new name", |
671 test_util::CreateQuitCallback( | 660 test_util::CreateQuitCallback( |
672 &run_loop, | 661 &run_loop, |
673 test_util::CreateCopyResultCallback(&error, &file_resource))); | 662 test_util::CreateCopyResultCallback(&error, &file_resource))); |
674 request_sender_->StartRequestWithRetry(request); | 663 request_sender_->StartRequestWithRetry(request); |
675 run_loop.Run(); | 664 run_loop.Run(); |
676 } | 665 } |
(...skipping 15 matching lines...) Expand all Loading... |
692 test_util::GetTestFilePath("chromeos/drive/directory_entry.json"); | 681 test_util::GetTestFilePath("chromeos/drive/directory_entry.json"); |
693 | 682 |
694 GDataErrorCode error = GDATA_OTHER_ERROR; | 683 GDataErrorCode error = GDATA_OTHER_ERROR; |
695 | 684 |
696 // Trash a resource with the given resource id. | 685 // Trash a resource with the given resource id. |
697 { | 686 { |
698 base::RunLoop run_loop; | 687 base::RunLoop run_loop; |
699 drive::TrashResourceRequest* request = | 688 drive::TrashResourceRequest* request = |
700 new drive::TrashResourceRequest( | 689 new drive::TrashResourceRequest( |
701 request_sender_.get(), | 690 request_sender_.get(), |
702 request_context_getter_.get(), | |
703 *url_generator_, | 691 *url_generator_, |
704 "resource_id", | 692 "resource_id", |
705 test_util::CreateQuitCallback( | 693 test_util::CreateQuitCallback( |
706 &run_loop, | 694 &run_loop, |
707 test_util::CreateCopyResultCallback(&error))); | 695 test_util::CreateCopyResultCallback(&error))); |
708 request_sender_->StartRequestWithRetry(request); | 696 request_sender_->StartRequestWithRetry(request); |
709 run_loop.Run(); | 697 run_loop.Run(); |
710 } | 698 } |
711 | 699 |
712 EXPECT_EQ(HTTP_SUCCESS, error); | 700 EXPECT_EQ(HTTP_SUCCESS, error); |
(...skipping 10 matching lines...) Expand all Loading... |
723 | 711 |
724 GDataErrorCode error = GDATA_OTHER_ERROR; | 712 GDataErrorCode error = GDATA_OTHER_ERROR; |
725 | 713 |
726 // Add a resource with "resource_id" to a directory with | 714 // Add a resource with "resource_id" to a directory with |
727 // "parent_resource_id". | 715 // "parent_resource_id". |
728 { | 716 { |
729 base::RunLoop run_loop; | 717 base::RunLoop run_loop; |
730 drive::InsertResourceRequest* request = | 718 drive::InsertResourceRequest* request = |
731 new drive::InsertResourceRequest( | 719 new drive::InsertResourceRequest( |
732 request_sender_.get(), | 720 request_sender_.get(), |
733 request_context_getter_.get(), | |
734 *url_generator_, | 721 *url_generator_, |
735 "parent_resource_id", | 722 "parent_resource_id", |
736 "resource_id", | 723 "resource_id", |
737 test_util::CreateQuitCallback( | 724 test_util::CreateQuitCallback( |
738 &run_loop, | 725 &run_loop, |
739 test_util::CreateCopyResultCallback(&error))); | 726 test_util::CreateCopyResultCallback(&error))); |
740 request_sender_->StartRequestWithRetry(request); | 727 request_sender_->StartRequestWithRetry(request); |
741 run_loop.Run(); | 728 run_loop.Run(); |
742 } | 729 } |
743 | 730 |
(...skipping 10 matching lines...) Expand all Loading... |
754 TEST_F(DriveApiRequestsTest, DeleteResourceRequest) { | 741 TEST_F(DriveApiRequestsTest, DeleteResourceRequest) { |
755 GDataErrorCode error = GDATA_OTHER_ERROR; | 742 GDataErrorCode error = GDATA_OTHER_ERROR; |
756 | 743 |
757 // Remove a resource with "resource_id" from a directory with | 744 // Remove a resource with "resource_id" from a directory with |
758 // "parent_resource_id". | 745 // "parent_resource_id". |
759 { | 746 { |
760 base::RunLoop run_loop; | 747 base::RunLoop run_loop; |
761 drive::DeleteResourceRequest* request = | 748 drive::DeleteResourceRequest* request = |
762 new drive::DeleteResourceRequest( | 749 new drive::DeleteResourceRequest( |
763 request_sender_.get(), | 750 request_sender_.get(), |
764 request_context_getter_.get(), | |
765 *url_generator_, | 751 *url_generator_, |
766 "parent_resource_id", | 752 "parent_resource_id", |
767 "resource_id", | 753 "resource_id", |
768 test_util::CreateQuitCallback( | 754 test_util::CreateQuitCallback( |
769 &run_loop, | 755 &run_loop, |
770 test_util::CreateCopyResultCallback(&error))); | 756 test_util::CreateCopyResultCallback(&error))); |
771 request_sender_->StartRequestWithRetry(request); | 757 request_sender_->StartRequestWithRetry(request); |
772 run_loop.Run(); | 758 run_loop.Run(); |
773 } | 759 } |
774 | 760 |
(...skipping 17 matching lines...) Expand all Loading... |
792 GDataErrorCode error = GDATA_OTHER_ERROR; | 778 GDataErrorCode error = GDATA_OTHER_ERROR; |
793 GURL upload_url; | 779 GURL upload_url; |
794 | 780 |
795 // Initiate uploading a new file to the directory with | 781 // Initiate uploading a new file to the directory with |
796 // "parent_resource_id". | 782 // "parent_resource_id". |
797 { | 783 { |
798 base::RunLoop run_loop; | 784 base::RunLoop run_loop; |
799 drive::InitiateUploadNewFileRequest* request = | 785 drive::InitiateUploadNewFileRequest* request = |
800 new drive::InitiateUploadNewFileRequest( | 786 new drive::InitiateUploadNewFileRequest( |
801 request_sender_.get(), | 787 request_sender_.get(), |
802 request_context_getter_.get(), | |
803 *url_generator_, | 788 *url_generator_, |
804 kTestContentType, | 789 kTestContentType, |
805 kTestContent.size(), | 790 kTestContent.size(), |
806 "parent_resource_id", // The resource id of the parent directory. | 791 "parent_resource_id", // The resource id of the parent directory. |
807 "new file title", // The title of the file being uploaded. | 792 "new file title", // The title of the file being uploaded. |
808 test_util::CreateQuitCallback( | 793 test_util::CreateQuitCallback( |
809 &run_loop, | 794 &run_loop, |
810 test_util::CreateCopyResultCallback(&error, &upload_url))); | 795 test_util::CreateCopyResultCallback(&error, &upload_url))); |
811 request_sender_->StartRequestWithRetry(request); | 796 request_sender_->StartRequestWithRetry(request); |
812 run_loop.Run(); | 797 run_loop.Run(); |
(...skipping 19 matching lines...) Expand all Loading... |
832 | 817 |
833 // Upload the content to the upload URL. | 818 // Upload the content to the upload URL. |
834 UploadRangeResponse response; | 819 UploadRangeResponse response; |
835 scoped_ptr<FileResource> new_entry; | 820 scoped_ptr<FileResource> new_entry; |
836 | 821 |
837 { | 822 { |
838 base::RunLoop run_loop; | 823 base::RunLoop run_loop; |
839 drive::ResumeUploadRequest* resume_request = | 824 drive::ResumeUploadRequest* resume_request = |
840 new drive::ResumeUploadRequest( | 825 new drive::ResumeUploadRequest( |
841 request_sender_.get(), | 826 request_sender_.get(), |
842 request_context_getter_.get(), | |
843 upload_url, | 827 upload_url, |
844 0, // start_position | 828 0, // start_position |
845 kTestContent.size(), // end_position (exclusive) | 829 kTestContent.size(), // end_position (exclusive) |
846 kTestContent.size(), // content_length, | 830 kTestContent.size(), // content_length, |
847 kTestContentType, | 831 kTestContentType, |
848 kTestFilePath, | 832 kTestFilePath, |
849 test_util::CreateQuitCallback( | 833 test_util::CreateQuitCallback( |
850 &run_loop, | 834 &run_loop, |
851 test_util::CreateCopyResultCallback(&response, &new_entry)), | 835 test_util::CreateCopyResultCallback(&response, &new_entry)), |
852 ProgressCallback()); | 836 ProgressCallback()); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
886 | 870 |
887 GDataErrorCode error = GDATA_OTHER_ERROR; | 871 GDataErrorCode error = GDATA_OTHER_ERROR; |
888 GURL upload_url; | 872 GURL upload_url; |
889 | 873 |
890 // Initiate uploading a new file to the directory with "parent_resource_id". | 874 // Initiate uploading a new file to the directory with "parent_resource_id". |
891 { | 875 { |
892 base::RunLoop run_loop; | 876 base::RunLoop run_loop; |
893 drive::InitiateUploadNewFileRequest* request = | 877 drive::InitiateUploadNewFileRequest* request = |
894 new drive::InitiateUploadNewFileRequest( | 878 new drive::InitiateUploadNewFileRequest( |
895 request_sender_.get(), | 879 request_sender_.get(), |
896 request_context_getter_.get(), | |
897 *url_generator_, | 880 *url_generator_, |
898 kTestContentType, | 881 kTestContentType, |
899 0, | 882 0, |
900 "parent_resource_id", // The resource id of the parent directory. | 883 "parent_resource_id", // The resource id of the parent directory. |
901 "new file title", // The title of the file being uploaded. | 884 "new file title", // The title of the file being uploaded. |
902 test_util::CreateQuitCallback( | 885 test_util::CreateQuitCallback( |
903 &run_loop, | 886 &run_loop, |
904 test_util::CreateCopyResultCallback(&error, &upload_url))); | 887 test_util::CreateCopyResultCallback(&error, &upload_url))); |
905 request_sender_->StartRequestWithRetry(request); | 888 request_sender_->StartRequestWithRetry(request); |
906 run_loop.Run(); | 889 run_loop.Run(); |
(...skipping 18 matching lines...) Expand all Loading... |
925 | 908 |
926 // Upload the content to the upload URL. | 909 // Upload the content to the upload URL. |
927 UploadRangeResponse response; | 910 UploadRangeResponse response; |
928 scoped_ptr<FileResource> new_entry; | 911 scoped_ptr<FileResource> new_entry; |
929 | 912 |
930 { | 913 { |
931 base::RunLoop run_loop; | 914 base::RunLoop run_loop; |
932 drive::ResumeUploadRequest* resume_request = | 915 drive::ResumeUploadRequest* resume_request = |
933 new drive::ResumeUploadRequest( | 916 new drive::ResumeUploadRequest( |
934 request_sender_.get(), | 917 request_sender_.get(), |
935 request_context_getter_.get(), | |
936 upload_url, | 918 upload_url, |
937 0, // start_position | 919 0, // start_position |
938 0, // end_position (exclusive) | 920 0, // end_position (exclusive) |
939 0, // content_length, | 921 0, // content_length, |
940 kTestContentType, | 922 kTestContentType, |
941 kTestFilePath, | 923 kTestFilePath, |
942 test_util::CreateQuitCallback( | 924 test_util::CreateQuitCallback( |
943 &run_loop, | 925 &run_loop, |
944 test_util::CreateCopyResultCallback(&response, &new_entry)), | 926 test_util::CreateCopyResultCallback(&response, &new_entry)), |
945 ProgressCallback()); | 927 ProgressCallback()); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
977 | 959 |
978 GDataErrorCode error = GDATA_OTHER_ERROR; | 960 GDataErrorCode error = GDATA_OTHER_ERROR; |
979 GURL upload_url; | 961 GURL upload_url; |
980 | 962 |
981 // Initiate uploading a new file to the directory with "parent_resource_id". | 963 // Initiate uploading a new file to the directory with "parent_resource_id". |
982 { | 964 { |
983 base::RunLoop run_loop; | 965 base::RunLoop run_loop; |
984 drive::InitiateUploadNewFileRequest* request = | 966 drive::InitiateUploadNewFileRequest* request = |
985 new drive::InitiateUploadNewFileRequest( | 967 new drive::InitiateUploadNewFileRequest( |
986 request_sender_.get(), | 968 request_sender_.get(), |
987 request_context_getter_.get(), | |
988 *url_generator_, | 969 *url_generator_, |
989 kTestContentType, | 970 kTestContentType, |
990 kTestContent.size(), | 971 kTestContent.size(), |
991 "parent_resource_id", // The resource id of the parent directory. | 972 "parent_resource_id", // The resource id of the parent directory. |
992 "new file title", // The title of the file being uploaded. | 973 "new file title", // The title of the file being uploaded. |
993 test_util::CreateQuitCallback( | 974 test_util::CreateQuitCallback( |
994 &run_loop, | 975 &run_loop, |
995 test_util::CreateCopyResultCallback(&error, &upload_url))); | 976 test_util::CreateCopyResultCallback(&error, &upload_url))); |
996 request_sender_->StartRequestWithRetry(request); | 977 request_sender_->StartRequestWithRetry(request); |
997 run_loop.Run(); | 978 run_loop.Run(); |
(...skipping 22 matching lines...) Expand all Loading... |
1020 { | 1001 { |
1021 UploadRangeResponse response; | 1002 UploadRangeResponse response; |
1022 scoped_ptr<FileResource> new_entry; | 1003 scoped_ptr<FileResource> new_entry; |
1023 | 1004 |
1024 // Check the response by GetUploadStatusRequest. | 1005 // Check the response by GetUploadStatusRequest. |
1025 { | 1006 { |
1026 base::RunLoop run_loop; | 1007 base::RunLoop run_loop; |
1027 drive::GetUploadStatusRequest* get_upload_status_request = | 1008 drive::GetUploadStatusRequest* get_upload_status_request = |
1028 new drive::GetUploadStatusRequest( | 1009 new drive::GetUploadStatusRequest( |
1029 request_sender_.get(), | 1010 request_sender_.get(), |
1030 request_context_getter_.get(), | |
1031 upload_url, | 1011 upload_url, |
1032 kTestContent.size(), | 1012 kTestContent.size(), |
1033 test_util::CreateQuitCallback( | 1013 test_util::CreateQuitCallback( |
1034 &run_loop, | 1014 &run_loop, |
1035 test_util::CreateCopyResultCallback(&response, &new_entry))); | 1015 test_util::CreateCopyResultCallback(&response, &new_entry))); |
1036 request_sender_->StartRequestWithRetry(get_upload_status_request); | 1016 request_sender_->StartRequestWithRetry(get_upload_status_request); |
1037 run_loop.Run(); | 1017 run_loop.Run(); |
1038 } | 1018 } |
1039 | 1019 |
1040 // METHOD_PUT should be used to upload data. | 1020 // METHOD_PUT should be used to upload data. |
(...skipping 21 matching lines...) Expand all Loading... |
1062 const size_t end_position = start_position + payload.size(); | 1042 const size_t end_position = start_position + payload.size(); |
1063 | 1043 |
1064 UploadRangeResponse response; | 1044 UploadRangeResponse response; |
1065 scoped_ptr<FileResource> new_entry; | 1045 scoped_ptr<FileResource> new_entry; |
1066 | 1046 |
1067 { | 1047 { |
1068 base::RunLoop run_loop; | 1048 base::RunLoop run_loop; |
1069 drive::ResumeUploadRequest* resume_request = | 1049 drive::ResumeUploadRequest* resume_request = |
1070 new drive::ResumeUploadRequest( | 1050 new drive::ResumeUploadRequest( |
1071 request_sender_.get(), | 1051 request_sender_.get(), |
1072 request_context_getter_.get(), | |
1073 upload_url, | 1052 upload_url, |
1074 start_position, | 1053 start_position, |
1075 end_position, | 1054 end_position, |
1076 kTestContent.size(), // content_length, | 1055 kTestContent.size(), // content_length, |
1077 kTestContentType, | 1056 kTestContentType, |
1078 kTestFilePath, | 1057 kTestFilePath, |
1079 test_util::CreateQuitCallback( | 1058 test_util::CreateQuitCallback( |
1080 &run_loop, | 1059 &run_loop, |
1081 test_util::CreateCopyResultCallback(&response, &new_entry)), | 1060 test_util::CreateCopyResultCallback(&response, &new_entry)), |
1082 ProgressCallback()); | 1061 ProgressCallback()); |
(...skipping 29 matching lines...) Expand all Loading... |
1112 EXPECT_EQ(HTTP_RESUME_INCOMPLETE, response.code); | 1091 EXPECT_EQ(HTTP_RESUME_INCOMPLETE, response.code); |
1113 EXPECT_EQ(0, response.start_position_received); | 1092 EXPECT_EQ(0, response.start_position_received); |
1114 EXPECT_EQ(static_cast<int64>(end_position), response.end_position_received); | 1093 EXPECT_EQ(static_cast<int64>(end_position), response.end_position_received); |
1115 | 1094 |
1116 // Check the response by GetUploadStatusRequest. | 1095 // Check the response by GetUploadStatusRequest. |
1117 { | 1096 { |
1118 base::RunLoop run_loop; | 1097 base::RunLoop run_loop; |
1119 drive::GetUploadStatusRequest* get_upload_status_request = | 1098 drive::GetUploadStatusRequest* get_upload_status_request = |
1120 new drive::GetUploadStatusRequest( | 1099 new drive::GetUploadStatusRequest( |
1121 request_sender_.get(), | 1100 request_sender_.get(), |
1122 request_context_getter_.get(), | |
1123 upload_url, | 1101 upload_url, |
1124 kTestContent.size(), | 1102 kTestContent.size(), |
1125 test_util::CreateQuitCallback( | 1103 test_util::CreateQuitCallback( |
1126 &run_loop, | 1104 &run_loop, |
1127 test_util::CreateCopyResultCallback(&response, &new_entry))); | 1105 test_util::CreateCopyResultCallback(&response, &new_entry))); |
1128 request_sender_->StartRequestWithRetry(get_upload_status_request); | 1106 request_sender_->StartRequestWithRetry(get_upload_status_request); |
1129 run_loop.Run(); | 1107 run_loop.Run(); |
1130 } | 1108 } |
1131 | 1109 |
1132 // METHOD_PUT should be used to upload data. | 1110 // METHOD_PUT should be used to upload data. |
(...skipping 26 matching lines...) Expand all Loading... |
1159 | 1137 |
1160 GDataErrorCode error = GDATA_OTHER_ERROR; | 1138 GDataErrorCode error = GDATA_OTHER_ERROR; |
1161 GURL upload_url; | 1139 GURL upload_url; |
1162 | 1140 |
1163 // Initiate uploading a new file to the directory with "parent_resource_id". | 1141 // Initiate uploading a new file to the directory with "parent_resource_id". |
1164 { | 1142 { |
1165 base::RunLoop run_loop; | 1143 base::RunLoop run_loop; |
1166 drive::InitiateUploadExistingFileRequest* request = | 1144 drive::InitiateUploadExistingFileRequest* request = |
1167 new drive::InitiateUploadExistingFileRequest( | 1145 new drive::InitiateUploadExistingFileRequest( |
1168 request_sender_.get(), | 1146 request_sender_.get(), |
1169 request_context_getter_.get(), | |
1170 *url_generator_, | 1147 *url_generator_, |
1171 kTestContentType, | 1148 kTestContentType, |
1172 kTestContent.size(), | 1149 kTestContent.size(), |
1173 "resource_id", // The resource id of the file to be overwritten. | 1150 "resource_id", // The resource id of the file to be overwritten. |
1174 std::string(), // No etag. | 1151 std::string(), // No etag. |
1175 test_util::CreateQuitCallback( | 1152 test_util::CreateQuitCallback( |
1176 &run_loop, | 1153 &run_loop, |
1177 test_util::CreateCopyResultCallback(&error, &upload_url))); | 1154 test_util::CreateCopyResultCallback(&error, &upload_url))); |
1178 request_sender_->StartRequestWithRetry(request); | 1155 request_sender_->StartRequestWithRetry(request); |
1179 run_loop.Run(); | 1156 run_loop.Run(); |
(...skipping 14 matching lines...) Expand all Loading... |
1194 | 1171 |
1195 // Upload the content to the upload URL. | 1172 // Upload the content to the upload URL. |
1196 UploadRangeResponse response; | 1173 UploadRangeResponse response; |
1197 scoped_ptr<FileResource> new_entry; | 1174 scoped_ptr<FileResource> new_entry; |
1198 | 1175 |
1199 { | 1176 { |
1200 base::RunLoop run_loop; | 1177 base::RunLoop run_loop; |
1201 drive::ResumeUploadRequest* resume_request = | 1178 drive::ResumeUploadRequest* resume_request = |
1202 new drive::ResumeUploadRequest( | 1179 new drive::ResumeUploadRequest( |
1203 request_sender_.get(), | 1180 request_sender_.get(), |
1204 request_context_getter_.get(), | |
1205 upload_url, | 1181 upload_url, |
1206 0, // start_position | 1182 0, // start_position |
1207 kTestContent.size(), // end_position (exclusive) | 1183 kTestContent.size(), // end_position (exclusive) |
1208 kTestContent.size(), // content_length, | 1184 kTestContent.size(), // content_length, |
1209 kTestContentType, | 1185 kTestContentType, |
1210 kTestFilePath, | 1186 kTestFilePath, |
1211 test_util::CreateQuitCallback( | 1187 test_util::CreateQuitCallback( |
1212 &run_loop, | 1188 &run_loop, |
1213 test_util::CreateCopyResultCallback(&response, &new_entry)), | 1189 test_util::CreateCopyResultCallback(&response, &new_entry)), |
1214 ProgressCallback()); | 1190 ProgressCallback()); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1248 | 1224 |
1249 GDataErrorCode error = GDATA_OTHER_ERROR; | 1225 GDataErrorCode error = GDATA_OTHER_ERROR; |
1250 GURL upload_url; | 1226 GURL upload_url; |
1251 | 1227 |
1252 // Initiate uploading a new file to the directory with "parent_resource_id". | 1228 // Initiate uploading a new file to the directory with "parent_resource_id". |
1253 { | 1229 { |
1254 base::RunLoop run_loop; | 1230 base::RunLoop run_loop; |
1255 drive::InitiateUploadExistingFileRequest* request = | 1231 drive::InitiateUploadExistingFileRequest* request = |
1256 new drive::InitiateUploadExistingFileRequest( | 1232 new drive::InitiateUploadExistingFileRequest( |
1257 request_sender_.get(), | 1233 request_sender_.get(), |
1258 request_context_getter_.get(), | |
1259 *url_generator_, | 1234 *url_generator_, |
1260 kTestContentType, | 1235 kTestContentType, |
1261 kTestContent.size(), | 1236 kTestContent.size(), |
1262 "resource_id", // The resource id of the file to be overwritten. | 1237 "resource_id", // The resource id of the file to be overwritten. |
1263 kTestETag, | 1238 kTestETag, |
1264 test_util::CreateQuitCallback( | 1239 test_util::CreateQuitCallback( |
1265 &run_loop, | 1240 &run_loop, |
1266 test_util::CreateCopyResultCallback(&error, &upload_url))); | 1241 test_util::CreateCopyResultCallback(&error, &upload_url))); |
1267 request_sender_->StartRequestWithRetry(request); | 1242 request_sender_->StartRequestWithRetry(request); |
1268 run_loop.Run(); | 1243 run_loop.Run(); |
(...skipping 14 matching lines...) Expand all Loading... |
1283 | 1258 |
1284 // Upload the content to the upload URL. | 1259 // Upload the content to the upload URL. |
1285 UploadRangeResponse response; | 1260 UploadRangeResponse response; |
1286 scoped_ptr<FileResource> new_entry; | 1261 scoped_ptr<FileResource> new_entry; |
1287 | 1262 |
1288 { | 1263 { |
1289 base::RunLoop run_loop; | 1264 base::RunLoop run_loop; |
1290 drive::ResumeUploadRequest* resume_request = | 1265 drive::ResumeUploadRequest* resume_request = |
1291 new drive::ResumeUploadRequest( | 1266 new drive::ResumeUploadRequest( |
1292 request_sender_.get(), | 1267 request_sender_.get(), |
1293 request_context_getter_.get(), | |
1294 upload_url, | 1268 upload_url, |
1295 0, // start_position | 1269 0, // start_position |
1296 kTestContent.size(), // end_position (exclusive) | 1270 kTestContent.size(), // end_position (exclusive) |
1297 kTestContent.size(), // content_length, | 1271 kTestContent.size(), // content_length, |
1298 kTestContentType, | 1272 kTestContentType, |
1299 kTestFilePath, | 1273 kTestFilePath, |
1300 test_util::CreateQuitCallback( | 1274 test_util::CreateQuitCallback( |
1301 &run_loop, | 1275 &run_loop, |
1302 test_util::CreateCopyResultCallback(&response, &new_entry)), | 1276 test_util::CreateCopyResultCallback(&response, &new_entry)), |
1303 ProgressCallback()); | 1277 ProgressCallback()); |
(...skipping 30 matching lines...) Expand all Loading... |
1334 | 1308 |
1335 GDataErrorCode error = GDATA_OTHER_ERROR; | 1309 GDataErrorCode error = GDATA_OTHER_ERROR; |
1336 GURL upload_url; | 1310 GURL upload_url; |
1337 | 1311 |
1338 // Initiate uploading a new file to the directory with "parent_resource_id". | 1312 // Initiate uploading a new file to the directory with "parent_resource_id". |
1339 { | 1313 { |
1340 base::RunLoop run_loop; | 1314 base::RunLoop run_loop; |
1341 drive::InitiateUploadExistingFileRequest* request = | 1315 drive::InitiateUploadExistingFileRequest* request = |
1342 new drive::InitiateUploadExistingFileRequest( | 1316 new drive::InitiateUploadExistingFileRequest( |
1343 request_sender_.get(), | 1317 request_sender_.get(), |
1344 request_context_getter_.get(), | |
1345 *url_generator_, | 1318 *url_generator_, |
1346 kTestContentType, | 1319 kTestContentType, |
1347 kTestContent.size(), | 1320 kTestContent.size(), |
1348 "resource_id", // The resource id of the file to be overwritten. | 1321 "resource_id", // The resource id of the file to be overwritten. |
1349 "Conflicting-etag", | 1322 "Conflicting-etag", |
1350 test_util::CreateQuitCallback( | 1323 test_util::CreateQuitCallback( |
1351 &run_loop, | 1324 &run_loop, |
1352 test_util::CreateCopyResultCallback(&error, &upload_url))); | 1325 test_util::CreateCopyResultCallback(&error, &upload_url))); |
1353 request_sender_->StartRequestWithRetry(request); | 1326 request_sender_->StartRequestWithRetry(request); |
1354 run_loop.Run(); | 1327 run_loop.Run(); |
1355 } | 1328 } |
1356 | 1329 |
1357 EXPECT_EQ(HTTP_PRECONDITION, error); | 1330 EXPECT_EQ(HTTP_PRECONDITION, error); |
1358 EXPECT_EQ(kTestContentType, http_request_.headers["X-Upload-Content-Type"]); | 1331 EXPECT_EQ(kTestContentType, http_request_.headers["X-Upload-Content-Type"]); |
1359 EXPECT_EQ(base::Int64ToString(kTestContent.size()), | 1332 EXPECT_EQ(base::Int64ToString(kTestContent.size()), |
1360 http_request_.headers["X-Upload-Content-Length"]); | 1333 http_request_.headers["X-Upload-Content-Length"]); |
1361 EXPECT_EQ("Conflicting-etag", http_request_.headers["If-Match"]); | 1334 EXPECT_EQ("Conflicting-etag", http_request_.headers["If-Match"]); |
1362 | 1335 |
1363 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); | 1336 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); |
1364 EXPECT_EQ("/upload/drive/v2/files/resource_id?uploadType=resumable", | 1337 EXPECT_EQ("/upload/drive/v2/files/resource_id?uploadType=resumable", |
1365 http_request_.relative_url); | 1338 http_request_.relative_url); |
1366 EXPECT_TRUE(http_request_.has_content); | 1339 EXPECT_TRUE(http_request_.has_content); |
1367 EXPECT_TRUE(http_request_.content.empty()); | 1340 EXPECT_TRUE(http_request_.content.empty()); |
1368 } | 1341 } |
1369 | 1342 |
1370 } // namespace google_apis | 1343 } // namespace google_apis |
OLD | NEW |