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

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

Issue 1124813003: [chrome/browser/chromeos/drive] Avoid use of MessageLoopProxy by use of TTRH (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/change_list_loader.h" 5 #include "chrome/browser/chromeos/drive/change_list_loader.h"
6 6
7 #include "base/callback_helpers.h" 7 #include "base/callback_helpers.h"
8 #include "base/files/scoped_temp_dir.h" 8 #include "base/files/scoped_temp_dir.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/prefs/testing_pref_service.h" 10 #include "base/prefs/testing_pref_service.h"
11 #include "base/run_loop.h" 11 #include "base/run_loop.h"
12 #include "base/single_thread_task_runner.h"
13 #include "base/thread_task_runner_handle.h"
12 #include "chrome/browser/chromeos/drive/change_list_loader_observer.h" 14 #include "chrome/browser/chromeos/drive/change_list_loader_observer.h"
13 #include "chrome/browser/chromeos/drive/file_cache.h" 15 #include "chrome/browser/chromeos/drive/file_cache.h"
14 #include "chrome/browser/chromeos/drive/file_change.h" 16 #include "chrome/browser/chromeos/drive/file_change.h"
15 #include "chrome/browser/chromeos/drive/file_system_util.h" 17 #include "chrome/browser/chromeos/drive/file_system_util.h"
16 #include "chrome/browser/chromeos/drive/job_scheduler.h" 18 #include "chrome/browser/chromeos/drive/job_scheduler.h"
17 #include "chrome/browser/chromeos/drive/resource_metadata.h" 19 #include "chrome/browser/chromeos/drive/resource_metadata.h"
18 #include "chrome/browser/chromeos/drive/test_util.h" 20 #include "chrome/browser/chromeos/drive/test_util.h"
19 #include "chrome/browser/drive/event_logger.h" 21 #include "chrome/browser/drive/event_logger.h"
20 #include "chrome/browser/drive/fake_drive_service.h" 22 #include "chrome/browser/drive/fake_drive_service.h"
21 #include "chrome/browser/drive/test_util.h" 23 #include "chrome/browser/drive/test_util.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 void SetUp() override { 73 void SetUp() override {
72 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 74 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
73 pref_service_.reset(new TestingPrefServiceSimple); 75 pref_service_.reset(new TestingPrefServiceSimple);
74 test_util::RegisterDrivePrefs(pref_service_->registry()); 76 test_util::RegisterDrivePrefs(pref_service_->registry());
75 77
76 logger_.reset(new EventLogger); 78 logger_.reset(new EventLogger);
77 79
78 drive_service_.reset(new FakeDriveService); 80 drive_service_.reset(new FakeDriveService);
79 ASSERT_TRUE(test_util::SetUpTestEntries(drive_service_.get())); 81 ASSERT_TRUE(test_util::SetUpTestEntries(drive_service_.get()));
80 82
81 scheduler_.reset(new JobScheduler(pref_service_.get(), 83 scheduler_.reset(new JobScheduler(pref_service_.get(), logger_.get(),
82 logger_.get(),
83 drive_service_.get(), 84 drive_service_.get(),
84 base::MessageLoopProxy::current().get())); 85 base::ThreadTaskRunnerHandle::Get()));
85 metadata_storage_.reset(new ResourceMetadataStorage( 86 metadata_storage_.reset(new ResourceMetadataStorage(
86 temp_dir_.path(), base::MessageLoopProxy::current().get())); 87 temp_dir_.path(), base::ThreadTaskRunnerHandle::Get()));
87 ASSERT_TRUE(metadata_storage_->Initialize()); 88 ASSERT_TRUE(metadata_storage_->Initialize());
88 89
89 cache_.reset(new FileCache(metadata_storage_.get(), 90 cache_.reset(new FileCache(metadata_storage_.get(), temp_dir_.path(),
90 temp_dir_.path(), 91 base::ThreadTaskRunnerHandle::Get(),
91 base::MessageLoopProxy::current().get(),
92 NULL /* free_disk_space_getter */)); 92 NULL /* free_disk_space_getter */));
93 ASSERT_TRUE(cache_->Initialize()); 93 ASSERT_TRUE(cache_->Initialize());
94 94
95 metadata_.reset(new ResourceMetadata( 95 metadata_.reset(new ResourceMetadata(metadata_storage_.get(), cache_.get(),
96 metadata_storage_.get(), cache_.get(), 96 base::ThreadTaskRunnerHandle::Get()));
97 base::MessageLoopProxy::current().get()));
98 ASSERT_EQ(FILE_ERROR_OK, metadata_->Initialize()); 97 ASSERT_EQ(FILE_ERROR_OK, metadata_->Initialize());
99 98
100 about_resource_loader_.reset(new AboutResourceLoader(scheduler_.get())); 99 about_resource_loader_.reset(new AboutResourceLoader(scheduler_.get()));
101 loader_controller_.reset(new LoaderController); 100 loader_controller_.reset(new LoaderController);
102 change_list_loader_.reset( 101 change_list_loader_.reset(new ChangeListLoader(
103 new ChangeListLoader(logger_.get(), 102 logger_.get(), base::ThreadTaskRunnerHandle::Get(), metadata_.get(),
104 base::MessageLoopProxy::current().get(), 103 scheduler_.get(), about_resource_loader_.get(),
105 metadata_.get(), 104 loader_controller_.get()));
satorux1 2015/05/05 16:23:23 Please keep them aligned vertically for consistenc
Pranay 2015/05/08 10:21:16 Done.
106 scheduler_.get(),
107 about_resource_loader_.get(),
108 loader_controller_.get()));
109 } 105 }
110 106
111 // Adds a new file to the root directory of the service. 107 // Adds a new file to the root directory of the service.
112 scoped_ptr<google_apis::FileResource> AddNewFile(const std::string& title) { 108 scoped_ptr<google_apis::FileResource> AddNewFile(const std::string& title) {
113 google_apis::DriveApiErrorCode error = google_apis::DRIVE_FILE_ERROR; 109 google_apis::DriveApiErrorCode error = google_apis::DRIVE_FILE_ERROR;
114 scoped_ptr<google_apis::FileResource> entry; 110 scoped_ptr<google_apis::FileResource> entry;
115 drive_service_->AddNewFile( 111 drive_service_->AddNewFile(
116 "text/plain", 112 "text/plain",
117 "content text", 113 "content text",
118 drive_service_->GetRootResourceId(), 114 drive_service_->GetRootResourceId(),
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 TEST_F(ChangeListLoaderTest, Load_LocalMetadataAvailable) { 234 TEST_F(ChangeListLoaderTest, Load_LocalMetadataAvailable) {
239 // Prepare metadata. 235 // Prepare metadata.
240 FileError error = FILE_ERROR_FAILED; 236 FileError error = FILE_ERROR_FAILED;
241 change_list_loader_->LoadIfNeeded( 237 change_list_loader_->LoadIfNeeded(
242 google_apis::test_util::CreateCopyResultCallback(&error)); 238 google_apis::test_util::CreateCopyResultCallback(&error));
243 base::RunLoop().RunUntilIdle(); 239 base::RunLoop().RunUntilIdle();
244 EXPECT_EQ(FILE_ERROR_OK, error); 240 EXPECT_EQ(FILE_ERROR_OK, error);
245 241
246 // Reset loader. 242 // Reset loader.
247 about_resource_loader_.reset(new AboutResourceLoader(scheduler_.get())); 243 about_resource_loader_.reset(new AboutResourceLoader(scheduler_.get()));
248 change_list_loader_.reset( 244 change_list_loader_.reset(new ChangeListLoader(
249 new ChangeListLoader(logger_.get(), 245 logger_.get(), base::ThreadTaskRunnerHandle::Get(), metadata_.get(),
250 base::MessageLoopProxy::current().get(), 246 scheduler_.get(), about_resource_loader_.get(),
251 metadata_.get(), 247 loader_controller_.get()));
252 scheduler_.get(),
253 about_resource_loader_.get(),
254 loader_controller_.get()));
255 248
256 // Add a file to the service. 249 // Add a file to the service.
257 scoped_ptr<google_apis::FileResource> gdata_entry = AddNewFile("New File"); 250 scoped_ptr<google_apis::FileResource> gdata_entry = AddNewFile("New File");
258 ASSERT_TRUE(gdata_entry); 251 ASSERT_TRUE(gdata_entry);
259 252
260 // Start loading. Because local metadata is available, the load results in 253 // Start loading. Because local metadata is available, the load results in
261 // returning FILE_ERROR_OK without fetching full list of resources. 254 // returning FILE_ERROR_OK without fetching full list of resources.
262 const int previous_file_list_load_count = 255 const int previous_file_list_load_count =
263 drive_service_->file_list_load_count(); 256 drive_service_->file_list_load_count();
264 TestChangeListLoaderObserver observer(change_list_loader_.get()); 257 TestChangeListLoaderObserver observer(change_list_loader_.get());
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 382
390 // Unlock the loader, this should resume the pending update. 383 // Unlock the loader, this should resume the pending update.
391 lock.reset(); 384 lock.reset();
392 base::RunLoop().RunUntilIdle(); 385 base::RunLoop().RunUntilIdle();
393 EXPECT_TRUE( 386 EXPECT_TRUE(
394 observer.changed_files().CountDirectory(util::GetDriveMyDriveRootPath())); 387 observer.changed_files().CountDirectory(util::GetDriveMyDriveRootPath()));
395 } 388 }
396 389
397 } // namespace internal 390 } // namespace internal
398 } // namespace drive 391 } // namespace drive
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/drive/change_list_loader.cc ('k') | chrome/browser/chromeos/drive/change_list_processor_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698