| 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 #include "sync/sessions/sync_session.h" | 5 #include "sync/sessions/sync_session.h" |
| 6 | 6 |
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 | 185 |
| 186 scoped_ptr<SyncSession> session(MakeSession()); | 186 scoped_ptr<SyncSession> session(MakeSession()); |
| 187 EXPECT_TRUE(NULL == session->write_transaction()); | 187 EXPECT_TRUE(NULL == session->write_transaction()); |
| 188 { | 188 { |
| 189 WriteTransaction trans(FROM_HERE, syncable::UNITTEST, directory); | 189 WriteTransaction trans(FROM_HERE, syncable::UNITTEST, directory); |
| 190 sessions::ScopedSetSessionWriteTransaction set_trans(session.get(), &trans); | 190 sessions::ScopedSetSessionWriteTransaction set_trans(session.get(), &trans); |
| 191 EXPECT_TRUE(&trans == session->write_transaction()); | 191 EXPECT_TRUE(&trans == session->write_transaction()); |
| 192 } | 192 } |
| 193 } | 193 } |
| 194 | 194 |
| 195 TEST_F(SyncSessionTest, MoreToSyncIfUnsyncedGreaterThanCommitted) { | |
| 196 // If any forward progress was made during the session, and the number of | |
| 197 // unsynced handles still exceeds the number of commit ids we added, there is | |
| 198 // more to sync. For example, this occurs if we had more commit ids | |
| 199 // than could fit in a single commit batch. | |
| 200 EXPECT_FALSE(session_->HasMoreToSync()); | |
| 201 OrderedCommitSet commit_set(routes_); | |
| 202 commit_set.AddCommitItem(0, syncable::Id(), syncable::BOOKMARKS); | |
| 203 status()->set_commit_set(commit_set); | |
| 204 EXPECT_FALSE(session_->HasMoreToSync()); | |
| 205 | |
| 206 std::vector<int64> unsynced_handles; | |
| 207 unsynced_handles.push_back(1); | |
| 208 unsynced_handles.push_back(2); | |
| 209 status()->set_unsynced_handles(unsynced_handles); | |
| 210 EXPECT_FALSE(session_->HasMoreToSync()); | |
| 211 status()->increment_num_successful_commits(); | |
| 212 EXPECT_TRUE(session_->HasMoreToSync()); | |
| 213 } | |
| 214 | |
| 215 TEST_F(SyncSessionTest, MoreToDownloadIfDownloadFailed) { | 195 TEST_F(SyncSessionTest, MoreToDownloadIfDownloadFailed) { |
| 216 status()->set_updates_request_types(ParamsMeaningAllEnabledTypes()); | 196 status()->set_updates_request_types(ParamsMeaningAllEnabledTypes()); |
| 217 | 197 |
| 218 // When DownloadUpdatesCommand fails, these should be false. | 198 // When DownloadUpdatesCommand fails, these should be false. |
| 219 EXPECT_FALSE(status()->ServerSaysNothingMoreToDownload()); | 199 EXPECT_FALSE(status()->ServerSaysNothingMoreToDownload()); |
| 220 EXPECT_FALSE(status()->download_updates_succeeded()); | 200 EXPECT_FALSE(status()->download_updates_succeeded()); |
| 221 | 201 |
| 222 // Download updates has its own loop in the syncer; it shouldn't factor | 202 // Download updates has its own loop in the syncer; it shouldn't factor |
| 223 // into HasMoreToSync. | 203 // into HasMoreToSync. |
| 224 EXPECT_FALSE(session_->HasMoreToSync()); | 204 EXPECT_FALSE(session_->HasMoreToSync()); |
| (...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 587 EXPECT_EQ(empty_payload, original[syncable::BOOKMARKS]); | 567 EXPECT_EQ(empty_payload, original[syncable::BOOKMARKS]); |
| 588 EXPECT_EQ(payload1, original[syncable::PASSWORDS]); | 568 EXPECT_EQ(payload1, original[syncable::PASSWORDS]); |
| 589 EXPECT_EQ(payload1, original[syncable::AUTOFILL]); | 569 EXPECT_EQ(payload1, original[syncable::AUTOFILL]); |
| 590 EXPECT_EQ(payload2, original[syncable::SESSIONS]); | 570 EXPECT_EQ(payload2, original[syncable::SESSIONS]); |
| 591 EXPECT_EQ(payload3, original[syncable::THEMES]); | 571 EXPECT_EQ(payload3, original[syncable::THEMES]); |
| 592 } | 572 } |
| 593 | 573 |
| 594 } // namespace | 574 } // namespace |
| 595 } // namespace sessions | 575 } // namespace sessions |
| 596 } // namespace browser_sync | 576 } // namespace browser_sync |
| OLD | NEW |