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

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

Issue 10692154: gdata: Remove IsCache/SetCache/ClearCache* functions from GDataCache (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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.
hashimoto 2012/07/11 11:08:04 nit: s/CAche/Cache/
satorux1 2012/07/11 19:54:42 Done.
126 GDataCache::CacheEntry ToCacheEntry(int cache_state) {
127 return GDataCache::CacheEntry("dummy_md5", cache_state);
128 }
129
125 } // anonymous namespace 130 } // anonymous namespace
hashimoto 2012/07/11 11:08:04 Could you fix this while you are at this file? s/a
satorux1 2012/07/11 19:54:42 Done.
126 131
127 class MockFreeDiskSpaceGetter : public FreeDiskSpaceGetterInterface { 132 class MockFreeDiskSpaceGetter : public FreeDiskSpaceGetterInterface {
128 public: 133 public:
129 virtual ~MockFreeDiskSpaceGetter() {} 134 virtual ~MockFreeDiskSpaceGetter() {}
130 MOCK_CONST_METHOD0(AmountOfFreeDiskSpace, int64()); 135 MOCK_CONST_METHOD0(AmountOfFreeDiskSpace, int64());
131 }; 136 };
132 137
133 class MockGDataUploader : public GDataUploaderInterface { 138 class MockGDataUploader : public GDataUploaderInterface {
134 public: 139 public:
135 virtual ~MockGDataUploader() {} 140 virtual ~MockGDataUploader() {}
(...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after
692 void VerifyCacheFileState(base::PlatformFileError error, 697 void VerifyCacheFileState(base::PlatformFileError error,
693 const std::string& resource_id, 698 const std::string& resource_id,
694 const std::string& md5) { 699 const std::string& md5) {
695 ++num_callback_invocations_; 700 ++num_callback_invocations_;
696 701
697 EXPECT_EQ(expected_error_, error); 702 EXPECT_EQ(expected_error_, error);
698 703
699 // Verify cache map. 704 // Verify cache map.
700 scoped_ptr<GDataCache::CacheEntry> cache_entry = 705 scoped_ptr<GDataCache::CacheEntry> cache_entry =
701 GetCacheEntryFromOriginThread(resource_id, md5); 706 GetCacheEntryFromOriginThread(resource_id, md5);
702 if (GDataCache::IsCachePresent(expected_cache_state_) || 707 if (ToCacheEntry(expected_cache_state_).IsPresent() ||
703 GDataCache::IsCachePinned(expected_cache_state_)) { 708 ToCacheEntry(expected_cache_state_).IsPinned()) {
704 ASSERT_TRUE(cache_entry.get()); 709 ASSERT_TRUE(cache_entry.get());
705 EXPECT_EQ(expected_cache_state_, cache_entry->cache_state); 710 EXPECT_EQ(expected_cache_state_, cache_entry->cache_state);
706 EXPECT_EQ(expected_sub_dir_type_, cache_entry->GetSubDirectoryType()); 711 EXPECT_EQ(expected_sub_dir_type_, cache_entry->GetSubDirectoryType());
707 } else { 712 } else {
708 EXPECT_FALSE(cache_entry.get()); 713 EXPECT_FALSE(cache_entry.get());
709 } 714 }
710 715
711 // Verify actual cache file. 716 // Verify actual cache file.
712 FilePath dest_path = cache_->GetCacheFilePath( 717 FilePath dest_path = cache_->GetCacheFilePath(
713 resource_id, 718 resource_id,
714 md5, 719 md5,
715 GDataCache::IsCachePinned(expected_cache_state_) || 720 ToCacheEntry(expected_cache_state_).IsPinned() ||
716 GDataCache::IsCacheDirty(expected_cache_state_) ? 721 ToCacheEntry(expected_cache_state_).IsDirty() ?
717 GDataCache::CACHE_TYPE_PERSISTENT : 722 GDataCache::CACHE_TYPE_PERSISTENT :
718 GDataCache::CACHE_TYPE_TMP, 723 GDataCache::CACHE_TYPE_TMP,
719 GDataCache::IsCacheDirty(expected_cache_state_) ? 724 ToCacheEntry(expected_cache_state_).IsDirty() ?
720 GDataCache::CACHED_FILE_LOCALLY_MODIFIED : 725 GDataCache::CACHED_FILE_LOCALLY_MODIFIED :
721 GDataCache::CACHED_FILE_FROM_SERVER); 726 GDataCache::CACHED_FILE_FROM_SERVER);
722 bool exists = file_util::PathExists(dest_path); 727 bool exists = file_util::PathExists(dest_path);
723 if (GDataCache::IsCachePresent(expected_cache_state_)) 728 if (ToCacheEntry(expected_cache_state_).IsPresent())
724 EXPECT_TRUE(exists); 729 EXPECT_TRUE(exists);
725 else 730 else
726 EXPECT_FALSE(exists); 731 EXPECT_FALSE(exists);
727 732
728 // Verify symlink in pinned dir. 733 // Verify symlink in pinned dir.
729 FilePath symlink_path = cache_->GetCacheFilePath( 734 FilePath symlink_path = cache_->GetCacheFilePath(
730 resource_id, 735 resource_id,
731 std::string(), 736 std::string(),
732 GDataCache::CACHE_TYPE_PINNED, 737 GDataCache::CACHE_TYPE_PINNED,
733 GDataCache::CACHED_FILE_FROM_SERVER); 738 GDataCache::CACHED_FILE_FROM_SERVER);
734 // Check that pin symlink exists, without deferencing to target path. 739 // Check that pin symlink exists, without deferencing to target path.
735 exists = file_util::IsLink(symlink_path); 740 exists = file_util::IsLink(symlink_path);
736 if (GDataCache::IsCachePinned(expected_cache_state_)) { 741 if (ToCacheEntry(expected_cache_state_).IsPinned()) {
737 EXPECT_TRUE(exists); 742 EXPECT_TRUE(exists);
738 FilePath target_path; 743 FilePath target_path;
739 EXPECT_TRUE(file_util::ReadSymbolicLink(symlink_path, &target_path)); 744 EXPECT_TRUE(file_util::ReadSymbolicLink(symlink_path, &target_path));
740 if (GDataCache::IsCachePresent(expected_cache_state_)) 745 if (ToCacheEntry(expected_cache_state_).IsPresent())
741 EXPECT_EQ(dest_path, target_path); 746 EXPECT_EQ(dest_path, target_path);
742 else 747 else
743 EXPECT_EQ(kSymLinkToDevNull, target_path.value()); 748 EXPECT_EQ(kSymLinkToDevNull, target_path.value());
744 } else { 749 } else {
745 EXPECT_FALSE(exists); 750 EXPECT_FALSE(exists);
746 } 751 }
747 752
748 // Verify symlink in outgoing dir. 753 // Verify symlink in outgoing dir.
749 symlink_path = cache_->GetCacheFilePath( 754 symlink_path = cache_->GetCacheFilePath(
750 resource_id, 755 resource_id,
751 std::string(), 756 std::string(),
752 GDataCache::CACHE_TYPE_OUTGOING, 757 GDataCache::CACHE_TYPE_OUTGOING,
753 GDataCache::CACHED_FILE_FROM_SERVER); 758 GDataCache::CACHED_FILE_FROM_SERVER);
754 // Check that outgoing symlink exists, without deferencing to target path. 759 // Check that outgoing symlink exists, without deferencing to target path.
755 exists = file_util::IsLink(symlink_path); 760 exists = file_util::IsLink(symlink_path);
756 if (expect_outgoing_symlink_ && 761 if (expect_outgoing_symlink_ &&
757 GDataCache::IsCacheDirty(expected_cache_state_)) { 762 ToCacheEntry(expected_cache_state_).IsDirty()) {
758 EXPECT_TRUE(exists); 763 EXPECT_TRUE(exists);
759 FilePath target_path; 764 FilePath target_path;
760 EXPECT_TRUE(file_util::ReadSymbolicLink(symlink_path, &target_path)); 765 EXPECT_TRUE(file_util::ReadSymbolicLink(symlink_path, &target_path));
761 EXPECT_TRUE(target_path.value() != kSymLinkToDevNull); 766 EXPECT_TRUE(target_path.value() != kSymLinkToDevNull);
762 if (GDataCache::IsCachePresent(expected_cache_state_)) 767 if (ToCacheEntry(expected_cache_state_).IsPresent())
763 EXPECT_EQ(dest_path, target_path); 768 EXPECT_EQ(dest_path, target_path);
764 } else { 769 } else {
765 EXPECT_FALSE(exists); 770 EXPECT_FALSE(exists);
766 } 771 }
767 } 772 }
768 773
769 void SetExpectationsForGetDocumentEntry(scoped_ptr<base::Value>* document, 774 void SetExpectationsForGetDocumentEntry(scoped_ptr<base::Value>* document,
770 const std::string& resource_id) { 775 const std::string& resource_id) {
771 EXPECT_CALL(*mock_doc_service_, GetDocumentEntry(resource_id, _)) 776 EXPECT_CALL(*mock_doc_service_, GetDocumentEntry(resource_id, _))
772 .WillOnce(MockGetDocumentEntryCallback(gdata::HTTP_SUCCESS, document)); 777 .WillOnce(MockGetDocumentEntryCallback(gdata::HTTP_SUCCESS, document));
(...skipping 1853 matching lines...) Expand 10 before | Expand all | Expand 10 after
2626 2631
2627 // Try to close the same file twice. 2632 // Try to close the same file twice.
2628 file_system_->CloseFile(kFileInRoot, close_file_callback); 2633 file_system_->CloseFile(kFileInRoot, close_file_callback);
2629 message_loop_.Run(); 2634 message_loop_.Run();
2630 2635
2631 // It must fail. 2636 // It must fail.
2632 EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND, callback_helper_->last_error_); 2637 EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND, callback_helper_->last_error_);
2633 } 2638 }
2634 2639
2635 } // namespace gdata 2640 } // namespace gdata
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698