mock_remote_file_sync_service.h revision 2385ea399aae016c0806a4f9ef3c9cfe3d2a39df
1ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com// Copyright (c) 2012 The Chromium Authors. All rights reserved.
28a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com// Use of this source code is governed by a BSD-style license that can be
3ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com// found in the LICENSE file.
48a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
5ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com#ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_MOCK_REMOTE_FILE_SYNC_SERVICE_H_
6ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com#define CHROME_BROWSER_SYNC_FILE_SYSTEM_MOCK_REMOTE_FILE_SYNC_SERVICE_H_
78a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
88a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include <map>
9ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com
108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "base/memory/scoped_ptr.h"
118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "base/observer_list.h"
128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "base/values.h"
138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "chrome/browser/sync_file_system/file_status_observer.h"
148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "chrome/browser/sync_file_system/mock_local_change_processor.h"
158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "chrome/browser/sync_file_system/remote_change_processor.h"
168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "chrome/browser/sync_file_system/remote_file_sync_service.h"
178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "chrome/browser/sync_file_system/sync_callbacks.h"
188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "chrome/browser/sync_file_system/sync_direction.h"
198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "chrome/browser/sync_file_system/sync_file_metadata.h"
208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "testing/gmock/include/gmock/gmock.h"
218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "url/gurl.h"
228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
23d26147adbbdca85f07dff432025afee0c8614387caryclark@google.comnamespace sync_file_system {
24d26147adbbdca85f07dff432025afee0c8614387caryclark@google.com
25d26147adbbdca85f07dff432025afee0c8614387caryclark@google.comclass MockRemoteFileSyncService : public RemoteFileSyncService {
26d26147adbbdca85f07dff432025afee0c8614387caryclark@google.com public:
27a2ca41e3afdd8fad5e0e924dec029f33918e0a67djsollen@google.com  MockRemoteFileSyncService();
28d26147adbbdca85f07dff432025afee0c8614387caryclark@google.com  virtual ~MockRemoteFileSyncService();
29d26147adbbdca85f07dff432025afee0c8614387caryclark@google.com
30a2ca41e3afdd8fad5e0e924dec029f33918e0a67djsollen@google.com  // RemoteFileSyncService overrides.
31a2ca41e3afdd8fad5e0e924dec029f33918e0a67djsollen@google.com  MOCK_METHOD1(AddServiceObserver,
32a2ca41e3afdd8fad5e0e924dec029f33918e0a67djsollen@google.com               void(RemoteFileSyncService::Observer* observer));
33a2ca41e3afdd8fad5e0e924dec029f33918e0a67djsollen@google.com  MOCK_METHOD1(AddFileStatusObserver,
34d26147adbbdca85f07dff432025afee0c8614387caryclark@google.com               void(FileStatusObserver* observer));
35d26147adbbdca85f07dff432025afee0c8614387caryclark@google.com  MOCK_METHOD2(RegisterOriginForTrackingChanges,
36d26147adbbdca85f07dff432025afee0c8614387caryclark@google.com               void(const GURL& origin, const SyncStatusCallback& callback));
37d26147adbbdca85f07dff432025afee0c8614387caryclark@google.com  MOCK_METHOD2(UnregisterOriginForTrackingChanges,
38a2ca41e3afdd8fad5e0e924dec029f33918e0a67djsollen@google.com               void(const GURL& origin, const SyncStatusCallback& callback));
39a2ca41e3afdd8fad5e0e924dec029f33918e0a67djsollen@google.com  MOCK_METHOD2(EnableOriginForTrackingChanges,
40a2ca41e3afdd8fad5e0e924dec029f33918e0a67djsollen@google.com               void(const GURL& origin, const SyncStatusCallback& callback));
41d26147adbbdca85f07dff432025afee0c8614387caryclark@google.com  MOCK_METHOD2(DisableOriginForTrackingChanges,
42a2ca41e3afdd8fad5e0e924dec029f33918e0a67djsollen@google.com               void(const GURL& origin, const SyncStatusCallback& callback));
43d26147adbbdca85f07dff432025afee0c8614387caryclark@google.com  MOCK_METHOD2(UninstallOrigin,
44d26147adbbdca85f07dff432025afee0c8614387caryclark@google.com               void(const GURL& origin, const SyncStatusCallback& callback));
45a2ca41e3afdd8fad5e0e924dec029f33918e0a67djsollen@google.com  MOCK_METHOD1(ProcessRemoteChange,
46a2ca41e3afdd8fad5e0e924dec029f33918e0a67djsollen@google.com               void(const SyncFileCallback& callback));
47d26147adbbdca85f07dff432025afee0c8614387caryclark@google.com  MOCK_METHOD1(SetRemoteChangeProcessor,
48d26147adbbdca85f07dff432025afee0c8614387caryclark@google.com               void(RemoteChangeProcessor* processor));
49d26147adbbdca85f07dff432025afee0c8614387caryclark@google.com  MOCK_METHOD0(GetLocalChangeProcessor, LocalChangeProcessor*());
50d26147adbbdca85f07dff432025afee0c8614387caryclark@google.com  MOCK_METHOD1(IsConflicting, bool(const fileapi::FileSystemURL& url));
51d26147adbbdca85f07dff432025afee0c8614387caryclark@google.com  MOCK_CONST_METHOD0(GetCurrentState,
52ba28d03e94dc221d6a803bf2a84a420b9159255cdjsollen@google.com                     RemoteServiceState());
53ba28d03e94dc221d6a803bf2a84a420b9159255cdjsollen@google.com  MOCK_METHOD1(GetOriginStatusMap,
54ba28d03e94dc221d6a803bf2a84a420b9159255cdjsollen@google.com               void(RemoteFileSyncService::OriginStatusMap* status_map));
55ba28d03e94dc221d6a803bf2a84a420b9159255cdjsollen@google.com  MOCK_METHOD1(SetSyncEnabled, void(bool));
56ba28d03e94dc221d6a803bf2a84a420b9159255cdjsollen@google.com  MOCK_METHOD1(SetConflictResolutionPolicy,
57ba28d03e94dc221d6a803bf2a84a420b9159255cdjsollen@google.com               SyncStatusCode(ConflictResolutionPolicy));
58ba28d03e94dc221d6a803bf2a84a420b9159255cdjsollen@google.com  MOCK_CONST_METHOD0(GetConflictResolutionPolicy,
59ba28d03e94dc221d6a803bf2a84a420b9159255cdjsollen@google.com                     ConflictResolutionPolicy());
60ba28d03e94dc221d6a803bf2a84a420b9159255cdjsollen@google.com
618a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  virtual scoped_ptr<base::ListValue> DumpFiles(const GURL& origin) OVERRIDE;
628a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
638a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  // Send notifications to the observers.
648a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  // Can be used in the mock implementation.
658a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  void NotifyRemoteChangeQueueUpdated(int64 pending_changes);
668a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  void NotifyRemoteServiceStateUpdated(
677ffb1b21abcc7bbed5a0fc711f6dd7b9dbb4f577ctguil@chromium.org      RemoteServiceState state,
688a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com      const std::string& description);
698a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  void NotifyFileStatusChanged(
708a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com      const fileapi::FileSystemURL& url,
718a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com      SyncFileStatus sync_status,
728a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com      SyncAction action_taken,
738a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com      SyncDirection direction);
748a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
758a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com private:
768a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  void AddServiceObserverStub(Observer* observer);
778a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  void AddFileStatusObserverStub(FileStatusObserver* observer);
788a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  void RegisterOriginForTrackingChangesStub(
798a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com      const GURL& origin, const SyncStatusCallback& callback);
808a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  void UnregisterOriginForTrackingChangesStub(
818a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com      const GURL& origin, const SyncStatusCallback& callback);
828a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  void DeleteOriginDirectoryStub(
838a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com      const GURL& origin, const SyncStatusCallback& callback);
848a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  void ProcessRemoteChangeStub(const SyncFileCallback& callback);
858a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  SyncStatusCode SetConflictResolutionPolicyStub(
868a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com      ConflictResolutionPolicy policy);
87a2ca41e3afdd8fad5e0e924dec029f33918e0a67djsollen@google.com  ConflictResolutionPolicy GetConflictResolutionPolicyStub() const;
888a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
898a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  // For default implementation.
908a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  ::testing::NiceMock<MockLocalChangeProcessor> mock_local_change_processor_;
918a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
928a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  ObserverList<Observer> service_observers_;
938a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  ObserverList<FileStatusObserver> file_status_observers_;
94a2ca41e3afdd8fad5e0e924dec029f33918e0a67djsollen@google.com
958a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  ConflictResolutionPolicy conflict_resolution_policy_;
968a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
97d26147adbbdca85f07dff432025afee0c8614387caryclark@google.com  DISALLOW_COPY_AND_ASSIGN(MockRemoteFileSyncService);
98d26147adbbdca85f07dff432025afee0c8614387caryclark@google.com};
99d26147adbbdca85f07dff432025afee0c8614387caryclark@google.com
100d26147adbbdca85f07dff432025afee0c8614387caryclark@google.com}  // namespace sync_file_system
101d26147adbbdca85f07dff432025afee0c8614387caryclark@google.com
1029d0c6ecb8440e8e546881a4ff850eb6333f24541caryclark@google.com#endif  // CHROME_BROWSER_SYNC_FILE_SYSTEM_MOCK_REMOTE_FILE_SYNC_SERVICE_H_
1039d0c6ecb8440e8e546881a4ff850eb6333f24541caryclark@google.com