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

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

Issue 10640006: gdata: Stop getting GDataUploader via GDataSystemService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add OVERRIDE Created 8 years, 6 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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 } 152 }
153 153
154 } // anonymous namespace 154 } // anonymous namespace
155 155
156 class MockFreeDiskSpaceGetter : public FreeDiskSpaceGetterInterface { 156 class MockFreeDiskSpaceGetter : public FreeDiskSpaceGetterInterface {
157 public: 157 public:
158 virtual ~MockFreeDiskSpaceGetter() {} 158 virtual ~MockFreeDiskSpaceGetter() {}
159 MOCK_CONST_METHOD0(AmountOfFreeDiskSpace, int64()); 159 MOCK_CONST_METHOD0(AmountOfFreeDiskSpace, int64());
160 }; 160 };
161 161
162 class MockGDataUploader : public GDataUploaderInterface {
163 public:
164 virtual ~MockGDataUploader() {}
165 // This function is not mockable by gmock.
166 virtual int UploadFile(
167 scoped_ptr<UploadFileInfo> upload_file_info) OVERRIDE {
168 return -1;
169 }
170
171 MOCK_METHOD2(UpdateUpload, void(int upload_id,
172 content::DownloadItem* download));
173 MOCK_CONST_METHOD1(GetUploadedBytes, int64(int upload_id));
174 };
175
162 class GDataFileSystemTest : public testing::Test { 176 class GDataFileSystemTest : public testing::Test {
163 protected: 177 protected:
164 GDataFileSystemTest() 178 GDataFileSystemTest()
165 : ui_thread_(content::BrowserThread::UI, &message_loop_), 179 : ui_thread_(content::BrowserThread::UI, &message_loop_),
166 io_thread_(content::BrowserThread::IO), 180 io_thread_(content::BrowserThread::IO),
167 sequence_token_( 181 sequence_token_(
168 content::BrowserThread::GetBlockingPool()->GetSequenceToken()), 182 content::BrowserThread::GetBlockingPool()->GetSequenceToken()),
183 cache_(NULL),
169 file_system_(NULL), 184 file_system_(NULL),
170 mock_doc_service_(NULL), 185 mock_doc_service_(NULL),
171 num_callback_invocations_(0), 186 num_callback_invocations_(0),
172 expected_error_(base::PLATFORM_FILE_OK), 187 expected_error_(base::PLATFORM_FILE_OK),
173 expected_cache_state_(0), 188 expected_cache_state_(0),
174 expected_sub_dir_type_(GDataCache::CACHE_TYPE_META), 189 expected_sub_dir_type_(GDataCache::CACHE_TYPE_META),
175 expect_outgoing_symlink_(false), 190 expect_outgoing_symlink_(false),
176 root_feed_changestamp_(0) { 191 root_feed_changestamp_(0) {
177 } 192 }
178 193
(...skipping 13 matching lines...) Expand all
192 207
193 // Likewise, this will be owned by GDataFileSystem. 208 // Likewise, this will be owned by GDataFileSystem.
194 mock_free_disk_space_checker_ = new MockFreeDiskSpaceGetter; 209 mock_free_disk_space_checker_ = new MockFreeDiskSpaceGetter;
195 SetFreeDiskSpaceGetterForTesting(mock_free_disk_space_checker_); 210 SetFreeDiskSpaceGetterForTesting(mock_free_disk_space_checker_);
196 211
197 cache_ = GDataCache::CreateGDataCacheOnUIThread( 212 cache_ = GDataCache::CreateGDataCacheOnUIThread(
198 GDataCache::GetCacheRootPath(profile_.get()), 213 GDataCache::GetCacheRootPath(profile_.get()),
199 content::BrowserThread::GetBlockingPool(), 214 content::BrowserThread::GetBlockingPool(),
200 sequence_token_); 215 sequence_token_);
201 216
217 mock_uploader_.reset(new StrictMock<MockGDataUploader>);
218
202 ASSERT_FALSE(file_system_); 219 ASSERT_FALSE(file_system_);
203 file_system_ = new GDataFileSystem(profile_.get(), 220 file_system_ = new GDataFileSystem(profile_.get(),
204 cache_, 221 cache_,
205 mock_doc_service_, 222 mock_doc_service_,
223 mock_uploader_.get(),
206 sequence_token_); 224 sequence_token_);
207 225
208 mock_sync_client_.reset(new StrictMock<MockGDataSyncClient>); 226 mock_sync_client_.reset(new StrictMock<MockGDataSyncClient>);
209 cache_->AddObserver(mock_sync_client_.get()); 227 cache_->AddObserver(mock_sync_client_.get());
210 228
211 mock_directory_observer_.reset(new StrictMock<MockDirectoryChangeObserver>); 229 mock_directory_observer_.reset(new StrictMock<MockDirectoryChangeObserver>);
212 file_system_->AddObserver(mock_directory_observer_.get()); 230 file_system_->AddObserver(mock_directory_observer_.get());
213 231
214 file_system_->Initialize(); 232 file_system_->Initialize();
215 cache_->RequestInitializeOnUIThread(); 233 cache_->RequestInitializeOnUIThread();
(...skipping 1046 matching lines...) Expand 10 before | Expand all | Expand 10 after
1262 1280
1263 MessageLoopForUI message_loop_; 1281 MessageLoopForUI message_loop_;
1264 // The order of the test threads is important, do not change the order. 1282 // The order of the test threads is important, do not change the order.
1265 // See also content/browser/browser_thread_imple.cc. 1283 // See also content/browser/browser_thread_imple.cc.
1266 content::TestBrowserThread ui_thread_; 1284 content::TestBrowserThread ui_thread_;
1267 content::TestBrowserThread io_thread_; 1285 content::TestBrowserThread io_thread_;
1268 const base::SequencedWorkerPool::SequenceToken sequence_token_; 1286 const base::SequencedWorkerPool::SequenceToken sequence_token_;
1269 scoped_ptr<TestingProfile> profile_; 1287 scoped_ptr<TestingProfile> profile_;
1270 scoped_refptr<CallbackHelper> callback_helper_; 1288 scoped_refptr<CallbackHelper> callback_helper_;
1271 GDataCache* cache_; 1289 GDataCache* cache_;
1290 scoped_ptr<StrictMock<MockGDataUploader> > mock_uploader_;
1272 GDataFileSystem* file_system_; 1291 GDataFileSystem* file_system_;
1273 MockDocumentsService* mock_doc_service_; 1292 MockDocumentsService* mock_doc_service_;
1274 MockFreeDiskSpaceGetter* mock_free_disk_space_checker_; 1293 MockFreeDiskSpaceGetter* mock_free_disk_space_checker_;
1275 scoped_ptr<StrictMock<MockGDataSyncClient> > mock_sync_client_; 1294 scoped_ptr<StrictMock<MockGDataSyncClient> > mock_sync_client_;
1276 scoped_ptr<StrictMock<MockDirectoryChangeObserver> > mock_directory_observer_; 1295 scoped_ptr<StrictMock<MockDirectoryChangeObserver> > mock_directory_observer_;
1277 1296
1278 int num_callback_invocations_; 1297 int num_callback_invocations_;
1279 base::PlatformFileError expected_error_; 1298 base::PlatformFileError expected_error_;
1280 int expected_cache_state_; 1299 int expected_cache_state_;
1281 GDataCache::CacheSubDirectoryType expected_sub_dir_type_; 1300 GDataCache::CacheSubDirectoryType expected_sub_dir_type_;
(...skipping 2209 matching lines...) Expand 10 before | Expand all | Expand 10 after
3491 3510
3492 // Try to close the same file twice. 3511 // Try to close the same file twice.
3493 file_system_->CloseFile(kFileInRoot, close_file_callback); 3512 file_system_->CloseFile(kFileInRoot, close_file_callback);
3494 message_loop_.Run(); 3513 message_loop_.Run();
3495 3514
3496 // It must fail. 3515 // It must fail.
3497 EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND, callback_helper_->last_error_); 3516 EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND, callback_helper_->last_error_);
3498 } 3517 }
3499 3518
3500 } // namespace gdata 3519 } // namespace gdata
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/gdata/gdata_file_system.cc ('k') | chrome/browser/chromeos/gdata/gdata_system_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698