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

Side by Side Diff: chrome/browser/chromeos/gdata/gdata_file_system_unittest.cc

Issue 10690149: gdata: Move GDataCache::CacheEntry out of GDataCache (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: removing the existing test Created 8 years, 5 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 <errno.h> 5 #include <errno.h>
6 #include <string> 6 #include <string>
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 upload_file_info->gdata_path = gdata_path; 115 upload_file_info->gdata_path = gdata_path;
116 upload_file_info->file_path = local_file_path; 116 upload_file_info->file_path = local_file_path;
117 upload_file_info->entry.reset(document_entry); 117 upload_file_info->entry.reset(document_entry);
118 base::MessageLoopProxy::current()->PostTask(FROM_HERE, 118 base::MessageLoopProxy::current()->PostTask(FROM_HERE,
119 base::Bind(arg5, error, base::Passed(&upload_file_info))); 119 base::Bind(arg5, error, base::Passed(&upload_file_info)));
120 120
121 const int kUploadId = 123; 121 const int kUploadId = 123;
122 return kUploadId; 122 return kUploadId;
123 } 123 }
124 124
125 // Converts |cache_state| to a GDataCache::CacheEntry. 125 // Converts |cache_state| to a GDataCacheEntry.
126 GDataCache::CacheEntry ToCacheEntry(int cache_state) { 126 GDataCacheEntry ToCacheEntry(int cache_state) {
127 return GDataCache::CacheEntry("dummy_md5", cache_state); 127 return GDataCacheEntry("dummy_md5", cache_state);
128 } 128 }
129 129
130 } // namespace 130 } // namespace
131 131
132 class MockFreeDiskSpaceGetter : public FreeDiskSpaceGetterInterface { 132 class MockFreeDiskSpaceGetter : public FreeDiskSpaceGetterInterface {
133 public: 133 public:
134 virtual ~MockFreeDiskSpaceGetter() {} 134 virtual ~MockFreeDiskSpaceGetter() {}
135 MOCK_CONST_METHOD0(AmountOfFreeDiskSpace, int64()); 135 MOCK_CONST_METHOD0(AmountOfFreeDiskSpace, int64());
136 }; 136 };
137 137
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 413
414 FilePath GetCacheFilePath(const std::string& resource_id, 414 FilePath GetCacheFilePath(const std::string& resource_id,
415 const std::string& md5, 415 const std::string& md5,
416 GDataCache::CacheSubDirectoryType sub_dir_type, 416 GDataCache::CacheSubDirectoryType sub_dir_type,
417 GDataCache::CachedFileOrigin file_origin) { 417 GDataCache::CachedFileOrigin file_origin) {
418 return cache_->GetCacheFilePath(resource_id, md5, sub_dir_type, 418 return cache_->GetCacheFilePath(resource_id, md5, sub_dir_type,
419 file_origin); 419 file_origin);
420 } 420 }
421 421
422 // Helper function to call GetCacheEntry from origin thread. 422 // Helper function to call GetCacheEntry from origin thread.
423 scoped_ptr<GDataCache::CacheEntry> GetCacheEntryFromOriginThread( 423 scoped_ptr<GDataCacheEntry> GetCacheEntryFromOriginThread(
424 const std::string& resource_id, 424 const std::string& resource_id,
425 const std::string& md5) { 425 const std::string& md5) {
426 scoped_ptr<GDataCache::CacheEntry> cache_entry; 426 scoped_ptr<GDataCacheEntry> cache_entry;
427 content::BrowserThread::GetBlockingPool() 427 content::BrowserThread::GetBlockingPool()
428 ->GetSequencedTaskRunner(sequence_token_)->PostTask( 428 ->GetSequencedTaskRunner(sequence_token_)->PostTask(
429 FROM_HERE, 429 FROM_HERE,
430 base::Bind( 430 base::Bind(
431 &GDataFileSystemTest::GetCacheEntryFromOriginThreadInternal, 431 &GDataFileSystemTest::GetCacheEntryFromOriginThreadInternal,
432 base::Unretained(this), 432 base::Unretained(this),
433 resource_id, 433 resource_id,
434 md5, 434 md5,
435 &cache_entry)); 435 &cache_entry));
436 test_util::RunBlockingPoolTask(); 436 test_util::RunBlockingPoolTask();
437 return cache_entry.Pass(); 437 return cache_entry.Pass();
438 } 438 }
439 439
440 // Used to implement GetCacheEntry. 440 // Used to implement GetCacheEntry.
441 void GetCacheEntryFromOriginThreadInternal( 441 void GetCacheEntryFromOriginThreadInternal(
442 const std::string& resource_id, 442 const std::string& resource_id,
443 const std::string& md5, 443 const std::string& md5,
444 scoped_ptr<GDataCache::CacheEntry>* cache_entry) { 444 scoped_ptr<GDataCacheEntry>* cache_entry) {
445 cache_entry->reset(cache_->GetCacheEntry(resource_id, md5).release()); 445 cache_entry->reset(cache_->GetCacheEntry(resource_id, md5).release());
446 } 446 }
447 447
448 // Returns true if the cache entry exists for the given resource ID and MD5. 448 // Returns true if the cache entry exists for the given resource ID and MD5.
449 bool CacheEntryExists(const std::string& resource_id, 449 bool CacheEntryExists(const std::string& resource_id,
450 const std::string& md5) { 450 const std::string& md5) {
451 return GetCacheEntryFromOriginThread(resource_id, md5).get(); 451 return GetCacheEntryFromOriginThread(resource_id, md5).get();
452 } 452 }
453 453
454 // Returns true if the cache file exists for the given resource ID and MD5. 454 // Returns true if the cache file exists for the given resource ID and MD5.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 } 495 }
496 496
497 void VerifyRemoveFromCache(base::PlatformFileError error, 497 void VerifyRemoveFromCache(base::PlatformFileError error,
498 const std::string& resource_id, 498 const std::string& resource_id,
499 const std::string& md5) { 499 const std::string& md5) {
500 ++num_callback_invocations_; 500 ++num_callback_invocations_;
501 501
502 EXPECT_EQ(expected_error_, error); 502 EXPECT_EQ(expected_error_, error);
503 503
504 // Verify cache map. 504 // Verify cache map.
505 scoped_ptr<GDataCache::CacheEntry> cache_entry = 505 scoped_ptr<GDataCacheEntry> cache_entry =
506 GetCacheEntryFromOriginThread(resource_id, md5); 506 GetCacheEntryFromOriginThread(resource_id, md5);
507 if (cache_entry.get()) 507 if (cache_entry.get())
508 EXPECT_TRUE(cache_entry->IsDirty()); 508 EXPECT_TRUE(cache_entry->IsDirty());
509 509
510 // If entry doesn't exist, verify that: 510 // If entry doesn't exist, verify that:
511 // - no files with "<resource_id>.* exists in persistent and tmp dirs 511 // - no files with "<resource_id>.* exists in persistent and tmp dirs
512 // - no "<resource_id>" symlink exists in pinned and outgoing dirs. 512 // - no "<resource_id>" symlink exists in pinned and outgoing dirs.
513 std::vector<PathToVerify> paths_to_verify; 513 std::vector<PathToVerify> paths_to_verify;
514 paths_to_verify.push_back( // Index 0: CACHE_TYPE_TMP. 514 paths_to_verify.push_back( // Index 0: CACHE_TYPE_TMP.
515 PathToVerify(cache_->GetCacheFilePath(resource_id, "*", 515 PathToVerify(cache_->GetCacheFilePath(resource_id, "*",
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
664 } 664 }
665 665
666 // Verify the file identified by |resource_id| and |md5| is in the expected 666 // Verify the file identified by |resource_id| and |md5| is in the expected
667 // cache state after |OpenFile|, that is, marked dirty and has no outgoing 667 // cache state after |OpenFile|, that is, marked dirty and has no outgoing
668 // symlink, etc. 668 // symlink, etc.
669 void VerifyCacheStateAfterOpenFile(base::PlatformFileError error, 669 void VerifyCacheStateAfterOpenFile(base::PlatformFileError error,
670 const std::string& resource_id, 670 const std::string& resource_id,
671 const std::string& md5, 671 const std::string& md5,
672 const FilePath& cache_file_path) { 672 const FilePath& cache_file_path) {
673 expected_error_ = base::PLATFORM_FILE_OK; 673 expected_error_ = base::PLATFORM_FILE_OK;
674 expected_cache_state_ = (GDataCache::CACHE_STATE_PRESENT | 674 expected_cache_state_ = (CACHE_STATE_PRESENT |
675 GDataCache::CACHE_STATE_DIRTY | 675 CACHE_STATE_DIRTY |
676 GDataCache::CACHE_STATE_PERSISTENT); 676 CACHE_STATE_PERSISTENT);
677 expected_sub_dir_type_ = GDataCache::CACHE_TYPE_PERSISTENT; 677 expected_sub_dir_type_ = GDataCache::CACHE_TYPE_PERSISTENT;
678 expect_outgoing_symlink_ = false; 678 expect_outgoing_symlink_ = false;
679 VerifyMarkDirty(error, resource_id, md5, cache_file_path); 679 VerifyMarkDirty(error, resource_id, md5, cache_file_path);
680 } 680 }
681 681
682 // Verify the file identified by |resource_id| and |md5| is in the expected 682 // Verify the file identified by |resource_id| and |md5| is in the expected
683 // cache state after |CloseFile|, that is, marked dirty and has an outgoing 683 // cache state after |CloseFile|, that is, marked dirty and has an outgoing
684 // symlink, etc. 684 // symlink, etc.
685 void VerifyCacheStateAfterCloseFile(base::PlatformFileError error, 685 void VerifyCacheStateAfterCloseFile(base::PlatformFileError error,
686 const std::string& resource_id, 686 const std::string& resource_id,
687 const std::string& md5) { 687 const std::string& md5) {
688 expected_error_ = base::PLATFORM_FILE_OK; 688 expected_error_ = base::PLATFORM_FILE_OK;
689 expected_cache_state_ = (GDataCache::CACHE_STATE_PRESENT | 689 expected_cache_state_ = (CACHE_STATE_PRESENT |
690 GDataCache::CACHE_STATE_DIRTY | 690 CACHE_STATE_DIRTY |
691 GDataCache::CACHE_STATE_PERSISTENT); 691 CACHE_STATE_PERSISTENT);
692 expected_sub_dir_type_ = GDataCache::CACHE_TYPE_PERSISTENT; 692 expected_sub_dir_type_ = GDataCache::CACHE_TYPE_PERSISTENT;
693 expect_outgoing_symlink_ = true; 693 expect_outgoing_symlink_ = true;
694 VerifyCacheFileState(error, resource_id, md5); 694 VerifyCacheFileState(error, resource_id, md5);
695 } 695 }
696 696
697 void VerifyCacheFileState(base::PlatformFileError error, 697 void VerifyCacheFileState(base::PlatformFileError error,
698 const std::string& resource_id, 698 const std::string& resource_id,
699 const std::string& md5) { 699 const std::string& md5) {
700 ++num_callback_invocations_; 700 ++num_callback_invocations_;
701 701
702 EXPECT_EQ(expected_error_, error); 702 EXPECT_EQ(expected_error_, error);
703 703
704 // Verify cache map. 704 // Verify cache map.
705 scoped_ptr<GDataCache::CacheEntry> cache_entry = 705 scoped_ptr<GDataCacheEntry> cache_entry =
706 GetCacheEntryFromOriginThread(resource_id, md5); 706 GetCacheEntryFromOriginThread(resource_id, md5);
707 if (ToCacheEntry(expected_cache_state_).IsPresent() || 707 if (ToCacheEntry(expected_cache_state_).IsPresent() ||
708 ToCacheEntry(expected_cache_state_).IsPinned()) { 708 ToCacheEntry(expected_cache_state_).IsPinned()) {
709 ASSERT_TRUE(cache_entry.get()); 709 ASSERT_TRUE(cache_entry.get());
710 EXPECT_EQ(expected_cache_state_, cache_entry->cache_state()); 710 EXPECT_EQ(expected_cache_state_, cache_entry->cache_state());
711 EXPECT_EQ(expected_sub_dir_type_, cache_entry->GetSubDirectoryType()); 711 EXPECT_EQ(expected_sub_dir_type_,
712 GDataCache::GetSubDirectoryType(*cache_entry));
712 } else { 713 } else {
713 EXPECT_FALSE(cache_entry.get()); 714 EXPECT_FALSE(cache_entry.get());
714 } 715 }
715 716
716 // Verify actual cache file. 717 // Verify actual cache file.
717 FilePath dest_path = cache_->GetCacheFilePath( 718 FilePath dest_path = cache_->GetCacheFilePath(
718 resource_id, 719 resource_id,
719 md5, 720 md5,
720 ToCacheEntry(expected_cache_state_).IsPinned() || 721 ToCacheEntry(expected_cache_state_).IsPinned() ||
721 ToCacheEntry(expected_cache_state_).IsDirty() ? 722 ToCacheEntry(expected_cache_state_).IsDirty() ?
(...skipping 1416 matching lines...) Expand 10 before | Expand all | Expand 10 after
2138 EXPECT_CALL(*mock_free_disk_space_checker_, AmountOfFreeDiskSpace()) 2139 EXPECT_CALL(*mock_free_disk_space_checker_, AmountOfFreeDiskSpace())
2139 .WillOnce(Return(0)) 2140 .WillOnce(Return(0))
2140 .WillOnce(Return(file_size + kMinFreeSpace)) 2141 .WillOnce(Return(file_size + kMinFreeSpace))
2141 .WillOnce(Return(file_size + kMinFreeSpace)); 2142 .WillOnce(Return(file_size + kMinFreeSpace));
2142 2143
2143 // Store something in the temporary cache directory. 2144 // Store something in the temporary cache directory.
2144 TestStoreToCache("<resource_id>", 2145 TestStoreToCache("<resource_id>",
2145 "<md5>", 2146 "<md5>",
2146 GetTestFilePath("root_feed.json"), 2147 GetTestFilePath("root_feed.json"),
2147 base::PLATFORM_FILE_OK, 2148 base::PLATFORM_FILE_OK,
2148 GDataCache::CACHE_STATE_PRESENT, 2149 CACHE_STATE_PRESENT,
2149 GDataCache::CACHE_TYPE_TMP); 2150 GDataCache::CACHE_TYPE_TMP);
2150 ASSERT_TRUE(CacheEntryExists("<resource_id>", "<md5>")); 2151 ASSERT_TRUE(CacheEntryExists("<resource_id>", "<md5>"));
2151 ASSERT_TRUE(CacheFileExists("<resource_id>", "<md5>")); 2152 ASSERT_TRUE(CacheFileExists("<resource_id>", "<md5>"));
2152 2153
2153 // Before Download starts metadata from server will be fetched. 2154 // Before Download starts metadata from server will be fetched.
2154 // We will read content url from the result. 2155 // We will read content url from the result.
2155 scoped_ptr<base::Value> document(LoadJSONFile("document_to_download.json")); 2156 scoped_ptr<base::Value> document(LoadJSONFile("document_to_download.json"));
2156 SetExpectationsForGetDocumentEntry(&document, "file:2_file_resource_id"); 2157 SetExpectationsForGetDocumentEntry(&document, "file:2_file_resource_id");
2157 2158
2158 // The file is obtained with the mock DocumentsService, because of we freed 2159 // The file is obtained with the mock DocumentsService, because of we freed
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
2232 FilePath file_in_root(FILE_PATH_LITERAL("drive/File 1.txt")); 2233 FilePath file_in_root(FILE_PATH_LITERAL("drive/File 1.txt"));
2233 GDataEntry* entry = FindEntry(file_in_root); 2234 GDataEntry* entry = FindEntry(file_in_root);
2234 GDataFile* file = entry->AsGDataFile(); 2235 GDataFile* file = entry->AsGDataFile();
2235 FilePath downloaded_file = GetCachePathForFile(file); 2236 FilePath downloaded_file = GetCachePathForFile(file);
2236 2237
2237 // Store something as cached version of this file. 2238 // Store something as cached version of this file.
2238 TestStoreToCache(file->resource_id(), 2239 TestStoreToCache(file->resource_id(),
2239 file->file_md5(), 2240 file->file_md5(),
2240 GetTestFilePath("root_feed.json"), 2241 GetTestFilePath("root_feed.json"),
2241 base::PLATFORM_FILE_OK, 2242 base::PLATFORM_FILE_OK,
2242 GDataCache::CACHE_STATE_PRESENT, 2243 CACHE_STATE_PRESENT,
2243 GDataCache::CACHE_TYPE_TMP); 2244 GDataCache::CACHE_TYPE_TMP);
2244 2245
2245 // Make sure we don't fetch metadata for downloading file. 2246 // Make sure we don't fetch metadata for downloading file.
2246 EXPECT_CALL(*mock_doc_service_, GetDocumentEntry(_, _)).Times(0); 2247 EXPECT_CALL(*mock_doc_service_, GetDocumentEntry(_, _)).Times(0);
2247 2248
2248 // Make sure we don't call downloads at all. 2249 // Make sure we don't call downloads at all.
2249 EXPECT_CALL(*mock_doc_service_, 2250 EXPECT_CALL(*mock_doc_service_,
2250 DownloadFile(file_in_root, 2251 DownloadFile(file_in_root,
2251 downloaded_file, 2252 downloaded_file,
2252 GURL("https://file_content_url_changed/"), 2253 GURL("https://file_content_url_changed/"),
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
2332 FilePath file_in_root(FILE_PATH_LITERAL("drive/File 1.txt")); 2333 FilePath file_in_root(FILE_PATH_LITERAL("drive/File 1.txt"));
2333 GDataEntry* entry = FindEntry(file_in_root); 2334 GDataEntry* entry = FindEntry(file_in_root);
2334 GDataFile* file = entry->AsGDataFile(); 2335 GDataFile* file = entry->AsGDataFile();
2335 FilePath downloaded_file = GetCachePathForFile(file); 2336 FilePath downloaded_file = GetCachePathForFile(file);
2336 2337
2337 // Store something as cached version of this file. 2338 // Store something as cached version of this file.
2338 TestStoreToCache(file->resource_id(), 2339 TestStoreToCache(file->resource_id(),
2339 file->file_md5(), 2340 file->file_md5(),
2340 GetTestFilePath("root_feed.json"), 2341 GetTestFilePath("root_feed.json"),
2341 base::PLATFORM_FILE_OK, 2342 base::PLATFORM_FILE_OK,
2342 GDataCache::CACHE_STATE_PRESENT, 2343 CACHE_STATE_PRESENT,
2343 GDataCache::CACHE_TYPE_TMP); 2344 GDataCache::CACHE_TYPE_TMP);
2344 2345
2345 // The file is obtained from the cache. 2346 // The file is obtained from the cache.
2346 // Make sure we don't call downloads at all. 2347 // Make sure we don't call downloads at all.
2347 EXPECT_CALL(*mock_doc_service_, DownloadFile(_, _, _, _, _)) 2348 EXPECT_CALL(*mock_doc_service_, DownloadFile(_, _, _, _, _))
2348 .Times(0); 2349 .Times(0);
2349 2350
2350 file_system_->GetFileByResourceId(file->resource_id(), callback, 2351 file_system_->GetFileByResourceId(file->resource_id(), callback,
2351 GetDownloadDataCallback()); 2352 GetDownloadDataCallback());
2352 test_util::RunBlockingPoolTask(); 2353 test_util::RunBlockingPoolTask();
2353 2354
2354 EXPECT_EQ(REGULAR_FILE, callback_helper_->file_type_); 2355 EXPECT_EQ(REGULAR_FILE, callback_helper_->file_type_);
2355 EXPECT_EQ(downloaded_file.value(), 2356 EXPECT_EQ(downloaded_file.value(),
2356 callback_helper_->download_path_.value()); 2357 callback_helper_->download_path_.value());
2357 } 2358 }
2358 2359
2359 TEST_F(GDataFileSystemTest, UpdateFileByResourceId_PersistentFile) { 2360 TEST_F(GDataFileSystemTest, UpdateFileByResourceId_PersistentFile) {
2360 LoadRootFeedDocument("root_feed.json"); 2361 LoadRootFeedDocument("root_feed.json");
2361 2362
2362 // This is a file defined in root_feed.json. 2363 // This is a file defined in root_feed.json.
2363 const FilePath kFilePath(FILE_PATH_LITERAL("drive/File 1.txt")); 2364 const FilePath kFilePath(FILE_PATH_LITERAL("drive/File 1.txt"));
2364 const std::string kResourceId("file:2_file_resource_id"); 2365 const std::string kResourceId("file:2_file_resource_id");
2365 const std::string kMd5("3b4382ebefec6e743578c76bbd0575ce"); 2366 const std::string kMd5("3b4382ebefec6e743578c76bbd0575ce");
2366 2367
2367 // Pin the file so it'll be store in "persistent" directory. 2368 // Pin the file so it'll be store in "persistent" directory.
2368 EXPECT_CALL(*mock_sync_client_, OnCachePinned(kResourceId, kMd5)).Times(1); 2369 EXPECT_CALL(*mock_sync_client_, OnCachePinned(kResourceId, kMd5)).Times(1);
2369 TestPin(kResourceId, 2370 TestPin(kResourceId,
2370 kMd5, 2371 kMd5,
2371 base::PLATFORM_FILE_OK, 2372 base::PLATFORM_FILE_OK,
2372 GDataCache::CACHE_STATE_PINNED, 2373 CACHE_STATE_PINNED,
2373 GDataCache::CACHE_TYPE_TMP); 2374 GDataCache::CACHE_TYPE_TMP);
2374 2375
2375 // First store a file to cache. A cache file will be created at: 2376 // First store a file to cache. A cache file will be created at:
2376 // GCache/v1/persistent/<kResourceId>.<kMd5> 2377 // GCache/v1/persistent/<kResourceId>.<kMd5>
2377 const FilePath original_cache_file_path = 2378 const FilePath original_cache_file_path =
2378 GDataCache::GetCacheRootPath(profile_.get()) 2379 GDataCache::GetCacheRootPath(profile_.get())
2379 .AppendASCII("persistent") 2380 .AppendASCII("persistent")
2380 .AppendASCII(kResourceId + "." + kMd5); 2381 .AppendASCII(kResourceId + "." + kMd5);
2381 TestStoreToCache(kResourceId, 2382 TestStoreToCache(kResourceId,
2382 kMd5, 2383 kMd5,
2383 GetTestFilePath("root_feed.json"), // Anything works. 2384 GetTestFilePath("root_feed.json"), // Anything works.
2384 base::PLATFORM_FILE_OK, 2385 base::PLATFORM_FILE_OK,
2385 GDataCache::CACHE_STATE_PRESENT | 2386 CACHE_STATE_PRESENT |
2386 GDataCache::CACHE_STATE_PINNED | 2387 CACHE_STATE_PINNED |
2387 GDataCache::CACHE_STATE_PERSISTENT, 2388 CACHE_STATE_PERSISTENT,
2388 GDataCache::CACHE_TYPE_PERSISTENT); 2389 GDataCache::CACHE_TYPE_PERSISTENT);
2389 ASSERT_TRUE(file_util::PathExists(original_cache_file_path)); 2390 ASSERT_TRUE(file_util::PathExists(original_cache_file_path));
2390 2391
2391 // Add the dirty bit. The cache file will be renamed to 2392 // Add the dirty bit. The cache file will be renamed to
2392 // GCache/v1/persistent/<kResourceId>.local 2393 // GCache/v1/persistent/<kResourceId>.local
2393 TestMarkDirty(kResourceId, 2394 TestMarkDirty(kResourceId,
2394 kMd5, 2395 kMd5,
2395 base::PLATFORM_FILE_OK, 2396 base::PLATFORM_FILE_OK,
2396 GDataCache::CACHE_STATE_PRESENT | 2397 CACHE_STATE_PRESENT |
2397 GDataCache::CACHE_STATE_PINNED | 2398 CACHE_STATE_PINNED |
2398 GDataCache::CACHE_STATE_DIRTY | 2399 CACHE_STATE_DIRTY |
2399 GDataCache::CACHE_STATE_PERSISTENT, 2400 CACHE_STATE_PERSISTENT,
2400 GDataCache::CACHE_TYPE_PERSISTENT); 2401 GDataCache::CACHE_TYPE_PERSISTENT);
2401 const FilePath dirty_cache_file_path = 2402 const FilePath dirty_cache_file_path =
2402 GDataCache::GetCacheRootPath(profile_.get()) 2403 GDataCache::GetCacheRootPath(profile_.get())
2403 .AppendASCII("persistent") 2404 .AppendASCII("persistent")
2404 .AppendASCII(kResourceId + ".local"); 2405 .AppendASCII(kResourceId + ".local");
2405 ASSERT_FALSE(file_util::PathExists(original_cache_file_path)); 2406 ASSERT_FALSE(file_util::PathExists(original_cache_file_path));
2406 ASSERT_TRUE(file_util::PathExists(dirty_cache_file_path)); 2407 ASSERT_TRUE(file_util::PathExists(dirty_cache_file_path));
2407 2408
2408 // Commit the dirty bit. The cache file name remains the same 2409 // Commit the dirty bit. The cache file name remains the same
2409 // but a symlink will be created at: 2410 // but a symlink will be created at:
2410 // GCache/v1/outgoing/<kResourceId> 2411 // GCache/v1/outgoing/<kResourceId>
2411 EXPECT_CALL(*mock_sync_client_, OnCacheCommitted(kResourceId)).Times(1); 2412 EXPECT_CALL(*mock_sync_client_, OnCacheCommitted(kResourceId)).Times(1);
2412 TestCommitDirty(kResourceId, 2413 TestCommitDirty(kResourceId,
2413 kMd5, 2414 kMd5,
2414 base::PLATFORM_FILE_OK, 2415 base::PLATFORM_FILE_OK,
2415 GDataCache::CACHE_STATE_PRESENT | 2416 CACHE_STATE_PRESENT |
2416 GDataCache::CACHE_STATE_PINNED | 2417 CACHE_STATE_PINNED |
2417 GDataCache::CACHE_STATE_DIRTY | 2418 CACHE_STATE_DIRTY |
2418 GDataCache::CACHE_STATE_PERSISTENT, 2419 CACHE_STATE_PERSISTENT,
2419 GDataCache::CACHE_TYPE_PERSISTENT); 2420 GDataCache::CACHE_TYPE_PERSISTENT);
2420 const FilePath outgoing_symlink_path = 2421 const FilePath outgoing_symlink_path =
2421 GDataCache::GetCacheRootPath(profile_.get()) 2422 GDataCache::GetCacheRootPath(profile_.get())
2422 .AppendASCII("outgoing") 2423 .AppendASCII("outgoing")
2423 .AppendASCII(kResourceId); 2424 .AppendASCII(kResourceId);
2424 ASSERT_TRUE(file_util::PathExists(dirty_cache_file_path)); 2425 ASSERT_TRUE(file_util::PathExists(dirty_cache_file_path));
2425 ASSERT_TRUE(file_util::PathExists(outgoing_symlink_path)); 2426 ASSERT_TRUE(file_util::PathExists(outgoing_symlink_path));
2426 2427
2427 // Create a DocumentEntry, which is needed to mock 2428 // Create a DocumentEntry, which is needed to mock
2428 // GDataUploaderInterface::UploadExistingFile(). 2429 // GDataUploaderInterface::UploadExistingFile().
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
2631 2632
2632 // Try to close the same file twice. 2633 // Try to close the same file twice.
2633 file_system_->CloseFile(kFileInRoot, close_file_callback); 2634 file_system_->CloseFile(kFileInRoot, close_file_callback);
2634 message_loop_.Run(); 2635 message_loop_.Run();
2635 2636
2636 // It must fail. 2637 // It must fail.
2637 EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND, callback_helper_->last_error_); 2638 EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND, callback_helper_->last_error_);
2638 } 2639 }
2639 2640
2640 } // namespace gdata 2641 } // namespace gdata
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698