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 1681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1692 mock_server_->AddUpdateDirectory(1, 0, "", 1, 10); | 1692 mock_server_->AddUpdateDirectory(1, 0, "", 1, 10); |
1693 // And one legal one that we're going to delete. | 1693 // And one legal one that we're going to delete. |
1694 mock_server_->AddUpdateDirectory(2, 0, "FOO", 1, 10); | 1694 mock_server_->AddUpdateDirectory(2, 0, "FOO", 1, 10); |
1695 SyncShareAsDelegate(); | 1695 SyncShareAsDelegate(); |
1696 // Delete the legal one. The new update has a null name. | 1696 // Delete the legal one. The new update has a null name. |
1697 mock_server_->AddUpdateDirectory(2, 0, "", 2, 20); | 1697 mock_server_->AddUpdateDirectory(2, 0, "", 2, 20); |
1698 mock_server_->SetLastUpdateDeleted(); | 1698 mock_server_->SetLastUpdateDeleted(); |
1699 SyncShareAsDelegate(); | 1699 SyncShareAsDelegate(); |
1700 } | 1700 } |
1701 | 1701 |
1702 TEST_F(SyncerTest, DontGetStuckWithTwoSameNames) { | |
tim (not reviewing)
2012/01/10 17:01:47
Is it bad to test that two updates with the same n
rlarocque
2012/01/10 21:39:32
My understanding is that we don't actually look at
tim (not reviewing)
2012/01/11 02:15:35
That's not true, actually. We haven't deleted them
rlarocque
2012/01/11 19:58:36
I exaggerated when I commented on the state of thi
| |
1703 // We should not get stuck here because we get | |
1704 // two server updates with exactly the same name. | |
1705 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); | |
1706 ASSERT_TRUE(dir.good()); | |
1707 mock_server_->AddUpdateDirectory(1, 0, "foo:", 1, 10); | |
1708 SyncShareAsDelegate(); | |
1709 mock_server_->AddUpdateDirectory(2, 0, "foo:", 1, 20); | |
1710 SyncRepeatedlyToTriggerStuckSignal(session_.get()); | |
1711 EXPECT_FALSE(session_->status_controller().syncer_status().syncer_stuck); | |
1712 saw_syncer_event_ = false; | |
1713 } | |
1714 | |
1715 TEST_F(SyncerTest, TestBasicUpdate) { | 1702 TEST_F(SyncerTest, TestBasicUpdate) { |
1716 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); | 1703 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); |
1717 ASSERT_TRUE(dir.good()); | 1704 ASSERT_TRUE(dir.good()); |
1718 string id = "some_id"; | 1705 string id = "some_id"; |
1719 string parent_id = "0"; | 1706 string parent_id = "0"; |
1720 string name = "in_root"; | 1707 string name = "in_root"; |
1721 int64 version = 10; | 1708 int64 version = 10; |
1722 int64 timestamp = 10; | 1709 int64 timestamp = 10; |
1723 mock_server_->AddUpdateDirectory(id, parent_id, name, version, timestamp); | 1710 mock_server_->AddUpdateDirectory(id, parent_id, name, version, timestamp); |
1724 | 1711 |
(...skipping 1522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3247 SyncShareAsDelegate(); | 3234 SyncShareAsDelegate(); |
3248 { | 3235 { |
3249 WriteTransaction trans(FROM_HERE, UNITTEST, dir); | 3236 WriteTransaction trans(FROM_HERE, UNITTEST, dir); |
3250 MutableEntry entry(&trans, CREATE, trans.root_id(), "Copy of base"); | 3237 MutableEntry entry(&trans, CREATE, trans.root_id(), "Copy of base"); |
3251 WriteTestDataToEntry(&trans, &entry); | 3238 WriteTestDataToEntry(&trans, &entry); |
3252 } | 3239 } |
3253 mock_server_->AddUpdateBookmark(1, 0, "Copy of base", 50, 50); | 3240 mock_server_->AddUpdateBookmark(1, 0, "Copy of base", 50, 50); |
3254 SyncRepeatedlyToTriggerConflictResolution(session_.get()); | 3241 SyncRepeatedlyToTriggerConflictResolution(session_.get()); |
3255 } | 3242 } |
3256 | 3243 |
3257 TEST_F(SyncerTest, OneBajillionUpdates) { | |
3258 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); | |
3259 CHECK(dir.good()); | |
3260 int one_bajillion = 4000; | |
3261 | |
3262 syncable::Id parent_id = ids_.MakeServer("Parent"); | |
3263 mock_server_->AddUpdateDirectory(parent_id, ids_.root(), "foo", 1, 1); | |
3264 | |
3265 for (int i = 1; i <= one_bajillion; ++i) { | |
3266 syncable::Id item_id = ids_.FromNumber(i); | |
3267 mock_server_->AddUpdateDirectory(item_id, parent_id, "dude", 1, 1); | |
3268 } | |
3269 | |
3270 syncer_->SyncShare(session_.get(), SYNCER_BEGIN, SYNCER_END); | |
3271 EXPECT_FALSE(session_->status_controller().syncer_status().syncer_stuck); | |
tim (not reviewing)
2012/01/10 17:01:47
I kind of have the same question as above. I don'
rlarocque
2012/01/10 21:39:32
I'm not sure this ever made sense. What did we ho
tim (not reviewing)
2012/01/11 02:15:35
Well, even though I closed the bug myself with a s
rlarocque
2012/01/11 19:58:36
I agree, scale* tests are useful. But a scale tes
| |
3272 } | |
3273 | |
3274 // In this test a long changelog contains a child at the start of the changelog | 3244 // In this test a long changelog contains a child at the start of the changelog |
3275 // and a parent at the end. While these updates are in progress the client would | 3245 // and a parent at the end. While these updates are in progress the client would |
3276 // appear stuck. | 3246 // appear stuck. |
3277 TEST_F(SyncerTest, LongChangelistWithApplicationConflict) { | 3247 TEST_F(SyncerTest, LongChangelistWithApplicationConflict) { |
3278 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); | 3248 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); |
3279 CHECK(dir.good()); | 3249 CHECK(dir.good()); |
3280 const int depth = 400; | 3250 const int depth = 400; |
3281 syncable::Id folder_id = ids_.FromNumber(1); | 3251 syncable::Id folder_id = ids_.FromNumber(1); |
3282 | 3252 |
3283 // First we an item in a folder in the root. However the folder won't come | 3253 // First we an item in a folder in the root. However the folder won't come |
3284 // till much later. | 3254 // till much later. |
3285 syncable::Id stuck_entry_id = TestIdFactory::FromNumber(99999); | 3255 syncable::Id stuck_entry_id = TestIdFactory::FromNumber(99999); |
3286 mock_server_->AddUpdateDirectory(stuck_entry_id, | 3256 mock_server_->AddUpdateDirectory(stuck_entry_id, |
3287 folder_id, "stuck", 1, 1); | 3257 folder_id, "stuck", 1, 1); |
3288 mock_server_->SetChangesRemaining(depth - 1); | 3258 mock_server_->SetChangesRemaining(depth - 1); |
3289 syncer_->SyncShare(session_.get(), SYNCER_BEGIN, SYNCER_END); | 3259 syncer_->SyncShare(session_.get(), SYNCER_BEGIN, SYNCER_END); |
3290 | 3260 |
3291 // Buffer up a very long series of downloads. | 3261 // Buffer up a very long series of downloads. |
3292 // We should never be stuck (conflict resolution shouldn't | 3262 // We should never be stuck (conflict resolution shouldn't |
3293 // kick in so long as we're making forward progress). | 3263 // kick in so long as we're making forward progress). |
3294 for (int i = 0; i < depth; i++) { | 3264 for (int i = 0; i < depth; i++) { |
3295 mock_server_->NextUpdateBatch(); | 3265 mock_server_->NextUpdateBatch(); |
3296 mock_server_->SetNewTimestamp(i + 1); | 3266 mock_server_->SetNewTimestamp(i + 1); |
3297 mock_server_->SetChangesRemaining(depth - i); | 3267 mock_server_->SetChangesRemaining(depth - i); |
3298 } | 3268 } |
3299 | 3269 |
3300 syncer_->SyncShare(session_.get(), SYNCER_BEGIN, SYNCER_END); | 3270 syncer_->SyncShare(session_.get(), SYNCER_BEGIN, SYNCER_END); |
3301 EXPECT_FALSE(session_->status_controller().syncer_status().syncer_stuck); | |
3302 | 3271 |
3303 // Ensure our folder hasn't somehow applied. | 3272 // Ensure our folder hasn't somehow applied. |
3304 { | 3273 { |
3305 ReadTransaction trans(FROM_HERE, dir); | 3274 ReadTransaction trans(FROM_HERE, dir); |
3306 Entry child(&trans, GET_BY_ID, stuck_entry_id); | 3275 Entry child(&trans, GET_BY_ID, stuck_entry_id); |
3307 EXPECT_TRUE(child.good()); | 3276 EXPECT_TRUE(child.good()); |
3308 EXPECT_TRUE(child.Get(IS_UNAPPLIED_UPDATE)); | 3277 EXPECT_TRUE(child.Get(IS_UNAPPLIED_UPDATE)); |
3309 EXPECT_TRUE(child.Get(IS_DEL)); | 3278 EXPECT_TRUE(child.Get(IS_DEL)); |
3310 EXPECT_FALSE(child.Get(IS_UNSYNCED)); | 3279 EXPECT_FALSE(child.Get(IS_UNSYNCED)); |
3311 } | 3280 } |
(...skipping 1538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4850 Add(low_id_); | 4819 Add(low_id_); |
4851 Add(high_id_); | 4820 Add(high_id_); |
4852 SyncShareAsDelegate(); | 4821 SyncShareAsDelegate(); |
4853 ExpectLocalOrderIsByServerId(); | 4822 ExpectLocalOrderIsByServerId(); |
4854 } | 4823 } |
4855 | 4824 |
4856 const SyncerTest::CommitOrderingTest | 4825 const SyncerTest::CommitOrderingTest |
4857 SyncerTest::CommitOrderingTest::LAST_COMMIT_ITEM = {-1, TestIdFactory::root()}; | 4826 SyncerTest::CommitOrderingTest::LAST_COMMIT_ITEM = {-1, TestIdFactory::root()}; |
4858 | 4827 |
4859 } // namespace browser_sync | 4828 } // namespace browser_sync |
OLD | NEW |