Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / sync_file_system / mock_remote_file_sync_service.h
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.
4
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_
7
8 #include <string>
9
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"
21 #include "url/gurl.h"
22
23 namespace sync_file_system {
24
25 class MockRemoteFileSyncService : public RemoteFileSyncService {
26  public:
27   MockRemoteFileSyncService();
28   virtual ~MockRemoteFileSyncService();
29
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,
43                     UninstallFlag flag,
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_CONST_METHOD0(GetCurrentState,
51                      RemoteServiceState());
52   MOCK_METHOD1(GetOriginStatusMap,
53                void(const StatusMapCallback& callback));
54   MOCK_METHOD1(SetSyncEnabled, void(bool enabled));
55   MOCK_METHOD1(PromoteDemotedChanges, void(const base::Closure& callback));
56
57   virtual void DumpFiles(const GURL& origin,
58                          const ListCallback& callback) OVERRIDE;
59   virtual void DumpDatabase(const ListCallback& callback) OVERRIDE;
60
61   void SetServiceState(RemoteServiceState state);
62
63   // Send notifications to the observers.
64   // Can be used in the mock implementation.
65   void NotifyRemoteChangeQueueUpdated(int64 pending_changes);
66   void NotifyRemoteServiceStateUpdated(
67       RemoteServiceState state,
68       const std::string& description);
69   void NotifyFileStatusChanged(
70       const fileapi::FileSystemURL& url,
71       SyncFileStatus sync_status,
72       SyncAction action_taken,
73       SyncDirection direction);
74
75  private:
76   void AddServiceObserverStub(Observer* observer);
77   void AddFileStatusObserverStub(FileStatusObserver* observer);
78   void RegisterOriginStub(
79       const GURL& origin, const SyncStatusCallback& callback);
80   void DeleteOriginDirectoryStub(
81       const GURL& origin, UninstallFlag flag,
82       const SyncStatusCallback& callback);
83   void ProcessRemoteChangeStub(const SyncFileCallback& callback);
84   RemoteServiceState GetCurrentStateStub() const;
85
86   // For default implementation.
87   ::testing::NiceMock<MockLocalChangeProcessor> mock_local_change_processor_;
88
89   ObserverList<Observer> service_observers_;
90   ObserverList<FileStatusObserver> file_status_observers_;
91
92   ConflictResolutionPolicy conflict_resolution_policy_;
93
94   RemoteServiceState state_;
95
96   DISALLOW_COPY_AND_ASSIGN(MockRemoteFileSyncService);
97 };
98
99 }  // namespace sync_file_system
100
101 #endif  // CHROME_BROWSER_SYNC_FILE_SYSTEM_MOCK_REMOTE_FILE_SYNC_SERVICE_H_