X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fchrome%2Fbrowser%2Fchromeos%2Fdrive%2Ffile_system%2Fdownload_operation_unittest.cc;h=836d50a7d41f75174f922fc38f3ffc7e69f68258;hb=ff3e2503a20db9193d323c1d19c38c68004dec4a;hp=5aaedfcb9249f3499747a35319b07dc801733917;hpb=7338fba38ba696536d1cc9d389afd716a6ab2fe6;p=platform%2Fframework%2Fweb%2Fcrosswalk.git diff --git a/src/chrome/browser/chromeos/drive/file_system/download_operation_unittest.cc b/src/chrome/browser/chromeos/drive/file_system/download_operation_unittest.cc index 5aaedfc..836d50a 100644 --- a/src/chrome/browser/chromeos/drive/file_system/download_operation_unittest.cc +++ b/src/chrome/browser/chromeos/drive/file_system/download_operation_unittest.cc @@ -4,7 +4,6 @@ #include "chrome/browser/chromeos/drive/file_system/download_operation.h" -#include "base/callback_helpers.h" #include "base/file_util.h" #include "base/task_runner_util.h" #include "chrome/browser/chromeos/drive/fake_free_disk_space_getter.h" @@ -260,6 +259,7 @@ TEST_F(DownloadOperationTest, EnsureFileDownloadedByPath_HostedDocument) { EXPECT_EQ(GURL(entry->file_specific_info().alternate_url()), util::ReadUrlFromGDocFile(file_path)); EXPECT_EQ(entry->resource_id(), util::ReadResourceIdFromGDocFile(file_path)); + EXPECT_EQ(FILE_PATH_LITERAL(".gdoc"), file_path.Extension()); } TEST_F(DownloadOperationTest, EnsureFileDownloadedByLocalId) { @@ -427,23 +427,12 @@ TEST_F(DownloadOperationTest, EnsureFileDownloadedByPath_DirtyCache) { base::Bind(&internal::FileCache::Store, base::Unretained(cache()), GetLocalId(file_in_root), - src_entry.file_specific_info().md5(), + std::string(), dirty_file, internal::FileCache::FILE_OPERATION_COPY), google_apis::test_util::CreateCopyResultCallback(&error)); test_util::RunBlockingPoolTask(); EXPECT_EQ(FILE_ERROR_OK, error); - scoped_ptr file_closer; - base::PostTaskAndReplyWithResult( - blocking_task_runner(), - FROM_HERE, - base::Bind(&internal::FileCache::OpenForWrite, - base::Unretained(cache()), - GetLocalId(file_in_root), - &file_closer), - google_apis::test_util::CreateCopyResultCallback(&error)); - test_util::RunBlockingPoolTask(); - EXPECT_EQ(FILE_ERROR_OK, error); // Record values passed to GetFileContentInitializedCallback(). FileError init_error; @@ -469,5 +458,48 @@ TEST_F(DownloadOperationTest, EnsureFileDownloadedByPath_DirtyCache) { EXPECT_EQ(static_cast(dirty_size), entry->file_info().size()); } +TEST_F(DownloadOperationTest, EnsureFileDownloadedByPath_LocallyCreatedFile) { + // Add a new file with an empty resource ID. + base::FilePath file_path(FILE_PATH_LITERAL("drive/root/New File.txt")); + ResourceEntry parent; + ASSERT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(file_path.DirName(), &parent)); + + ResourceEntry new_file; + new_file.set_title("New File.txt"); + new_file.set_parent_local_id(parent.local_id()); + + FileError error = FILE_ERROR_FAILED; + std::string local_id; + base::PostTaskAndReplyWithResult( + blocking_task_runner(), + FROM_HERE, + base::Bind(&internal::ResourceMetadata::AddEntry, + base::Unretained(metadata()), + new_file, + &local_id), + google_apis::test_util::CreateCopyResultCallback(&error)); + test_util::RunBlockingPoolTask(); + EXPECT_EQ(FILE_ERROR_OK, error); + + // Empty cache file should be returned. + base::FilePath cache_file_path; + scoped_ptr entry; + operation_->EnsureFileDownloadedByPath( + file_path, + ClientContext(USER_INITIATED), + GetFileContentInitializedCallback(), + google_apis::GetContentCallback(), + google_apis::test_util::CreateCopyResultCallback( + &error, &cache_file_path, &entry)); + test_util::RunBlockingPoolTask(); + EXPECT_EQ(FILE_ERROR_OK, error); + + int64 cache_file_size = 0; + EXPECT_TRUE(base::GetFileSize(cache_file_path, &cache_file_size)); + EXPECT_EQ(static_cast(0), cache_file_size); + ASSERT_TRUE(entry); + EXPECT_EQ(cache_file_size, entry->file_info().size()); +} + } // namespace file_system } // namespace drive