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

Unified Diff: chrome/browser/google_apis/drive_uploader_unittest.cc

Issue 12207075: Split InitiateUpload method into two. (Closed) Base URL: http://git.chromium.org/chromium/src.git@b148632_extract_initiate_upload_operation_base
Patch Set: Rebase Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/google_apis/drive_uploader.cc ('k') | chrome/browser/google_apis/dummy_drive_service.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/google_apis/drive_uploader_unittest.cc
diff --git a/chrome/browser/google_apis/drive_uploader_unittest.cc b/chrome/browser/google_apis/drive_uploader_unittest.cc
index c57bae30f3b249aabc71f4a0276b1b4609c669a7..2737c4c3746ce090361201f7cb36a4f0cb887f67 100644
--- a/chrome/browser/google_apis/drive_uploader_unittest.cc
+++ b/chrome/browser/google_apis/drive_uploader_unittest.cc
@@ -67,20 +67,38 @@ class MockDriveServiceWithUploadExpectation : public DummyDriveService {
private:
// DriveServiceInterface overrides.
// Handles a request for obtaining an upload location URL.
- virtual void InitiateUpload(const InitiateUploadParams& params,
- const InitiateUploadCallback& callback) OVERRIDE {
+ virtual void InitiateUploadNewFile(
+ const FilePath& drive_file_path,
+ const std::string& content_type,
+ int64 content_length,
+ const GURL& parent_upload_url,
+ const std::string& title,
+ const InitiateUploadCallback& callback) OVERRIDE {
+ EXPECT_EQ(kTestDocumentTitle, title);
+ EXPECT_EQ(kTestMimeType, content_type);
const int64 expected_size = expected_upload_content_.size();
+ EXPECT_EQ(expected_size, content_length);
+ EXPECT_EQ(GURL(kTestInitialUploadURL), parent_upload_url);
- // Verify that the expected parameters are passed.
- if (params.upload_mode == UPLOAD_NEW_FILE)
- EXPECT_EQ(kTestDocumentTitle, params.title);
- else
- EXPECT_EQ("", params.title);
- EXPECT_EQ(kTestMimeType, params.content_type);
- EXPECT_EQ(expected_size, params.content_length);
- EXPECT_EQ(GURL(kTestInitialUploadURL), params.upload_location);
+ // Calls back the upload URL for subsequent ResumeUpload operations.
+ // InitiateUpload is an asynchronous function, so don't callback directly.
+ MessageLoop::current()->PostTask(FROM_HERE,
+ base::Bind(callback, HTTP_SUCCESS, GURL(kTestUploadURL)));
+ }
+
+ virtual void InitiateUploadExistingFile(
+ const FilePath& drive_file_path,
+ const std::string& content_type,
+ int64 content_length,
+ const GURL& upload_url,
+ const std::string& etag,
+ const InitiateUploadCallback& callback) OVERRIDE {
+ EXPECT_EQ(kTestMimeType, content_type);
+ const int64 expected_size = expected_upload_content_.size();
+ EXPECT_EQ(expected_size, content_length);
+ EXPECT_EQ(GURL(kTestInitialUploadURL), upload_url);
- if (!params.etag.empty() && params.etag != kTestETag) {
+ if (!etag.empty() && etag != kTestETag) {
MessageLoop::current()->PostTask(FROM_HERE,
base::Bind(callback, HTTP_PRECONDITION, GURL()));
return;
@@ -152,8 +170,24 @@ class MockDriveServiceWithUploadExpectation : public DummyDriveService {
// Mock DriveService that returns a failure at InitiateUpload().
class MockDriveServiceNoConnectionAtInitiate : public DummyDriveService {
// Returns error.
- virtual void InitiateUpload(const InitiateUploadParams& params,
- const InitiateUploadCallback& callback) OVERRIDE {
+ virtual void InitiateUploadNewFile(
+ const FilePath& drive_file_path,
+ const std::string& content_type,
+ int64 content_length,
+ const GURL& parent_upload_url,
+ const std::string& title,
+ const InitiateUploadCallback& callback) OVERRIDE {
+ MessageLoop::current()->PostTask(FROM_HERE,
+ base::Bind(callback, GDATA_NO_CONNECTION, GURL()));
+ }
+
+ virtual void InitiateUploadExistingFile(
+ const FilePath& drive_file_path,
+ const std::string& content_type,
+ int64 content_length,
+ const GURL& upload_url,
+ const std::string& etag,
+ const InitiateUploadCallback& callback) OVERRIDE {
MessageLoop::current()->PostTask(FROM_HERE,
base::Bind(callback, GDATA_NO_CONNECTION, GURL()));
}
@@ -168,8 +202,24 @@ class MockDriveServiceNoConnectionAtInitiate : public DummyDriveService {
// Mock DriveService that returns a failure at ResumeUpload().
class MockDriveServiceNoConnectionAtResume : public DummyDriveService {
// Succeeds and returns an upload location URL.
- virtual void InitiateUpload(const InitiateUploadParams& params,
- const InitiateUploadCallback& callback) OVERRIDE {
+ virtual void InitiateUploadNewFile(
+ const FilePath& drive_file_path,
+ const std::string& content_type,
+ int64 content_length,
+ const GURL& parent_upload_url,
+ const std::string& title,
+ const InitiateUploadCallback& callback) OVERRIDE {
+ MessageLoop::current()->PostTask(FROM_HERE,
+ base::Bind(callback, HTTP_SUCCESS, GURL(kTestInitialUploadURL)));
+ }
+
+ virtual void InitiateUploadExistingFile(
+ const FilePath& drive_file_path,
+ const std::string& content_type,
+ int64 content_length,
+ const GURL& upload_url,
+ const std::string& etag,
+ const InitiateUploadCallback& callback) OVERRIDE {
MessageLoop::current()->PostTask(FROM_HERE,
base::Bind(callback, HTTP_SUCCESS, GURL(kTestInitialUploadURL)));
}
« no previous file with comments | « chrome/browser/google_apis/drive_uploader.cc ('k') | chrome/browser/google_apis/dummy_drive_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698