| Index: chrome/browser/drive/fake_drive_service_unittest.cc
|
| diff --git a/chrome/browser/drive/fake_drive_service_unittest.cc b/chrome/browser/drive/fake_drive_service_unittest.cc
|
| index 6d45f15eac67e9d26f4f31223a059ad541a9522c..1f220ab5311e71bc789adb7a44ff47f81155934d 100644
|
| --- a/chrome/browser/drive/fake_drive_service_unittest.cc
|
| +++ b/chrome/browser/drive/fake_drive_service_unittest.cc
|
| @@ -9,6 +9,7 @@
|
|
|
| #include "base/file_util.h"
|
| #include "base/files/scoped_temp_dir.h"
|
| +#include "base/md5.h"
|
| #include "base/run_loop.h"
|
| #include "base/stl_util.h"
|
| #include "base/strings/stringprintf.h"
|
| @@ -1636,8 +1637,7 @@ TEST_F(FakeDriveServiceTest, InitiateUpload_ExistingFile) {
|
| base::RunLoop().RunUntilIdle();
|
|
|
| EXPECT_EQ(HTTP_SUCCESS, error);
|
| - EXPECT_EQ(GURL("https://2_file_link_resumable_create_media?mode=existing"),
|
| - upload_location);
|
| + EXPECT_TRUE(upload_location.is_valid());
|
| }
|
|
|
| TEST_F(FakeDriveServiceTest, ResumeUpload_Offline) {
|
| @@ -1710,6 +1710,13 @@ TEST_F(FakeDriveServiceTest, ResumeUpload_NotFound) {
|
| }
|
|
|
| TEST_F(FakeDriveServiceTest, ResumeUpload_ExistingFile) {
|
| + base::ScopedTempDir temp_dir;
|
| + ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
|
| + base::FilePath local_file_path =
|
| + temp_dir.path().Append(FILE_PATH_LITERAL("File 1.txt"));
|
| + std::string contents("hogefugapiyo");
|
| + ASSERT_TRUE(test_util::WriteStringToFile(local_file_path, contents));
|
| +
|
| ASSERT_TRUE(fake_service_.LoadResourceListForWapi(
|
| "chromeos/gdata/root_feed.json"));
|
|
|
| @@ -1718,7 +1725,7 @@ TEST_F(FakeDriveServiceTest, ResumeUpload_ExistingFile) {
|
| fake_service_.InitiateUploadExistingFile(
|
| base::FilePath(FILE_PATH_LITERAL("drive/File 1.txt")),
|
| "text/plain",
|
| - 15,
|
| + contents.size(),
|
| "file:2_file_resource_id",
|
| "\"HhMOFgxXHit7ImBr\"",
|
| test_util::CreateCopyResultCallback(&error, &upload_location));
|
| @@ -1732,8 +1739,8 @@ TEST_F(FakeDriveServiceTest, ResumeUpload_ExistingFile) {
|
| fake_service_.ResumeUpload(
|
| base::FilePath(FILE_PATH_LITERAL("drive/File 1.txt")),
|
| upload_location,
|
| - 0, 13, 15, "text/plain",
|
| - base::FilePath(),
|
| + 0, contents.size() / 2, contents.size(), "text/plain",
|
| + local_file_path,
|
| test_util::CreateCopyResultCallback(&response, &entry),
|
| base::Bind(&test_util::AppendProgressCallbackResult,
|
| &upload_progress_values));
|
| @@ -1744,14 +1751,15 @@ TEST_F(FakeDriveServiceTest, ResumeUpload_ExistingFile) {
|
| ASSERT_TRUE(!upload_progress_values.empty());
|
| EXPECT_TRUE(base::STLIsSorted(upload_progress_values));
|
| EXPECT_LE(0, upload_progress_values.front().first);
|
| - EXPECT_GE(13, upload_progress_values.back().first);
|
| + EXPECT_GE(static_cast<int64>(contents.size() / 2),
|
| + upload_progress_values.back().first);
|
|
|
| upload_progress_values.clear();
|
| fake_service_.ResumeUpload(
|
| base::FilePath(FILE_PATH_LITERAL("drive/File 1.txt")),
|
| upload_location,
|
| - 13, 15, 15, "text/plain",
|
| - base::FilePath(),
|
| + contents.size() / 2, contents.size(), contents.size(), "text/plain",
|
| + local_file_path,
|
| test_util::CreateCopyResultCallback(&response, &entry),
|
| base::Bind(&test_util::AppendProgressCallbackResult,
|
| &upload_progress_values));
|
| @@ -1759,15 +1767,25 @@ TEST_F(FakeDriveServiceTest, ResumeUpload_ExistingFile) {
|
|
|
| EXPECT_EQ(HTTP_SUCCESS, response.code);
|
| EXPECT_TRUE(entry.get());
|
| - EXPECT_EQ(15L, entry->file_size());
|
| + EXPECT_EQ(static_cast<int64>(contents.size()),
|
| + entry->file_size());
|
| EXPECT_TRUE(Exists(entry->resource_id()));
|
| ASSERT_TRUE(!upload_progress_values.empty());
|
| EXPECT_TRUE(base::STLIsSorted(upload_progress_values));
|
| EXPECT_LE(0, upload_progress_values.front().first);
|
| - EXPECT_GE(2, upload_progress_values.back().first);
|
| + EXPECT_GE(static_cast<int64>(contents.size() - contents.size() / 2),
|
| + upload_progress_values.back().first);
|
| + EXPECT_EQ(base::MD5String(contents), entry->file_md5());
|
| }
|
|
|
| TEST_F(FakeDriveServiceTest, ResumeUpload_NewFile) {
|
| + base::ScopedTempDir temp_dir;
|
| + ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
|
| + base::FilePath local_file_path =
|
| + temp_dir.path().Append(FILE_PATH_LITERAL("new file.foo"));
|
| + std::string contents("hogefugapiyo");
|
| + ASSERT_TRUE(test_util::WriteStringToFile(local_file_path, contents));
|
| +
|
| ASSERT_TRUE(fake_service_.LoadResourceListForWapi(
|
| "chromeos/gdata/root_feed.json"));
|
|
|
| @@ -1776,7 +1794,7 @@ TEST_F(FakeDriveServiceTest, ResumeUpload_NewFile) {
|
| fake_service_.InitiateUploadNewFile(
|
| base::FilePath(FILE_PATH_LITERAL("drive/Directory 1/new file.foo")),
|
| "test/foo",
|
| - 15,
|
| + contents.size(),
|
| "folder:1_folder_resource_id",
|
| "new file.foo",
|
| test_util::CreateCopyResultCallback(&error, &upload_location));
|
| @@ -1793,8 +1811,8 @@ TEST_F(FakeDriveServiceTest, ResumeUpload_NewFile) {
|
| fake_service_.ResumeUpload(
|
| base::FilePath(FILE_PATH_LITERAL("drive/Directory 1/new file.foo")),
|
| upload_location,
|
| - 0, 13, 15, "test/foo",
|
| - base::FilePath(),
|
| + 0, contents.size() / 2, contents.size(), "test/foo",
|
| + local_file_path,
|
| test_util::CreateCopyResultCallback(&response, &entry),
|
| base::Bind(&test_util::AppendProgressCallbackResult,
|
| &upload_progress_values));
|
| @@ -1805,14 +1823,15 @@ TEST_F(FakeDriveServiceTest, ResumeUpload_NewFile) {
|
| ASSERT_TRUE(!upload_progress_values.empty());
|
| EXPECT_TRUE(base::STLIsSorted(upload_progress_values));
|
| EXPECT_LE(0, upload_progress_values.front().first);
|
| - EXPECT_GE(13, upload_progress_values.back().first);
|
| + EXPECT_GE(static_cast<int64>(contents.size() / 2),
|
| + upload_progress_values.back().first);
|
|
|
| upload_progress_values.clear();
|
| fake_service_.ResumeUpload(
|
| base::FilePath(FILE_PATH_LITERAL("drive/Directory 1/new file.foo")),
|
| upload_location,
|
| - 13, 15, 15, "test/foo",
|
| - base::FilePath(),
|
| + contents.size() / 2, contents.size(), contents.size(), "test/foo",
|
| + local_file_path,
|
| test_util::CreateCopyResultCallback(&response, &entry),
|
| base::Bind(&test_util::AppendProgressCallbackResult,
|
| &upload_progress_values));
|
| @@ -1820,12 +1839,14 @@ TEST_F(FakeDriveServiceTest, ResumeUpload_NewFile) {
|
|
|
| EXPECT_EQ(HTTP_CREATED, response.code);
|
| EXPECT_TRUE(entry.get());
|
| - EXPECT_EQ(15L, entry->file_size());
|
| + EXPECT_EQ(static_cast<int64>(contents.size()), entry->file_size());
|
| EXPECT_TRUE(Exists(entry->resource_id()));
|
| ASSERT_TRUE(!upload_progress_values.empty());
|
| EXPECT_TRUE(base::STLIsSorted(upload_progress_values));
|
| EXPECT_LE(0, upload_progress_values.front().first);
|
| - EXPECT_GE(2, upload_progress_values.back().first);
|
| + EXPECT_GE(static_cast<int64>(contents.size() - contents.size() / 2),
|
| + upload_progress_values.back().first);
|
| + EXPECT_EQ(base::MD5String(contents), entry->file_md5());
|
| }
|
|
|
| TEST_F(FakeDriveServiceTest, AddNewFile_ToRootDirectory) {
|
| @@ -1864,6 +1885,7 @@ TEST_F(FakeDriveServiceTest, AddNewFile_ToRootDirectory) {
|
| // Should be incremented as a new directory was created.
|
| EXPECT_EQ(old_largest_change_id + 1, fake_service_.largest_changestamp());
|
| EXPECT_EQ(old_largest_change_id + 1, GetLargestChangeByAboutResource());
|
| + EXPECT_EQ(base::MD5String(kContentData), resource_entry->file_md5());
|
| }
|
|
|
| TEST_F(FakeDriveServiceTest, AddNewFile_ToRootDirectoryOnEmptyFileSystem) {
|
| @@ -1902,6 +1924,7 @@ TEST_F(FakeDriveServiceTest, AddNewFile_ToRootDirectoryOnEmptyFileSystem) {
|
| // Should be incremented as a new directory was created.
|
| EXPECT_EQ(old_largest_change_id + 1, fake_service_.largest_changestamp());
|
| EXPECT_EQ(old_largest_change_id + 1, GetLargestChangeByAboutResource());
|
| + EXPECT_EQ(base::MD5String(kContentData), resource_entry->file_md5());
|
| }
|
|
|
| TEST_F(FakeDriveServiceTest, AddNewFile_ToNonRootDirectory) {
|
| @@ -1940,6 +1963,7 @@ TEST_F(FakeDriveServiceTest, AddNewFile_ToNonRootDirectory) {
|
| // Should be incremented as a new directory was created.
|
| EXPECT_EQ(old_largest_change_id + 1, fake_service_.largest_changestamp());
|
| EXPECT_EQ(old_largest_change_id + 1, GetLargestChangeByAboutResource());
|
| + EXPECT_EQ(base::MD5String(kContentData), resource_entry->file_md5());
|
| }
|
|
|
| TEST_F(FakeDriveServiceTest, AddNewFile_ToNonexistingDirectory) {
|
| @@ -2028,6 +2052,7 @@ TEST_F(FakeDriveServiceTest, AddNewFile_SharedWithMeLabel) {
|
| // Should be incremented as a new directory was created.
|
| EXPECT_EQ(old_largest_change_id + 1, fake_service_.largest_changestamp());
|
| EXPECT_EQ(old_largest_change_id + 1, GetLargestChangeByAboutResource());
|
| + EXPECT_EQ(base::MD5String(kContentData), resource_entry->file_md5());
|
| }
|
|
|
| TEST_F(FakeDriveServiceTest, SetLastModifiedTime_ExistingFile) {
|
|
|