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 "base/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
6 #include "base/string_util.h" | 6 #include "base/string_util.h" |
7 #include "base/time.h" | 7 #include "base/time.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "chrome/browser/search_engines/template_url.h" | 9 #include "chrome/browser/search_engines/template_url.h" |
10 #include "chrome/browser/search_engines/template_url_service.h" | 10 #include "chrome/browser/search_engines/template_url_service.h" |
11 #include "chrome/browser/search_engines/template_url_service_factory.h" | 11 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| 12 #include "chrome/browser/webdata/web_data_service_factory.h" |
12 #include "chrome/common/chrome_notification_types.h" | 13 #include "chrome/common/chrome_notification_types.h" |
13 #include "chrome/common/pref_names.h" | 14 #include "chrome/common/pref_names.h" |
14 #include "chrome/test/base/testing_pref_service.h" | 15 #include "chrome/test/base/testing_pref_service.h" |
15 #include "chrome/test/base/testing_profile.h" | 16 #include "chrome/test/base/testing_profile.h" |
16 #include "content/public/browser/notification_service.h" | 17 #include "content/public/browser/notification_service.h" |
17 #include "sync/protocol/search_engine_specifics.pb.h" | 18 #include "sync/protocol/search_engine_specifics.pb.h" |
18 #include "sync/protocol/sync.pb.h" | 19 #include "sync/protocol/sync.pb.h" |
19 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
20 | 21 |
21 using base::Time; | 22 using base::Time; |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 // Our dummy ChangeProcessor used to inspect changes pushed to Sync. | 235 // Our dummy ChangeProcessor used to inspect changes pushed to Sync. |
235 scoped_ptr<TestChangeProcessor> sync_processor_; | 236 scoped_ptr<TestChangeProcessor> sync_processor_; |
236 scoped_ptr<SyncChangeProcessorDelegate> sync_processor_delegate_; | 237 scoped_ptr<SyncChangeProcessorDelegate> sync_processor_delegate_; |
237 | 238 |
238 DISALLOW_COPY_AND_ASSIGN(TemplateURLServiceSyncTest); | 239 DISALLOW_COPY_AND_ASSIGN(TemplateURLServiceSyncTest); |
239 }; | 240 }; |
240 | 241 |
241 TemplateURLServiceSyncTest::TemplateURLServiceSyncTest() | 242 TemplateURLServiceSyncTest::TemplateURLServiceSyncTest() |
242 : sync_processor_(new TestChangeProcessor), | 243 : sync_processor_(new TestChangeProcessor), |
243 sync_processor_delegate_(new SyncChangeProcessorDelegate( | 244 sync_processor_delegate_(new SyncChangeProcessorDelegate( |
244 sync_processor_.get())) { | 245 sync_processor_.get())) {} |
245 } | |
246 | 246 |
247 void TemplateURLServiceSyncTest::SetUp() { | 247 void TemplateURLServiceSyncTest::SetUp() { |
248 profile_a_.reset(new TestingProfile); | 248 profile_a_.reset(new TestingProfile); |
| 249 WebDataServiceFactory::GetInstance()->SetTestingFactory(profile_a_.get(), |
| 250 NULL); |
249 TemplateURLServiceFactory::GetInstance()->RegisterUserPrefsOnProfile( | 251 TemplateURLServiceFactory::GetInstance()->RegisterUserPrefsOnProfile( |
250 profile_a_.get()); | 252 profile_a_.get()); |
251 model_a_.reset(new TemplateURLService(profile_a_.get())); | 253 model_a_.reset(new TemplateURLService(profile_a_.get())); |
252 model_a_->Load(); | 254 model_a_->Load(); |
253 profile_b_.reset(new TestingProfile); | 255 profile_b_.reset(new TestingProfile); |
| 256 WebDataServiceFactory::GetInstance()->SetTestingFactory(profile_b_.get(), |
| 257 NULL); |
254 TemplateURLServiceFactory::GetInstance()->RegisterUserPrefsOnProfile( | 258 TemplateURLServiceFactory::GetInstance()->RegisterUserPrefsOnProfile( |
255 profile_b_.get()); | 259 profile_b_.get()); |
256 model_b_.reset(new TemplateURLService(profile_b_.get())); | 260 model_b_.reset(new TemplateURLService(profile_b_.get())); |
257 model_b_->Load(); | 261 model_b_->Load(); |
258 } | 262 } |
259 | 263 |
260 scoped_ptr<SyncChangeProcessor> TemplateURLServiceSyncTest::PassProcessor() { | 264 scoped_ptr<SyncChangeProcessor> TemplateURLServiceSyncTest::PassProcessor() { |
261 return sync_processor_delegate_.PassAs<SyncChangeProcessor>(); | 265 return sync_processor_delegate_.PassAs<SyncChangeProcessor>(); |
262 } | 266 } |
263 | 267 |
(...skipping 1020 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1284 | 1288 |
1285 // The key1 entry should be a duplicate of the default. | 1289 // The key1 entry should be a duplicate of the default. |
1286 model()->MergeDataAndStartSyncing(syncable::SEARCH_ENGINES, | 1290 model()->MergeDataAndStartSyncing(syncable::SEARCH_ENGINES, |
1287 CreateInitialSyncData(), PassProcessor()); | 1291 CreateInitialSyncData(), PassProcessor()); |
1288 | 1292 |
1289 EXPECT_EQ(3U, model()->GetAllSyncData(syncable::SEARCH_ENGINES).size()); | 1293 EXPECT_EQ(3U, model()->GetAllSyncData(syncable::SEARCH_ENGINES).size()); |
1290 EXPECT_FALSE(model()->GetTemplateURLForGUID("whateverguid")); | 1294 EXPECT_FALSE(model()->GetTemplateURLForGUID("whateverguid")); |
1291 EXPECT_EQ(model()->GetDefaultSearchProvider(), | 1295 EXPECT_EQ(model()->GetDefaultSearchProvider(), |
1292 model()->GetTemplateURLForGUID("key1")); | 1296 model()->GetTemplateURLForGUID("key1")); |
1293 } | 1297 } |
OLD | NEW |