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

Unified Diff: chrome/browser/chromeos/gdata/gdata_file_system_unittest.cc

Issue 10116044: gdata: Support mounting archive files in GData cache. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: gdata: Support mounting archive files in GData cache. Created 8 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/gdata/gdata_file_system_unittest.cc
diff --git a/chrome/browser/chromeos/gdata/gdata_file_system_unittest.cc b/chrome/browser/chromeos/gdata/gdata_file_system_unittest.cc
index 339d6a501f13a82bef6c9a81beb38225cd69dc7e..5c3d653ea3fd5dffac20713b08d7c1792ef8cd13 100644
--- a/chrome/browser/chromeos/gdata/gdata_file_system_unittest.cc
+++ b/chrome/browser/chromeos/gdata/gdata_file_system_unittest.cc
@@ -638,6 +638,42 @@ class GDataFileSystemTest : public testing::Test {
RunAllPendingForIO();
}
+ void VerifySetMountedState(const std::string& resource_id,
+ const std::string& md5,
+ bool to_mount,
+ base::PlatformFileError error,
+ const FilePath& file_path) {
+ ++num_callback_invocations_;
+ EXPECT_TRUE(file_util::PathExists(file_path));
+ EXPECT_TRUE(file_path == file_system_->GetCacheFilePath(
+ resource_id,
+ md5,
+ expected_sub_dir_type_,
+ to_mount ?
+ GDataFileSystemInterface::CACHED_FILE_MOUNTED :
+ GDataFileSystemInterface::CACHED_FILE_FROM_SERVER));
+ }
+
+ void TestSetMountedState(
+ const std::string& resource_id,
+ const std::string& md5,
+ const FilePath& file_path,
+ bool to_mount,
+ base::PlatformFileError expected_error,
+ int expected_cache_state,
+ GDataRootDirectory::CacheSubDirectoryType expected_sub_dir_type) {
+ expected_error_ = expected_error;
+ expected_cache_state_ = expected_cache_state;
+ expected_sub_dir_type_ = expected_sub_dir_type;
+ expect_outgoing_symlink_ = false;
+
+ file_system_->SetMountedState(file_path, to_mount,
+ base::Bind(&GDataFileSystemTest::VerifySetMountedState,
+ base::Unretained(this), resource_id, md5, to_mount));
+
+ RunAllPendingForIO();
+ }
+
void PrepareForInitCacheTest() {
// Create gdata cache sub directories.
ASSERT_TRUE(file_util::CreateDirectory(
@@ -3022,4 +3058,50 @@ TEST_F(GDataFileSystemTest, GetAvailableSpace) {
EXPECT_TRUE(file_util::PathExists(path));
}
+TEST_F(GDataFileSystemTest, MountUnmount) {
+ EXPECT_CALL(*mock_sync_client_, OnCacheInitialized()).Times(1);
+
+ FilePath file_path;
+ std::string resource_id("pdf:1a2b");
+ std::string md5("abcdef0123456789");
+
+ // First store a file to cache in the tmp subdir.
+ TestStoreToCache(resource_id, md5, GetTestFilePath("root_feed.json"),
+ base::PLATFORM_FILE_OK, GDataFile::CACHE_STATE_PRESENT,
+ GDataRootDirectory::CACHE_TYPE_TMP);
+
+ // Mark the file mounted.
+ num_callback_invocations_ = 0;
+ file_path = file_system_->GetCacheFilePath(
+ resource_id, md5,
+ GDataRootDirectory::CACHE_TYPE_TMP,
+ GDataFileSystemInterface::CACHED_FILE_FROM_SERVER);
+ TestSetMountedState(resource_id, md5, file_path, true,
+ base::PLATFORM_FILE_OK,
+ GDataFile::CACHE_STATE_PRESENT |
+ GDataFile::CACHE_STATE_MOUNTED,
+ GDataRootDirectory::CACHE_TYPE_PERSISTENT);
+ EXPECT_EQ(1, num_callback_invocations_);
+ EXPECT_TRUE(CacheEntryExists(resource_id, md5));
+
+ // Clear mounted state of the file.
+ num_callback_invocations_ = 0;
+ file_path = file_system_->GetCacheFilePath(
+ resource_id,
+ md5,
+ GDataRootDirectory::CACHE_TYPE_PERSISTENT,
+ GDataFileSystemInterface::CACHED_FILE_MOUNTED);
+ TestSetMountedState(resource_id, md5, file_path, false,
+ base::PLATFORM_FILE_OK,
+ GDataFile::CACHE_STATE_PRESENT,
+ GDataRootDirectory::CACHE_TYPE_TMP);
+ EXPECT_EQ(1, num_callback_invocations_);
+ EXPECT_TRUE(CacheEntryExists(resource_id, md5));
+
+ // Try to remove the file.
+ num_callback_invocations_ = 0;
+ TestRemoveFromCache(resource_id, base::PLATFORM_FILE_OK);
+ EXPECT_EQ(1, num_callback_invocations_);
+}
+
} // namespace gdata

Powered by Google App Engine
This is Rietveld 408576698