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

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

Issue 13448003: Narrow the ownership of DriveUploader from DriveSystemService to DriveScheduler. (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/path_service.h" 17 #include "base/path_service.h"
18 #include "base/stringprintf.h" 18 #include "base/stringprintf.h"
19 #include "base/threading/sequenced_worker_pool.h" 19 #include "base/threading/sequenced_worker_pool.h"
20 #include "base/values.h" 20 #include "base/values.h"
21 #include "chrome/browser/chromeos/drive/drive.pb.h" 21 #include "chrome/browser/chromeos/drive/drive.pb.h"
22 #include "chrome/browser/chromeos/drive/drive_file_system_util.h" 22 #include "chrome/browser/chromeos/drive/drive_file_system_util.h"
23 #include "chrome/browser/chromeos/drive/drive_test_util.h" 23 #include "chrome/browser/chromeos/drive/drive_test_util.h"
24 #include "chrome/browser/chromeos/drive/drive_webapps_registry.h" 24 #include "chrome/browser/chromeos/drive/drive_webapps_registry.h"
25 #include "chrome/browser/chromeos/drive/fake_free_disk_space_getter.h" 25 #include "chrome/browser/chromeos/drive/fake_free_disk_space_getter.h"
26 #include "chrome/browser/chromeos/drive/file_system/remove_operation.h" 26 #include "chrome/browser/chromeos/drive/file_system/remove_operation.h"
27 #include "chrome/browser/chromeos/drive/mock_directory_change_observer.h" 27 #include "chrome/browser/chromeos/drive/mock_directory_change_observer.h"
28 #include "chrome/browser/chromeos/drive/mock_drive_cache_observer.h" 28 #include "chrome/browser/chromeos/drive/mock_drive_cache_observer.h"
29 #include "chrome/browser/google_apis/drive_api_parser.h" 29 #include "chrome/browser/google_apis/drive_api_parser.h"
30 #include "chrome/browser/google_apis/drive_uploader.h"
31 #include "chrome/browser/google_apis/fake_drive_service.h" 30 #include "chrome/browser/google_apis/fake_drive_service.h"
32 #include "chrome/browser/google_apis/test_util.h" 31 #include "chrome/browser/google_apis/test_util.h"
33 #include "chrome/common/chrome_paths.h" 32 #include "chrome/common/chrome_paths.h"
34 #include "chrome/test/base/testing_profile.h" 33 #include "chrome/test/base/testing_profile.h"
35 #include "content/public/browser/browser_thread.h" 34 #include "content/public/browser/browser_thread.h"
36 #include "content/public/test/test_browser_thread.h" 35 #include "content/public/test/test_browser_thread.h"
37 #include "testing/gmock/include/gmock/gmock.h" 36 #include "testing/gmock/include/gmock/gmock.h"
38 #include "testing/gtest/include/gtest/gtest.h" 37 #include "testing/gtest/include/gtest/gtest.h"
39 38
40 using ::testing::AnyNumber; 39 using ::testing::AnyNumber;
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 119
121 scoped_refptr<base::SequencedWorkerPool> pool = 120 scoped_refptr<base::SequencedWorkerPool> pool =
122 content::BrowserThread::GetBlockingPool(); 121 content::BrowserThread::GetBlockingPool();
123 blocking_task_runner_ = 122 blocking_task_runner_ =
124 pool->GetSequencedTaskRunner(pool->GetSequenceToken()); 123 pool->GetSequencedTaskRunner(pool->GetSequenceToken());
125 124
126 cache_.reset(new DriveCache(DriveCache::GetCacheRootPath(profile_.get()), 125 cache_.reset(new DriveCache(DriveCache::GetCacheRootPath(profile_.get()),
127 blocking_task_runner_, 126 blocking_task_runner_,
128 fake_free_disk_space_getter_.get())); 127 fake_free_disk_space_getter_.get()));
129 128
130 uploader_.reset(new google_apis::DriveUploader(fake_drive_service_.get()));
131 drive_webapps_registry_.reset(new DriveWebAppsRegistry); 129 drive_webapps_registry_.reset(new DriveWebAppsRegistry);
132 130
133 131
134 mock_cache_observer_.reset(new StrictMock<MockDriveCacheObserver>); 132 mock_cache_observer_.reset(new StrictMock<MockDriveCacheObserver>);
135 cache_->AddObserver(mock_cache_observer_.get()); 133 cache_->AddObserver(mock_cache_observer_.get());
136 134
137 mock_directory_observer_.reset(new StrictMock<MockDirectoryChangeObserver>); 135 mock_directory_observer_.reset(new StrictMock<MockDirectoryChangeObserver>);
138 136
139 cache_->RequestInitializeForTesting(); 137 cache_->RequestInitializeForTesting();
140 google_apis::test_util::RunBlockingPoolTask(); 138 google_apis::test_util::RunBlockingPoolTask();
141 139
142 SetUpResourceMetadataAndFileSystem(); 140 SetUpResourceMetadataAndFileSystem();
143 } 141 }
144 142
145 void SetUpResourceMetadataAndFileSystem() { 143 void SetUpResourceMetadataAndFileSystem() {
146 resource_metadata_.reset(new DriveResourceMetadata( 144 resource_metadata_.reset(new DriveResourceMetadata(
147 fake_drive_service_->GetRootResourceId(), 145 fake_drive_service_->GetRootResourceId(),
148 cache_->GetCacheDirectoryPath(DriveCache::CACHE_TYPE_META), 146 cache_->GetCacheDirectoryPath(DriveCache::CACHE_TYPE_META),
149 blocking_task_runner_)); 147 blocking_task_runner_));
150 148
151 file_system_.reset(new DriveFileSystem(profile_.get(), 149 file_system_.reset(new DriveFileSystem(profile_.get(),
152 cache_.get(), 150 cache_.get(),
153 fake_drive_service_.get(), 151 fake_drive_service_.get(),
154 uploader_.get(),
155 drive_webapps_registry_.get(), 152 drive_webapps_registry_.get(),
156 resource_metadata_.get(), 153 resource_metadata_.get(),
157 blocking_task_runner_)); 154 blocking_task_runner_));
158 file_system_->AddObserver(mock_directory_observer_.get()); 155 file_system_->AddObserver(mock_directory_observer_.get());
159 file_system_->Initialize(); 156 file_system_->Initialize();
160 157
161 DriveFileError error = DRIVE_FILE_ERROR_FAILED; 158 DriveFileError error = DRIVE_FILE_ERROR_FAILED;
162 resource_metadata_->Initialize( 159 resource_metadata_->Initialize(
163 google_apis::test_util::CreateCopyResultCallback(&error)); 160 google_apis::test_util::CreateCopyResultCallback(&error));
164 google_apis::test_util::RunBlockingPoolTask(); 161 google_apis::test_util::RunBlockingPoolTask();
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 EXPECT_EQ(entry_proto.resource_id(), resource_id); 440 EXPECT_EQ(entry_proto.resource_id(), resource_id);
444 } 441 }
445 442
446 MessageLoopForUI message_loop_; 443 MessageLoopForUI message_loop_;
447 // The order of the test threads is important, do not change the order. 444 // The order of the test threads is important, do not change the order.
448 // See also content/browser/browser_thread_impl.cc. 445 // See also content/browser/browser_thread_impl.cc.
449 content::TestBrowserThread ui_thread_; 446 content::TestBrowserThread ui_thread_;
450 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; 447 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_;
451 scoped_ptr<TestingProfile> profile_; 448 scoped_ptr<TestingProfile> profile_;
452 scoped_ptr<DriveCache, test_util::DestroyHelperForTests> cache_; 449 scoped_ptr<DriveCache, test_util::DestroyHelperForTests> cache_;
453 scoped_ptr<google_apis::DriveUploaderInterface> uploader_;
454 scoped_ptr<DriveFileSystem> file_system_; 450 scoped_ptr<DriveFileSystem> file_system_;
455 scoped_ptr<google_apis::FakeDriveService> fake_drive_service_; 451 scoped_ptr<google_apis::FakeDriveService> fake_drive_service_;
456 scoped_ptr<DriveWebAppsRegistry> drive_webapps_registry_; 452 scoped_ptr<DriveWebAppsRegistry> drive_webapps_registry_;
457 scoped_ptr<DriveResourceMetadata, test_util::DestroyHelperForTests> 453 scoped_ptr<DriveResourceMetadata, test_util::DestroyHelperForTests>
458 resource_metadata_; 454 resource_metadata_;
459 scoped_ptr<FakeFreeDiskSpaceGetter> fake_free_disk_space_getter_; 455 scoped_ptr<FakeFreeDiskSpaceGetter> fake_free_disk_space_getter_;
460 scoped_ptr<StrictMock<MockDriveCacheObserver> > mock_cache_observer_; 456 scoped_ptr<StrictMock<MockDriveCacheObserver> > mock_cache_observer_;
461 scoped_ptr<StrictMock<MockDirectoryChangeObserver> > mock_directory_observer_; 457 scoped_ptr<StrictMock<MockDirectoryChangeObserver> > mock_directory_observer_;
462 458
463 bool expected_success_; 459 bool expected_success_;
(...skipping 1657 matching lines...) Expand 10 before | Expand all | Expand 10 after
2121 2117
2122 // An app for foo.exe should now be found, as the registry was loaded. 2118 // An app for foo.exe should now be found, as the registry was loaded.
2123 drive_webapps_registry_->GetWebAppsForFile( 2119 drive_webapps_registry_->GetWebAppsForFile(
2124 base::FilePath(FILE_PATH_LITERAL("foo.exe")), 2120 base::FilePath(FILE_PATH_LITERAL("foo.exe")),
2125 "" /* mime_type */, 2121 "" /* mime_type */,
2126 &apps); 2122 &apps);
2127 EXPECT_EQ(1U, apps.size()); 2123 EXPECT_EQ(1U, apps.size());
2128 } 2124 }
2129 2125
2130 } // namespace drive 2126 } // 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