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/sync_file_system/mock_remote_file_sync_service.h" | 5 #include "chrome/browser/sync_file_system/mock_remote_file_sync_service.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/message_loop_proxy.h" | 9 #include "base/message_loop_proxy.h" |
10 #include "googleurl/src/gurl.h" | 10 #include "googleurl/src/gurl.h" |
11 #include "webkit/fileapi/file_system_url.h" | 11 #include "webkit/fileapi/file_system_url.h" |
12 | 12 |
13 using ::testing::_; | 13 using ::testing::_; |
14 using ::testing::Invoke; | 14 using ::testing::Invoke; |
15 using ::testing::Return; | 15 using ::testing::Return; |
16 | 16 |
17 namespace sync_file_system { | 17 namespace sync_file_system { |
18 | 18 |
19 MockRemoteFileSyncService::MockRemoteFileSyncService() { | 19 MockRemoteFileSyncService::MockRemoteFileSyncService() { |
20 typedef MockRemoteFileSyncService self; | 20 typedef MockRemoteFileSyncService self; |
| 21 ON_CALL(*this, RegisterOriginForTrackingChanges(_, _)) |
| 22 .WillByDefault(Invoke(this, &self::RegisterOriginForTrackingChangesStub)); |
| 23 ON_CALL(*this, UnregisterOriginForTrackingChanges(_, _)) |
| 24 .WillByDefault( |
| 25 Invoke(this, &self::UnregisterOriginForTrackingChangesStub)); |
21 ON_CALL(*this, ProcessRemoteChange(_, _)) | 26 ON_CALL(*this, ProcessRemoteChange(_, _)) |
22 .WillByDefault(Invoke(this, &self::ProcessRemoteChangeStub)); | 27 .WillByDefault(Invoke(this, &self::ProcessRemoteChangeStub)); |
23 ON_CALL(*this, GetLocalChangeProcessor()) | 28 ON_CALL(*this, GetLocalChangeProcessor()) |
24 .WillByDefault(Return(local_change_processor_.get())); | 29 .WillByDefault(Return(local_change_processor_.get())); |
25 ON_CALL(*this, GetConflictFiles(_, _)) | 30 ON_CALL(*this, GetConflictFiles(_, _)) |
26 .WillByDefault(Invoke(this, &self::GetConflictFilesStub)); | 31 .WillByDefault(Invoke(this, &self::GetConflictFilesStub)); |
27 ON_CALL(*this, GetRemoteFileMetadata(_, _)) | 32 ON_CALL(*this, GetRemoteFileMetadata(_, _)) |
28 .WillByDefault(Invoke(this, &self::GetRemoteFileMetadataStub)); | 33 .WillByDefault(Invoke(this, &self::GetRemoteFileMetadataStub)); |
29 } | 34 } |
30 | 35 |
31 MockRemoteFileSyncService::~MockRemoteFileSyncService() { | 36 MockRemoteFileSyncService::~MockRemoteFileSyncService() { |
32 } | 37 } |
| 38 |
| 39 void MockRemoteFileSyncService::RegisterOriginForTrackingChangesStub( |
| 40 const GURL& origin, |
| 41 const fileapi::SyncStatusCallback& callback) { |
| 42 base::MessageLoopProxy::current()->PostTask( |
| 43 FROM_HERE, |
| 44 base::Bind(callback, fileapi::SYNC_STATUS_OK)); |
| 45 } |
| 46 |
| 47 void MockRemoteFileSyncService::UnregisterOriginForTrackingChangesStub( |
| 48 const GURL& origin, |
| 49 const fileapi::SyncStatusCallback& callback) { |
| 50 base::MessageLoopProxy::current()->PostTask( |
| 51 FROM_HERE, |
| 52 base::Bind(callback, fileapi::SYNC_STATUS_OK)); |
| 53 } |
| 54 |
33 void MockRemoteFileSyncService::ProcessRemoteChangeStub( | 55 void MockRemoteFileSyncService::ProcessRemoteChangeStub( |
34 RemoteChangeProcessor* processor, | 56 RemoteChangeProcessor* processor, |
35 const fileapi::SyncFileCallback& callback) { | 57 const fileapi::SyncFileCallback& callback) { |
36 base::MessageLoopProxy::current()->PostTask( | 58 base::MessageLoopProxy::current()->PostTask( |
37 FROM_HERE, | 59 FROM_HERE, |
38 base::Bind(callback, fileapi::SYNC_STATUS_NO_CHANGE_TO_SYNC, | 60 base::Bind(callback, fileapi::SYNC_STATUS_NO_CHANGE_TO_SYNC, |
39 fileapi::FileSystemURL())); | 61 fileapi::FileSystemURL())); |
40 } | 62 } |
41 | 63 |
42 void MockRemoteFileSyncService::GetConflictFilesStub( | 64 void MockRemoteFileSyncService::GetConflictFilesStub( |
(...skipping 16 matching lines...) Expand all Loading... |
59 FROM_HERE, | 81 FROM_HERE, |
60 base::Bind(callback, fileapi::SYNC_FILE_ERROR_NOT_FOUND, | 82 base::Bind(callback, fileapi::SYNC_FILE_ERROR_NOT_FOUND, |
61 fileapi::SyncFileMetadata())); | 83 fileapi::SyncFileMetadata())); |
62 return; | 84 return; |
63 } | 85 } |
64 base::MessageLoopProxy::current()->PostTask( | 86 base::MessageLoopProxy::current()->PostTask( |
65 FROM_HERE, base::Bind(callback, fileapi::SYNC_STATUS_OK, iter->second)); | 87 FROM_HERE, base::Bind(callback, fileapi::SYNC_STATUS_OK, iter->second)); |
66 } | 88 } |
67 | 89 |
68 } // namespace sync_file_system | 90 } // namespace sync_file_system |
OLD | NEW |