| OLD | NEW |
| 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 #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.h" | 10 #include "base/message_loop.h" |
| 11 #include "sync/engine/conflict_resolver.h" | 11 #include "sync/engine/conflict_resolver.h" |
| 12 #include "sync/engine/syncer_types.h" | 12 #include "sync/engine/syncer_types.h" |
| 13 #include "sync/engine/throttled_data_type_tracker.h" |
| 13 #include "sync/internal_api/public/syncable/model_type.h" | 14 #include "sync/internal_api/public/syncable/model_type.h" |
| 14 #include "sync/sessions/session_state.h" | 15 #include "sync/sessions/session_state.h" |
| 15 #include "sync/sessions/status_controller.h" | 16 #include "sync/sessions/status_controller.h" |
| 16 #include "sync/syncable/syncable.h" | 17 #include "sync/syncable/syncable.h" |
| 17 #include "sync/syncable/syncable_id.h" | 18 #include "sync/syncable/syncable_id.h" |
| 18 #include "sync/test/engine/fake_model_worker.h" | 19 #include "sync/test/engine/fake_model_worker.h" |
| 19 #include "sync/test/engine/test_directory_setter_upper.h" | 20 #include "sync/test/engine/test_directory_setter_upper.h" |
| 20 #include "sync/test/fake_extensions_activity_monitor.h" | 21 #include "sync/test/fake_extensions_activity_monitor.h" |
| 21 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
| 22 | 23 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 41 virtual void SetUp() { | 42 virtual void SetUp() { |
| 42 ModelSafeRoutingInfo routing_info; | 43 ModelSafeRoutingInfo routing_info; |
| 43 std::vector<ModelSafeWorker*> workers; | 44 std::vector<ModelSafeWorker*> workers; |
| 44 | 45 |
| 45 GetModelSafeRoutingInfo(&routing_info); | 46 GetModelSafeRoutingInfo(&routing_info); |
| 46 GetWorkers(&workers); | 47 GetWorkers(&workers); |
| 47 | 48 |
| 48 context_.reset( | 49 context_.reset( |
| 49 new SyncSessionContext( | 50 new SyncSessionContext( |
| 50 NULL, NULL, routing_info, workers, &extensions_activity_monitor_, | 51 NULL, NULL, routing_info, workers, &extensions_activity_monitor_, |
| 52 throttled_data_type_tracker_.get(), |
| 51 std::vector<SyncEngineEventListener*>(), NULL, NULL)); | 53 std::vector<SyncEngineEventListener*>(), NULL, NULL)); |
| 52 routes_.clear(); | 54 routes_.clear(); |
| 53 routes_[syncable::BOOKMARKS] = GROUP_UI; | 55 routes_[syncable::BOOKMARKS] = GROUP_UI; |
| 54 routes_[syncable::AUTOFILL] = GROUP_DB; | 56 routes_[syncable::AUTOFILL] = GROUP_DB; |
| 55 scoped_refptr<ModelSafeWorker> passive_worker( | 57 scoped_refptr<ModelSafeWorker> passive_worker( |
| 56 new FakeModelWorker(GROUP_PASSIVE)); | 58 new FakeModelWorker(GROUP_PASSIVE)); |
| 57 scoped_refptr<ModelSafeWorker> ui_worker( | 59 scoped_refptr<ModelSafeWorker> ui_worker( |
| 58 new FakeModelWorker(GROUP_UI)); | 60 new FakeModelWorker(GROUP_UI)); |
| 59 scoped_refptr<ModelSafeWorker> db_worker( | 61 scoped_refptr<ModelSafeWorker> db_worker( |
| 60 new FakeModelWorker(GROUP_DB)); | 62 new FakeModelWorker(GROUP_DB)); |
| 61 workers_.clear(); | 63 workers_.clear(); |
| 62 workers_.push_back(passive_worker); | 64 workers_.push_back(passive_worker); |
| 63 workers_.push_back(ui_worker); | 65 workers_.push_back(ui_worker); |
| 64 workers_.push_back(db_worker); | 66 workers_.push_back(db_worker); |
| 65 session_.reset(MakeSession()); | 67 session_.reset(MakeSession()); |
| 68 throttled_data_type_tracker_.reset(new ThrottledDataTypeTracker(NULL)); |
| 66 } | 69 } |
| 67 virtual void TearDown() { | 70 virtual void TearDown() { |
| 68 session_.reset(); | 71 session_.reset(); |
| 69 context_.reset(); | 72 context_.reset(); |
| 70 } | 73 } |
| 71 | 74 |
| 72 virtual void OnSilencedUntil(const base::TimeTicks& silenced_until) OVERRIDE { | 75 virtual void OnSilencedUntil(const base::TimeTicks& silenced_until) OVERRIDE { |
| 73 FailControllerInvocationIfDisabled("OnSilencedUntil"); | 76 FailControllerInvocationIfDisabled("OnSilencedUntil"); |
| 74 } | 77 } |
| 75 virtual bool IsSyncingCurrentlySilenced() OVERRIDE { | 78 virtual bool IsSyncingCurrentlySilenced() OVERRIDE { |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 return syncable::ModelTypeSet(syncable::AUTOFILL); | 127 return syncable::ModelTypeSet(syncable::AUTOFILL); |
| 125 } | 128 } |
| 126 | 129 |
| 127 MessageLoop message_loop_; | 130 MessageLoop message_loop_; |
| 128 bool controller_invocations_allowed_; | 131 bool controller_invocations_allowed_; |
| 129 scoped_ptr<SyncSession> session_; | 132 scoped_ptr<SyncSession> session_; |
| 130 scoped_ptr<SyncSessionContext> context_; | 133 scoped_ptr<SyncSessionContext> context_; |
| 131 std::vector<scoped_refptr<ModelSafeWorker> > workers_; | 134 std::vector<scoped_refptr<ModelSafeWorker> > workers_; |
| 132 ModelSafeRoutingInfo routes_; | 135 ModelSafeRoutingInfo routes_; |
| 133 FakeExtensionsActivityMonitor extensions_activity_monitor_; | 136 FakeExtensionsActivityMonitor extensions_activity_monitor_; |
| 137 scoped_ptr<ThrottledDataTypeTracker> throttled_data_type_tracker_; |
| 134 }; | 138 }; |
| 135 | 139 |
| 136 TEST_F(SyncSessionTest, EnabledGroupsEmpty) { | 140 TEST_F(SyncSessionTest, EnabledGroupsEmpty) { |
| 137 routes_.clear(); | 141 routes_.clear(); |
| 138 workers_.clear(); | 142 workers_.clear(); |
| 139 scoped_ptr<SyncSession> session(MakeSession()); | 143 scoped_ptr<SyncSession> session(MakeSession()); |
| 140 std::set<ModelSafeGroup> expected_enabled_groups; | 144 std::set<ModelSafeGroup> expected_enabled_groups; |
| 141 expected_enabled_groups.insert(GROUP_PASSIVE); | 145 expected_enabled_groups.insert(GROUP_PASSIVE); |
| 142 EXPECT_EQ(expected_enabled_groups, session->GetEnabledGroups()); | 146 EXPECT_EQ(expected_enabled_groups, session->GetEnabledGroups()); |
| 143 } | 147 } |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 527 EXPECT_EQ(empty_payload, original[syncable::BOOKMARKS]); | 531 EXPECT_EQ(empty_payload, original[syncable::BOOKMARKS]); |
| 528 EXPECT_EQ(payload1, original[syncable::PASSWORDS]); | 532 EXPECT_EQ(payload1, original[syncable::PASSWORDS]); |
| 529 EXPECT_EQ(payload1, original[syncable::AUTOFILL]); | 533 EXPECT_EQ(payload1, original[syncable::AUTOFILL]); |
| 530 EXPECT_EQ(payload2, original[syncable::SESSIONS]); | 534 EXPECT_EQ(payload2, original[syncable::SESSIONS]); |
| 531 EXPECT_EQ(payload3, original[syncable::THEMES]); | 535 EXPECT_EQ(payload3, original[syncable::THEMES]); |
| 532 } | 536 } |
| 533 | 537 |
| 534 } // namespace | 538 } // namespace |
| 535 } // namespace sessions | 539 } // namespace sessions |
| 536 } // namespace browser_sync | 540 } // namespace browser_sync |
| OLD | NEW |