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

Side by Side Diff: chrome/browser/chromeos/drive/stale_cache_files_remover_unittest.cc

Issue 11368002: Use DriveFileSystem::Reload() instead of reloading root feed. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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 | « no previous file | 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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 delete mock_drive_service_; 125 delete mock_drive_service_;
126 mock_drive_service_ = NULL; 126 mock_drive_service_ = NULL;
127 SetFreeDiskSpaceGetterForTesting(NULL); 127 SetFreeDiskSpaceGetterForTesting(NULL);
128 cache_->DestroyOnUIThread(); 128 cache_->DestroyOnUIThread();
129 // The cache destruction requires to post a task to the blocking pool. 129 // The cache destruction requires to post a task to the blocking pool.
130 google_apis::test_util::RunBlockingPoolTask(); 130 google_apis::test_util::RunBlockingPoolTask();
131 131
132 profile_.reset(NULL); 132 profile_.reset(NULL);
133 } 133 }
134 134
135 // Loads test json file as root ("/drive") element.
136 void LoadRootFeedDocument(const std::string& filename) {
137 test_util::LoadChangeFeed(filename,
138 file_system_,
139 0,
140 root_feed_changestamp_++);
141 }
142
143 MessageLoopForUI message_loop_; 135 MessageLoopForUI message_loop_;
144 // The order of the test threads is important, do not change the order. 136 // The order of the test threads is important, do not change the order.
145 // See also content/browser/browser_thread_impl.cc. 137 // See also content/browser/browser_thread_impl.cc.
146 content::TestBrowserThread ui_thread_; 138 content::TestBrowserThread ui_thread_;
147 content::TestBrowserThread io_thread_; 139 content::TestBrowserThread io_thread_;
148 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; 140 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_;
149 scoped_ptr<TestingProfile> profile_; 141 scoped_ptr<TestingProfile> profile_;
150 DriveCache* cache_; 142 DriveCache* cache_;
151 scoped_ptr<StrictMock<google_apis::MockDriveUploader> > mock_uploader_; 143 scoped_ptr<StrictMock<google_apis::MockDriveUploader> > mock_uploader_;
152 DriveFileSystem* file_system_; 144 DriveFileSystem* file_system_;
(...skipping 23 matching lines...) Expand all
176 google_apis::test_util::RunBlockingPoolTask(); 168 google_apis::test_util::RunBlockingPoolTask();
177 169
178 // Verify that the cache file exists. 170 // Verify that the cache file exists.
179 FilePath path = cache_->GetCacheFilePath(resource_id, 171 FilePath path = cache_->GetCacheFilePath(resource_id,
180 md5, 172 md5,
181 DriveCache::CACHE_TYPE_TMP, 173 DriveCache::CACHE_TYPE_TMP,
182 DriveCache::CACHED_FILE_FROM_SERVER); 174 DriveCache::CACHED_FILE_FROM_SERVER);
183 EXPECT_TRUE(file_util::PathExists(path)); 175 EXPECT_TRUE(file_util::PathExists(path));
184 176
185 // Verify that the corresponding file entry doesn't exist. 177 // Verify that the corresponding file entry doesn't exist.
186 EXPECT_CALL(*mock_drive_service_, GetAccountMetadata(_)).Times(1); 178 EXPECT_CALL(*mock_drive_service_, GetAccountMetadata(_)).Times(2);
187 EXPECT_CALL(*mock_drive_service_, GetDocuments(Eq(GURL()), _, "", _, _)) 179 EXPECT_CALL(*mock_drive_service_, GetDocuments(Eq(GURL()), _, "", _, _))
188 .Times(1); 180 .Times(2);
189 EXPECT_CALL(*mock_webapps_registry_, UpdateFromFeed(_)).Times(1); 181 EXPECT_CALL(*mock_webapps_registry_, UpdateFromFeed(_)).Times(1);
190 182
191 DriveFileError error(DRIVE_FILE_OK); 183 DriveFileError error(DRIVE_FILE_OK);
192 FilePath unused; 184 FilePath unused;
193 scoped_ptr<DriveEntryProto> entry_proto; 185 scoped_ptr<DriveEntryProto> entry_proto;
194 file_system_->GetEntryInfoByResourceId( 186 file_system_->GetEntryInfoByResourceId(
195 resource_id, 187 resource_id,
196 base::Bind(&test_util::CopyResultsFromGetEntryInfoWithFilePathCallback, 188 base::Bind(&test_util::CopyResultsFromGetEntryInfoWithFilePathCallback,
197 &error, 189 &error,
198 &unused, 190 &unused,
199 &entry_proto)); 191 &entry_proto));
200 google_apis::test_util::RunBlockingPoolTask(); 192 google_apis::test_util::RunBlockingPoolTask();
201 EXPECT_EQ(DRIVE_FILE_ERROR_NOT_FOUND, error); 193 EXPECT_EQ(DRIVE_FILE_ERROR_NOT_FOUND, error);
202 194
203 file_system_->GetEntryInfoByPath( 195 file_system_->GetEntryInfoByPath(
204 path, 196 path,
205 base::Bind(&test_util::CopyResultsFromGetEntryInfoCallback, 197 base::Bind(&test_util::CopyResultsFromGetEntryInfoCallback,
206 &error, 198 &error,
207 &entry_proto)); 199 &entry_proto));
208 google_apis::test_util::RunBlockingPoolTask(); 200 google_apis::test_util::RunBlockingPoolTask();
209 EXPECT_EQ(DRIVE_FILE_ERROR_NOT_FOUND, error); 201 EXPECT_EQ(DRIVE_FILE_ERROR_NOT_FOUND, error);
210 EXPECT_FALSE(entry_proto.get()); 202 EXPECT_FALSE(entry_proto.get());
211 203
212 // Load a root feed. 204 // Load a root feed again to kick the StaleCacheFilesRemover.
213 LoadRootFeedDocument("gdata/root_feed.json"); 205 file_system_->Reload();
214 206
215 // Wait for StaleCacheFilesRemover to finish cleaning up the stale file. 207 // Wait for StaleCacheFilesRemover to finish cleaning up the stale file.
216 google_apis::test_util::RunBlockingPoolTask(); 208 google_apis::test_util::RunBlockingPoolTask();
217 209
218 // Verify that the cache file is deleted. 210 // Verify that the cache file is deleted.
219 path = cache_->GetCacheFilePath(resource_id, 211 path = cache_->GetCacheFilePath(resource_id,
220 md5, 212 md5,
221 DriveCache::CACHE_TYPE_TMP, 213 DriveCache::CACHE_TYPE_TMP,
222 DriveCache::CACHED_FILE_FROM_SERVER); 214 DriveCache::CACHED_FILE_FROM_SERVER);
223 EXPECT_FALSE(file_util::PathExists(path)); 215 EXPECT_FALSE(file_util::PathExists(path));
224 } 216 }
225 217
226 } // namespace drive 218 } // namespace drive
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698