| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-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/engine/apply_updates_command.h" | 5 #include "chrome/browser/sync/engine/apply_updates_command.h" |
| 6 #include "chrome/browser/sync/sessions/sync_session.h" | 6 #include "chrome/browser/sync/sessions/sync_session.h" |
| 7 #include "chrome/browser/sync/syncable/directory_manager.h" | 7 #include "chrome/browser/sync/syncable/directory_manager.h" |
| 8 #include "chrome/browser/sync/syncable/syncable.h" | 8 #include "chrome/browser/sync/syncable/syncable.h" |
| 9 #include "chrome/browser/sync/syncable/syncable_id.h" | 9 #include "chrome/browser/sync/syncable/syncable_id.h" |
| 10 #include "chrome/test/sync/engine/test_directory_setter_upper.h" | 10 #include "chrome/test/sync/engine/test_directory_setter_upper.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 | 12 |
| 13 using std::string; | 13 using std::string; |
| 14 using syncable::ScopedDirLookup; | 14 using syncable::ScopedDirLookup; |
| 15 using syncable::WriteTransaction; | 15 using syncable::WriteTransaction; |
| 16 using syncable::ReadTransaction; | 16 using syncable::ReadTransaction; |
| 17 using syncable::MutableEntry; | 17 using syncable::MutableEntry; |
| 18 using syncable::Entry; | 18 using syncable::Entry; |
| 19 using syncable::Id; | 19 using syncable::Id; |
| 20 using syncable::UNITTEST; | 20 using syncable::UNITTEST; |
| 21 | 21 |
| 22 namespace browser_sync { | 22 namespace browser_sync { |
| 23 using sessions::SyncSessionContext; | 23 using sessions::SyncSessionContext; |
| 24 using sessions::SyncSession; | 24 using sessions::SyncSession; |
| 25 | 25 |
| 26 // A test fixture for tests exercising ApplyUpdatesCommand. | 26 // A test fixture for tests exercising ApplyUpdatesCommand. |
| 27 class ApplyUpdatesCommandTest : public testing::Test, | 27 class ApplyUpdatesCommandTest : public testing::Test, |
| 28 public SyncSession::Delegate { | 28 public SyncSession::Delegate, |
| 29 public ModelSafeWorkerRegistrar { |
| 29 public: | 30 public: |
| 30 // SyncSession::Delegate implementation. | 31 // SyncSession::Delegate implementation. |
| 31 virtual void OnSilencedUntil(const base::TimeTicks& silenced_until) { | 32 virtual void OnSilencedUntil(const base::TimeTicks& silenced_until) { |
| 32 FAIL() << "Should not get silenced."; | 33 FAIL() << "Should not get silenced."; |
| 33 } | 34 } |
| 34 virtual bool IsSyncingCurrentlySilenced() { | 35 virtual bool IsSyncingCurrentlySilenced() { |
| 35 ADD_FAILURE() << "No requests for silenced state should be made."; | 36 ADD_FAILURE() << "No requests for silenced state should be made."; |
| 36 return false; | 37 return false; |
| 37 } | 38 } |
| 38 virtual void OnReceivedLongPollIntervalUpdate( | 39 virtual void OnReceivedLongPollIntervalUpdate( |
| 39 const base::TimeDelta& new_interval) { | 40 const base::TimeDelta& new_interval) { |
| 40 FAIL() << "Should not get poll interval update."; | 41 FAIL() << "Should not get poll interval update."; |
| 41 } | 42 } |
| 42 virtual void OnReceivedShortPollIntervalUpdate( | 43 virtual void OnReceivedShortPollIntervalUpdate( |
| 43 const base::TimeDelta& new_interval) { | 44 const base::TimeDelta& new_interval) { |
| 44 FAIL() << "Should not get poll interval update."; | 45 FAIL() << "Should not get poll interval update."; |
| 45 } | 46 } |
| 46 | 47 |
| 48 // ModelSafeWorkerRegistrar implementation. |
| 49 virtual void GetWorkers(std::vector<ModelSafeWorker*>* out) {} |
| 50 virtual void GetModelSafeRoutingInfo(ModelSafeRoutingInfo* out) {} |
| 51 |
| 47 protected: | 52 protected: |
| 48 ApplyUpdatesCommandTest() : next_revision_(1) {} | 53 ApplyUpdatesCommandTest() : next_revision_(1) {} |
| 49 virtual ~ApplyUpdatesCommandTest() {} | 54 virtual ~ApplyUpdatesCommandTest() {} |
| 50 virtual void SetUp() { | 55 virtual void SetUp() { |
| 51 syncdb_.SetUp(); | 56 syncdb_.SetUp(); |
| 52 context_.reset(new SyncSessionContext(NULL, syncdb_.manager(), NULL)); | 57 context_.reset(new SyncSessionContext(NULL, syncdb_.manager(), this)); |
| 53 context_->set_account_name(syncdb_.name()); | 58 context_->set_account_name(syncdb_.name()); |
| 54 } | 59 } |
| 55 virtual void TearDown() { | 60 virtual void TearDown() { |
| 56 syncdb_.TearDown(); | 61 syncdb_.TearDown(); |
| 57 } | 62 } |
| 58 | 63 |
| 59 protected: | 64 protected: |
| 60 | 65 |
| 61 // Create a new unapplied update. | 66 // Create a new unapplied update. |
| 62 void CreateUnappliedNewItemWithParent(const string& item_id, | 67 void CreateUnappliedNewItemWithParent(const string& item_id, |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 sessions::StatusController* status = session.status_controller(); | 160 sessions::StatusController* status = session.status_controller(); |
| 156 EXPECT_EQ(6, status->update_progress().AppliedUpdatesSize()) | 161 EXPECT_EQ(6, status->update_progress().AppliedUpdatesSize()) |
| 157 << "All updates should have been attempted"; | 162 << "All updates should have been attempted"; |
| 158 EXPECT_EQ(2, status->conflict_progress()->ConflictingItemsSize()) | 163 EXPECT_EQ(2, status->conflict_progress()->ConflictingItemsSize()) |
| 159 << "The updates with unknown ancestors should be in conflict"; | 164 << "The updates with unknown ancestors should be in conflict"; |
| 160 EXPECT_EQ(4, status->update_progress().SuccessfullyAppliedUpdateCount()) | 165 EXPECT_EQ(4, status->update_progress().SuccessfullyAppliedUpdateCount()) |
| 161 << "The updates with known ancestors should be successfully applied"; | 166 << "The updates with known ancestors should be successfully applied"; |
| 162 } | 167 } |
| 163 | 168 |
| 164 } // namespace browser_sync | 169 } // namespace browser_sync |
| OLD | NEW |