| OLD | NEW | 
|---|
| 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 "chrome/browser/chromeos/drive/sync_client.h" | 5 #include "chrome/browser/chromeos/drive/sync_client.h" | 
| 6 | 6 | 
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" | 
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" | 
| 9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" | 
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" | 
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 128     metadata_.reset(new internal::ResourceMetadata( | 128     metadata_.reset(new internal::ResourceMetadata( | 
| 129         metadata_storage_.get(), base::MessageLoopProxy::current())); | 129         metadata_storage_.get(), base::MessageLoopProxy::current())); | 
| 130     ASSERT_EQ(FILE_ERROR_OK, metadata_->Initialize()); | 130     ASSERT_EQ(FILE_ERROR_OK, metadata_->Initialize()); | 
| 131 | 131 | 
| 132     cache_.reset(new FileCache(metadata_storage_.get(), | 132     cache_.reset(new FileCache(metadata_storage_.get(), | 
| 133                                temp_dir_.path(), | 133                                temp_dir_.path(), | 
| 134                                base::MessageLoopProxy::current().get(), | 134                                base::MessageLoopProxy::current().get(), | 
| 135                                NULL /* free_disk_space_getter */)); | 135                                NULL /* free_disk_space_getter */)); | 
| 136     ASSERT_TRUE(cache_->Initialize()); | 136     ASSERT_TRUE(cache_->Initialize()); | 
| 137 | 137 | 
|  | 138     loader_controller_.reset(new LoaderController); | 
| 138     change_list_loader_.reset(new ChangeListLoader( | 139     change_list_loader_.reset(new ChangeListLoader( | 
| 139         base::MessageLoopProxy::current().get(), | 140         base::MessageLoopProxy::current().get(), | 
| 140         metadata_.get(), | 141         metadata_.get(), | 
| 141         scheduler_.get(), | 142         scheduler_.get(), | 
| 142         drive_service_.get())); | 143         drive_service_.get(), | 
|  | 144         loader_controller_.get())); | 
| 143     ASSERT_NO_FATAL_FAILURE(SetUpTestData()); | 145     ASSERT_NO_FATAL_FAILURE(SetUpTestData()); | 
| 144 | 146 | 
| 145     sync_client_.reset(new SyncClient(base::MessageLoopProxy::current().get(), | 147     sync_client_.reset(new SyncClient(base::MessageLoopProxy::current().get(), | 
| 146                                       &observer_, | 148                                       &observer_, | 
| 147                                       scheduler_.get(), | 149                                       scheduler_.get(), | 
| 148                                       metadata_.get(), | 150                                       metadata_.get(), | 
| 149                                       cache_.get(), | 151                                       cache_.get(), | 
| 150                                       change_list_loader_.get(), | 152                                       loader_controller_.get(), | 
| 151                                       temp_dir_.path())); | 153                                       temp_dir_.path())); | 
| 152 | 154 | 
| 153     // Disable delaying so that DoSyncLoop() starts immediately. | 155     // Disable delaying so that DoSyncLoop() starts immediately. | 
| 154     sync_client_->set_delay_for_testing(base::TimeDelta::FromSeconds(0)); | 156     sync_client_->set_delay_for_testing(base::TimeDelta::FromSeconds(0)); | 
| 155   } | 157   } | 
| 156 | 158 | 
| 157   // Adds a file to the service root and |resource_ids_|. | 159   // Adds a file to the service root and |resource_ids_|. | 
| 158   void AddFileEntry(const std::string& title) { | 160   void AddFileEntry(const std::string& title) { | 
| 159     google_apis::GDataErrorCode error = google_apis::GDATA_FILE_ERROR; | 161     google_apis::GDataErrorCode error = google_apis::GDATA_FILE_ERROR; | 
| 160     scoped_ptr<google_apis::ResourceEntry> entry; | 162     scoped_ptr<google_apis::ResourceEntry> entry; | 
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 250   scoped_ptr<TestingPrefServiceSimple> pref_service_; | 252   scoped_ptr<TestingPrefServiceSimple> pref_service_; | 
| 251   scoped_ptr<test_util::FakeNetworkChangeNotifier> | 253   scoped_ptr<test_util::FakeNetworkChangeNotifier> | 
| 252       fake_network_change_notifier_; | 254       fake_network_change_notifier_; | 
| 253   scoped_ptr<SyncClientTestDriveService> drive_service_; | 255   scoped_ptr<SyncClientTestDriveService> drive_service_; | 
| 254   DummyOperationObserver observer_; | 256   DummyOperationObserver observer_; | 
| 255   scoped_ptr<JobScheduler> scheduler_; | 257   scoped_ptr<JobScheduler> scheduler_; | 
| 256   scoped_ptr<ResourceMetadataStorage, | 258   scoped_ptr<ResourceMetadataStorage, | 
| 257              test_util::DestroyHelperForTests> metadata_storage_; | 259              test_util::DestroyHelperForTests> metadata_storage_; | 
| 258   scoped_ptr<ResourceMetadata, test_util::DestroyHelperForTests> metadata_; | 260   scoped_ptr<ResourceMetadata, test_util::DestroyHelperForTests> metadata_; | 
| 259   scoped_ptr<FileCache, test_util::DestroyHelperForTests> cache_; | 261   scoped_ptr<FileCache, test_util::DestroyHelperForTests> cache_; | 
|  | 262   scoped_ptr<LoaderController> loader_controller_; | 
| 260   scoped_ptr<ChangeListLoader> change_list_loader_; | 263   scoped_ptr<ChangeListLoader> change_list_loader_; | 
| 261   scoped_ptr<SyncClient> sync_client_; | 264   scoped_ptr<SyncClient> sync_client_; | 
| 262 | 265 | 
| 263   std::map<std::string, std::string> resource_ids_;  // Name-to-id map. | 266   std::map<std::string, std::string> resource_ids_;  // Name-to-id map. | 
| 264 }; | 267 }; | 
| 265 | 268 | 
| 266 TEST_F(SyncClientTest, StartProcessingBacklog) { | 269 TEST_F(SyncClientTest, StartProcessingBacklog) { | 
| 267   sync_client_->StartProcessingBacklog(); | 270   sync_client_->StartProcessingBacklog(); | 
| 268   base::RunLoop().RunUntilIdle(); | 271   base::RunLoop().RunUntilIdle(); | 
| 269 | 272 | 
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 424   ASSERT_FALSE(drive_service_->paused_action().is_null()); | 427   ASSERT_FALSE(drive_service_->paused_action().is_null()); | 
| 425   drive_service_->paused_action().Run(); | 428   drive_service_->paused_action().Run(); | 
| 426   base::RunLoop().RunUntilIdle(); | 429   base::RunLoop().RunUntilIdle(); | 
| 427 | 430 | 
| 428   // Task should be run twice. | 431   // Task should be run twice. | 
| 429   EXPECT_EQ(2, drive_service_->download_file_count()); | 432   EXPECT_EQ(2, drive_service_->download_file_count()); | 
| 430 } | 433 } | 
| 431 | 434 | 
| 432 }  // namespace internal | 435 }  // namespace internal | 
| 433 }  // namespace drive | 436 }  // namespace drive | 
| OLD | NEW | 
|---|