Chromium Code Reviews| 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 #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/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| 11 #include "sync/engine/syncer_types.h" | 11 #include "sync/engine/syncer_types.h" |
| 12 #include "sync/internal_api/public/base/model_type.h" | 12 #include "sync/internal_api/public/base/model_type.h" |
| 13 #include "sync/sessions/status_controller.h" | 13 #include "sync/sessions/status_controller.h" |
| 14 #include "sync/syncable/syncable_id.h" | 14 #include "sync/syncable/syncable_id.h" |
| 15 #include "sync/syncable/syncable_write_transaction.h" | 15 #include "sync/syncable/syncable_write_transaction.h" |
| 16 #include "sync/test/engine/fake_model_worker.h" | 16 #include "sync/test/engine/fake_model_worker.h" |
| 17 #include "sync/test/engine/test_directory_setter_upper.h" | 17 #include "sync/test/engine/test_directory_setter_upper.h" |
| 18 #include "sync/util/extensions_activity.h" | 18 #include "sync/util/extensions_activity.h" |
| 19 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
| 20 | 20 |
| 21 namespace syncer { | 21 namespace syncer { |
| 22 | 22 |
| 23 using syncable::WriteTransaction; | 23 using syncable::WriteTransaction; |
| 24 | 24 |
| 25 namespace sessions { | 25 namespace sessions { |
| 26 namespace { | 26 namespace { |
| 27 | 27 |
| 28 class SyncSessionTest : public testing::Test, | 28 class SyncSessionTest : public testing::Test, |
|
rlarocque
2014/01/06 20:03:33
I just realized that all tests were moved out of h
| |
| 29 public SyncSession::Delegate { | 29 public SyncSession::Delegate { |
| 30 public: | 30 public: |
| 31 SyncSessionTest() : controller_invocations_allowed_(false) {} | 31 SyncSessionTest() : controller_invocations_allowed_(false) {} |
| 32 | 32 |
| 33 SyncSession* MakeSession() { | 33 SyncSession* MakeSession() { |
| 34 return SyncSession::Build(context_.get(), this); | 34 return SyncSession::Build(context_.get(), this); |
| 35 } | 35 } |
| 36 | 36 |
| 37 virtual void SetUp() { | 37 virtual void SetUp() { |
| 38 extensions_activity_ = new ExtensionsActivity(); | 38 extensions_activity_ = new ExtensionsActivity(); |
| 39 | 39 |
| 40 routes_.clear(); | 40 routes_.clear(); |
| 41 routes_[BOOKMARKS] = GROUP_UI; | 41 routes_[BOOKMARKS] = GROUP_UI; |
| 42 routes_[AUTOFILL] = GROUP_DB; | 42 routes_[AUTOFILL] = GROUP_DB; |
| 43 scoped_refptr<ModelSafeWorker> passive_worker( | 43 scoped_refptr<ModelSafeWorker> passive_worker( |
| 44 new FakeModelWorker(GROUP_PASSIVE)); | 44 new FakeModelWorker(GROUP_PASSIVE)); |
| 45 scoped_refptr<ModelSafeWorker> ui_worker( | 45 scoped_refptr<ModelSafeWorker> ui_worker( |
| 46 new FakeModelWorker(GROUP_UI)); | 46 new FakeModelWorker(GROUP_UI)); |
| 47 scoped_refptr<ModelSafeWorker> db_worker( | 47 scoped_refptr<ModelSafeWorker> db_worker( |
| 48 new FakeModelWorker(GROUP_DB)); | 48 new FakeModelWorker(GROUP_DB)); |
| 49 workers_.clear(); | 49 workers_.clear(); |
| 50 workers_.push_back(passive_worker); | 50 workers_.push_back(passive_worker); |
| 51 workers_.push_back(ui_worker); | 51 workers_.push_back(ui_worker); |
| 52 workers_.push_back(db_worker); | 52 workers_.push_back(db_worker); |
| 53 | 53 |
| 54 std::vector<ModelSafeWorker*> workers; | 54 std::vector<ModelSafeWorker*> workers; |
| 55 GetWorkers(&workers); | 55 GetWorkers(&workers); |
| 56 | 56 |
| 57 model_type_registry_.reset(new ModelTypeRegistry(NULL, workers)); | |
| 58 | |
| 57 context_.reset( | 59 context_.reset( |
| 58 new SyncSessionContext( | 60 new SyncSessionContext( |
| 59 NULL, | 61 NULL, |
| 60 NULL, | 62 NULL, |
| 61 workers, | |
| 62 extensions_activity_.get(), | 63 extensions_activity_.get(), |
| 63 std::vector<SyncEngineEventListener*>(), | 64 std::vector<SyncEngineEventListener*>(), |
| 64 NULL, | 65 NULL, |
| 65 NULL, | 66 NULL, |
| 67 model_type_registry_.get(), | |
| 66 true, // enable keystore encryption | 68 true, // enable keystore encryption |
| 67 false, // force enable pre-commit GU avoidance experiment | 69 false, // force enable pre-commit GU avoidance experiment |
| 68 "fake_invalidator_client_id")); | 70 "fake_invalidator_client_id")); |
| 69 context_->set_routing_info(routes_); | 71 context_->SetRoutingInfo(routes_); |
| 70 | 72 |
| 71 session_.reset(MakeSession()); | 73 session_.reset(MakeSession()); |
| 72 } | 74 } |
| 73 virtual void TearDown() { | 75 virtual void TearDown() { |
| 74 session_.reset(); | 76 session_.reset(); |
| 75 context_.reset(); | 77 context_.reset(); |
| 76 } | 78 } |
| 77 | 79 |
| 78 virtual void OnThrottled(const base::TimeDelta& throttle_duration) OVERRIDE { | 80 virtual void OnThrottled(const base::TimeDelta& throttle_duration) OVERRIDE { |
| 79 FailControllerInvocationIfDisabled("OnThrottled"); | 81 FailControllerInvocationIfDisabled("OnThrottled"); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 132 return request_params; | 134 return request_params; |
| 133 } | 135 } |
| 134 | 136 |
| 135 ModelTypeSet ParamsMeaningJustOneEnabledType() { | 137 ModelTypeSet ParamsMeaningJustOneEnabledType() { |
| 136 return ModelTypeSet(AUTOFILL); | 138 return ModelTypeSet(AUTOFILL); |
| 137 } | 139 } |
| 138 | 140 |
| 139 base::MessageLoop message_loop_; | 141 base::MessageLoop message_loop_; |
| 140 bool controller_invocations_allowed_; | 142 bool controller_invocations_allowed_; |
| 141 scoped_ptr<SyncSession> session_; | 143 scoped_ptr<SyncSession> session_; |
| 144 scoped_ptr<ModelTypeRegistry> model_type_registry_; | |
| 142 scoped_ptr<SyncSessionContext> context_; | 145 scoped_ptr<SyncSessionContext> context_; |
| 143 std::vector<scoped_refptr<ModelSafeWorker> > workers_; | 146 std::vector<scoped_refptr<ModelSafeWorker> > workers_; |
| 144 ModelSafeRoutingInfo routes_; | 147 ModelSafeRoutingInfo routes_; |
| 145 scoped_refptr<ExtensionsActivity> extensions_activity_; | 148 scoped_refptr<ExtensionsActivity> extensions_activity_; |
| 146 }; | 149 }; |
| 147 | 150 |
| 148 } // namespace | 151 } // namespace |
| 149 } // namespace sessions | 152 } // namespace sessions |
| 150 } // namespace syncer | 153 } // namespace syncer |
| OLD | NEW |