| 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 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 StatusController* status = session_->mutable_status_controller(); | 363 StatusController* status = session_->mutable_status_controller(); |
| 364 WriteTransaction wtrans(FROM_HERE, UNITTEST, dir); | 364 WriteTransaction wtrans(FROM_HERE, UNITTEST, dir); |
| 365 ScopedSetSessionWriteTransaction set_trans(session_.get(), &wtrans); | 365 ScopedSetSessionWriteTransaction set_trans(session_.get(), &wtrans); |
| 366 status->set_unsynced_handles(unsynced_handle_view); | 366 status->set_unsynced_handles(unsynced_handle_view); |
| 367 | 367 |
| 368 ModelSafeRoutingInfo routes; | 368 ModelSafeRoutingInfo routes; |
| 369 GetModelSafeRoutingInfo(&routes); | 369 GetModelSafeRoutingInfo(&routes); |
| 370 GetCommitIdsCommand command(limit); | 370 GetCommitIdsCommand command(limit); |
| 371 command.BuildCommitIds( | 371 command.BuildCommitIds( |
| 372 session_->status_controller().unsynced_handles(), | 372 session_->status_controller().unsynced_handles(), |
| 373 session_->write_transaction(), routes, syncable::ModelTypeSet()); | 373 session_->write_transaction(), routes, syncable::ModelEnumSet()); |
| 374 vector<syncable::Id> output = | 374 vector<syncable::Id> output = |
| 375 command.ordered_commit_set_->GetAllCommitIds(); | 375 command.ordered_commit_set_->GetAllCommitIds(); |
| 376 size_t truncated_size = std::min(limit, expected_id_order.size()); | 376 size_t truncated_size = std::min(limit, expected_id_order.size()); |
| 377 ASSERT_TRUE(truncated_size == output.size()); | 377 ASSERT_TRUE(truncated_size == output.size()); |
| 378 for (size_t i = 0; i < truncated_size; ++i) { | 378 for (size_t i = 0; i < truncated_size; ++i) { |
| 379 ASSERT_TRUE(expected_id_order[i] == output[i]) | 379 ASSERT_TRUE(expected_id_order[i] == output[i]) |
| 380 << "At index " << i << " with batch size limited to " << limit; | 380 << "At index " << i << " with batch size limited to " << limit; |
| 381 } | 381 } |
| 382 sessions::OrderedCommitSet::Projection proj; | 382 sessions::OrderedCommitSet::Projection proj; |
| 383 proj = command.ordered_commit_set_->GetCommitIdProjection(GROUP_PASSIVE); | 383 proj = command.ordered_commit_set_->GetCommitIdProjection(GROUP_PASSIVE); |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 551 expected_order.push_back(ids_.MakeLocal("x")); | 551 expected_order.push_back(ids_.MakeLocal("x")); |
| 552 expected_order.push_back(ids_.MakeLocal("b")); | 552 expected_order.push_back(ids_.MakeLocal("b")); |
| 553 expected_order.push_back(ids_.MakeLocal("c")); | 553 expected_order.push_back(ids_.MakeLocal("c")); |
| 554 expected_order.push_back(ids_.MakeLocal("e")); | 554 expected_order.push_back(ids_.MakeLocal("e")); |
| 555 DoTruncationTest(dir, unsynced_handle_view, expected_order); | 555 DoTruncationTest(dir, unsynced_handle_view, expected_order); |
| 556 } | 556 } |
| 557 | 557 |
| 558 TEST_F(SyncerTest, GetCommitIdsFiltersThrottledEntries) { | 558 TEST_F(SyncerTest, GetCommitIdsFiltersThrottledEntries) { |
| 559 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); | 559 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); |
| 560 ASSERT_TRUE(dir.good()); | 560 ASSERT_TRUE(dir.good()); |
| 561 syncable::ModelTypeSet throttled_types; | 561 const syncable::ModelEnumSet throttled_types(syncable::BOOKMARKS); |
| 562 throttled_types.insert(syncable::BOOKMARKS); | |
| 563 KeyParams key_params = {"localhost", "dummy", "foobar"}; | 562 KeyParams key_params = {"localhost", "dummy", "foobar"}; |
| 564 sync_pb::EntitySpecifics bookmark_data; | 563 sync_pb::EntitySpecifics bookmark_data; |
| 565 AddDefaultExtensionValue(syncable::BOOKMARKS, &bookmark_data); | 564 AddDefaultExtensionValue(syncable::BOOKMARKS, &bookmark_data); |
| 566 | 565 |
| 567 mock_server_->AddUpdateDirectory(1, 0, "A", 10, 10); | 566 mock_server_->AddUpdateDirectory(1, 0, "A", 10, 10); |
| 568 SyncShareAsDelegate(); | 567 SyncShareAsDelegate(); |
| 569 | 568 |
| 570 { | 569 { |
| 571 WriteTransaction wtrans(FROM_HERE, UNITTEST, dir); | 570 WriteTransaction wtrans(FROM_HERE, UNITTEST, dir); |
| 572 MutableEntry A(&wtrans, GET_BY_ID, ids_.FromNumber(1)); | 571 MutableEntry A(&wtrans, GET_BY_ID, ids_.FromNumber(1)); |
| (...skipping 4779 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5352 Add(low_id_); | 5351 Add(low_id_); |
| 5353 Add(high_id_); | 5352 Add(high_id_); |
| 5354 SyncShareAsDelegate(); | 5353 SyncShareAsDelegate(); |
| 5355 ExpectLocalOrderIsByServerId(); | 5354 ExpectLocalOrderIsByServerId(); |
| 5356 } | 5355 } |
| 5357 | 5356 |
| 5358 const SyncerTest::CommitOrderingTest | 5357 const SyncerTest::CommitOrderingTest |
| 5359 SyncerTest::CommitOrderingTest::LAST_COMMIT_ITEM = {-1, TestIdFactory::root()}; | 5358 SyncerTest::CommitOrderingTest::LAST_COMMIT_ITEM = {-1, TestIdFactory::root()}; |
| 5360 | 5359 |
| 5361 } // namespace browser_sync | 5360 } // namespace browser_sync |
| OLD | NEW |