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

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

Issue 13927002: Add callback for upload progress in Drive service and operation layer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 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/message_loop_proxy.h" 7 #include "base/message_loop_proxy.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "chrome/browser/google_apis/drive_api_operations.h" 10 #include "chrome/browser/google_apis/drive_api_operations.h"
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 UPLOAD_NEW_FILE, 614 UPLOAD_NEW_FILE,
615 base::FilePath(FILE_PATH_LITERAL("drive/file/path")), 615 base::FilePath(FILE_PATH_LITERAL("drive/file/path")),
616 upload_url, 616 upload_url,
617 0, // start_position 617 0, // start_position
618 kTestContent.size(), // end_position (exclusive) 618 kTestContent.size(), // end_position (exclusive)
619 kTestContent.size(), // content_length, 619 kTestContent.size(), // content_length,
620 kTestContentType, 620 kTestContentType,
621 buffer, 621 buffer,
622 CreateComposedCallback( 622 CreateComposedCallback(
623 base::Bind(&test_util::RunAndQuit), 623 base::Bind(&test_util::RunAndQuit),
624 test_util::CreateCopyResultCallback(&response, &new_entry))); 624 test_util::CreateCopyResultCallback(&response, &new_entry)),
625 ProgressCallback());
625 resume_operation->Start( 626 resume_operation->Start(
626 kTestDriveApiAuthToken, kTestUserAgent, 627 kTestDriveApiAuthToken, kTestUserAgent,
627 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); 628 base::Bind(&test_util::DoNothingForReAuthenticateCallback));
628 MessageLoop::current()->Run(); 629 MessageLoop::current()->Run();
629 630
630 // METHOD_PUT should be used to upload data. 631 // METHOD_PUT should be used to upload data.
631 EXPECT_EQ(test_server::METHOD_PUT, http_request_.method); 632 EXPECT_EQ(test_server::METHOD_PUT, http_request_.method);
632 // Request should go to the upload URL. 633 // Request should go to the upload URL.
633 EXPECT_EQ(upload_url.path(), http_request_.relative_url); 634 EXPECT_EQ(upload_url.path(), http_request_.relative_url);
634 // Content-Range header should be added. 635 // Content-Range header should be added.
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
706 UPLOAD_NEW_FILE, 707 UPLOAD_NEW_FILE,
707 base::FilePath(FILE_PATH_LITERAL("drive/file/path")), 708 base::FilePath(FILE_PATH_LITERAL("drive/file/path")),
708 upload_url, 709 upload_url,
709 0, // start_position 710 0, // start_position
710 0, // end_position (exclusive) 711 0, // end_position (exclusive)
711 0, // content_length, 712 0, // content_length,
712 kTestContentType, 713 kTestContentType,
713 buffer, 714 buffer,
714 CreateComposedCallback( 715 CreateComposedCallback(
715 base::Bind(&test_util::RunAndQuit), 716 base::Bind(&test_util::RunAndQuit),
716 test_util::CreateCopyResultCallback(&response, &new_entry))); 717 test_util::CreateCopyResultCallback(&response, &new_entry)),
718 ProgressCallback());
717 resume_operation->Start( 719 resume_operation->Start(
718 kTestDriveApiAuthToken, kTestUserAgent, 720 kTestDriveApiAuthToken, kTestUserAgent,
719 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); 721 base::Bind(&test_util::DoNothingForReAuthenticateCallback));
720 MessageLoop::current()->Run(); 722 MessageLoop::current()->Run();
721 723
722 // METHOD_PUT should be used to upload data. 724 // METHOD_PUT should be used to upload data.
723 EXPECT_EQ(test_server::METHOD_PUT, http_request_.method); 725 EXPECT_EQ(test_server::METHOD_PUT, http_request_.method);
724 // Request should go to the upload URL. 726 // Request should go to the upload URL.
725 EXPECT_EQ(upload_url.path(), http_request_.relative_url); 727 EXPECT_EQ(upload_url.path(), http_request_.relative_url);
726 // Content-Range header should NOT be added. 728 // Content-Range header should NOT be added.
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
803 UPLOAD_NEW_FILE, 805 UPLOAD_NEW_FILE,
804 base::FilePath(FILE_PATH_LITERAL("drive/file/path")), 806 base::FilePath(FILE_PATH_LITERAL("drive/file/path")),
805 upload_url, 807 upload_url,
806 start_position, 808 start_position,
807 end_position, 809 end_position,
808 kTestContent.size(), // content_length, 810 kTestContent.size(), // content_length,
809 kTestContentType, 811 kTestContentType,
810 buffer, 812 buffer,
811 CreateComposedCallback( 813 CreateComposedCallback(
812 base::Bind(&test_util::RunAndQuit), 814 base::Bind(&test_util::RunAndQuit),
813 test_util::CreateCopyResultCallback(&response, &new_entry))); 815 test_util::CreateCopyResultCallback(&response, &new_entry)),
816 ProgressCallback());
814 resume_operation->Start( 817 resume_operation->Start(
815 kTestDriveApiAuthToken, kTestUserAgent, 818 kTestDriveApiAuthToken, kTestUserAgent,
816 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); 819 base::Bind(&test_util::DoNothingForReAuthenticateCallback));
817 MessageLoop::current()->Run(); 820 MessageLoop::current()->Run();
818 821
819 // METHOD_PUT should be used to upload data. 822 // METHOD_PUT should be used to upload data.
820 EXPECT_EQ(test_server::METHOD_PUT, http_request_.method); 823 EXPECT_EQ(test_server::METHOD_PUT, http_request_.method);
821 // Request should go to the upload URL. 824 // Request should go to the upload URL.
822 EXPECT_EQ(upload_url.path(), http_request_.relative_url); 825 EXPECT_EQ(upload_url.path(), http_request_.relative_url);
823 // Content-Range header should be added. 826 // Content-Range header should be added.
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
901 UPLOAD_EXISTING_FILE, 904 UPLOAD_EXISTING_FILE,
902 base::FilePath(FILE_PATH_LITERAL("drive/file/path")), 905 base::FilePath(FILE_PATH_LITERAL("drive/file/path")),
903 upload_url, 906 upload_url,
904 0, // start_position 907 0, // start_position
905 kTestContent.size(), // end_position (exclusive) 908 kTestContent.size(), // end_position (exclusive)
906 kTestContent.size(), // content_length, 909 kTestContent.size(), // content_length,
907 kTestContentType, 910 kTestContentType,
908 buffer, 911 buffer,
909 CreateComposedCallback( 912 CreateComposedCallback(
910 base::Bind(&test_util::RunAndQuit), 913 base::Bind(&test_util::RunAndQuit),
911 test_util::CreateCopyResultCallback(&response, &new_entry))); 914 test_util::CreateCopyResultCallback(&response, &new_entry)),
915 ProgressCallback());
912 resume_operation->Start( 916 resume_operation->Start(
913 kTestDriveApiAuthToken, kTestUserAgent, 917 kTestDriveApiAuthToken, kTestUserAgent,
914 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); 918 base::Bind(&test_util::DoNothingForReAuthenticateCallback));
915 MessageLoop::current()->Run(); 919 MessageLoop::current()->Run();
916 920
917 // METHOD_PUT should be used to upload data. 921 // METHOD_PUT should be used to upload data.
918 EXPECT_EQ(test_server::METHOD_PUT, http_request_.method); 922 EXPECT_EQ(test_server::METHOD_PUT, http_request_.method);
919 // Request should go to the upload URL. 923 // Request should go to the upload URL.
920 EXPECT_EQ(upload_url.path(), http_request_.relative_url); 924 EXPECT_EQ(upload_url.path(), http_request_.relative_url);
921 // Content-Range header should be added. 925 // Content-Range header should be added.
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
988 UPLOAD_EXISTING_FILE, 992 UPLOAD_EXISTING_FILE,
989 base::FilePath(FILE_PATH_LITERAL("drive/file/path")), 993 base::FilePath(FILE_PATH_LITERAL("drive/file/path")),
990 upload_url, 994 upload_url,
991 0, // start_position 995 0, // start_position
992 kTestContent.size(), // end_position (exclusive) 996 kTestContent.size(), // end_position (exclusive)
993 kTestContent.size(), // content_length, 997 kTestContent.size(), // content_length,
994 kTestContentType, 998 kTestContentType,
995 buffer, 999 buffer,
996 CreateComposedCallback( 1000 CreateComposedCallback(
997 base::Bind(&test_util::RunAndQuit), 1001 base::Bind(&test_util::RunAndQuit),
998 test_util::CreateCopyResultCallback(&response, &new_entry))); 1002 test_util::CreateCopyResultCallback(&response, &new_entry)),
1003 ProgressCallback());
999 resume_operation->Start( 1004 resume_operation->Start(
1000 kTestDriveApiAuthToken, kTestUserAgent, 1005 kTestDriveApiAuthToken, kTestUserAgent,
1001 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); 1006 base::Bind(&test_util::DoNothingForReAuthenticateCallback));
1002 MessageLoop::current()->Run(); 1007 MessageLoop::current()->Run();
1003 1008
1004 // METHOD_PUT should be used to upload data. 1009 // METHOD_PUT should be used to upload data.
1005 EXPECT_EQ(test_server::METHOD_PUT, http_request_.method); 1010 EXPECT_EQ(test_server::METHOD_PUT, http_request_.method);
1006 // Request should go to the upload URL. 1011 // Request should go to the upload URL.
1007 EXPECT_EQ(upload_url.path(), http_request_.relative_url); 1012 EXPECT_EQ(upload_url.path(), http_request_.relative_url);
1008 // Content-Range header should be added. 1013 // Content-Range header should be added.
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1056 EXPECT_EQ("Conflicting-etag", http_request_.headers["If-Match"]); 1061 EXPECT_EQ("Conflicting-etag", http_request_.headers["If-Match"]);
1057 1062
1058 EXPECT_EQ(test_server::METHOD_PUT, http_request_.method); 1063 EXPECT_EQ(test_server::METHOD_PUT, http_request_.method);
1059 EXPECT_EQ("/upload/drive/v2/files/resource_id?uploadType=resumable", 1064 EXPECT_EQ("/upload/drive/v2/files/resource_id?uploadType=resumable",
1060 http_request_.relative_url); 1065 http_request_.relative_url);
1061 EXPECT_TRUE(http_request_.has_content); 1066 EXPECT_TRUE(http_request_.has_content);
1062 EXPECT_TRUE(http_request_.content.empty()); 1067 EXPECT_TRUE(http_request_.content.empty());
1063 } 1068 }
1064 1069
1065 } // namespace google_apis 1070 } // namespace google_apis
OLDNEW
« no previous file with comments | « chrome/browser/google_apis/drive_api_operations.cc ('k') | chrome/browser/google_apis/drive_api_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698