OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "chrome/browser/sync/glue/sync_backend_host_impl.h" | 5 #include "chrome/browser/sync/glue/sync_backend_host_impl.h" |
6 | 6 |
7 #include <cstddef> | 7 #include <cstddef> |
8 | 8 |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 } | 69 } |
70 | 70 |
71 void QuitMessageLoop() { | 71 void QuitMessageLoop() { |
72 base::MessageLoop::current()->Quit(); | 72 base::MessageLoop::current()->Quit(); |
73 } | 73 } |
74 | 74 |
75 class MockSyncFrontend : public SyncFrontend { | 75 class MockSyncFrontend : public SyncFrontend { |
76 public: | 76 public: |
77 virtual ~MockSyncFrontend() {} | 77 virtual ~MockSyncFrontend() {} |
78 | 78 |
79 MOCK_METHOD3( | 79 MOCK_METHOD4( |
80 OnBackendInitialized, | 80 OnBackendInitialized, |
81 void(const syncer::WeakHandle<syncer::JsBackend>&, | 81 void(const syncer::WeakHandle<syncer::JsBackend>&, |
82 const syncer::WeakHandle<syncer::DataTypeDebugInfoListener>&, | 82 const syncer::WeakHandle<syncer::DataTypeDebugInfoListener>&, |
| 83 const std::string&, |
83 bool)); | 84 bool)); |
84 MOCK_METHOD0(OnSyncCycleCompleted, void()); | 85 MOCK_METHOD0(OnSyncCycleCompleted, void()); |
85 MOCK_METHOD1(OnConnectionStatusChange, | 86 MOCK_METHOD1(OnConnectionStatusChange, |
86 void(syncer::ConnectionStatus status)); | 87 void(syncer::ConnectionStatus status)); |
87 MOCK_METHOD0(OnClearServerDataSucceeded, void()); | 88 MOCK_METHOD0(OnClearServerDataSucceeded, void()); |
88 MOCK_METHOD0(OnClearServerDataFailed, void()); | 89 MOCK_METHOD0(OnClearServerDataFailed, void()); |
89 MOCK_METHOD2(OnPassphraseRequired, | 90 MOCK_METHOD2(OnPassphraseRequired, |
90 void(syncer::PassphraseRequiredReason, | 91 void(syncer::PassphraseRequiredReason, |
91 const sync_pb::EncryptedData&)); | 92 const sync_pb::EncryptedData&)); |
92 MOCK_METHOD0(OnPassphraseAccepted, void()); | 93 MOCK_METHOD0(OnPassphraseAccepted, void()); |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 // Pump messages posted by the sync thread (which may end up | 201 // Pump messages posted by the sync thread (which may end up |
201 // posting on the IO thread). | 202 // posting on the IO thread). |
202 base::RunLoop().RunUntilIdle(); | 203 base::RunLoop().RunUntilIdle(); |
203 content::RunAllPendingInMessageLoop(BrowserThread::IO); | 204 content::RunAllPendingInMessageLoop(BrowserThread::IO); |
204 // Pump any messages posted by the IO thread. | 205 // Pump any messages posted by the IO thread. |
205 base::RunLoop().RunUntilIdle(); | 206 base::RunLoop().RunUntilIdle(); |
206 } | 207 } |
207 | 208 |
208 // Synchronously initializes the backend. | 209 // Synchronously initializes the backend. |
209 void InitializeBackend(bool expect_success) { | 210 void InitializeBackend(bool expect_success) { |
210 EXPECT_CALL(mock_frontend_, OnBackendInitialized(_, _, expect_success)). | 211 EXPECT_CALL(mock_frontend_, OnBackendInitialized(_, _, _, expect_success)). |
211 WillOnce(InvokeWithoutArgs(QuitMessageLoop)); | 212 WillOnce(InvokeWithoutArgs(QuitMessageLoop)); |
212 backend_->Initialize( | 213 backend_->Initialize( |
213 &mock_frontend_, | 214 &mock_frontend_, |
214 scoped_ptr<base::Thread>(), | 215 scoped_ptr<base::Thread>(), |
215 syncer::WeakHandle<syncer::JsEventHandler>(), | 216 syncer::WeakHandle<syncer::JsEventHandler>(), |
216 GURL(std::string()), | 217 GURL(std::string()), |
217 credentials_, | 218 credentials_, |
218 true, | 219 true, |
219 fake_manager_factory_.PassAs<syncer::SyncManagerFactory>(), | 220 fake_manager_factory_.PassAs<syncer::SyncManagerFactory>(), |
220 scoped_ptr<syncer::UnrecoverableErrorHandler>( | 221 scoped_ptr<syncer::UnrecoverableErrorHandler>( |
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
728 ASSERT_NE(-1, base::WriteFile(sync_file, nonsense, strlen(nonsense))); | 729 ASSERT_NE(-1, base::WriteFile(sync_file, nonsense, strlen(nonsense))); |
729 | 730 |
730 InitializeBackend(true); | 731 InitializeBackend(true); |
731 | 732 |
732 EXPECT_FALSE(base::PathExists(sync_file)); | 733 EXPECT_FALSE(base::PathExists(sync_file)); |
733 } | 734 } |
734 | 735 |
735 } // namespace | 736 } // namespace |
736 | 737 |
737 } // namespace browser_sync | 738 } // namespace browser_sync |
OLD | NEW |