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

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

Issue 23717047: Retry: sync: Gracefully handle early shutdown (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Renames Created 7 years, 3 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/engine/syncer_proto_util_unittest.cc ('k') | sync/internal_api/http_bridge.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 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 12 matching lines...) Expand all
23 #include "base/strings/stringprintf.h" 23 #include "base/strings/stringprintf.h"
24 #include "base/time/time.h" 24 #include "base/time/time.h"
25 #include "build/build_config.h" 25 #include "build/build_config.h"
26 #include "sync/engine/get_commit_ids.h" 26 #include "sync/engine/get_commit_ids.h"
27 #include "sync/engine/net/server_connection_manager.h" 27 #include "sync/engine/net/server_connection_manager.h"
28 #include "sync/engine/process_updates_command.h" 28 #include "sync/engine/process_updates_command.h"
29 #include "sync/engine/sync_scheduler_impl.h" 29 #include "sync/engine/sync_scheduler_impl.h"
30 #include "sync/engine/syncer.h" 30 #include "sync/engine/syncer.h"
31 #include "sync/engine/syncer_proto_util.h" 31 #include "sync/engine/syncer_proto_util.h"
32 #include "sync/engine/traffic_recorder.h" 32 #include "sync/engine/traffic_recorder.h"
33 #include "sync/internal_api/public/base/cancelation_signal.h"
33 #include "sync/internal_api/public/base/model_type.h" 34 #include "sync/internal_api/public/base/model_type.h"
34 #include "sync/internal_api/public/engine/model_safe_worker.h" 35 #include "sync/internal_api/public/engine/model_safe_worker.h"
35 #include "sync/protocol/bookmark_specifics.pb.h" 36 #include "sync/protocol/bookmark_specifics.pb.h"
36 #include "sync/protocol/nigori_specifics.pb.h" 37 #include "sync/protocol/nigori_specifics.pb.h"
37 #include "sync/protocol/preference_specifics.pb.h" 38 #include "sync/protocol/preference_specifics.pb.h"
38 #include "sync/protocol/sync.pb.h" 39 #include "sync/protocol/sync.pb.h"
39 #include "sync/sessions/sync_session_context.h" 40 #include "sync/sessions/sync_session_context.h"
40 #include "sync/syncable/mutable_entry.h" 41 #include "sync/syncable/mutable_entry.h"
41 #include "sync/syncable/nigori_util.h" 42 #include "sync/syncable/nigori_util.h"
42 #include "sync/syncable/syncable_delete_journal.h" 43 #include "sync/syncable/syncable_delete_journal.h"
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 void SyncShareConfigure() { 198 void SyncShareConfigure() {
198 session_.reset(SyncSession::Build(context_.get(), this)); 199 session_.reset(SyncSession::Build(context_.get(), this));
199 EXPECT_TRUE(syncer_->ConfigureSyncShare( 200 EXPECT_TRUE(syncer_->ConfigureSyncShare(
200 GetRoutingInfoTypes(context_->routing_info()), 201 GetRoutingInfoTypes(context_->routing_info()),
201 sync_pb::GetUpdatesCallerInfo::RECONFIGURATION, 202 sync_pb::GetUpdatesCallerInfo::RECONFIGURATION,
202 session_.get())); 203 session_.get()));
203 } 204 }
204 205
205 virtual void SetUp() { 206 virtual void SetUp() {
206 dir_maker_.SetUp(); 207 dir_maker_.SetUp();
207 mock_server_.reset(new MockConnectionManager(directory())); 208 mock_server_.reset(new MockConnectionManager(directory(),
209 &cancelation_signal_));
208 EnableDatatype(BOOKMARKS); 210 EnableDatatype(BOOKMARKS);
209 EnableDatatype(NIGORI); 211 EnableDatatype(NIGORI);
210 EnableDatatype(PREFERENCES); 212 EnableDatatype(PREFERENCES);
211 EnableDatatype(NIGORI); 213 EnableDatatype(NIGORI);
212 worker_ = new FakeModelWorker(GROUP_PASSIVE); 214 worker_ = new FakeModelWorker(GROUP_PASSIVE);
213 std::vector<SyncEngineEventListener*> listeners; 215 std::vector<SyncEngineEventListener*> listeners;
214 listeners.push_back(this); 216 listeners.push_back(this);
215 217
216 ModelSafeRoutingInfo routing_info; 218 ModelSafeRoutingInfo routing_info;
217 std::vector<ModelSafeWorker*> workers; 219 std::vector<ModelSafeWorker*> workers;
218 220
219 GetModelSafeRoutingInfo(&routing_info); 221 GetModelSafeRoutingInfo(&routing_info);
220 GetWorkers(&workers); 222 GetWorkers(&workers);
221 223
222 context_.reset( 224 context_.reset(
223 new SyncSessionContext( 225 new SyncSessionContext(
224 mock_server_.get(), directory(), workers, 226 mock_server_.get(), directory(), workers,
225 extensions_activity_, 227 extensions_activity_,
226 listeners, NULL, &traffic_recorder_, 228 listeners, NULL, &traffic_recorder_,
227 true, // enable keystore encryption 229 true, // enable keystore encryption
228 false, // force enable pre-commit GU avoidance experiment 230 false, // force enable pre-commit GU avoidance experiment
229 "fake_invalidator_client_id")); 231 "fake_invalidator_client_id"));
230 context_->set_routing_info(routing_info); 232 context_->set_routing_info(routing_info);
231 syncer_ = new Syncer(); 233 syncer_ = new Syncer(&cancelation_signal_);
232 234
233 syncable::ReadTransaction trans(FROM_HERE, directory()); 235 syncable::ReadTransaction trans(FROM_HERE, directory());
234 syncable::Directory::Metahandles children; 236 syncable::Directory::Metahandles children;
235 directory()->GetChildHandlesById(&trans, trans.root_id(), &children); 237 directory()->GetChildHandlesById(&trans, trans.root_id(), &children);
236 ASSERT_EQ(0u, children.size()); 238 ASSERT_EQ(0u, children.size());
237 saw_syncer_event_ = false; 239 saw_syncer_event_ = false;
238 root_id_ = TestIdFactory::root(); 240 root_id_ = TestIdFactory::root();
239 parent_id_ = ids_.MakeServer("parent id"); 241 parent_id_ = ids_.MakeServer("parent id");
240 child_id_ = ids_.MakeServer("child id"); 242 child_id_ = ids_.MakeServer("child id");
241 directory()->set_store_birthday(mock_server_->store_birthday()); 243 directory()->set_store_birthday(mock_server_->store_birthday());
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 syncable::Id root_id_; 499 syncable::Id root_id_;
498 syncable::Id parent_id_; 500 syncable::Id parent_id_;
499 syncable::Id child_id_; 501 syncable::Id child_id_;
500 502
501 TestIdFactory ids_; 503 TestIdFactory ids_;
502 504
503 TestDirectorySetterUpper dir_maker_; 505 TestDirectorySetterUpper dir_maker_;
504 FakeEncryptor encryptor_; 506 FakeEncryptor encryptor_;
505 scoped_refptr<ExtensionsActivity> extensions_activity_; 507 scoped_refptr<ExtensionsActivity> extensions_activity_;
506 scoped_ptr<MockConnectionManager> mock_server_; 508 scoped_ptr<MockConnectionManager> mock_server_;
509 CancelationSignal cancelation_signal_;
507 510
508 Syncer* syncer_; 511 Syncer* syncer_;
509 512
510 scoped_ptr<SyncSession> session_; 513 scoped_ptr<SyncSession> session_;
511 scoped_ptr<SyncSessionContext> context_; 514 scoped_ptr<SyncSessionContext> context_;
512 bool saw_syncer_event_; 515 bool saw_syncer_event_;
513 base::TimeDelta last_short_poll_interval_received_; 516 base::TimeDelta last_short_poll_interval_received_;
514 base::TimeDelta last_long_poll_interval_received_; 517 base::TimeDelta last_long_poll_interval_received_;
515 base::TimeDelta last_sessions_commit_delay_seconds_; 518 base::TimeDelta last_sessions_commit_delay_seconds_;
516 int last_client_invalidation_hint_buffer_size_; 519 int last_client_invalidation_hint_buffer_size_;
(...skipping 4230 matching lines...) Expand 10 before | Expand all | Expand 10 after
4747 EXPECT_EQ("xyz", final_monitor_records["xyz"].extension_id); 4750 EXPECT_EQ("xyz", final_monitor_records["xyz"].extension_id);
4748 EXPECT_EQ(2049U, final_monitor_records["ABC"].bookmark_write_count); 4751 EXPECT_EQ(2049U, final_monitor_records["ABC"].bookmark_write_count);
4749 EXPECT_EQ(4U, final_monitor_records["xyz"].bookmark_write_count); 4752 EXPECT_EQ(4U, final_monitor_records["xyz"].bookmark_write_count);
4750 } else { 4753 } else {
4751 EXPECT_TRUE(final_monitor_records.empty()) 4754 EXPECT_TRUE(final_monitor_records.empty())
4752 << "Should not restore records after successful bookmark commit."; 4755 << "Should not restore records after successful bookmark commit.";
4753 } 4756 }
4754 } 4757 }
4755 4758
4756 } // namespace syncer 4759 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/engine/syncer_proto_util_unittest.cc ('k') | sync/internal_api/http_bridge.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698