Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(501)

Side by Side Diff: sync/sessions/sync_session_unittest.cc

Issue 10210009: sync: Loop committing items without downloading updates (v2) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sync/sessions/sync_session.cc ('k') | sync/sessions/test_util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 status()->set_last_download_updates_result(NETWORK_IO_ERROR); 198 status()->set_last_download_updates_result(NETWORK_IO_ERROR);
219 199
220 // When DownloadUpdatesCommand fails, these should be false. 200 // When DownloadUpdatesCommand fails, these should be false.
221 EXPECT_FALSE(status()->ServerSaysNothingMoreToDownload()); 201 EXPECT_FALSE(status()->ServerSaysNothingMoreToDownload());
222 EXPECT_FALSE(status()->download_updates_succeeded()); 202 EXPECT_FALSE(status()->download_updates_succeeded());
223 203
224 // Download updates has its own loop in the syncer; it shouldn't factor 204 // Download updates has its own loop in the syncer; it shouldn't factor
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 EXPECT_EQ(empty_payload, original[syncable::BOOKMARKS]); 523 EXPECT_EQ(empty_payload, original[syncable::BOOKMARKS]);
544 EXPECT_EQ(payload1, original[syncable::PASSWORDS]); 524 EXPECT_EQ(payload1, original[syncable::PASSWORDS]);
545 EXPECT_EQ(payload1, original[syncable::AUTOFILL]); 525 EXPECT_EQ(payload1, original[syncable::AUTOFILL]);
546 EXPECT_EQ(payload2, original[syncable::SESSIONS]); 526 EXPECT_EQ(payload2, original[syncable::SESSIONS]);
547 EXPECT_EQ(payload3, original[syncable::THEMES]); 527 EXPECT_EQ(payload3, original[syncable::THEMES]);
548 } 528 }
549 529
550 } // namespace 530 } // namespace
551 } // namespace sessions 531 } // namespace sessions
552 } // namespace browser_sync 532 } // namespace browser_sync
OLDNEW
« no previous file with comments | « sync/sessions/sync_session.cc ('k') | sync/sessions/test_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698