OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <string> | 5 #include <string> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 2278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2289 test_util::TEST_CACHE_STATE_DIRTY | | 2289 test_util::TEST_CACHE_STATE_DIRTY | |
2290 test_util::TEST_CACHE_STATE_PERSISTENT, | 2290 test_util::TEST_CACHE_STATE_PERSISTENT, |
2291 GDataCache::CACHE_TYPE_PERSISTENT); | 2291 GDataCache::CACHE_TYPE_PERSISTENT); |
2292 const FilePath dirty_cache_file_path = | 2292 const FilePath dirty_cache_file_path = |
2293 GDataCache::GetCacheRootPath(profile_.get()) | 2293 GDataCache::GetCacheRootPath(profile_.get()) |
2294 .AppendASCII("persistent") | 2294 .AppendASCII("persistent") |
2295 .AppendASCII(kResourceId + ".local"); | 2295 .AppendASCII(kResourceId + ".local"); |
2296 ASSERT_FALSE(file_util::PathExists(original_cache_file_path)); | 2296 ASSERT_FALSE(file_util::PathExists(original_cache_file_path)); |
2297 ASSERT_TRUE(file_util::PathExists(dirty_cache_file_path)); | 2297 ASSERT_TRUE(file_util::PathExists(dirty_cache_file_path)); |
2298 | 2298 |
| 2299 // Modify the cached file. |
| 2300 const std::string kDummyCacheContent("modification to the cache"); |
| 2301 ASSERT_TRUE(file_util::WriteFile(dirty_cache_file_path, |
| 2302 kDummyCacheContent.c_str(), |
| 2303 kDummyCacheContent.size())); |
| 2304 |
2299 // Commit the dirty bit. The cache file name remains the same | 2305 // Commit the dirty bit. The cache file name remains the same |
2300 // but a symlink will be created at: | 2306 // but a symlink will be created at: |
2301 // GCache/v1/outgoing/<kResourceId> | 2307 // GCache/v1/outgoing/<kResourceId> |
2302 EXPECT_CALL(*mock_cache_observer_, OnCacheCommitted(kResourceId)).Times(1); | 2308 EXPECT_CALL(*mock_cache_observer_, OnCacheCommitted(kResourceId)).Times(1); |
2303 TestCommitDirty(kResourceId, | 2309 TestCommitDirty(kResourceId, |
2304 kMd5, | 2310 kMd5, |
2305 GDATA_FILE_OK, | 2311 GDATA_FILE_OK, |
2306 test_util::TEST_CACHE_STATE_PRESENT | | 2312 test_util::TEST_CACHE_STATE_PRESENT | |
2307 test_util::TEST_CACHE_STATE_PINNED | | 2313 test_util::TEST_CACHE_STATE_PINNED | |
2308 test_util::TEST_CACHE_STATE_DIRTY | | 2314 test_util::TEST_CACHE_STATE_DIRTY | |
(...skipping 27 matching lines...) Expand all Loading... |
2336 } | 2342 } |
2337 } | 2343 } |
2338 } | 2344 } |
2339 ASSERT_TRUE(document_entry); | 2345 ASSERT_TRUE(document_entry); |
2340 | 2346 |
2341 // The mock uploader will be used to simulate a file upload. | 2347 // The mock uploader will be used to simulate a file upload. |
2342 EXPECT_CALL(*mock_uploader_, UploadExistingFile( | 2348 EXPECT_CALL(*mock_uploader_, UploadExistingFile( |
2343 GURL("https://file_link_resumable_edit_media/"), | 2349 GURL("https://file_link_resumable_edit_media/"), |
2344 kFilePath, | 2350 kFilePath, |
2345 dirty_cache_file_path, | 2351 dirty_cache_file_path, |
2346 892721, // The size is written in the root_feed.json. | 2352 kDummyCacheContent.size(), // The size after modification must be used. |
2347 "audio/mpeg", | 2353 "audio/mpeg", |
2348 _)) // callback | 2354 _)) // callback |
2349 .WillOnce(MockUploadExistingFile( | 2355 .WillOnce(MockUploadExistingFile( |
2350 GDATA_FILE_OK, | 2356 GDATA_FILE_OK, |
2351 FilePath::FromUTF8Unsafe("drive/File1"), | 2357 FilePath::FromUTF8Unsafe("drive/File1"), |
2352 dirty_cache_file_path, | 2358 dirty_cache_file_path, |
2353 document_entry)); | 2359 document_entry)); |
2354 | 2360 |
2355 // We'll notify the directory change to the observer upon completion. | 2361 // We'll notify the directory change to the observer upon completion. |
2356 EXPECT_CALL(*mock_directory_observer_, | 2362 EXPECT_CALL(*mock_directory_observer_, |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2550 | 2556 |
2551 // Try to close the same file twice. | 2557 // Try to close the same file twice. |
2552 file_system_->CloseFile(kFileInRoot, close_file_callback); | 2558 file_system_->CloseFile(kFileInRoot, close_file_callback); |
2553 message_loop_.Run(); | 2559 message_loop_.Run(); |
2554 | 2560 |
2555 // It must fail. | 2561 // It must fail. |
2556 EXPECT_EQ(GDATA_FILE_ERROR_NOT_FOUND, callback_helper_->last_error_); | 2562 EXPECT_EQ(GDATA_FILE_ERROR_NOT_FOUND, callback_helper_->last_error_); |
2557 } | 2563 } |
2558 | 2564 |
2559 } // namespace gdata | 2565 } // namespace gdata |
OLD | NEW |