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

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

Issue 9826035: [Sync] Display the client server traffic log in about:sync. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: For submitting. Created 8 years, 8 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/sync_scheduler_whitebox_unittest.cc ('k') | sync/engine/traffic_recorder.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 (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 // 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 14 matching lines...) Expand all
25 #include "build/build_config.h" 25 #include "build/build_config.h"
26 #include "sync/engine/get_commit_ids_command.h" 26 #include "sync/engine/get_commit_ids_command.h"
27 #include "sync/engine/model_safe_worker.h" 27 #include "sync/engine/model_safe_worker.h"
28 #include "sync/engine/net/server_connection_manager.h" 28 #include "sync/engine/net/server_connection_manager.h"
29 #include "sync/engine/nigori_util.h" 29 #include "sync/engine/nigori_util.h"
30 #include "sync/engine/process_updates_command.h" 30 #include "sync/engine/process_updates_command.h"
31 #include "sync/engine/syncer.h" 31 #include "sync/engine/syncer.h"
32 #include "sync/engine/syncer_proto_util.h" 32 #include "sync/engine/syncer_proto_util.h"
33 #include "sync/engine/syncer_util.h" 33 #include "sync/engine/syncer_util.h"
34 #include "sync/engine/syncproto.h" 34 #include "sync/engine/syncproto.h"
35 #include "sync/engine/traffic_recorder.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/model_type.h" 41 #include "sync/syncable/model_type.h"
41 #include "sync/syncable/syncable.h" 42 #include "sync/syncable/syncable.h"
42 #include "sync/test/engine/fake_model_worker.h" 43 #include "sync/test/engine/fake_model_worker.h"
43 #include "sync/test/engine/mock_connection_manager.h" 44 #include "sync/test/engine/mock_connection_manager.h"
44 #include "sync/test/engine/test_directory_setter_upper.h" 45 #include "sync/test/engine/test_directory_setter_upper.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 using sessions::ScopedSetSessionWriteTransaction; 108 using sessions::ScopedSetSessionWriteTransaction;
108 using sessions::StatusController; 109 using sessions::StatusController;
109 using sessions::SyncSessionContext; 110 using sessions::SyncSessionContext;
110 using sessions::SyncSession; 111 using sessions::SyncSession;
111 112
112 class SyncerTest : public testing::Test, 113 class SyncerTest : public testing::Test,
113 public SyncSession::Delegate, 114 public SyncSession::Delegate,
114 public ModelSafeWorkerRegistrar, 115 public ModelSafeWorkerRegistrar,
115 public SyncEngineEventListener { 116 public SyncEngineEventListener {
116 protected: 117 protected:
117 SyncerTest() : syncer_(NULL), saw_syncer_event_(false) {} 118 SyncerTest()
119 : syncer_(NULL),
120 saw_syncer_event_(false),
121 traffic_recorder_(0, 0) {
122 }
118 123
119 // SyncSession::Delegate implementation. 124 // SyncSession::Delegate implementation.
120 virtual void OnSilencedUntil(const base::TimeTicks& silenced_until) OVERRIDE { 125 virtual void OnSilencedUntil(const base::TimeTicks& silenced_until) OVERRIDE {
121 FAIL() << "Should not get silenced."; 126 FAIL() << "Should not get silenced.";
122 } 127 }
123 virtual bool IsSyncingCurrentlySilenced() OVERRIDE { 128 virtual bool IsSyncingCurrentlySilenced() OVERRIDE {
124 return false; 129 return false;
125 } 130 }
126 virtual void OnReceivedLongPollIntervalUpdate( 131 virtual void OnReceivedLongPollIntervalUpdate(
127 const base::TimeDelta& new_interval) OVERRIDE { 132 const base::TimeDelta& new_interval) OVERRIDE {
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 EnableDatatype(syncable::BOOKMARKS); 207 EnableDatatype(syncable::BOOKMARKS);
203 EnableDatatype(syncable::NIGORI); 208 EnableDatatype(syncable::NIGORI);
204 EnableDatatype(syncable::PREFERENCES); 209 EnableDatatype(syncable::PREFERENCES);
205 EnableDatatype(syncable::NIGORI); 210 EnableDatatype(syncable::NIGORI);
206 worker_ = new FakeModelWorker(GROUP_PASSIVE); 211 worker_ = new FakeModelWorker(GROUP_PASSIVE);
207 std::vector<SyncEngineEventListener*> listeners; 212 std::vector<SyncEngineEventListener*> listeners;
208 listeners.push_back(this); 213 listeners.push_back(this);
209 context_.reset( 214 context_.reset(
210 new SyncSessionContext( 215 new SyncSessionContext(
211 mock_server_.get(), directory(), this, 216 mock_server_.get(), directory(), this,
212 &extensions_activity_monitor_, listeners, NULL)); 217 &extensions_activity_monitor_, listeners, NULL,
218 &traffic_recorder_));
213 ASSERT_FALSE(context_->resolver()); 219 ASSERT_FALSE(context_->resolver());
214 syncer_ = new Syncer(); 220 syncer_ = new Syncer();
215 session_.reset(MakeSession()); 221 session_.reset(MakeSession());
216 222
217 ReadTransaction trans(FROM_HERE, directory()); 223 ReadTransaction trans(FROM_HERE, directory());
218 syncable::Directory::ChildHandles children; 224 syncable::Directory::ChildHandles children;
219 directory()->GetChildHandlesById(&trans, trans.root_id(), &children); 225 directory()->GetChildHandlesById(&trans, trans.root_id(), &children);
220 ASSERT_EQ(0u, children.size()); 226 ASSERT_EQ(0u, children.size());
221 saw_syncer_event_ = false; 227 saw_syncer_event_ = false;
222 root_id_ = TestIdFactory::root(); 228 root_id_ = TestIdFactory::root();
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 511
506 scoped_ptr<SyncSession> session_; 512 scoped_ptr<SyncSession> session_;
507 scoped_ptr<SyncSessionContext> context_; 513 scoped_ptr<SyncSessionContext> context_;
508 bool saw_syncer_event_; 514 bool saw_syncer_event_;
509 base::TimeDelta last_short_poll_interval_received_; 515 base::TimeDelta last_short_poll_interval_received_;
510 base::TimeDelta last_long_poll_interval_received_; 516 base::TimeDelta last_long_poll_interval_received_;
511 base::TimeDelta last_sessions_commit_delay_seconds_; 517 base::TimeDelta last_sessions_commit_delay_seconds_;
512 scoped_refptr<ModelSafeWorker> worker_; 518 scoped_refptr<ModelSafeWorker> worker_;
513 519
514 syncable::ModelTypeSet enabled_datatypes_; 520 syncable::ModelTypeSet enabled_datatypes_;
521 browser_sync::TrafficRecorder traffic_recorder_;
515 522
516 DISALLOW_COPY_AND_ASSIGN(SyncerTest); 523 DISALLOW_COPY_AND_ASSIGN(SyncerTest);
517 }; 524 };
518 525
519 TEST_F(SyncerTest, TestCallGatherUnsyncedEntries) { 526 TEST_F(SyncerTest, TestCallGatherUnsyncedEntries) {
520 { 527 {
521 Syncer::UnsyncedMetaHandles handles; 528 Syncer::UnsyncedMetaHandles handles;
522 { 529 {
523 ReadTransaction trans(FROM_HERE, directory()); 530 ReadTransaction trans(FROM_HERE, directory());
524 SyncerUtil::GetUnsyncedEntries(&trans, &handles); 531 SyncerUtil::GetUnsyncedEntries(&trans, &handles);
(...skipping 4081 matching lines...) Expand 10 before | Expand all | Expand 10 after
4606 4613
4607 TEST_F(SyncerPositionTiebreakingTest, MidLowHigh) { 4614 TEST_F(SyncerPositionTiebreakingTest, MidLowHigh) {
4608 Add(mid_id_); 4615 Add(mid_id_);
4609 Add(low_id_); 4616 Add(low_id_);
4610 Add(high_id_); 4617 Add(high_id_);
4611 SyncShareAsDelegate(); 4618 SyncShareAsDelegate();
4612 ExpectLocalOrderIsByServerId(); 4619 ExpectLocalOrderIsByServerId();
4613 } 4620 }
4614 4621
4615 } // namespace browser_sync 4622 } // namespace browser_sync
OLDNEW
« no previous file with comments | « sync/engine/sync_scheduler_whitebox_unittest.cc ('k') | sync/engine/traffic_recorder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698