OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_HOST_MOCK_H__ | 5 #ifndef CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_HOST_MOCK_H__ |
6 #define CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_HOST_MOCK_H__ | 6 #define CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_HOST_MOCK_H__ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <set> | 9 #include <set> |
10 | 10 |
11 #include "chrome/browser/sync/glue/sync_backend_host.h" | 11 #include "chrome/browser/sync/glue/sync_backend_host.h" |
12 #include "base/task.h" | 12 #include "base/task.h" |
13 #include "chrome/browser/sync/profile_sync_test_util.h" | 13 #include "chrome/browser/sync/profile_sync_test_util.h" |
14 #include "chrome/common/notification_type.h" | 14 #include "chrome/common/notification_type.h" |
15 #include "testing/gmock/include/gmock/gmock.h" | 15 #include "testing/gmock/include/gmock/gmock.h" |
16 | 16 |
17 namespace browser_sync { | 17 namespace browser_sync { |
18 | 18 |
19 ACTION(InvokeTask) { | 19 ACTION(InvokeTask) { |
20 arg1->Run(); | 20 arg1->Run(); |
21 delete arg1; | 21 delete arg1; |
22 } | 22 } |
23 | 23 |
24 class SyncBackendHostMock : public SyncBackendHost { | 24 class SyncBackendHostMock : public SyncBackendHost { |
25 public: | 25 public: |
26 SyncBackendHostMock() { | 26 SyncBackendHostMock(); |
27 // By default, the RequestPause and RequestResume methods will | 27 virtual ~SyncBackendHostMock(); |
28 // send the confirmation notification and return true. | |
29 ON_CALL(*this, RequestPause()). | |
30 WillByDefault(testing::DoAll(Notify(NotificationType::SYNC_PAUSED), | |
31 testing::Return(true))); | |
32 ON_CALL(*this, RequestResume()). | |
33 WillByDefault(testing::DoAll(Notify(NotificationType::SYNC_RESUMED), | |
34 testing::Return(true))); | |
35 | |
36 // By default, invoke the ready callback. | |
37 ON_CALL(*this, ConfigureDataTypes(testing::_, testing::_)). | |
38 WillByDefault(InvokeTask()); | |
39 } | |
40 | 28 |
41 MOCK_METHOD2(ConfigureDataTypes, | 29 MOCK_METHOD2(ConfigureDataTypes, |
42 void(const std::set<syncable::ModelType>&, CancelableTask*)); | 30 void(const std::set<syncable::ModelType>&, CancelableTask*)); |
43 MOCK_METHOD0(RequestPause, bool()); | 31 MOCK_METHOD0(RequestPause, bool()); |
44 MOCK_METHOD0(RequestResume, bool()); | 32 MOCK_METHOD0(RequestResume, bool()); |
45 MOCK_METHOD0(StartSyncingWithServer, void()); | 33 MOCK_METHOD0(StartSyncingWithServer, void()); |
46 }; | 34 }; |
47 | 35 |
48 } // namespace browser_sync | 36 } // namespace browser_sync |
49 | 37 |
50 #endif // CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_HOST_MOCK_H__ | 38 #endif // CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_HOST_MOCK_H__ |
OLD | NEW |