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

Side by Side Diff: sync/engine/syncer_unittest.cc

Issue 72403003: sync: Per-type update application (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase + fix typo Created 7 years 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/engine/syncer_command.cc ('k') | sync/engine/update_applicator.h » ('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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 } 182 }
183 183
184 void SyncShareNudge() { 184 void SyncShareNudge() {
185 session_.reset(SyncSession::Build(context_.get(), this)); 185 session_.reset(SyncSession::Build(context_.get(), this));
186 186
187 // Pretend we've seen a local change, to make the nudge_tracker look normal. 187 // Pretend we've seen a local change, to make the nudge_tracker look normal.
188 nudge_tracker_.RecordLocalChange(ModelTypeSet(BOOKMARKS)); 188 nudge_tracker_.RecordLocalChange(ModelTypeSet(BOOKMARKS));
189 189
190 EXPECT_TRUE( 190 EXPECT_TRUE(
191 syncer_->NormalSyncShare( 191 syncer_->NormalSyncShare(
192 GetRoutingInfoTypes(context_->routing_info()), 192 context_->enabled_types(),
193 nudge_tracker_, 193 nudge_tracker_,
194 session_.get())); 194 session_.get()));
195 } 195 }
196 196
197 void SyncShareConfigure() { 197 void SyncShareConfigure() {
198 session_.reset(SyncSession::Build(context_.get(), this)); 198 session_.reset(SyncSession::Build(context_.get(), this));
199 EXPECT_TRUE(syncer_->ConfigureSyncShare( 199 EXPECT_TRUE(syncer_->ConfigureSyncShare(
200 GetRoutingInfoTypes(context_->routing_info()), 200 context_->enabled_types(),
201 sync_pb::GetUpdatesCallerInfo::RECONFIGURATION, 201 sync_pb::GetUpdatesCallerInfo::RECONFIGURATION,
202 session_.get())); 202 session_.get()));
203 } 203 }
204 204
205 virtual void SetUp() { 205 virtual void SetUp() {
206 dir_maker_.SetUp(); 206 dir_maker_.SetUp();
207 mock_server_.reset(new MockConnectionManager(directory(), 207 mock_server_.reset(new MockConnectionManager(directory(),
208 &cancelation_signal_)); 208 &cancelation_signal_));
209 debug_info_getter_.reset(new MockDebugInfoGetter); 209 debug_info_getter_.reset(new MockDebugInfoGetter);
210 EnableDatatype(BOOKMARKS); 210 EnableDatatype(BOOKMARKS);
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); 537 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory());
538 MutableEntry A(&wtrans, GET_BY_ID, ids_.FromNumber(1)); 538 MutableEntry A(&wtrans, GET_BY_ID, ids_.FromNumber(1));
539 ASSERT_TRUE(A.good()); 539 ASSERT_TRUE(A.good());
540 A.PutIsUnsynced(true); 540 A.PutIsUnsynced(true);
541 A.PutSpecifics(bookmark_data); 541 A.PutSpecifics(bookmark_data);
542 A.PutNonUniqueName("bookmark"); 542 A.PutNonUniqueName("bookmark");
543 } 543 }
544 544
545 // Now sync without enabling bookmarks. 545 // Now sync without enabling bookmarks.
546 syncer_->NormalSyncShare( 546 syncer_->NormalSyncShare(
547 Difference(GetRoutingInfoTypes(context_->routing_info()), 547 Difference(context_->enabled_types(), ModelTypeSet(BOOKMARKS)),
548 ModelTypeSet(BOOKMARKS)),
549 nudge_tracker_, 548 nudge_tracker_,
550 session_.get()); 549 session_.get());
551 550
552 { 551 {
553 // Nothing should have been committed as bookmarks is throttled. 552 // Nothing should have been committed as bookmarks is throttled.
554 syncable::ReadTransaction rtrans(FROM_HERE, directory()); 553 syncable::ReadTransaction rtrans(FROM_HERE, directory());
555 Entry entryA(&rtrans, syncable::GET_BY_ID, ids_.FromNumber(1)); 554 Entry entryA(&rtrans, syncable::GET_BY_ID, ids_.FromNumber(1));
556 ASSERT_TRUE(entryA.good()); 555 ASSERT_TRUE(entryA.good());
557 EXPECT_TRUE(entryA.GetIsUnsynced()); 556 EXPECT_TRUE(entryA.GetIsUnsynced());
558 } 557 }
559 558
560 // Sync again with bookmarks enabled. 559 // Sync again with bookmarks enabled.
561 syncer_->NormalSyncShare( 560 syncer_->NormalSyncShare(
562 GetRoutingInfoTypes(context_->routing_info()), 561 context_->enabled_types(),
563 nudge_tracker_, 562 nudge_tracker_,
564 session_.get()); 563 session_.get());
565 SyncShareNudge(); 564 SyncShareNudge();
566 { 565 {
567 // It should have been committed. 566 // It should have been committed.
568 syncable::ReadTransaction rtrans(FROM_HERE, directory()); 567 syncable::ReadTransaction rtrans(FROM_HERE, directory());
569 Entry entryA(&rtrans, syncable::GET_BY_ID, ids_.FromNumber(1)); 568 Entry entryA(&rtrans, syncable::GET_BY_ID, ids_.FromNumber(1));
570 ASSERT_TRUE(entryA.good()); 569 ASSERT_TRUE(entryA.good());
571 EXPECT_FALSE(entryA.GetIsUnsynced()); 570 EXPECT_FALSE(entryA.GetIsUnsynced());
572 } 571 }
(...skipping 4226 matching lines...) Expand 10 before | Expand all | Expand 10 after
4799 EXPECT_EQ("xyz", final_monitor_records["xyz"].extension_id); 4798 EXPECT_EQ("xyz", final_monitor_records["xyz"].extension_id);
4800 EXPECT_EQ(2049U, final_monitor_records["ABC"].bookmark_write_count); 4799 EXPECT_EQ(2049U, final_monitor_records["ABC"].bookmark_write_count);
4801 EXPECT_EQ(4U, final_monitor_records["xyz"].bookmark_write_count); 4800 EXPECT_EQ(4U, final_monitor_records["xyz"].bookmark_write_count);
4802 } else { 4801 } else {
4803 EXPECT_TRUE(final_monitor_records.empty()) 4802 EXPECT_TRUE(final_monitor_records.empty())
4804 << "Should not restore records after successful bookmark commit."; 4803 << "Should not restore records after successful bookmark commit.";
4805 } 4804 }
4806 } 4805 }
4807 4806
4808 } // namespace syncer 4807 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/engine/syncer_command.cc ('k') | sync/engine/update_applicator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698