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

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

Issue 21790002: drive: Discard upload location when there is no uploaded contents (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix test Created 7 years, 4 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/drive/drive_uploader.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/drive/drive_uploader_unittest.cc
diff --git a/chrome/browser/drive/drive_uploader_unittest.cc b/chrome/browser/drive/drive_uploader_unittest.cc
index 83afc2827d73f049688faf8545cb5e95a0ba56af..0d8d63625bb017c1db0e2b84212e5b3ae7173fd1 100644
--- a/chrome/browser/drive/drive_uploader_unittest.cc
+++ b/chrome/browser/drive/drive_uploader_unittest.cc
@@ -286,6 +286,21 @@ class MockDriveServiceNoConnectionAtResume : public DummyDriveService {
}
};
+// Mock DriveService that returns a failure at GetUploadStatus().
+class MockDriveServiceNoConnectionAtGetUploadStatus : public DummyDriveService {
+ // Returns error.
+ virtual CancelCallback GetUploadStatus(
+ const GURL& upload_url,
+ int64 content_length,
+ const UploadRangeCallback& callback) OVERRIDE {
+ base::MessageLoop::current()->PostTask(FROM_HERE,
+ base::Bind(callback,
+ UploadRangeResponse(GDATA_NO_CONNECTION, -1, -1),
+ base::Passed(scoped_ptr<ResourceEntry>())));
+ return CancelCallback();
+ }
+};
+
class DriveUploaderTest : public testing::Test {
public:
virtual void SetUp() OVERRIDE {
@@ -477,6 +492,31 @@ TEST_F(DriveUploaderTest, ResumeUploadFail) {
EXPECT_EQ(GURL(kTestUploadExistingFileURL), upload_location);
}
+TEST_F(DriveUploaderTest, GetUploadStatusFail) {
+ base::FilePath local_path;
+ std::string data;
+ ASSERT_TRUE(test_util::CreateFileOfSpecifiedSize(
+ temp_dir_.path(), 512 * 1024, &local_path, &data));
+
+ GDataErrorCode error = HTTP_SUCCESS;
+ GURL upload_location;
+ scoped_ptr<ResourceEntry> resource_entry;
+
+ MockDriveServiceNoConnectionAtGetUploadStatus mock_service;
+ DriveUploader uploader(&mock_service,
+ base::MessageLoopProxy::current().get());
+ uploader.ResumeUploadFile(GURL(kTestUploadExistingFileURL),
+ local_path,
+ kTestMimeType,
+ test_util::CreateCopyResultCallback(
+ &error, &upload_location, &resource_entry),
+ google_apis::ProgressCallback());
+ base::RunLoop().RunUntilIdle();
+
+ EXPECT_EQ(GDATA_NO_CONNECTION, error);
+ EXPECT_TRUE(upload_location.is_empty());
+}
+
TEST_F(DriveUploaderTest, NonExistingSourceFile) {
GDataErrorCode error = GDATA_OTHER_ERROR;
GURL upload_location;
« no previous file with comments | « chrome/browser/drive/drive_uploader.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698