| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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.h" | 5 #include "chrome/browser/sync/glue/sync_backend_host.h" |
| 6 | 6 |
| 7 #include <cstddef> | 7 #include <cstddef> |
| 8 | 8 |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 | 27 |
| 28 namespace browser_sync { | 28 namespace browser_sync { |
| 29 | 29 |
| 30 namespace { | 30 namespace { |
| 31 | 31 |
| 32 class MockSyncFrontend : public SyncFrontend { | 32 class MockSyncFrontend : public SyncFrontend { |
| 33 public: | 33 public: |
| 34 virtual ~MockSyncFrontend() {} | 34 virtual ~MockSyncFrontend() {} |
| 35 | 35 |
| 36 MOCK_METHOD2(OnBackendInitialized, | 36 MOCK_METHOD2(OnBackendInitialized, |
| 37 void(const csync::WeakHandle<csync::JsBackend>&, bool)); | 37 void(const syncer::WeakHandle<syncer::JsBackend>&, bool)); |
| 38 MOCK_METHOD0(OnSyncCycleCompleted, void()); | 38 MOCK_METHOD0(OnSyncCycleCompleted, void()); |
| 39 MOCK_METHOD1(OnConnectionStatusChange, | 39 MOCK_METHOD1(OnConnectionStatusChange, |
| 40 void(csync::ConnectionStatus status)); | 40 void(syncer::ConnectionStatus status)); |
| 41 MOCK_METHOD0(OnStopSyncingPermanently, void()); | 41 MOCK_METHOD0(OnStopSyncingPermanently, void()); |
| 42 MOCK_METHOD0(OnClearServerDataSucceeded, void()); | 42 MOCK_METHOD0(OnClearServerDataSucceeded, void()); |
| 43 MOCK_METHOD0(OnClearServerDataFailed, void()); | 43 MOCK_METHOD0(OnClearServerDataFailed, void()); |
| 44 MOCK_METHOD2(OnPassphraseRequired, | 44 MOCK_METHOD2(OnPassphraseRequired, |
| 45 void(csync::PassphraseRequiredReason, | 45 void(syncer::PassphraseRequiredReason, |
| 46 const sync_pb::EncryptedData&)); | 46 const sync_pb::EncryptedData&)); |
| 47 MOCK_METHOD0(OnPassphraseAccepted, void()); | 47 MOCK_METHOD0(OnPassphraseAccepted, void()); |
| 48 MOCK_METHOD2(OnEncryptedTypesChanged, | 48 MOCK_METHOD2(OnEncryptedTypesChanged, |
| 49 void(syncable::ModelTypeSet, bool)); | 49 void(syncable::ModelTypeSet, bool)); |
| 50 MOCK_METHOD0(OnEncryptionComplete, void()); | 50 MOCK_METHOD0(OnEncryptionComplete, void()); |
| 51 MOCK_METHOD1(OnMigrationNeededForTypes, void(syncable::ModelTypeSet)); | 51 MOCK_METHOD1(OnMigrationNeededForTypes, void(syncable::ModelTypeSet)); |
| 52 MOCK_METHOD1(OnExperimentsChanged, | 52 MOCK_METHOD1(OnExperimentsChanged, |
| 53 void(const csync::Experiments&)); | 53 void(const syncer::Experiments&)); |
| 54 MOCK_METHOD1(OnActionableError, | 54 MOCK_METHOD1(OnActionableError, |
| 55 void(const csync::SyncProtocolError& sync_error)); | 55 void(const syncer::SyncProtocolError& sync_error)); |
| 56 MOCK_METHOD0(OnSyncConfigureRetry, void()); | 56 MOCK_METHOD0(OnSyncConfigureRetry, void()); |
| 57 }; | 57 }; |
| 58 | 58 |
| 59 } // namespace | 59 } // namespace |
| 60 | 60 |
| 61 class SyncBackendHostTest : public testing::Test { | 61 class SyncBackendHostTest : public testing::Test { |
| 62 protected: | 62 protected: |
| 63 SyncBackendHostTest() | 63 SyncBackendHostTest() |
| 64 : ui_thread_(BrowserThread::UI, &ui_loop_), | 64 : ui_thread_(BrowserThread::UI, &ui_loop_), |
| 65 io_thread_(BrowserThread::IO) {} | 65 io_thread_(BrowserThread::IO) {} |
| (...skipping 28 matching lines...) Expand all Loading... |
| 94 TestingProfile profile; | 94 TestingProfile profile; |
| 95 profile.CreateRequestContext(); | 95 profile.CreateRequestContext(); |
| 96 | 96 |
| 97 SyncPrefs sync_prefs(profile.GetPrefs()); | 97 SyncPrefs sync_prefs(profile.GetPrefs()); |
| 98 InvalidatorStorage invalidator_storage(profile.GetPrefs()); | 98 InvalidatorStorage invalidator_storage(profile.GetPrefs()); |
| 99 SyncBackendHost backend(profile.GetDebugName(), | 99 SyncBackendHost backend(profile.GetDebugName(), |
| 100 &profile, sync_prefs.AsWeakPtr(), | 100 &profile, sync_prefs.AsWeakPtr(), |
| 101 invalidator_storage.AsWeakPtr()); | 101 invalidator_storage.AsWeakPtr()); |
| 102 | 102 |
| 103 MockSyncFrontend mock_frontend; | 103 MockSyncFrontend mock_frontend; |
| 104 csync::SyncCredentials credentials; | 104 syncer::SyncCredentials credentials; |
| 105 credentials.email = "user@example.com"; | 105 credentials.email = "user@example.com"; |
| 106 credentials.sync_token = "sync_token"; | 106 credentials.sync_token = "sync_token"; |
| 107 csync::TestUnrecoverableErrorHandler handler; | 107 syncer::TestUnrecoverableErrorHandler handler; |
| 108 backend.Initialize(&mock_frontend, | 108 backend.Initialize(&mock_frontend, |
| 109 csync::WeakHandle<csync::JsEventHandler>(), | 109 syncer::WeakHandle<syncer::JsEventHandler>(), |
| 110 GURL(k_mock_url), | 110 GURL(k_mock_url), |
| 111 syncable::ModelTypeSet(), | 111 syncable::ModelTypeSet(), |
| 112 credentials, | 112 credentials, |
| 113 true, | 113 true, |
| 114 &handler, | 114 &handler, |
| 115 NULL); | 115 NULL); |
| 116 backend.StopSyncingForShutdown(); | 116 backend.StopSyncingForShutdown(); |
| 117 backend.Shutdown(false); | 117 backend.Shutdown(false); |
| 118 } | 118 } |
| 119 | 119 |
| 120 // TODO(akalin): Write more SyncBackendHost unit tests. | 120 // TODO(akalin): Write more SyncBackendHost unit tests. |
| 121 | 121 |
| 122 } // namespace browser_sync | 122 } // namespace browser_sync |
| OLD | NEW |