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 // 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 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 | 225 |
226 throttled_data_type_tracker_.reset(new ThrottledDataTypeTracker(NULL)); | 226 throttled_data_type_tracker_.reset(new ThrottledDataTypeTracker(NULL)); |
227 | 227 |
228 context_.reset( | 228 context_.reset( |
229 new SyncSessionContext( | 229 new SyncSessionContext( |
230 mock_server_.get(), directory(), workers, | 230 mock_server_.get(), directory(), workers, |
231 &extensions_activity_monitor_, throttled_data_type_tracker_.get(), | 231 &extensions_activity_monitor_, throttled_data_type_tracker_.get(), |
232 listeners, NULL, &traffic_recorder_, | 232 listeners, NULL, &traffic_recorder_, |
233 true /* enable keystore encryption */)); | 233 true /* enable keystore encryption */)); |
234 context_->set_routing_info(routing_info); | 234 context_->set_routing_info(routing_info); |
235 ASSERT_FALSE(context_->resolver()); | |
236 syncer_ = new Syncer(); | 235 syncer_ = new Syncer(); |
237 session_.reset(MakeSession()); | 236 session_.reset(MakeSession()); |
238 | 237 |
239 syncable::ReadTransaction trans(FROM_HERE, directory()); | 238 syncable::ReadTransaction trans(FROM_HERE, directory()); |
240 syncable::Directory::ChildHandles children; | 239 syncable::Directory::ChildHandles children; |
241 directory()->GetChildHandlesById(&trans, trans.root_id(), &children); | 240 directory()->GetChildHandlesById(&trans, trans.root_id(), &children); |
242 ASSERT_EQ(0u, children.size()); | 241 ASSERT_EQ(0u, children.size()); |
243 saw_syncer_event_ = false; | 242 saw_syncer_event_ = false; |
244 root_id_ = TestIdFactory::root(); | 243 root_id_ = TestIdFactory::root(); |
245 parent_id_ = ids_.MakeServer("parent id"); | 244 parent_id_ = ids_.MakeServer("parent id"); |
(...skipping 2315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2561 } | 2560 } |
2562 } | 2561 } |
2563 ASSERT_EQ(items_to_commit, directory()->unsynced_entity_count()); | 2562 ASSERT_EQ(items_to_commit, directory()->unsynced_entity_count()); |
2564 | 2563 |
2565 // Return a CONFLICT response for the first item. | 2564 // Return a CONFLICT response for the first item. |
2566 mock_server_->set_conflict_n_commits(1); | 2565 mock_server_->set_conflict_n_commits(1); |
2567 SyncShareNudge(); | 2566 SyncShareNudge(); |
2568 | 2567 |
2569 // We should stop looping at the first sign of trouble. | 2568 // We should stop looping at the first sign of trouble. |
2570 EXPECT_EQ(1U, mock_server_->commit_messages().size()); | 2569 EXPECT_EQ(1U, mock_server_->commit_messages().size()); |
2571 EXPECT_FALSE(session_->HasMoreToSync()); | |
2572 EXPECT_EQ(items_to_commit - (kDefaultMaxCommitBatchSize - 1), | 2570 EXPECT_EQ(items_to_commit - (kDefaultMaxCommitBatchSize - 1), |
2573 directory()->unsynced_entity_count()); | 2571 directory()->unsynced_entity_count()); |
2574 } | 2572 } |
2575 | 2573 |
2576 TEST_F(SyncerTest, HugeConflict) { | 2574 TEST_F(SyncerTest, HugeConflict) { |
2577 int item_count = 300; // We should be able to do 300 or 3000 w/o issue. | 2575 int item_count = 300; // We should be able to do 300 or 3000 w/o issue. |
2578 | 2576 |
2579 syncable::Id parent_id = ids_.NewServerId(); | 2577 syncable::Id parent_id = ids_.NewServerId(); |
2580 syncable::Id last_id = parent_id; | 2578 syncable::Id last_id = parent_id; |
2581 vector<syncable::Id> tree_ids; | 2579 vector<syncable::Id> tree_ids; |
(...skipping 2131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4713 | 4711 |
4714 TEST_F(SyncerPositionTiebreakingTest, MidLowHigh) { | 4712 TEST_F(SyncerPositionTiebreakingTest, MidLowHigh) { |
4715 Add(mid_id_); | 4713 Add(mid_id_); |
4716 Add(low_id_); | 4714 Add(low_id_); |
4717 Add(high_id_); | 4715 Add(high_id_); |
4718 SyncShareNudge(); | 4716 SyncShareNudge(); |
4719 ExpectLocalOrderIsByServerId(); | 4717 ExpectLocalOrderIsByServerId(); |
4720 } | 4718 } |
4721 | 4719 |
4722 } // namespace syncer | 4720 } // namespace syncer |
OLD | NEW |