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

Side by Side Diff: components/sync/driver/generic_change_processor_unittest.cc

Issue 2799653006: Revert of [Sync] Stop accessing BrowserContextKeyedServiceFactory on non-UI thread. (Closed)
Patch Set: Created 3 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/sync/driver/generic_change_processor.h" 5 #include "components/sync/driver/generic_change_processor.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 }; 117 };
118 118
119 class SyncGenericChangeProcessorTest : public testing::Test { 119 class SyncGenericChangeProcessorTest : public testing::Test {
120 public: 120 public:
121 // Most test cases will use this type. For those that need a 121 // Most test cases will use this type. For those that need a
122 // GenericChangeProcessor for a different type, use |InitializeForType|. 122 // GenericChangeProcessor for a different type, use |InitializeForType|.
123 static const ModelType kType = PREFERENCES; 123 static const ModelType kType = PREFERENCES;
124 124
125 SyncGenericChangeProcessorTest() 125 SyncGenericChangeProcessorTest()
126 : syncable_service_ptr_factory_(&fake_syncable_service_), 126 : syncable_service_ptr_factory_(&fake_syncable_service_),
127 mock_attachment_service_(nullptr) {} 127 mock_attachment_service_(nullptr),
128 sync_client_(&sync_factory_) {}
128 129
129 void SetUp() override { 130 void SetUp() override {
130 // Use kType by default, but allow test cases to re-initialize with whatever 131 // Use kType by default, but allow test cases to re-initialize with whatever
131 // type they choose. Therefore, it's important that all type dependent 132 // type they choose. Therefore, it's important that all type dependent
132 // initialization occurs in InitializeForType. 133 // initialization occurs in InitializeForType.
133 InitializeForType(kType); 134 InitializeForType(kType);
134 } 135 }
135 136
136 void TearDown() override { 137 void TearDown() override {
137 mock_attachment_service_ = nullptr; 138 mock_attachment_service_ = nullptr;
(...skipping 21 matching lines...) Expand all
159 ConstructGenericChangeProcessor(type); 160 ConstructGenericChangeProcessor(type);
160 } 161 }
161 162
162 void ConstructGenericChangeProcessor(ModelType type) { 163 void ConstructGenericChangeProcessor(ModelType type) {
163 std::unique_ptr<AttachmentStore> attachment_store = 164 std::unique_ptr<AttachmentStore> attachment_store =
164 AttachmentStore::CreateInMemoryStore(); 165 AttachmentStore::CreateInMemoryStore();
165 change_processor_ = base::MakeUnique<GenericChangeProcessor>( 166 change_processor_ = base::MakeUnique<GenericChangeProcessor>(
166 type, base::MakeUnique<DataTypeErrorHandlerMock>(), 167 type, base::MakeUnique<DataTypeErrorHandlerMock>(),
167 syncable_service_ptr_factory_.GetWeakPtr(), 168 syncable_service_ptr_factory_.GetWeakPtr(),
168 merge_result_ptr_factory_->GetWeakPtr(), test_user_share_->user_share(), 169 merge_result_ptr_factory_->GetWeakPtr(), test_user_share_->user_share(),
169 &sync_factory_, attachment_store->CreateAttachmentStoreForSync()); 170 &sync_client_, attachment_store->CreateAttachmentStoreForSync());
170 mock_attachment_service_ = sync_factory_.GetMockAttachmentService(); 171 mock_attachment_service_ = sync_factory_.GetMockAttachmentService();
171 } 172 }
172 173
173 void BuildChildNodes(ModelType type, int n) { 174 void BuildChildNodes(ModelType type, int n) {
174 WriteTransaction trans(FROM_HERE, user_share()); 175 WriteTransaction trans(FROM_HERE, user_share());
175 for (int i = 0; i < n; ++i) { 176 for (int i = 0; i < n; ++i) {
176 WriteNode node(&trans); 177 WriteNode node(&trans);
177 node.InitUniqueByCreation(type, base::StringPrintf("node%05d", i)); 178 node.InitUniqueByCreation(type, base::StringPrintf("node%05d", i));
178 } 179 }
179 } 180 }
(...skipping 16 matching lines...) Expand all
196 197
197 std::unique_ptr<SyncMergeResult> sync_merge_result_; 198 std::unique_ptr<SyncMergeResult> sync_merge_result_;
198 std::unique_ptr<base::WeakPtrFactory<SyncMergeResult>> 199 std::unique_ptr<base::WeakPtrFactory<SyncMergeResult>>
199 merge_result_ptr_factory_; 200 merge_result_ptr_factory_;
200 201
201 FakeSyncableService fake_syncable_service_; 202 FakeSyncableService fake_syncable_service_;
202 base::WeakPtrFactory<FakeSyncableService> syncable_service_ptr_factory_; 203 base::WeakPtrFactory<FakeSyncableService> syncable_service_ptr_factory_;
203 204
204 std::unique_ptr<TestUserShare> test_user_share_; 205 std::unique_ptr<TestUserShare> test_user_share_;
205 MockAttachmentService* mock_attachment_service_; 206 MockAttachmentService* mock_attachment_service_;
207 FakeSyncClient sync_client_;
206 MockSyncApiComponentFactory sync_factory_; 208 MockSyncApiComponentFactory sync_factory_;
207 209
208 std::unique_ptr<GenericChangeProcessor> change_processor_; 210 std::unique_ptr<GenericChangeProcessor> change_processor_;
209 }; 211 };
210 212
211 // Similar to above, but focused on the method that implements sync/api 213 // Similar to above, but focused on the method that implements sync/api
212 // interfaces and is hence exposed to datatypes directly. 214 // interfaces and is hence exposed to datatypes directly.
213 TEST_F(SyncGenericChangeProcessorTest, StressGetAllSyncData) { 215 TEST_F(SyncGenericChangeProcessorTest, StressGetAllSyncData) {
214 const int kNumChildNodes = 1000; 216 const int kNumChildNodes = 1000;
215 const int kRepeatCount = 1; 217 const int kRepeatCount = 1;
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 SyncDataList sync_data = change_processor()->GetAllSyncData(SESSIONS); 501 SyncDataList sync_data = change_processor()->GetAllSyncData(SESSIONS);
500 ASSERT_EQ(sync_data.size(), 1U); 502 ASSERT_EQ(sync_data.size(), 1U);
501 ASSERT_EQ("session tag 2", 503 ASSERT_EQ("session tag 2",
502 sync_data[0].GetSpecifics().session().session_tag()); 504 sync_data[0].GetSpecifics().session().session_tag());
503 EXPECT_FALSE(SyncDataRemote(sync_data[0]).GetClientTagHash().empty()); 505 EXPECT_FALSE(SyncDataRemote(sync_data[0]).GetClientTagHash().empty());
504 } 506 }
505 507
506 } // namespace 508 } // namespace
507 509
508 } // namespace syncer 510 } // namespace syncer
OLDNEW
« no previous file with comments | « components/sync/driver/generic_change_processor_factory.cc ('k') | components/sync/driver/shared_change_processor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698