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

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

Issue 408143014: Rename OperationObserver to OperationDelegate (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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
« no previous file with comments | « chrome/browser/chromeos/drive/sync_client.cc ('k') | chrome/chrome_browser_chromeos.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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"
11 #include "base/prefs/testing_pref_service.h" 11 #include "base/prefs/testing_pref_service.h"
12 #include "base/run_loop.h" 12 #include "base/run_loop.h"
13 #include "base/test/test_timeouts.h" 13 #include "base/test/test_timeouts.h"
14 #include "chrome/browser/chromeos/drive/change_list_loader.h" 14 #include "chrome/browser/chromeos/drive/change_list_loader.h"
15 #include "chrome/browser/chromeos/drive/drive.pb.h" 15 #include "chrome/browser/chromeos/drive/drive.pb.h"
16 #include "chrome/browser/chromeos/drive/fake_free_disk_space_getter.h" 16 #include "chrome/browser/chromeos/drive/fake_free_disk_space_getter.h"
17 #include "chrome/browser/chromeos/drive/file_cache.h" 17 #include "chrome/browser/chromeos/drive/file_cache.h"
18 #include "chrome/browser/chromeos/drive/file_change.h" 18 #include "chrome/browser/chromeos/drive/file_change.h"
19 #include "chrome/browser/chromeos/drive/file_system/move_operation.h" 19 #include "chrome/browser/chromeos/drive/file_system/move_operation.h"
20 #include "chrome/browser/chromeos/drive/file_system/operation_observer.h" 20 #include "chrome/browser/chromeos/drive/file_system/operation_delegate.h"
21 #include "chrome/browser/chromeos/drive/file_system/remove_operation.h" 21 #include "chrome/browser/chromeos/drive/file_system/remove_operation.h"
22 #include "chrome/browser/chromeos/drive/file_system_util.h" 22 #include "chrome/browser/chromeos/drive/file_system_util.h"
23 #include "chrome/browser/chromeos/drive/job_scheduler.h" 23 #include "chrome/browser/chromeos/drive/job_scheduler.h"
24 #include "chrome/browser/chromeos/drive/resource_entry_conversion.h" 24 #include "chrome/browser/chromeos/drive/resource_entry_conversion.h"
25 #include "chrome/browser/chromeos/drive/resource_metadata.h" 25 #include "chrome/browser/chromeos/drive/resource_metadata.h"
26 #include "chrome/browser/chromeos/drive/test_util.h" 26 #include "chrome/browser/chromeos/drive/test_util.h"
27 #include "chrome/browser/drive/event_logger.h" 27 #include "chrome/browser/drive/event_logger.h"
28 #include "chrome/browser/drive/fake_drive_service.h" 28 #include "chrome/browser/drive/fake_drive_service.h"
29 #include "content/public/test/test_browser_thread_bundle.h" 29 #include "content/public/test/test_browser_thread_bundle.h"
30 #include "google_apis/drive/drive_api_parser.h" 30 #include "google_apis/drive/drive_api_parser.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 89
90 const base::Closure& paused_action() const { return paused_action_; } 90 const base::Closure& paused_action() const { return paused_action_; }
91 91
92 private: 92 private:
93 int download_file_count_; 93 int download_file_count_;
94 std::string resource_id_to_be_cancelled_; 94 std::string resource_id_to_be_cancelled_;
95 std::string resource_id_to_be_paused_; 95 std::string resource_id_to_be_paused_;
96 base::Closure paused_action_; 96 base::Closure paused_action_;
97 }; 97 };
98 98
99 class DummyOperationObserver : public file_system::OperationObserver {
100 // OperationObserver override:
101 virtual void OnFileChangedByOperation(
102 const FileChange& changed_files) OVERRIDE {}
103 };
104
105 } // namespace 99 } // namespace
106 100
107 class SyncClientTest : public testing::Test { 101 class SyncClientTest : public testing::Test {
108 public: 102 public:
109 virtual void SetUp() OVERRIDE { 103 virtual void SetUp() OVERRIDE {
110 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 104 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
111 105
112 pref_service_.reset(new TestingPrefServiceSimple); 106 pref_service_.reset(new TestingPrefServiceSimple);
113 test_util::RegisterDrivePrefs(pref_service_->registry()); 107 test_util::RegisterDrivePrefs(pref_service_->registry());
114 108
(...skipping 29 matching lines...) Expand all
144 change_list_loader_.reset(new ChangeListLoader( 138 change_list_loader_.reset(new ChangeListLoader(
145 logger_.get(), 139 logger_.get(),
146 base::MessageLoopProxy::current().get(), 140 base::MessageLoopProxy::current().get(),
147 metadata_.get(), 141 metadata_.get(),
148 scheduler_.get(), 142 scheduler_.get(),
149 about_resource_loader_.get(), 143 about_resource_loader_.get(),
150 loader_controller_.get())); 144 loader_controller_.get()));
151 ASSERT_NO_FATAL_FAILURE(SetUpTestData()); 145 ASSERT_NO_FATAL_FAILURE(SetUpTestData());
152 146
153 sync_client_.reset(new SyncClient(base::MessageLoopProxy::current().get(), 147 sync_client_.reset(new SyncClient(base::MessageLoopProxy::current().get(),
154 &observer_, 148 &delegate_,
155 scheduler_.get(), 149 scheduler_.get(),
156 metadata_.get(), 150 metadata_.get(),
157 cache_.get(), 151 cache_.get(),
158 loader_controller_.get(), 152 loader_controller_.get(),
159 temp_dir_.path())); 153 temp_dir_.path()));
160 154
161 // Disable delaying so that DoSyncLoop() starts immediately. 155 // Disable delaying so that DoSyncLoop() starts immediately.
162 sync_client_->set_delay_for_testing(base::TimeDelta::FromSeconds(0)); 156 sync_client_->set_delay_for_testing(base::TimeDelta::FromSeconds(0));
163 } 157 }
164 158
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 EXPECT_EQ(FILE_ERROR_OK, cache_->Pin(GetLocalId("fetched"))); 210 EXPECT_EQ(FILE_ERROR_OK, cache_->Pin(GetLocalId("fetched")));
217 211
218 // Prepare a pinned-and-fetched-and-dirty file. 212 // Prepare a pinned-and-fetched-and-dirty file.
219 EXPECT_EQ(FILE_ERROR_OK, 213 EXPECT_EQ(FILE_ERROR_OK,
220 cache_->Store(GetLocalId("dirty"), std::string(), 214 cache_->Store(GetLocalId("dirty"), std::string(),
221 temp_file, FileCache::FILE_OPERATION_COPY)); 215 temp_file, FileCache::FILE_OPERATION_COPY));
222 EXPECT_EQ(FILE_ERROR_OK, cache_->Pin(GetLocalId("dirty"))); 216 EXPECT_EQ(FILE_ERROR_OK, cache_->Pin(GetLocalId("dirty")));
223 217
224 // Prepare a removed file. 218 // Prepare a removed file.
225 file_system::RemoveOperation remove_operation( 219 file_system::RemoveOperation remove_operation(
226 base::MessageLoopProxy::current().get(), &observer_, metadata_.get(), 220 base::MessageLoopProxy::current().get(), &delegate_, metadata_.get(),
227 cache_.get()); 221 cache_.get());
228 remove_operation.Remove( 222 remove_operation.Remove(
229 util::GetDriveMyDriveRootPath().AppendASCII("removed"), 223 util::GetDriveMyDriveRootPath().AppendASCII("removed"),
230 false, // is_recursive 224 false, // is_recursive
231 google_apis::test_util::CreateCopyResultCallback(&error)); 225 google_apis::test_util::CreateCopyResultCallback(&error));
232 base::RunLoop().RunUntilIdle(); 226 base::RunLoop().RunUntilIdle();
233 EXPECT_EQ(FILE_ERROR_OK, error); 227 EXPECT_EQ(FILE_ERROR_OK, error);
234 228
235 // Prepare a moved file. 229 // Prepare a moved file.
236 file_system::MoveOperation move_operation( 230 file_system::MoveOperation move_operation(
237 base::MessageLoopProxy::current().get(), &observer_, metadata_.get()); 231 base::MessageLoopProxy::current().get(), &delegate_, metadata_.get());
238 move_operation.Move( 232 move_operation.Move(
239 util::GetDriveMyDriveRootPath().AppendASCII("moved"), 233 util::GetDriveMyDriveRootPath().AppendASCII("moved"),
240 util::GetDriveMyDriveRootPath().AppendASCII("moved_new_title"), 234 util::GetDriveMyDriveRootPath().AppendASCII("moved_new_title"),
241 google_apis::test_util::CreateCopyResultCallback(&error)); 235 google_apis::test_util::CreateCopyResultCallback(&error));
242 base::RunLoop().RunUntilIdle(); 236 base::RunLoop().RunUntilIdle();
243 EXPECT_EQ(FILE_ERROR_OK, error); 237 EXPECT_EQ(FILE_ERROR_OK, error);
244 } 238 }
245 239
246 protected: 240 protected:
247 std::string GetLocalId(const std::string& title) { 241 std::string GetLocalId(const std::string& title) {
248 EXPECT_EQ(1U, resource_ids_.count(title)); 242 EXPECT_EQ(1U, resource_ids_.count(title));
249 std::string local_id; 243 std::string local_id;
250 EXPECT_EQ(FILE_ERROR_OK, 244 EXPECT_EQ(FILE_ERROR_OK,
251 metadata_->GetIdByResourceId(resource_ids_[title], &local_id)); 245 metadata_->GetIdByResourceId(resource_ids_[title], &local_id));
252 return local_id; 246 return local_id;
253 } 247 }
254 248
255 content::TestBrowserThreadBundle thread_bundle_; 249 content::TestBrowserThreadBundle thread_bundle_;
256 base::ScopedTempDir temp_dir_; 250 base::ScopedTempDir temp_dir_;
257 scoped_ptr<TestingPrefServiceSimple> pref_service_; 251 scoped_ptr<TestingPrefServiceSimple> pref_service_;
258 scoped_ptr<test_util::FakeNetworkChangeNotifier> 252 scoped_ptr<test_util::FakeNetworkChangeNotifier>
259 fake_network_change_notifier_; 253 fake_network_change_notifier_;
260 scoped_ptr<EventLogger> logger_; 254 scoped_ptr<EventLogger> logger_;
261 scoped_ptr<SyncClientTestDriveService> drive_service_; 255 scoped_ptr<SyncClientTestDriveService> drive_service_;
262 DummyOperationObserver observer_; 256 file_system::OperationDelegate delegate_;
263 scoped_ptr<JobScheduler> scheduler_; 257 scoped_ptr<JobScheduler> scheduler_;
264 scoped_ptr<ResourceMetadataStorage, 258 scoped_ptr<ResourceMetadataStorage,
265 test_util::DestroyHelperForTests> metadata_storage_; 259 test_util::DestroyHelperForTests> metadata_storage_;
266 scoped_ptr<FileCache, test_util::DestroyHelperForTests> cache_; 260 scoped_ptr<FileCache, test_util::DestroyHelperForTests> cache_;
267 scoped_ptr<ResourceMetadata, test_util::DestroyHelperForTests> metadata_; 261 scoped_ptr<ResourceMetadata, test_util::DestroyHelperForTests> metadata_;
268 scoped_ptr<AboutResourceLoader> about_resource_loader_; 262 scoped_ptr<AboutResourceLoader> about_resource_loader_;
269 scoped_ptr<LoaderController> loader_controller_; 263 scoped_ptr<LoaderController> loader_controller_;
270 scoped_ptr<ChangeListLoader> change_list_loader_; 264 scoped_ptr<ChangeListLoader> change_list_loader_;
271 scoped_ptr<SyncClient> sync_client_; 265 scoped_ptr<SyncClient> sync_client_;
272 266
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 local_id, google_apis::test_util::CreateCopyResultCallback(&error))); 511 local_id, google_apis::test_util::CreateCopyResultCallback(&error)));
518 512
519 base::RunLoop().RunUntilIdle(); 513 base::RunLoop().RunUntilIdle();
520 514
521 // The callback is called. 515 // The callback is called.
522 EXPECT_EQ(FILE_ERROR_OK, error); 516 EXPECT_EQ(FILE_ERROR_OK, error);
523 } 517 }
524 518
525 } // namespace internal 519 } // namespace internal
526 } // namespace drive 520 } // namespace drive
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/drive/sync_client.cc ('k') | chrome/chrome_browser_chromeos.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698