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

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

Issue 2769113002: [Sync] Stop accessing BrowserContextKeyedServiceFactory on non-UI thread. (Closed)
Patch Set: Rebase and removing dependent 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_) {}
129 128
130 void SetUp() override { 129 void SetUp() override {
131 // Use kType by default, but allow test cases to re-initialize with whatever 130 // Use kType by default, but allow test cases to re-initialize with whatever
132 // type they choose. Therefore, it's important that all type dependent 131 // type they choose. Therefore, it's important that all type dependent
133 // initialization occurs in InitializeForType. 132 // initialization occurs in InitializeForType.
134 InitializeForType(kType); 133 InitializeForType(kType);
135 } 134 }
136 135
137 void TearDown() override { 136 void TearDown() override {
138 mock_attachment_service_ = nullptr; 137 mock_attachment_service_ = nullptr;
(...skipping 21 matching lines...) Expand all
160 ConstructGenericChangeProcessor(type); 159 ConstructGenericChangeProcessor(type);
161 } 160 }
162 161
163 void ConstructGenericChangeProcessor(ModelType type) { 162 void ConstructGenericChangeProcessor(ModelType type) {
164 std::unique_ptr<AttachmentStore> attachment_store = 163 std::unique_ptr<AttachmentStore> attachment_store =
165 AttachmentStore::CreateInMemoryStore(); 164 AttachmentStore::CreateInMemoryStore();
166 change_processor_ = base::MakeUnique<GenericChangeProcessor>( 165 change_processor_ = base::MakeUnique<GenericChangeProcessor>(
167 type, base::MakeUnique<DataTypeErrorHandlerMock>(), 166 type, base::MakeUnique<DataTypeErrorHandlerMock>(),
168 syncable_service_ptr_factory_.GetWeakPtr(), 167 syncable_service_ptr_factory_.GetWeakPtr(),
169 merge_result_ptr_factory_->GetWeakPtr(), test_user_share_->user_share(), 168 merge_result_ptr_factory_->GetWeakPtr(), test_user_share_->user_share(),
170 &sync_client_, attachment_store->CreateAttachmentStoreForSync()); 169 &sync_factory_, attachment_store->CreateAttachmentStoreForSync());
171 mock_attachment_service_ = sync_factory_.GetMockAttachmentService(); 170 mock_attachment_service_ = sync_factory_.GetMockAttachmentService();
172 } 171 }
173 172
174 void BuildChildNodes(ModelType type, int n) { 173 void BuildChildNodes(ModelType type, int n) {
175 WriteTransaction trans(FROM_HERE, user_share()); 174 WriteTransaction trans(FROM_HERE, user_share());
176 for (int i = 0; i < n; ++i) { 175 for (int i = 0; i < n; ++i) {
177 WriteNode node(&trans); 176 WriteNode node(&trans);
178 node.InitUniqueByCreation(type, base::StringPrintf("node%05d", i)); 177 node.InitUniqueByCreation(type, base::StringPrintf("node%05d", i));
179 } 178 }
180 } 179 }
(...skipping 16 matching lines...) Expand all
197 196
198 std::unique_ptr<SyncMergeResult> sync_merge_result_; 197 std::unique_ptr<SyncMergeResult> sync_merge_result_;
199 std::unique_ptr<base::WeakPtrFactory<SyncMergeResult>> 198 std::unique_ptr<base::WeakPtrFactory<SyncMergeResult>>
200 merge_result_ptr_factory_; 199 merge_result_ptr_factory_;
201 200
202 FakeSyncableService fake_syncable_service_; 201 FakeSyncableService fake_syncable_service_;
203 base::WeakPtrFactory<FakeSyncableService> syncable_service_ptr_factory_; 202 base::WeakPtrFactory<FakeSyncableService> syncable_service_ptr_factory_;
204 203
205 std::unique_ptr<TestUserShare> test_user_share_; 204 std::unique_ptr<TestUserShare> test_user_share_;
206 MockAttachmentService* mock_attachment_service_; 205 MockAttachmentService* mock_attachment_service_;
207 FakeSyncClient sync_client_;
208 MockSyncApiComponentFactory sync_factory_; 206 MockSyncApiComponentFactory sync_factory_;
209 207
210 std::unique_ptr<GenericChangeProcessor> change_processor_; 208 std::unique_ptr<GenericChangeProcessor> change_processor_;
211 }; 209 };
212 210
213 // Similar to above, but focused on the method that implements sync/api 211 // Similar to above, but focused on the method that implements sync/api
214 // interfaces and is hence exposed to datatypes directly. 212 // interfaces and is hence exposed to datatypes directly.
215 TEST_F(SyncGenericChangeProcessorTest, StressGetAllSyncData) { 213 TEST_F(SyncGenericChangeProcessorTest, StressGetAllSyncData) {
216 const int kNumChildNodes = 1000; 214 const int kNumChildNodes = 1000;
217 const int kRepeatCount = 1; 215 const int kRepeatCount = 1;
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 SyncDataList sync_data = change_processor()->GetAllSyncData(SESSIONS); 499 SyncDataList sync_data = change_processor()->GetAllSyncData(SESSIONS);
502 ASSERT_EQ(sync_data.size(), 1U); 500 ASSERT_EQ(sync_data.size(), 1U);
503 ASSERT_EQ("session tag 2", 501 ASSERT_EQ("session tag 2",
504 sync_data[0].GetSpecifics().session().session_tag()); 502 sync_data[0].GetSpecifics().session().session_tag());
505 EXPECT_FALSE(SyncDataRemote(sync_data[0]).GetClientTagHash().empty()); 503 EXPECT_FALSE(SyncDataRemote(sync_data[0]).GetClientTagHash().empty());
506 } 504 }
507 505
508 } // namespace 506 } // namespace
509 507
510 } // namespace syncer 508 } // 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