| OLD | NEW |
| 1 // Copyright (c) 2011 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 // Syncer unit tests. Unfortunately a lot of these tests | 5 // Syncer unit tests. Unfortunately a lot of these tests |
| 6 // are outdated and need to be reworked and updated. | 6 // are outdated and need to be reworked and updated. |
| 7 | 7 |
| 8 #include <algorithm> | 8 #include <algorithm> |
| 9 #include <limits> | 9 #include <limits> |
| 10 #include <list> | 10 #include <list> |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 #include "chrome/test/sync/engine/test_syncable_utils.h" | 40 #include "chrome/test/sync/engine/test_syncable_utils.h" |
| 41 #include "testing/gtest/include/gtest/gtest.h" | 41 #include "testing/gtest/include/gtest/gtest.h" |
| 42 | 42 |
| 43 using base::TimeDelta; | 43 using base::TimeDelta; |
| 44 | 44 |
| 45 using std::map; | 45 using std::map; |
| 46 using std::multimap; | 46 using std::multimap; |
| 47 using std::set; | 47 using std::set; |
| 48 using std::string; | 48 using std::string; |
| 49 | 49 |
| 50 using ::testing::_; |
| 51 |
| 50 namespace browser_sync { | 52 namespace browser_sync { |
| 51 | 53 |
| 52 using syncable::BaseTransaction; | 54 using syncable::BaseTransaction; |
| 53 using syncable::Blob; | 55 using syncable::Blob; |
| 54 using syncable::CountEntriesWithName; | 56 using syncable::CountEntriesWithName; |
| 55 using syncable::Directory; | 57 using syncable::Directory; |
| 56 using syncable::Entry; | 58 using syncable::Entry; |
| 57 using syncable::GetFirstEntryWithName; | 59 using syncable::GetFirstEntryWithName; |
| 58 using syncable::GetOnlyEntryWithName; | 60 using syncable::GetOnlyEntryWithName; |
| 59 using syncable::Id; | 61 using syncable::Id; |
| (...skipping 4430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4490 DisableDatatype(syncable::AUTOFILL); | 4492 DisableDatatype(syncable::AUTOFILL); |
| 4491 SyncShareAsDelegate(); | 4493 SyncShareAsDelegate(); |
| 4492 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); | 4494 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); |
| 4493 | 4495 |
| 4494 DisableDatatype(syncable::PREFERENCES); | 4496 DisableDatatype(syncable::PREFERENCES); |
| 4495 EnableDatatype(syncable::AUTOFILL); | 4497 EnableDatatype(syncable::AUTOFILL); |
| 4496 SyncShareAsDelegate(); | 4498 SyncShareAsDelegate(); |
| 4497 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); | 4499 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); |
| 4498 } | 4500 } |
| 4499 | 4501 |
| 4502 TEST_F(SyncerTest, CleanupDisabledTypes) { |
| 4503 // Set up mock directory and expectations. |
| 4504 MockDirectorySetterUpper mock_setter_upper; |
| 4505 mock_setter_upper.SetUp(); |
| 4506 EXPECT_CALL(*mock_setter_upper.directory(), PurgeEntriesWithTypeIn(_)); |
| 4507 |
| 4508 // Set up context. |
| 4509 std::vector<SyncEngineEventListener*> listeners; |
| 4510 SyncSessionContext context(mock_server_.get(), |
| 4511 mock_setter_upper.manager(), this, listeners); |
| 4512 context.set_account_name(mock_setter_upper.name()); |
| 4513 |
| 4514 // Set up session. |
| 4515 ModelSafeRoutingInfo info; |
| 4516 std::vector<ModelSafeWorker*> workers; |
| 4517 GetModelSafeRoutingInfo(&info); |
| 4518 GetWorkers(&workers); |
| 4519 syncable::ModelTypePayloadMap types = |
| 4520 syncable::ModelTypePayloadMapFromRoutingInfo(info, std::string()); |
| 4521 SyncSession sync_session( |
| 4522 &context, this, |
| 4523 sessions::SyncSourceInfo(sync_pb::GetUpdatesCallerInfo::UNKNOWN, types), |
| 4524 info, workers); |
| 4525 |
| 4526 // Do cleanup. |
| 4527 syncer_->CleanupDisabledTypes(&sync_session); |
| 4528 } |
| 4529 |
| 4500 // Test what happens if a client deletes, then recreates, an object very | 4530 // Test what happens if a client deletes, then recreates, an object very |
| 4501 // quickly. It is possible that the deletion gets sent as a commit, and | 4531 // quickly. It is possible that the deletion gets sent as a commit, and |
| 4502 // the undelete happens during the commit request. The principle here | 4532 // the undelete happens during the commit request. The principle here |
| 4503 // is that with a single committing client, conflicts should never | 4533 // is that with a single committing client, conflicts should never |
| 4504 // be encountered, and a client encountering its past actions during | 4534 // be encountered, and a client encountering its past actions during |
| 4505 // getupdates should never feed back to override later actions. | 4535 // getupdates should never feed back to override later actions. |
| 4506 // | 4536 // |
| 4507 // In cases of ordering A-F below, the outcome should be the same. | 4537 // In cases of ordering A-F below, the outcome should be the same. |
| 4508 // Exercised by UndeleteDuringCommit: | 4538 // Exercised by UndeleteDuringCommit: |
| 4509 // A. Delete - commit - undelete - commitresponse. | 4539 // A. Delete - commit - undelete - commitresponse. |
| (...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5177 Add(low_id_); | 5207 Add(low_id_); |
| 5178 Add(high_id_); | 5208 Add(high_id_); |
| 5179 SyncShareAsDelegate(); | 5209 SyncShareAsDelegate(); |
| 5180 ExpectLocalOrderIsByServerId(); | 5210 ExpectLocalOrderIsByServerId(); |
| 5181 } | 5211 } |
| 5182 | 5212 |
| 5183 const SyncerTest::CommitOrderingTest | 5213 const SyncerTest::CommitOrderingTest |
| 5184 SyncerTest::CommitOrderingTest::LAST_COMMIT_ITEM = {-1, TestIdFactory::root()}; | 5214 SyncerTest::CommitOrderingTest::LAST_COMMIT_ITEM = {-1, TestIdFactory::root()}; |
| 5185 | 5215 |
| 5186 } // namespace browser_sync | 5216 } // namespace browser_sync |
| OLD | NEW |