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

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

Issue 14118006: Change owner of DriveScheduler from DriveFileSystem to DriveSystemService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 8 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 "chrome/browser/chromeos/drive/drive_file_system.h" 5 #include "chrome/browser/chromeos/drive/drive_file_system.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/file_util.h" 11 #include "base/file_util.h"
12 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
13 #include "base/files/scoped_temp_dir.h" 13 #include "base/files/scoped_temp_dir.h"
14 #include "base/json/json_file_value_serializer.h" 14 #include "base/json/json_file_value_serializer.h"
15 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
16 #include "base/message_loop.h" 16 #include "base/message_loop.h"
17 #include "base/stringprintf.h" 17 #include "base/stringprintf.h"
18 #include "base/threading/sequenced_worker_pool.h" 18 #include "base/threading/sequenced_worker_pool.h"
19 #include "base/values.h" 19 #include "base/values.h"
20 #include "chrome/browser/chromeos/drive/drive.pb.h" 20 #include "chrome/browser/chromeos/drive/drive.pb.h"
21 #include "chrome/browser/chromeos/drive/drive_file_system_util.h" 21 #include "chrome/browser/chromeos/drive/drive_file_system_util.h"
22 #include "chrome/browser/chromeos/drive/drive_scheduler.h"
22 #include "chrome/browser/chromeos/drive/drive_test_util.h" 23 #include "chrome/browser/chromeos/drive/drive_test_util.h"
23 #include "chrome/browser/chromeos/drive/drive_webapps_registry.h" 24 #include "chrome/browser/chromeos/drive/drive_webapps_registry.h"
24 #include "chrome/browser/chromeos/drive/fake_free_disk_space_getter.h" 25 #include "chrome/browser/chromeos/drive/fake_free_disk_space_getter.h"
25 #include "chrome/browser/chromeos/drive/mock_directory_change_observer.h" 26 #include "chrome/browser/chromeos/drive/mock_directory_change_observer.h"
26 #include "chrome/browser/chromeos/drive/mock_drive_cache_observer.h" 27 #include "chrome/browser/chromeos/drive/mock_drive_cache_observer.h"
27 #include "chrome/browser/google_apis/drive_api_parser.h" 28 #include "chrome/browser/google_apis/drive_api_parser.h"
28 #include "chrome/browser/google_apis/fake_drive_service.h" 29 #include "chrome/browser/google_apis/fake_drive_service.h"
29 #include "chrome/browser/google_apis/test_util.h" 30 #include "chrome/browser/google_apis/test_util.h"
30 #include "chrome/test/base/testing_profile.h" 31 #include "chrome/test/base/testing_profile.h"
31 #include "content/public/browser/browser_thread.h" 32 #include "content/public/browser/browser_thread.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 // The fake object will be manually deleted in TearDown(). 127 // The fake object will be manually deleted in TearDown().
127 fake_drive_service_.reset(new google_apis::FakeDriveService); 128 fake_drive_service_.reset(new google_apis::FakeDriveService);
128 fake_drive_service_->LoadResourceListForWapi( 129 fake_drive_service_->LoadResourceListForWapi(
129 "chromeos/gdata/root_feed.json"); 130 "chromeos/gdata/root_feed.json");
130 fake_drive_service_->LoadAccountMetadataForWapi( 131 fake_drive_service_->LoadAccountMetadataForWapi(
131 "chromeos/gdata/account_metadata.json"); 132 "chromeos/gdata/account_metadata.json");
132 fake_drive_service_->LoadAppListForDriveApi("chromeos/drive/applist.json"); 133 fake_drive_service_->LoadAppListForDriveApi("chromeos/drive/applist.json");
133 134
134 fake_free_disk_space_getter_.reset(new FakeFreeDiskSpaceGetter); 135 fake_free_disk_space_getter_.reset(new FakeFreeDiskSpaceGetter);
135 136
137 scheduler_.reset(new DriveScheduler(profile_.get(),
138 fake_drive_service_.get()));
139
136 scoped_refptr<base::SequencedWorkerPool> pool = 140 scoped_refptr<base::SequencedWorkerPool> pool =
137 content::BrowserThread::GetBlockingPool(); 141 content::BrowserThread::GetBlockingPool();
138 blocking_task_runner_ = 142 blocking_task_runner_ =
139 pool->GetSequencedTaskRunner(pool->GetSequenceToken()); 143 pool->GetSequencedTaskRunner(pool->GetSequenceToken());
140 144
141 cache_.reset(new DriveCache(DriveCache::GetCacheRootPath(profile_.get()), 145 cache_.reset(new DriveCache(DriveCache::GetCacheRootPath(profile_.get()),
142 blocking_task_runner_, 146 blocking_task_runner_,
143 fake_free_disk_space_getter_.get())); 147 fake_free_disk_space_getter_.get()));
144 148
145 drive_webapps_registry_.reset(new DriveWebAppsRegistry); 149 drive_webapps_registry_.reset(new DriveWebAppsRegistry);
(...skipping 10 matching lines...) Expand all
156 } 160 }
157 161
158 void SetUpResourceMetadataAndFileSystem() { 162 void SetUpResourceMetadataAndFileSystem() {
159 resource_metadata_.reset(new DriveResourceMetadata( 163 resource_metadata_.reset(new DriveResourceMetadata(
160 cache_->GetCacheDirectoryPath(DriveCache::CACHE_TYPE_META), 164 cache_->GetCacheDirectoryPath(DriveCache::CACHE_TYPE_META),
161 blocking_task_runner_)); 165 blocking_task_runner_));
162 166
163 file_system_.reset(new DriveFileSystem(profile_.get(), 167 file_system_.reset(new DriveFileSystem(profile_.get(),
164 cache_.get(), 168 cache_.get(),
165 fake_drive_service_.get(), 169 fake_drive_service_.get(),
170 scheduler_.get(),
166 drive_webapps_registry_.get(), 171 drive_webapps_registry_.get(),
167 resource_metadata_.get(), 172 resource_metadata_.get(),
168 blocking_task_runner_)); 173 blocking_task_runner_));
169 file_system_->AddObserver(mock_directory_observer_.get()); 174 file_system_->AddObserver(mock_directory_observer_.get());
170 file_system_->Initialize(); 175 file_system_->Initialize();
171 176
172 DriveFileError error = DRIVE_FILE_ERROR_FAILED; 177 DriveFileError error = DRIVE_FILE_ERROR_FAILED;
173 resource_metadata_->Initialize( 178 resource_metadata_->Initialize(
174 google_apis::test_util::CreateCopyResultCallback(&error)); 179 google_apis::test_util::CreateCopyResultCallback(&error));
175 google_apis::test_util::RunBlockingPoolTask(); 180 google_apis::test_util::RunBlockingPoolTask();
176 ASSERT_EQ(DRIVE_FILE_OK, error); 181 ASSERT_EQ(DRIVE_FILE_OK, error);
177 } 182 }
178 183
179 virtual void TearDown() OVERRIDE { 184 virtual void TearDown() OVERRIDE {
180 ASSERT_TRUE(file_system_); 185 ASSERT_TRUE(file_system_);
181 file_system_.reset(); 186 file_system_.reset();
187 scheduler_.reset();
182 fake_drive_service_.reset(); 188 fake_drive_service_.reset();
183 cache_.reset(); 189 cache_.reset();
184 profile_.reset(NULL); 190 profile_.reset(NULL);
185 } 191 }
186 192
187 // Loads test json file as root ("/drive") element. 193 // Loads test json file as root ("/drive") element.
188 bool LoadRootFeedDocument() { 194 bool LoadRootFeedDocument() {
189 DriveFileError error = DRIVE_FILE_ERROR_FAILED; 195 DriveFileError error = DRIVE_FILE_ERROR_FAILED;
190 file_system_->change_list_loader()->LoadIfNeeded( 196 file_system_->change_list_loader()->LoadIfNeeded(
191 DirectoryFetchInfo(), 197 DirectoryFetchInfo(),
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 } 460 }
455 461
456 MessageLoopForUI message_loop_; 462 MessageLoopForUI message_loop_;
457 content::TestBrowserThread ui_thread_; 463 content::TestBrowserThread ui_thread_;
458 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; 464 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_;
459 scoped_ptr<TestingProfile> profile_; 465 scoped_ptr<TestingProfile> profile_;
460 466
461 scoped_ptr<DriveCache, test_util::DestroyHelperForTests> cache_; 467 scoped_ptr<DriveCache, test_util::DestroyHelperForTests> cache_;
462 scoped_ptr<DriveFileSystem> file_system_; 468 scoped_ptr<DriveFileSystem> file_system_;
463 scoped_ptr<google_apis::FakeDriveService> fake_drive_service_; 469 scoped_ptr<google_apis::FakeDriveService> fake_drive_service_;
470 scoped_ptr<DriveScheduler> scheduler_;
464 scoped_ptr<DriveWebAppsRegistry> drive_webapps_registry_; 471 scoped_ptr<DriveWebAppsRegistry> drive_webapps_registry_;
465 scoped_ptr<DriveResourceMetadata, test_util::DestroyHelperForTests> 472 scoped_ptr<DriveResourceMetadata, test_util::DestroyHelperForTests>
466 resource_metadata_; 473 resource_metadata_;
467 scoped_ptr<FakeFreeDiskSpaceGetter> fake_free_disk_space_getter_; 474 scoped_ptr<FakeFreeDiskSpaceGetter> fake_free_disk_space_getter_;
468 scoped_ptr<StrictMock<MockDriveCacheObserver> > mock_cache_observer_; 475 scoped_ptr<StrictMock<MockDriveCacheObserver> > mock_cache_observer_;
469 scoped_ptr<StrictMock<MockDirectoryChangeObserver> > mock_directory_observer_; 476 scoped_ptr<StrictMock<MockDirectoryChangeObserver> > mock_directory_observer_;
470 477
471 int root_feed_changestamp_; 478 int root_feed_changestamp_;
472 }; 479 };
473 480
(...skipping 1651 matching lines...) Expand 10 before | Expand all | Expand 10 after
2125 2132
2126 // An app for foo.exe should now be found, as the registry was loaded. 2133 // An app for foo.exe should now be found, as the registry was loaded.
2127 drive_webapps_registry_->GetWebAppsForFile( 2134 drive_webapps_registry_->GetWebAppsForFile(
2128 base::FilePath(FILE_PATH_LITERAL("foo.exe")), 2135 base::FilePath(FILE_PATH_LITERAL("foo.exe")),
2129 "" /* mime_type */, 2136 "" /* mime_type */,
2130 &apps); 2137 &apps);
2131 EXPECT_EQ(1U, apps.size()); 2138 EXPECT_EQ(1U, apps.size());
2132 } 2139 }
2133 2140
2134 } // namespace drive 2141 } // namespace drive
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/drive/drive_file_system.cc ('k') | chrome/browser/chromeos/drive/drive_scheduler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698