| OLD | NEW | 
|---|
| 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 10 matching lines...) Expand all  Loading... | 
| 21 #include "base/message_loop/message_loop.h" | 21 #include "base/message_loop/message_loop.h" | 
| 22 #include "base/strings/string_number_conversions.h" | 22 #include "base/strings/string_number_conversions.h" | 
| 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/sync_scheduler_impl.h" | 28 #include "sync/engine/sync_scheduler_impl.h" | 
| 29 #include "sync/engine/syncer.h" | 29 #include "sync/engine/syncer.h" | 
| 30 #include "sync/engine/syncer_proto_util.h" | 30 #include "sync/engine/syncer_proto_util.h" | 
| 31 #include "sync/engine/traffic_recorder.h" |  | 
| 32 #include "sync/internal_api/public/base/cancelation_signal.h" | 31 #include "sync/internal_api/public/base/cancelation_signal.h" | 
| 33 #include "sync/internal_api/public/base/model_type.h" | 32 #include "sync/internal_api/public/base/model_type.h" | 
| 34 #include "sync/internal_api/public/engine/model_safe_worker.h" | 33 #include "sync/internal_api/public/engine/model_safe_worker.h" | 
| 35 #include "sync/protocol/bookmark_specifics.pb.h" | 34 #include "sync/protocol/bookmark_specifics.pb.h" | 
| 36 #include "sync/protocol/nigori_specifics.pb.h" | 35 #include "sync/protocol/nigori_specifics.pb.h" | 
| 37 #include "sync/protocol/preference_specifics.pb.h" | 36 #include "sync/protocol/preference_specifics.pb.h" | 
| 38 #include "sync/protocol/sync.pb.h" | 37 #include "sync/protocol/sync.pb.h" | 
| 39 #include "sync/sessions/sync_session_context.h" | 38 #include "sync/sessions/sync_session_context.h" | 
| 40 #include "sync/syncable/mutable_entry.h" | 39 #include "sync/syncable/mutable_entry.h" | 
| 41 #include "sync/syncable/nigori_util.h" | 40 #include "sync/syncable/nigori_util.h" | 
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 111 using sessions::SyncSession; | 110 using sessions::SyncSession; | 
| 112 | 111 | 
| 113 class SyncerTest : public testing::Test, | 112 class SyncerTest : public testing::Test, | 
| 114                    public SyncSession::Delegate, | 113                    public SyncSession::Delegate, | 
| 115                    public SyncEngineEventListener { | 114                    public SyncEngineEventListener { | 
| 116  protected: | 115  protected: | 
| 117   SyncerTest() | 116   SyncerTest() | 
| 118       : extensions_activity_(new ExtensionsActivity), | 117       : extensions_activity_(new ExtensionsActivity), | 
| 119         syncer_(NULL), | 118         syncer_(NULL), | 
| 120         saw_syncer_event_(false), | 119         saw_syncer_event_(false), | 
| 121         last_client_invalidation_hint_buffer_size_(10), | 120         last_client_invalidation_hint_buffer_size_(10) { | 
| 122         traffic_recorder_(0, 0) { |  | 
| 123 } | 121 } | 
| 124 | 122 | 
| 125   // SyncSession::Delegate implementation. | 123   // SyncSession::Delegate implementation. | 
| 126   virtual void OnThrottled(const base::TimeDelta& throttle_duration) OVERRIDE { | 124   virtual void OnThrottled(const base::TimeDelta& throttle_duration) OVERRIDE { | 
| 127     FAIL() << "Should not get silenced."; | 125     FAIL() << "Should not get silenced."; | 
| 128   } | 126   } | 
| 129   virtual void OnTypesThrottled( | 127   virtual void OnTypesThrottled( | 
| 130       ModelTypeSet types, | 128       ModelTypeSet types, | 
| 131       const base::TimeDelta& throttle_duration) OVERRIDE { | 129       const base::TimeDelta& throttle_duration) OVERRIDE { | 
| 132     FAIL() << "Should not get silenced."; | 130     FAIL() << "Should not get silenced."; | 
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 224 | 222 | 
| 225     ModelSafeRoutingInfo routing_info; | 223     ModelSafeRoutingInfo routing_info; | 
| 226     GetModelSafeRoutingInfo(&routing_info); | 224     GetModelSafeRoutingInfo(&routing_info); | 
| 227 | 225 | 
| 228     model_type_registry_.reset(new ModelTypeRegistry(workers_, directory())); | 226     model_type_registry_.reset(new ModelTypeRegistry(workers_, directory())); | 
| 229 | 227 | 
| 230     context_.reset( | 228     context_.reset( | 
| 231         new SyncSessionContext( | 229         new SyncSessionContext( | 
| 232             mock_server_.get(), directory(), | 230             mock_server_.get(), directory(), | 
| 233             extensions_activity_, | 231             extensions_activity_, | 
| 234             listeners, debug_info_getter_.get(), &traffic_recorder_, | 232             listeners, debug_info_getter_.get(), | 
| 235             model_type_registry_.get(), | 233             model_type_registry_.get(), | 
| 236             true,  // enable keystore encryption | 234             true,  // enable keystore encryption | 
| 237             false,  // force enable pre-commit GU avoidance experiment | 235             false,  // force enable pre-commit GU avoidance experiment | 
| 238             "fake_invalidator_client_id")); | 236             "fake_invalidator_client_id")); | 
| 239     context_->SetRoutingInfo(routing_info); | 237     context_->SetRoutingInfo(routing_info); | 
| 240     syncer_ = new Syncer(&cancelation_signal_); | 238     syncer_ = new Syncer(&cancelation_signal_); | 
| 241 | 239 | 
| 242     syncable::ReadTransaction trans(FROM_HERE, directory()); | 240     syncable::ReadTransaction trans(FROM_HERE, directory()); | 
| 243     syncable::Directory::Metahandles children; | 241     syncable::Directory::Metahandles children; | 
| 244     directory()->GetChildHandlesById(&trans, trans.root_id(), &children); | 242     directory()->GetChildHandlesById(&trans, trans.root_id(), &children); | 
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 504   scoped_ptr<ModelTypeRegistry> model_type_registry_; | 502   scoped_ptr<ModelTypeRegistry> model_type_registry_; | 
| 505   scoped_ptr<SyncSessionContext> context_; | 503   scoped_ptr<SyncSessionContext> context_; | 
| 506   bool saw_syncer_event_; | 504   bool saw_syncer_event_; | 
| 507   base::TimeDelta last_short_poll_interval_received_; | 505   base::TimeDelta last_short_poll_interval_received_; | 
| 508   base::TimeDelta last_long_poll_interval_received_; | 506   base::TimeDelta last_long_poll_interval_received_; | 
| 509   base::TimeDelta last_sessions_commit_delay_seconds_; | 507   base::TimeDelta last_sessions_commit_delay_seconds_; | 
| 510   int last_client_invalidation_hint_buffer_size_; | 508   int last_client_invalidation_hint_buffer_size_; | 
| 511   std::vector<scoped_refptr<ModelSafeWorker> > workers_; | 509   std::vector<scoped_refptr<ModelSafeWorker> > workers_; | 
| 512 | 510 | 
| 513   ModelTypeSet enabled_datatypes_; | 511   ModelTypeSet enabled_datatypes_; | 
| 514   TrafficRecorder traffic_recorder_; |  | 
| 515   sessions::NudgeTracker nudge_tracker_; | 512   sessions::NudgeTracker nudge_tracker_; | 
| 516   scoped_ptr<MockDebugInfoGetter> debug_info_getter_; | 513   scoped_ptr<MockDebugInfoGetter> debug_info_getter_; | 
| 517 | 514 | 
| 518   DISALLOW_COPY_AND_ASSIGN(SyncerTest); | 515   DISALLOW_COPY_AND_ASSIGN(SyncerTest); | 
| 519 }; | 516 }; | 
| 520 | 517 | 
| 521 TEST_F(SyncerTest, TestCallGatherUnsyncedEntries) { | 518 TEST_F(SyncerTest, TestCallGatherUnsyncedEntries) { | 
| 522   { | 519   { | 
| 523     Syncer::UnsyncedMetaHandles handles; | 520     Syncer::UnsyncedMetaHandles handles; | 
| 524     { | 521     { | 
| (...skipping 4281 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 4806     EXPECT_EQ("xyz", final_monitor_records["xyz"].extension_id); | 4803     EXPECT_EQ("xyz", final_monitor_records["xyz"].extension_id); | 
| 4807     EXPECT_EQ(2049U, final_monitor_records["ABC"].bookmark_write_count); | 4804     EXPECT_EQ(2049U, final_monitor_records["ABC"].bookmark_write_count); | 
| 4808     EXPECT_EQ(4U,    final_monitor_records["xyz"].bookmark_write_count); | 4805     EXPECT_EQ(4U,    final_monitor_records["xyz"].bookmark_write_count); | 
| 4809   } else { | 4806   } else { | 
| 4810     EXPECT_TRUE(final_monitor_records.empty()) | 4807     EXPECT_TRUE(final_monitor_records.empty()) | 
| 4811         << "Should not restore records after successful bookmark commit."; | 4808         << "Should not restore records after successful bookmark commit."; | 
| 4812   } | 4809   } | 
| 4813 } | 4810 } | 
| 4814 | 4811 | 
| 4815 }  // namespace syncer | 4812 }  // namespace syncer | 
| OLD | NEW | 
|---|