| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/sessions/sync_session.h" | 5 #include "chrome/browser/sync/sessions/sync_session.h" |
| 6 | 6 |
| 7 #include "chrome/browser/sync/engine/conflict_resolver.h" | 7 #include "chrome/browser/sync/engine/conflict_resolver.h" |
| 8 #include "chrome/browser/sync/engine/syncer_types.h" | 8 #include "chrome/browser/sync/engine/syncer_types.h" |
| 9 #include "chrome/browser/sync/engine/syncer_util.h" | 9 #include "chrome/browser/sync/engine/syncer_util.h" |
| 10 #include "chrome/browser/sync/syncable/directory_manager.h" | 10 #include "chrome/browser/sync/syncable/directory_manager.h" |
| 11 #include "chrome/browser/sync/syncable/syncable.h" | 11 #include "chrome/browser/sync/syncable/syncable.h" |
| 12 #include "chrome/test/sync/engine/test_directory_setter_upper.h" | 12 #include "chrome/test/sync/engine/test_directory_setter_upper.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 14 | 14 |
| 15 using syncable::MultiTypeTimeStamp; | 15 using syncable::MultiTypeTimeStamp; |
| 16 using syncable::WriteTransaction; | 16 using syncable::WriteTransaction; |
| 17 | 17 |
| 18 namespace browser_sync { | 18 namespace browser_sync { |
| 19 namespace sessions { | 19 namespace sessions { |
| 20 namespace { | 20 namespace { |
| 21 | 21 |
| 22 class SyncSessionTest : public testing::Test, | 22 class SyncSessionTest : public testing::Test, |
| 23 public SyncSession::Delegate, | 23 public SyncSession::Delegate, |
| 24 public ModelSafeWorkerRegistrar { | 24 public ModelSafeWorkerRegistrar { |
| 25 public: | 25 public: |
| 26 SyncSessionTest() : controller_invocations_allowed_(false) { | 26 SyncSessionTest() : controller_invocations_allowed_(false) { |
| 27 GetModelSafeRoutingInfo(&routes_); | 27 GetModelSafeRoutingInfo(&routes_); |
| 28 } | 28 } |
| 29 virtual void SetUp() { | 29 virtual void SetUp() { |
| 30 context_.reset(new SyncSessionContext(NULL, NULL, NULL, this)); | 30 context_.reset(new SyncSessionContext(NULL, NULL, this)); |
| 31 session_.reset(new SyncSession(context_.get(), this)); | 31 session_.reset(new SyncSession(context_.get(), this)); |
| 32 } | 32 } |
| 33 virtual void TearDown() { | 33 virtual void TearDown() { |
| 34 session_.reset(); | 34 session_.reset(); |
| 35 context_.reset(); | 35 context_.reset(); |
| 36 } | 36 } |
| 37 | 37 |
| 38 virtual void OnSilencedUntil(const base::TimeTicks& silenced_until) { | 38 virtual void OnSilencedUntil(const base::TimeTicks& silenced_until) { |
| 39 FailControllerInvocationIfDisabled("OnSilencedUntil"); | 39 FailControllerInvocationIfDisabled("OnSilencedUntil"); |
| 40 } | 40 } |
| 41 virtual bool IsSyncingCurrentlySilenced() { | 41 virtual bool IsSyncingCurrentlySilenced() { |
| 42 FailControllerInvocationIfDisabled("IsSyncingCurrentlySilenced"); | 42 FailControllerInvocationIfDisabled("IsSyncingCurrentlySilenced"); |
| 43 return false; | 43 return false; |
| 44 } | 44 } |
| 45 virtual void OnReceivedLongPollIntervalUpdate( | 45 virtual void OnReceivedLongPollIntervalUpdate( |
| 46 const base::TimeDelta& new_interval) { | 46 const base::TimeDelta& new_interval) { |
| 47 FailControllerInvocationIfDisabled("OnReceivedLongPollIntervalUpdate"); | 47 FailControllerInvocationIfDisabled("OnReceivedLongPollIntervalUpdate"); |
| 48 } | 48 } |
| 49 virtual void OnReceivedShortPollIntervalUpdate( | 49 virtual void OnReceivedShortPollIntervalUpdate( |
| 50 const base::TimeDelta& new_interval) { | 50 const base::TimeDelta& new_interval) { |
| 51 FailControllerInvocationIfDisabled("OnReceivedShortPollIntervalUpdate"); | 51 FailControllerInvocationIfDisabled("OnReceivedShortPollIntervalUpdate"); |
| 52 } | 52 } |
| 53 virtual void OnShouldStopSyncingPermanently() { | 53 virtual void OnShouldStopSyncingPermanently() { |
| 54 FailControllerInvocationIfDisabled("OnShouldStopSyncingPermanently"); | 54 FailControllerInvocationIfDisabled("OnShouldStopSyncingPermanently"); |
| 55 } | 55 } |
| 56 | 56 |
| 57 // ModelSafeWorkerRegistrar implementation. | 57 // ModelSafeWorkerRegistrar implementation. |
| 58 virtual void GetWorkers(std::vector<ModelSafeWorker*>* out) {} | 58 virtual void GetWorkers(std::vector<ModelSafeWorker*>* out) {} |
| 59 virtual void GetModelSafeRoutingInfo(ModelSafeRoutingInfo* out) { | 59 virtual void GetModelSafeRoutingInfo(ModelSafeRoutingInfo* out) { |
| 60 (*out)[syncable::BOOKMARKS] = GROUP_UI; | 60 (*out)[syncable::BOOKMARKS] = GROUP_UI; |
| 61 (*out)[syncable::AUTOFILL] = GROUP_UI; | 61 (*out)[syncable::AUTOFILL] = GROUP_UI; |
| 62 } | 62 } |
| 63 | 63 |
| 64 StatusController* status() { return session_->status_controller(); } | 64 StatusController* status() { return session_->status_controller(); } |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 EXPECT_FALSE(context_->resolver()); | 103 EXPECT_FALSE(context_->resolver()); |
| 104 EXPECT_FALSE(context_->syncer_event_channel()); | 104 EXPECT_FALSE(context_->syncer_event_channel()); |
| 105 channel->Notify(SyncerEvent(SyncerEvent::SHUTDOWN_USE_WITH_CARE)); | 105 channel->Notify(SyncerEvent(SyncerEvent::SHUTDOWN_USE_WITH_CARE)); |
| 106 delete channel; | 106 delete channel; |
| 107 } | 107 } |
| 108 | 108 |
| 109 TEST_F(SyncSessionTest, SetWriteTransaction) { | 109 TEST_F(SyncSessionTest, SetWriteTransaction) { |
| 110 TestDirectorySetterUpper db; | 110 TestDirectorySetterUpper db; |
| 111 db.SetUp(); | 111 db.SetUp(); |
| 112 session_.reset(NULL); | 112 session_.reset(NULL); |
| 113 context_.reset(new SyncSessionContext(NULL, NULL, db.manager(), this)); | 113 context_.reset(new SyncSessionContext(NULL, db.manager(), this)); |
| 114 session_.reset(new SyncSession(context_.get(), this)); | 114 session_.reset(new SyncSession(context_.get(), this)); |
| 115 context_->set_account_name(db.name()); | 115 context_->set_account_name(db.name()); |
| 116 syncable::ScopedDirLookup dir(context_->directory_manager(), | 116 syncable::ScopedDirLookup dir(context_->directory_manager(), |
| 117 context_->account_name()); | 117 context_->account_name()); |
| 118 ASSERT_TRUE(dir.good()); | 118 ASSERT_TRUE(dir.good()); |
| 119 | 119 |
| 120 SyncSession session(context_.get(), this); | 120 SyncSession session(context_.get(), this); |
| 121 EXPECT_TRUE(NULL == session.write_transaction()); | 121 EXPECT_TRUE(NULL == session.write_transaction()); |
| 122 { | 122 { |
| 123 WriteTransaction trans(dir, syncable::UNITTEST, __FILE__, __LINE__); | 123 WriteTransaction trans(dir, syncable::UNITTEST, __FILE__, __LINE__); |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 // Conflict resolution happens after get updates and commit, | 230 // Conflict resolution happens after get updates and commit, |
| 231 // so we need to loop back and get updates / commit again now | 231 // so we need to loop back and get updates / commit again now |
| 232 // that we have made forward progress. | 232 // that we have made forward progress. |
| 233 status()->update_conflicts_resolved(true); | 233 status()->update_conflicts_resolved(true); |
| 234 EXPECT_TRUE(session_->HasMoreToSync()); | 234 EXPECT_TRUE(session_->HasMoreToSync()); |
| 235 } | 235 } |
| 236 | 236 |
| 237 } // namespace | 237 } // namespace |
| 238 } // namespace sessions | 238 } // namespace sessions |
| 239 } // namespace browser_sync | 239 } // namespace browser_sync |
| OLD | NEW |