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

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

Issue 10823285: Reland http://codereview.chromium.org/10831279/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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
« no previous file with comments | « chrome/browser/chromeos/gdata/gdata_cache_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <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 1224 matching lines...) Expand 10 before | Expand all | Expand 10 after
1235 mock_doc_service_->set_account_metadata( 1235 mock_doc_service_->set_account_metadata(
1236 LoadJSONFile("account_metadata.json")); 1236 LoadJSONFile("account_metadata.json"));
1237 EXPECT_CALL(*mock_doc_service_, GetAccountMetadata(_)).Times(1); 1237 EXPECT_CALL(*mock_doc_service_, GetAccountMetadata(_)).Times(1);
1238 EXPECT_CALL(*mock_webapps_registry_, UpdateFromFeed(NotNull())).Times(1); 1238 EXPECT_CALL(*mock_webapps_registry_, UpdateFromFeed(NotNull())).Times(1);
1239 1239
1240 file_system_->CheckForUpdates(); 1240 file_system_->CheckForUpdates();
1241 test_util::RunBlockingPoolTask(); 1241 test_util::RunBlockingPoolTask();
1242 } 1242 }
1243 1243
1244 TEST_F(GDataFileSystemTest, TransferFileFromLocalToRemote_RegularFile) { 1244 TEST_F(GDataFileSystemTest, TransferFileFromLocalToRemote_RegularFile) {
1245 EXPECT_CALL(*mock_free_disk_space_checker_, AmountOfFreeDiskSpace())
1246 .Times(AtLeast(1)).WillRepeatedly(Return(kLotsOfSpace));
1247
1245 LoadRootFeedDocument("root_feed.json"); 1248 LoadRootFeedDocument("root_feed.json");
1246 1249
1247 // We'll add a file to the Drive root directory. 1250 // We'll add a file to the Drive root directory.
1248 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( 1251 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged(
1249 Eq(FilePath(FILE_PATH_LITERAL("drive"))))).Times(1); 1252 Eq(FilePath(FILE_PATH_LITERAL("drive"))))).Times(1);
1250 1253
1251 FileOperationCallback callback = 1254 FileOperationCallback callback =
1252 base::Bind(&CallbackHelper::FileOperationCallback, 1255 base::Bind(&CallbackHelper::FileOperationCallback,
1253 callback_helper_.get()); 1256 callback_helper_.get());
1254 1257
(...skipping 784 matching lines...) Expand 10 before | Expand all | Expand 10 after
2039 scoped_ptr<GDataEntryProto> entry_proto(GetEntryInfoByPathSync(file_in_root)); 2042 scoped_ptr<GDataEntryProto> entry_proto(GetEntryInfoByPathSync(file_in_root));
2040 FilePath downloaded_file = GetCachePathForFile( 2043 FilePath downloaded_file = GetCachePathForFile(
2041 entry_proto->resource_id(), 2044 entry_proto->resource_id(),
2042 entry_proto->file_specific_info().file_md5()); 2045 entry_proto->file_specific_info().file_md5());
2043 const int64 file_size = entry_proto->file_info().size(); 2046 const int64 file_size = entry_proto->file_info().size();
2044 2047
2045 // Pretend we have no space first (checked before downloading a file), 2048 // Pretend we have no space first (checked before downloading a file),
2046 // but then start reporting we have space. This is to emulate that 2049 // but then start reporting we have space. This is to emulate that
2047 // the disk space was freed up by removing temporary files. 2050 // the disk space was freed up by removing temporary files.
2048 EXPECT_CALL(*mock_free_disk_space_checker_, AmountOfFreeDiskSpace()) 2051 EXPECT_CALL(*mock_free_disk_space_checker_, AmountOfFreeDiskSpace())
2052 .WillOnce(Return(file_size + kMinFreeSpace))
2049 .WillOnce(Return(0)) 2053 .WillOnce(Return(0))
2050 .WillOnce(Return(file_size + kMinFreeSpace)) 2054 .WillOnce(Return(file_size + kMinFreeSpace))
2051 .WillOnce(Return(file_size + kMinFreeSpace)); 2055 .WillOnce(Return(file_size + kMinFreeSpace));
2052 2056
2053 // Store something in the temporary cache directory. 2057 // Store something in the temporary cache directory.
2054 TestStoreToCache("<resource_id>", 2058 TestStoreToCache("<resource_id>",
2055 "<md5>", 2059 "<md5>",
2056 GetTestFilePath("root_feed.json"), 2060 GetTestFilePath("root_feed.json"),
2057 GDATA_FILE_OK, 2061 GDATA_FILE_OK,
2058 test_util::TEST_CACHE_STATE_PRESENT, 2062 test_util::TEST_CACHE_STATE_PRESENT,
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
2127 2131
2128 file_system_->GetFileByPath(file_in_root, callback, 2132 file_system_->GetFileByPath(file_in_root, callback,
2129 GetContentCallback()); 2133 GetContentCallback());
2130 test_util::RunBlockingPoolTask(); 2134 test_util::RunBlockingPoolTask();
2131 2135
2132 EXPECT_EQ(GDATA_FILE_ERROR_NO_SPACE, 2136 EXPECT_EQ(GDATA_FILE_ERROR_NO_SPACE,
2133 callback_helper_->last_error_); 2137 callback_helper_->last_error_);
2134 } 2138 }
2135 2139
2136 TEST_F(GDataFileSystemTest, GetFileByPath_FromCache) { 2140 TEST_F(GDataFileSystemTest, GetFileByPath_FromCache) {
2141 EXPECT_CALL(*mock_free_disk_space_checker_, AmountOfFreeDiskSpace())
2142 .Times(AtLeast(1)).WillRepeatedly(Return(kLotsOfSpace));
2143
2137 LoadRootFeedDocument("root_feed.json"); 2144 LoadRootFeedDocument("root_feed.json");
2138 2145
2139 GetFileCallback callback = 2146 GetFileCallback callback =
2140 base::Bind(&CallbackHelper::GetFileCallback, 2147 base::Bind(&CallbackHelper::GetFileCallback,
2141 callback_helper_.get()); 2148 callback_helper_.get());
2142 2149
2143 FilePath file_in_root(FILE_PATH_LITERAL("drive/File 1.txt")); 2150 FilePath file_in_root(FILE_PATH_LITERAL("drive/File 1.txt"));
2144 scoped_ptr<GDataEntryProto> entry_proto(GetEntryInfoByPathSync(file_in_root)); 2151 scoped_ptr<GDataEntryProto> entry_proto(GetEntryInfoByPathSync(file_in_root));
2145 FilePath downloaded_file = GetCachePathForFile( 2152 FilePath downloaded_file = GetCachePathForFile(
2146 entry_proto->resource_id(), 2153 entry_proto->resource_id(),
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
2232 callback, 2239 callback,
2233 GetContentCallback()); 2240 GetContentCallback());
2234 test_util::RunBlockingPoolTask(); 2241 test_util::RunBlockingPoolTask();
2235 2242
2236 EXPECT_EQ(REGULAR_FILE, callback_helper_->file_type_); 2243 EXPECT_EQ(REGULAR_FILE, callback_helper_->file_type_);
2237 EXPECT_EQ(downloaded_file.value(), 2244 EXPECT_EQ(downloaded_file.value(),
2238 callback_helper_->download_path_.value()); 2245 callback_helper_->download_path_.value());
2239 } 2246 }
2240 2247
2241 TEST_F(GDataFileSystemTest, GetFileByResourceId_FromCache) { 2248 TEST_F(GDataFileSystemTest, GetFileByResourceId_FromCache) {
2249 EXPECT_CALL(*mock_free_disk_space_checker_, AmountOfFreeDiskSpace())
2250 .Times(AtLeast(1)).WillRepeatedly(Return(kLotsOfSpace));
2251
2242 LoadRootFeedDocument("root_feed.json"); 2252 LoadRootFeedDocument("root_feed.json");
2243 2253
2244 GetFileCallback callback = 2254 GetFileCallback callback =
2245 base::Bind(&CallbackHelper::GetFileCallback, 2255 base::Bind(&CallbackHelper::GetFileCallback,
2246 callback_helper_.get()); 2256 callback_helper_.get());
2247 2257
2248 FilePath file_in_root(FILE_PATH_LITERAL("drive/File 1.txt")); 2258 FilePath file_in_root(FILE_PATH_LITERAL("drive/File 1.txt"));
2249 scoped_ptr<GDataEntryProto> entry_proto(GetEntryInfoByPathSync(file_in_root)); 2259 scoped_ptr<GDataEntryProto> entry_proto(GetEntryInfoByPathSync(file_in_root));
2250 FilePath downloaded_file = GetCachePathForFile( 2260 FilePath downloaded_file = GetCachePathForFile(
2251 entry_proto->resource_id(), 2261 entry_proto->resource_id(),
(...skipping 16 matching lines...) Expand all
2268 callback, 2278 callback,
2269 GetContentCallback()); 2279 GetContentCallback());
2270 test_util::RunBlockingPoolTask(); 2280 test_util::RunBlockingPoolTask();
2271 2281
2272 EXPECT_EQ(REGULAR_FILE, callback_helper_->file_type_); 2282 EXPECT_EQ(REGULAR_FILE, callback_helper_->file_type_);
2273 EXPECT_EQ(downloaded_file.value(), 2283 EXPECT_EQ(downloaded_file.value(),
2274 callback_helper_->download_path_.value()); 2284 callback_helper_->download_path_.value());
2275 } 2285 }
2276 2286
2277 TEST_F(GDataFileSystemTest, UpdateFileByResourceId_PersistentFile) { 2287 TEST_F(GDataFileSystemTest, UpdateFileByResourceId_PersistentFile) {
2288 EXPECT_CALL(*mock_free_disk_space_checker_, AmountOfFreeDiskSpace())
2289 .Times(AtLeast(1)).WillRepeatedly(Return(kLotsOfSpace));
2290
2278 LoadRootFeedDocument("root_feed.json"); 2291 LoadRootFeedDocument("root_feed.json");
2279 2292
2280 // This is a file defined in root_feed.json. 2293 // This is a file defined in root_feed.json.
2281 const FilePath kFilePath(FILE_PATH_LITERAL("drive/File 1.txt")); 2294 const FilePath kFilePath(FILE_PATH_LITERAL("drive/File 1.txt"));
2282 const std::string kResourceId("file:2_file_resource_id"); 2295 const std::string kResourceId("file:2_file_resource_id");
2283 const std::string kMd5("3b4382ebefec6e743578c76bbd0575ce"); 2296 const std::string kMd5("3b4382ebefec6e743578c76bbd0575ce");
2284 2297
2285 // Pin the file so it'll be store in "persistent" directory. 2298 // Pin the file so it'll be store in "persistent" directory.
2286 EXPECT_CALL(*mock_cache_observer_, OnCachePinned(kResourceId, kMd5)).Times(1); 2299 EXPECT_CALL(*mock_cache_observer_, OnCachePinned(kResourceId, kMd5)).Times(1);
2287 TestPin(kResourceId, 2300 TestPin(kResourceId,
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
2616 2629
2617 // Try to close the same file twice. 2630 // Try to close the same file twice.
2618 file_system_->CloseFile(kFileInRoot, close_file_callback); 2631 file_system_->CloseFile(kFileInRoot, close_file_callback);
2619 message_loop_.Run(); 2632 message_loop_.Run();
2620 2633
2621 // It must fail. 2634 // It must fail.
2622 EXPECT_EQ(GDATA_FILE_ERROR_NOT_FOUND, callback_helper_->last_error_); 2635 EXPECT_EQ(GDATA_FILE_ERROR_NOT_FOUND, callback_helper_->last_error_);
2623 } 2636 }
2624 2637
2625 } // namespace gdata 2638 } // namespace gdata
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/gdata/gdata_cache_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698