Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chrome / browser / sync_file_system / mock_remote_file_sync_service.cc
blob25d9d2d18d2729265fb3a3381b06677dc4f0df1a
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 #include "chrome/browser/sync_file_system/mock_remote_file_sync_service.h"
7 #include <string>
9 #include "base/bind.h"
10 #include "base/location.h"
11 #include "base/single_thread_task_runner.h"
12 #include "base/thread_task_runner_handle.h"
13 #include "storage/browser/fileapi/file_system_url.h"
14 #include "url/gurl.h"
16 using ::testing::_;
17 using ::testing::Invoke;
18 using ::testing::Return;
20 namespace sync_file_system {
22 MockRemoteFileSyncService::MockRemoteFileSyncService()
23 : state_(REMOTE_SERVICE_OK) {
24 typedef MockRemoteFileSyncService self;
25 ON_CALL(*this, AddServiceObserver(_))
26 .WillByDefault(Invoke(this, &self::AddServiceObserverStub));
27 ON_CALL(*this, AddFileStatusObserver(_))
28 .WillByDefault(Invoke(this, &self::AddFileStatusObserverStub));
29 ON_CALL(*this, RegisterOrigin(_, _))
30 .WillByDefault(Invoke(this, &self::RegisterOriginStub));
31 ON_CALL(*this, UninstallOrigin(_, _, _))
32 .WillByDefault(
33 Invoke(this, &self::DeleteOriginDirectoryStub));
34 ON_CALL(*this, ProcessRemoteChange(_))
35 .WillByDefault(Invoke(this, &self::ProcessRemoteChangeStub));
36 ON_CALL(*this, GetLocalChangeProcessor())
37 .WillByDefault(Return(&mock_local_change_processor_));
38 ON_CALL(*this, GetCurrentState())
39 .WillByDefault(Invoke(this, &self::GetCurrentStateStub));
42 MockRemoteFileSyncService::~MockRemoteFileSyncService() {
45 void MockRemoteFileSyncService::DumpFiles(const GURL& origin,
46 const ListCallback& callback) {
47 callback.Run(nullptr);
50 void MockRemoteFileSyncService::DumpDatabase(const ListCallback& callback) {
51 callback.Run(nullptr);
54 void MockRemoteFileSyncService::SetServiceState(RemoteServiceState state) {
55 state_ = state;
58 void MockRemoteFileSyncService::NotifyRemoteChangeQueueUpdated(
59 int64 pending_changes) {
60 FOR_EACH_OBSERVER(Observer, service_observers_,
61 OnRemoteChangeQueueUpdated(pending_changes));
64 void MockRemoteFileSyncService::NotifyRemoteServiceStateUpdated(
65 RemoteServiceState state,
66 const std::string& description) {
67 FOR_EACH_OBSERVER(Observer, service_observers_,
68 OnRemoteServiceStateUpdated(state, description));
71 void MockRemoteFileSyncService::NotifyFileStatusChanged(
72 const storage::FileSystemURL& url,
73 SyncFileType file_type,
74 SyncFileStatus sync_status,
75 SyncAction action_taken,
76 SyncDirection direction) {
77 FOR_EACH_OBSERVER(FileStatusObserver, file_status_observers_,
78 OnFileStatusChanged(url, file_type, sync_status,
79 action_taken, direction));
82 void MockRemoteFileSyncService::AddServiceObserverStub(Observer* observer) {
83 service_observers_.AddObserver(observer);
86 void MockRemoteFileSyncService::AddFileStatusObserverStub(
87 FileStatusObserver* observer) {
88 file_status_observers_.AddObserver(observer);
91 void MockRemoteFileSyncService::RegisterOriginStub(
92 const GURL& origin,
93 const SyncStatusCallback& callback) {
94 base::ThreadTaskRunnerHandle::Get()->PostTask(
95 FROM_HERE,
96 base::Bind(callback, SYNC_STATUS_OK));
99 void MockRemoteFileSyncService::DeleteOriginDirectoryStub(
100 const GURL& origin,
101 UninstallFlag flag,
102 const SyncStatusCallback& callback) {
103 base::ThreadTaskRunnerHandle::Get()->PostTask(
104 FROM_HERE,
105 base::Bind(callback, SYNC_STATUS_OK));
108 void MockRemoteFileSyncService::ProcessRemoteChangeStub(
109 const SyncFileCallback& callback) {
110 base::ThreadTaskRunnerHandle::Get()->PostTask(
111 FROM_HERE,
112 base::Bind(
113 callback, SYNC_STATUS_NO_CHANGE_TO_SYNC, storage::FileSystemURL()));
116 RemoteServiceState MockRemoteFileSyncService::GetCurrentStateStub() const {
117 return state_;
120 } // namespace sync_file_system