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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_MOCK_REMOTE_FILE_SYNC_SERVICE_H_
6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_MOCK_REMOTE_FILE_SYNC_SERVICE_H_
10 #include "base/memory/scoped_ptr.h"
11 #include "base/observer_list.h"
12 #include "base/values.h"
13 #include "chrome/browser/sync_file_system/file_status_observer.h"
14 #include "chrome/browser/sync_file_system/mock_local_change_processor.h"
15 #include "chrome/browser/sync_file_system/remote_change_processor.h"
16 #include "chrome/browser/sync_file_system/remote_file_sync_service.h"
17 #include "chrome/browser/sync_file_system/sync_callbacks.h"
18 #include "chrome/browser/sync_file_system/sync_direction.h"
19 #include "chrome/browser/sync_file_system/sync_file_metadata.h"
20 #include "testing/gmock/include/gmock/gmock.h"
23 namespace sync_file_system
{
25 class MockRemoteFileSyncService
: public RemoteFileSyncService
{
27 MockRemoteFileSyncService();
28 virtual ~MockRemoteFileSyncService();
30 // RemoteFileSyncService overrides.
31 MOCK_METHOD1(AddServiceObserver
,
32 void(RemoteFileSyncService::Observer
* observer
));
33 MOCK_METHOD1(AddFileStatusObserver
,
34 void(FileStatusObserver
* observer
));
35 MOCK_METHOD2(RegisterOrigin
,
36 void(const GURL
& origin
, const SyncStatusCallback
& callback
));
37 MOCK_METHOD2(EnableOrigin
,
38 void(const GURL
& origin
, const SyncStatusCallback
& callback
));
39 MOCK_METHOD2(DisableOrigin
,
40 void(const GURL
& origin
, const SyncStatusCallback
& callback
));
41 MOCK_METHOD3(UninstallOrigin
,
42 void(const GURL
& origin
,
44 const SyncStatusCallback
& callback
));
45 MOCK_METHOD1(ProcessRemoteChange
,
46 void(const SyncFileCallback
& callback
));
47 MOCK_METHOD1(SetRemoteChangeProcessor
,
48 void(RemoteChangeProcessor
* processor
));
49 MOCK_METHOD0(GetLocalChangeProcessor
, LocalChangeProcessor
*());
50 MOCK_METHOD1(IsConflicting
, bool(const fileapi::FileSystemURL
& url
));
51 MOCK_CONST_METHOD0(GetCurrentState
,
52 RemoteServiceState());
53 MOCK_METHOD1(GetOriginStatusMap
,
54 void(RemoteFileSyncService::OriginStatusMap
* status_map
));
55 MOCK_METHOD1(SetSyncEnabled
, void(bool enabled
));
56 MOCK_METHOD1(SetConflictResolutionPolicy
,
57 SyncStatusCode(ConflictResolutionPolicy
));
58 MOCK_CONST_METHOD0(GetConflictResolutionPolicy
,
59 ConflictResolutionPolicy());
60 MOCK_METHOD2(GetRemoteVersions
,
61 void(const fileapi::FileSystemURL
&,
62 const RemoteVersionsCallback
&));
63 MOCK_METHOD3(DownloadRemoteVersion
,
64 void(const fileapi::FileSystemURL
&,
66 const DownloadVersionCallback
&));
67 MOCK_METHOD0(PromoteDemotedChanges
, void());
69 virtual scoped_ptr
<base::ListValue
> DumpFiles(const GURL
& origin
) OVERRIDE
;
70 virtual scoped_ptr
<base::ListValue
> DumpDatabase() OVERRIDE
;
72 void SetServiceState(RemoteServiceState state
);
74 // Send notifications to the observers.
75 // Can be used in the mock implementation.
76 void NotifyRemoteChangeQueueUpdated(int64 pending_changes
);
77 void NotifyRemoteServiceStateUpdated(
78 RemoteServiceState state
,
79 const std::string
& description
);
80 void NotifyFileStatusChanged(
81 const fileapi::FileSystemURL
& url
,
82 SyncFileStatus sync_status
,
83 SyncAction action_taken
,
84 SyncDirection direction
);
87 void AddServiceObserverStub(Observer
* observer
);
88 void AddFileStatusObserverStub(FileStatusObserver
* observer
);
89 void RegisterOriginStub(
90 const GURL
& origin
, const SyncStatusCallback
& callback
);
91 void DeleteOriginDirectoryStub(
92 const GURL
& origin
, UninstallFlag flag
,
93 const SyncStatusCallback
& callback
);
94 void ProcessRemoteChangeStub(const SyncFileCallback
& callback
);
95 SyncStatusCode
SetConflictResolutionPolicyStub(
96 ConflictResolutionPolicy policy
);
97 ConflictResolutionPolicy
GetConflictResolutionPolicyStub() const;
98 RemoteServiceState
GetCurrentStateStub() const;
100 // For default implementation.
101 ::testing::NiceMock
<MockLocalChangeProcessor
> mock_local_change_processor_
;
103 ObserverList
<Observer
> service_observers_
;
104 ObserverList
<FileStatusObserver
> file_status_observers_
;
106 ConflictResolutionPolicy conflict_resolution_policy_
;
108 RemoteServiceState state_
;
110 DISALLOW_COPY_AND_ASSIGN(MockRemoteFileSyncService
);
113 } // namespace sync_file_system
115 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_MOCK_REMOTE_FILE_SYNC_SERVICE_H_